You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Ord implementation on Entity behaves the same way as the to_bits representation of the entity: sorted by generation first, then by ID. That parity is nice, but I am unsure if this is the right default order.
I think it might make sense to sort entities by their ID first and then their generation. This makes the behavior of data structures like BTreeMap with entity keys behave more deterministically.
In our game, we have a WireNetwork component that holds a BTreeMap<EntityHandle, Connections>, where EntityHandle is a new-typed wrapper around Entity with custom serialization behavior. We were deriving Ord on that type, but I was surprised when the entries in the map would get shuffled around. This ended up being due to generations sometimes being different between runs, reordering the map!
We were able to solve that issue by manually implementing Ord to compare the entity's ID first. Doing that made me wonder whether the same change would be right for hecs itself.
The text was updated successfully, but these errors were encountered:
Currently, the
Ord
implementation onEntity
behaves the same way as theto_bits
representation of the entity: sorted by generation first, then by ID. That parity is nice, but I am unsure if this is the right default order.I think it might make sense to sort entities by their ID first and then their generation. This makes the behavior of data structures like
BTreeMap
with entity keys behave more deterministically.In our game, we have a
WireNetwork
component that holds aBTreeMap<EntityHandle, Connections>
, whereEntityHandle
is a new-typed wrapper aroundEntity
with custom serialization behavior. We were derivingOrd
on that type, but I was surprised when the entries in the map would get shuffled around. This ended up being due to generations sometimes being different between runs, reordering the map!We were able to solve that issue by manually implementing
Ord
to compare the entity's ID first. Doing that made me wonder whether the same change would be right for hecs itself.The text was updated successfully, but these errors were encountered: