mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 05:01:24 +00:00
[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:
parent
767f4ff02e
commit
75171743a4
1 changed files with 2 additions and 1 deletions
|
@ -50,10 +50,11 @@ ECS_DelRegistry (ecs_registry_t *registry)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
registry->locked = 1;
|
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 = ®istry->components.a[i];
|
__auto_type comp = ®istry->components.a[i];
|
||||||
__auto_type pool = ®istry->comp_pools[i];
|
__auto_type pool = ®istry->comp_pools[i];
|
||||||
Component_DestroyElements (comp, pool->data, 0, pool->count);
|
Component_DestroyElements (comp, pool->data, 0, pool->count);
|
||||||
|
pool->count = 0;
|
||||||
}
|
}
|
||||||
free (registry->entities);
|
free (registry->entities);
|
||||||
for (uint32_t i = 0; i < registry->components.size; i++) {
|
for (uint32_t i = 0; i < registry->components.size; i++) {
|
||||||
|
|
Loading…
Reference in a new issue