SanderMertens / flecs

A fast entity component system (ECS) for C & C++
https://www.flecs.dev
Other
6.47k stars 454 forks source link

When deleting an entity, the next created entity gets a bad ID (FLECS 3.2.9) #1099

Closed ebootdpr closed 11 months ago

ebootdpr commented 11 months ago

Describe the bug Deleting an entity makes that the next entity created with ecs_new_id gets a high id and is obviusly a bug since it breaks other stuff like in the docs on the pairing with Bob and Alice after adding both behavior to each other: where Alice has low ID (526) and Bob has High ID with this bug: ecs_pair(IsTargetingAt,Alice) works ok when checking ecs_pair_first and ecs_pair_second But when testing ecs_pair(IsTargetingAt,Bob) I get that ecs_pair_first is Bob and it Should be IsTargetingAt.

To Reproduce Steps to reproduce the behavior:

  1. Create an entity
  2. Delete it
  3. Create another entity
  4. Check the id of the created entity

Expected behavior New entity should have +1 on the ID, not a High id image

Additional context I'm using bindings to C in Odin Lang, so maybe there is a problem in the bindings, but im pretty sure im doing a direct call to the C functions I'm using W11 home, intel hd 620 discardable laptop. I'm using the dynamic release .dll + .lib of the 3.2.9 I didn't sleep well in 4 days. -~A lot of other features work well, I'm only having trouble whit filters ecs_field_size(&it,2) gives me 0 but it shouldn't, ecs_field_size(&it,1) works well but that i need to quadruple check before making an issue. p := field(&it,C.Position,1) works and iterates ok but p := field(&it,C.Velocity,2) segfaults~- I will check again.

SanderMertens commented 11 months ago

This is not a bug, see the FAQ: https://www.flecs.dev/flecs/md_docs_FAQ.html#autotoc_md66

When you inspect the integer value of an entity you may see that this value is very large, usually around 4 billion. This is not a bug, and instead means that the entity id has been recycled. This example shows when recycling happens: