Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Misc
Collaboration diagram for Misc:

Macros

#define ecs_poly_is(object, type)    ecs_poly_is_(object, type##_magic)
 

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_tecs_get_build_info (void)
 Get build info.
 
const ecs_world_info_tecs_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_tecs_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 ecs_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.
 

Detailed Description

Macro Definition Documentation

◆ ecs_poly_is

#define ecs_poly_is ( object,
type )    ecs_poly_is_(object, type##_magic)

Definition at line 2378 of file flecs.h.

Function Documentation

◆ ecs_delete_empty_tables()

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.

Parameters
worldThe world.
idOptional component filter for the tables to evaluate.
clear_generationFree table data when generation > clear_generation.
delete_generationDelete table when generation > delete_generation.
min_id_countMinimum number of component ids the table should have.
time_budget_secondsAmount of time operation is allowed to spend.
Returns
Number of deleted tables.

◆ ecs_dim()

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.

Parameters
worldThe world.
entity_countThe number of entities to preallocate.

◆ ecs_enable_range_check()

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.

Parameters
worldThe world.
enableTrue if range checking should be enabled, false to disable.
Returns
The previous value.

◆ ecs_get_binding_ctx()

void * ecs_get_binding_ctx ( const ecs_world_t * world)

Get the world binding context.

This operation retrieves a previously set world binding context.

Parameters
worldThe world.
Returns
The context set with ecs_set_binding_ctx(). If no context was set, the function returns NULL.

◆ ecs_get_build_info()

const ecs_build_info_t * ecs_get_build_info ( void )

Get build info.

Returns information about the current Flecs build.

◆ ecs_get_ctx()

void * ecs_get_ctx ( const ecs_world_t * world)

Get the world context.

This operation retrieves a previously set world context.

Parameters
worldThe world.
Returns
The context set with ecs_set_ctx(). If no context was set, the function returns NULL.

◆ ecs_get_entity()

ecs_entity_t ecs_get_entity ( const ecs_poly_t * poly)

Get entity from poly.

Parameters
polyA pointer to a poly object.
Returns
Entity associated with the poly object.

◆ ecs_get_max_id()

ecs_entity_t ecs_get_max_id ( const ecs_world_t * world)

Get the largest issued entity id (not counting generation).

Parameters
worldThe world.

◆ ecs_get_world()

const ecs_world_t * ecs_get_world ( const ecs_poly_t * poly)

Get world from poly.

Parameters
polyA pointer to a poly object.
Returns
The world.

◆ ecs_get_world_info()

const ecs_world_info_t * ecs_get_world_info ( const ecs_world_t * world)

Get world info.

Parameters
worldThe world.
Returns
Pointer to the world info. Valid for as long as the world exists.

◆ ecs_make_pair()

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.

Parameters
firstThe first element of the pair of the pair.
secondThe target of the pair.

◆ ecs_poly_is_()

bool ecs_poly_is_ ( const ecs_poly_t * object,
int32_t type )

Test if pointer is of specified type.

Usage:

ecs_poly_is(ptr, ecs_world_t)
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:362

This operation only works for poly types.

Parameters
objectThe object to test.
typeThe id of the type.
Returns
True if the pointer is of the specified type.

◆ ecs_run_aperiodic()

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.

Parameters
worldThe world.
flagsThe flags specifying which actions to run.

◆ ecs_set_binding_ctx()

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.

Parameters
worldThe world.
ctxA pointer to a user defined structure.
ctx_freeA function that is invoked with ctx when the world is freed.

◆ ecs_set_ctx()

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.

Parameters
worldThe world.
ctxA pointer to a user defined structure.
ctx_freeA function that is invoked with ctx when the world is freed.

◆ ecs_set_entity_range()

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() 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.

Parameters
worldThe world.
id_startThe start of the range.
id_endThe end of the range.