Tuesday, July 8, 2025
spot_img

ECS structure in non-gaming state of affairs : finest approach to mannequin relationships?


I am going to preface the wall of textual content beneath by saying that I’ve next-to-no expertise with recreation design/programming. However I’ve a state of affairs that is perhaps pretty attention-grabbing to of us right here.

I am at the moment working in an area associated to Constructing info modelling. In a nutshell – it entails producing 3d fashions of buildings with an important diploma of accuracy (sufficient for use for building). These fashions encompass objects like projectSite, constructing, storey and so on. that are organized in a hierarchical style (so projectSite -> constructing -> storey and so forth). There are operations to be carried out on every of those objects, following which knowledge is generated and saved on them.

For instance, primarily based on the location and constructing knowledge, a storey object may get populated with bespoke geometry and different knowledge – a few of which is perhaps helpful for components additional down the tree.

I am going to be aware that the hierarchy has already been pre-defined, and is represented as a directed tree. I am going to additionally be aware that the operations being carried out on the objects do NOT contain the graphics/render pipelines and are utterly within the backend. All that will get despatched to the frontend is the ultimate output on the finish of an operation chain (so I is usually a bit lax with my knowledge constructions).

I have been trying into utilizing ECS structure to symbolize these objects because it appears nicely suited to the issue. The problem of hierarchy may be solved by including mother or father() and youngsters() strategies on the objects and utilizing a graph-based knowledge construction (the tip product is not going to be a efficiency hungry recreation so I do not actually need to fret an excessive amount of in regards to the penalties of utilizing graphs as an alternative of arrays)

Nevertheless, I am working right into a roadblock in relation to non-hierarchical bi-directional relationships (or hyperlinks, if you’ll), that are fairly considerable in buildings.

I’ve famous an summary instance beneath:
enter image description here

To symbolize this in ECS I’ve regarded by way of current sources and it appears the usual approach is to easily deal with relationships as elements.

So if I want bi-directional relations, I would add the hyperlink part to each elementC and someObject with knowledge that displays the double-ended nature of the hyperlink (supply and goal could be reversed relying on if the hyperlink is on elementC or on someObject). An instance of that is within the Flecs repo right here: LINK

Nevertheless, this implies I now want to trace this relationship all through the lifetime of a mannequin. An additional complication is that some operations are harmful (i.e. they might delete entities) by which case I have to replace the connection states/take away "useless" relationships earlier than any operations proceed. That is doable, however fairly advanced.

One other approach I considered was to easily have relationships be entities as an alternative of elements, and add them to my graph construction as uni-directional edges. I would now not have the ability to have a tree (and subsequently would lose some good properties) however I would solely want so as to add one relationship as an alternative of two, and this method would resolve my monitoring points too (there are graph libraries that enable deletion of edges when vertices get eliminated, so I needn’t do any further monitoring).

The large downsides I see with this method are that my graph finally ends up being a lot bigger, and traversal can change into costly. That being stated, I’ve no expertise with ECS structure so I do not know if there are different points with this method that will come again to chunk me later.

Are there any higher approaches to this ? Or are there any modifications I ought to be making to my famous approaches above to make them extra helpful for my functions ?

Thanks prematurely !

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles