[ecs] Destroy component pools in reverse order

This seems to be the best solution for interlinked entities/components,
the idea being that components with higher indices can "own" those with
lower (eg, imui_reference can "own" a view_href, but not the other way)
and makes it relatively easy to manage (components that can own others
get added to the registry later), and might even allow validation at a
later stage.
This commit is contained in:
Bill Currie 2023-12-26 11:10:07 +09:00
parent 767f4ff02e
commit 75171743a4

View file

@ -50,10 +50,11 @@ ECS_DelRegistry (ecs_registry_t *registry)
return;
}
registry->locked = 1;
for (uint32_t i = 0; i < registry->components.size; i++) {
for (uint32_t i = registry->components.size; i-- > 0 ;) {
__auto_type comp = &registry->components.a[i];
__auto_type pool = &registry->comp_pools[i];
Component_DestroyElements (comp, pool->data, 0, pool->count);
pool->count = 0;
}
free (registry->entities);
for (uint32_t i = 0; i < registry->components.size; i++) {