Keeping "children" components sorted and accessible through a parent range #774
Replies: 1 comment
-
🤔 iterators for single component views do, unless you enabled pointer stability. As for your sorting function: registry.sort<ChildData>([®istry](const auto& lhs, const auto& rhs) { return lhs.parent < rhs.parent; }); It doesn't work probably because it doesn't infer a strict weak ordering. That is, if |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was looking for a way to keep components of children entities in a compact sequential range. I came up with the following, but I am not sure it is reliable, and it doesn't seem to be a supported approach as view iterators do not support random access (++ is supported, but
operator+(unsigned int)
doesn't seem to)In any case, the scheme I have is a component of children I care about with a
entity
reference to the parent:Parents on the other hand, have the following component to retrieve a children (component) range:
then after adding or removing
ChildData
components, I rerun aregistry.sort
call:and then run an update loop on the
ParentInfo
component:The good thing of this is that it (almost) allows me to do the following:
the problem is that
v.begin() + unsigned int
doesn't seem to compile. Perhaps there is a better way to access the children range in a similar way?Beta Was this translation helpful? Give feedback.
All reactions