pub unsafe extern "C" fn ecs_flatten(
world: *mut ecs_world_t,
pair: ecs_id_t,
desc: *const ecs_flatten_desc_t,
)Expand description
Recursively flatten relationship for target entity (experimental). This operation combines entities in the subtree of the specified pair from different parents in the same table. This can reduce memory fragmentation and reduces the number of tables in the storage, which improves RAM utilization and various other operations, such as entity cleanup.
The lifecycle of entities in a fixed subtree are bound to the specified parent. Entities in a fixed subtree cannot be deleted individually. Entities can also not change the target of the fixed relationship, which includes removing the relationship.
Entities in a fixed subtree are still fragmented on subtree depth. This ensures that entities can still be iterated in breadth-first order with the cascade query modifier.
The current implementation is limited to exclusive acyclic relationships, and does not allow for adding/removing to entities in flattened tables. An entity may only be flattened for a single relationship. Future iterations of the feature may remove these limitations.
@param world The world. @param pair The relationship pair from which to start flattening. @param desc Options for flattening the tree.