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

Macros

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

Functions

void ecs_set_context (ecs_world_t *world, void *ctx)
 Set a world context. More...
 
void * ecs_get_context (const ecs_world_t *world)
 Get the world context. More...
 
const ecs_world_info_tecs_get_world_info (const ecs_world_t *world)
 Get world info. More...
 
void ecs_dim (ecs_world_t *world, int32_t entity_count)
 Dimension the world for a specified number of entities. More...
 
void ecs_set_entity_range (ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end)
 Set a range for issueing new entity ids. More...
 
bool ecs_enable_range_check (ecs_world_t *world, bool enable)
 Enable/disable range limits. More...
 
void ecs_run_aperiodic (ecs_world_t *world, ecs_flags32_t flags)
 Force aperiodic actions. More...
 
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. More...
 
const ecs_world_tecs_get_world (const ecs_poly_t *poly)
 Get world from poly. More...
 
ecs_entity_t ecs_get_entity (const ecs_poly_t *poly)
 Get entity from poly. More...
 
bool _ecs_poly_is (const ecs_poly_t *object, int32_t type)
 Test if pointer is of specified type. More...
 
ecs_id_t ecs_make_pair (ecs_entity_t first, ecs_entity_t second)
 Make a pair id. More...
 

Detailed Description

Macro Definition Documentation

◆ ecs_poly_is

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

Definition at line 1942 of file flecs.h.

Function Documentation

◆ _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)

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_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_context()

void * ecs_get_context ( 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_context. 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_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. This pointer will remain valid for as long as the world is valid.

◆ 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_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_context()

void ecs_set_context ( ecs_world_t world,
void *  ctx 
)

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.

◆ 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 issueing 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 issueing 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.