I am going to preface the wall of textual content under by saying that I’ve next-to-no expertise with sport design/programming. However I’ve a scenario that could be pretty attention-grabbing to people right here.
I am at present working in an area associated to Constructing info modelling. In a nutshell – it includes producing 3d fashions of buildings with an incredible diploma of accuracy (sufficient for use for development). These fashions encompass objects like projectSite
, constructing
, storey
and so on. that are organized in a hierarchical vogue (so projectSite -> constructing -> storey
and so forth). There are operations to be carried out on every of those objects, following which information is generated and saved on them.
For instance, primarily based on the positioning and constructing information, a storey object would possibly get populated with bespoke geometry and different information – a few of which could be helpful for components additional down the tree.
I am going to notice that the hierarchy has already been pre-defined, and is represented as a directed tree. I am going to additionally notice 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 information constructions).
I have been wanting into utilizing ECS structure to signify these objects because it appears properly suited to the issue. The problem of hierarchy might be solved by including father or mother()
and kids()
strategies on the objects and utilizing a graph-based information construction (the top product is not going to be a efficiency hungry sport so I do not really want to fret an excessive amount of concerning the penalties of utilizing graphs as an alternative of arrays)
Nonetheless, I am working right into a roadblock on the subject of non-hierarchical bi-directional relationships (or hyperlinks, if you’ll), that are fairly plentiful in buildings.
I’ve famous an summary instance under:
To signify this in ECS I’ve regarded by current assets and it appears the usual approach is to easily deal with relationships as parts.
So if I want bi-directional relations, I might add the hyperlink
part to each elementC
and someObject
with information that displays the double-ended nature of the hyperlink (supply and goal can 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
Nonetheless, this implies I now want to trace this relationship all through the lifetime of a mannequin. An extra complication is that some operations are harmful (i.e. they might delete entities) during which case I have to replace the connection states/take away "useless" relationships earlier than any operations proceed. That is doable, however fairly complicated.
One other approach I considered was to easily have relationships be entities as an alternative of parts, and add them to my graph construction as uni-directional edges. I might now not be capable to have a tree (and subsequently would lose some good properties) however I might 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 massive downsides I see with this method are that my graph finally ends up being a lot bigger, and traversal can turn out to be 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 may come again to chew me later.
Are there any higher approaches to this ? Or are there any modifications I must be making to my famous approaches above to make them extra helpful for my functions ?
Thanks upfront !