Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Macros | |
#define | flecs_poly_is(object, type) flecs_poly_is_(object, type##_magic) |
Test if pointer is of specified type. | |
Functions | |
void | ecs_set_ctx (ecs_world_t *world, void *ctx, ecs_ctx_free_t ctx_free) |
Set a world context. | |
void | ecs_set_binding_ctx (ecs_world_t *world, void *ctx, ecs_ctx_free_t ctx_free) |
Set a world binding context. | |
void * | ecs_get_ctx (const ecs_world_t *world) |
Get the world context. | |
void * | ecs_get_binding_ctx (const ecs_world_t *world) |
Get the world binding context. | |
const ecs_build_info_t * | ecs_get_build_info (void) |
Get build info. | |
const ecs_world_info_t * | ecs_get_world_info (const ecs_world_t *world) |
Get world info. | |
void | ecs_dim (ecs_world_t *world, int32_t entity_count) |
Dimension the world for a specified number of entities. | |
void | ecs_set_entity_range (ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end) |
Set a range for issuing new entity ids. | |
bool | ecs_enable_range_check (ecs_world_t *world, bool enable) |
Enable/disable range limits. | |
ecs_entity_t | ecs_get_max_id (const ecs_world_t *world) |
Get the largest issued entity id (not counting generation). | |
void | ecs_run_aperiodic (ecs_world_t *world, ecs_flags32_t flags) |
Force aperiodic actions. | |
int32_t | ecs_delete_empty_tables (ecs_world_t *world, ecs_id_t id, uint16_t clear_generation, uint16_t delete_generation, int32_t min_id_count, double time_budget_seconds) |
Cleanup empty tables. | |
const ecs_world_t * | ecs_get_world (const ecs_poly_t *poly) |
Get world from poly. | |
ecs_entity_t | ecs_get_entity (const ecs_poly_t *poly) |
Get entity from poly. | |
bool | flecs_poly_is_ (const ecs_poly_t *object, int32_t type) |
Test if pointer is of specified type. | |
ecs_id_t | ecs_make_pair (ecs_entity_t first, ecs_entity_t second) |
Make a pair id. | |
#define flecs_poly_is | ( | object, | |
type ) flecs_poly_is_(object, type##_magic) |
Test if pointer is of specified type.
int32_t ecs_delete_empty_tables | ( | ecs_world_t * | world, |
ecs_id_t | id, | ||
uint16_t | clear_generation, | ||
uint16_t | delete_generation, | ||
int32_t | min_id_count, | ||
double | time_budget_seconds ) |
Cleanup empty tables.
This operation cleans up empty tables that meet certain conditions. Having large amounts of empty tables does not negatively impact performance of the ECS, but can take up considerable amounts of memory, especially in applications with many components, and many components per entity.
The generation specifies the minimum number of times this operation has to be called before an empty table is cleaned up. If a table becomes non empty, the generation is reset.
The operation allows for both a "clear" generation and a "delete" generation. When the clear generation is reached, the table's resources are freed (like component arrays) but the table itself is not deleted. When the delete generation is reached, the empty table is deleted.
By specifying a non-zero id the cleanup logic can be limited to tables with a specific (component) id. The operation will only increase the generation count of matching tables.
The min_id_count specifies a lower bound for the number of components a table should have. Often the more components a table has, the more specific it is and therefore less likely to be reused.
The time budget specifies how long the operation should take at most.
world | The world. |
id | Optional component filter for the tables to evaluate. |
clear_generation | Free table data when generation > clear_generation. |
delete_generation | Delete table when generation > delete_generation. |
min_id_count | Minimum number of component ids the table should have. |
time_budget_seconds | Amount of time operation is allowed to spend. |
void ecs_dim | ( | ecs_world_t * | world, |
int32_t | entity_count ) |
Dimension the world for a specified number of entities.
This operation will preallocate memory in the world for the specified number of entities. Specifying a number lower than the current number of entities in the world will have no effect.
world | The world. |
entity_count | The number of entities to preallocate. |
bool ecs_enable_range_check | ( | ecs_world_t * | world, |
bool | enable ) |
Enable/disable range limits.
When an application is both a receiver of range-limited entities and a producer of range-limited entities, range checking needs to be temporarily disabled when inserting received entities. Range checking is disabled on a stage, so setting this value is thread safe.
world | The world. |
enable | True if range checking should be enabled, false to disable. |
void * ecs_get_binding_ctx | ( | const ecs_world_t * | world | ) |
Get the world binding context.
This operation retrieves a previously set world binding context.
world | The world. |
const ecs_build_info_t * ecs_get_build_info | ( | void | ) |
Get build info.
Returns information about the current Flecs build.
void * ecs_get_ctx | ( | const ecs_world_t * | world | ) |
Get the world context.
This operation retrieves a previously set world context.
world | The world. |
ecs_entity_t ecs_get_entity | ( | const ecs_poly_t * | poly | ) |
Get entity from poly.
poly | A pointer to a poly object. |
ecs_entity_t ecs_get_max_id | ( | const ecs_world_t * | world | ) |
Get the largest issued entity id (not counting generation).
world | The world. |
const ecs_world_t * ecs_get_world | ( | const ecs_poly_t * | poly | ) |
Get world from poly.
poly | A pointer to a poly object. |
const ecs_world_info_t * ecs_get_world_info | ( | const ecs_world_t * | world | ) |
Get world info.
world | The world. |
ecs_id_t ecs_make_pair | ( | ecs_entity_t | first, |
ecs_entity_t | second ) |
Make a pair id.
This function is equivalent to using the ecs_pair() macro, and is added for convenience to make it easier for non C/C++ bindings to work with pairs.
first | The first element of the pair of the pair. |
second | The target of the pair. |
void ecs_run_aperiodic | ( | ecs_world_t * | world, |
ecs_flags32_t | flags ) |
Force aperiodic actions.
The world may delay certain operations until they are necessary for the application to function correctly. This may cause observable side effects such as delayed triggering of events, which can be inconvenient when for example running a test suite.
The flags parameter specifies which aperiodic actions to run. Specify 0 to run all actions. Supported flags start with 'EcsAperiodic'. Flags identify internal mechanisms and may change unannounced.
world | The world. |
flags | The flags specifying which actions to run. |
void ecs_set_binding_ctx | ( | ecs_world_t * | world, |
void * | ctx, | ||
ecs_ctx_free_t | ctx_free ) |
Set a world binding context.
Same as ecs_set_ctx() but for binding context. A binding context is intended specifically for language bindings to store binding specific data.
world | The world. |
ctx | A pointer to a user defined structure. |
ctx_free | A function that is invoked with ctx when the world is freed. |
void ecs_set_ctx | ( | ecs_world_t * | world, |
void * | ctx, | ||
ecs_ctx_free_t | ctx_free ) |
Set a world context.
This operation allows an application to register custom data with a world that can be accessed anywhere where the application has the world.
world | The world. |
ctx | A pointer to a user defined structure. |
ctx_free | A function that is invoked with ctx when the world is freed. |
void ecs_set_entity_range | ( | ecs_world_t * | world, |
ecs_entity_t | id_start, | ||
ecs_entity_t | id_end ) |
Set a range for issuing new entity ids.
This function constrains the entity identifiers returned by ecs_new_w() to the specified range. This operation can be used to ensure that multiple processes can run in the same simulation without requiring a central service that coordinates issuing identifiers.
If id_end
is set to 0, the range is infinite. If id_end
is set to a non-zero value, it has to be larger than id_start
. If id_end
is set and ecs_new() is invoked after an id is issued that is equal to id_end
, the application will abort.
world | The world. |
id_start | The start of the range. |
id_end | The end of the range. |
bool flecs_poly_is_ | ( | const ecs_poly_t * | object, |
int32_t | type ) |
Test if pointer is of specified type.
Usage:
This operation only works for poly types.
object | The object to test. |
type | The id of the type. |