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 is likely to be pretty fascinating to of us right here.
I am presently working in an area associated to Constructing data modelling. In a nutshell – it includes 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 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 may get populated with bespoke geometry and different information – a few of which is likely to be helpful for parts additional down the tree.
I am going to observe that the hierarchy has already been pre-defined, and is represented as a directed tree. I am going to additionally observe that the operations being carried out on the objects do NOT contain the graphics/render pipelines and are fully within the backend. All that will get despatched to the frontend is the ultimate output on the finish of an operation chain (so I could be 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 difficulty of hierarchy may be solved by including mother or father()
and kids()
strategies on the objects and utilizing a graph-based information construction (the top product won’t be a efficiency hungry sport so I do not actually need to fret an excessive amount of concerning the penalties of utilizing graphs as a substitute of arrays)
Nevertheless, I am operating right into a roadblock relating to non-hierarchical bi-directional relationships (or hyperlinks, if you’ll), that are fairly ample in buildings.
I’ve famous an summary instance under:
To signify this in ECS I’ve appeared by present sources and it appears the usual manner is to easily deal with relationships as parts.
So if I want bi-directional relations, I would add the hyperlink
part to each elementC
and someObject
with information 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 extra complication is that some operations are harmful (i.e. they might delete entities) during which case I must replace the connection states/take away "useless" relationships earlier than any operations proceed. That is doable, however fairly complicated.
One other manner I considered was to easily have relationships be entities as a substitute of parts, and add them to my graph construction as uni-directional edges. I would not be capable to have a tree (and subsequently would lose some good properties) however I would solely want so as to add one relationship as a substitute of two, and this strategy would resolve my monitoring points too (there are graph libraries that permit deletion of edges when vertices get eliminated, so I needn’t do any additional monitoring).
The large downsides I see with this strategy 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 strategy that might come again to chunk 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 prematurely !