sebas77/Svelto.ECS

Preallocating after entities have been created results in corrupting the entity reference table.

Closed this issue · 2 comments

If you preallocate after any entities have been created, it can result in a corrupted entity reference lookup on some indices.

Repro Steps:

  • Create two entities of different descriptors in different groups
  • Preallocate those groups
  • Try to convert a entity reference on both of the entities to a EGID, one should be broken

this actually makes sense because with the preallocation you are changing the size of the sets which invalidates the entity references because the indices will change.

With some effort I may be able to update the references during a preallocation, but it's not the way to go. By definition preallocation shouldn't be called on an already allocated group, so I am going to add an exception when this happens.

ok changed the code to throw an exception if preallocation is called when entities are already submitted