Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Pipelines order and schedule systems for execution. More...
Classes | |
struct | ecs_pipeline_desc_t |
Pipeline descriptor, used with ecs_pipeline_init(). More... | |
Macros | |
#define | FLECS_PIPELINE_H |
#define | ECS_PIPELINE_DEFINE(world, id_, ...) |
Convenience macro to create a predeclared pipeline. | |
#define | ECS_PIPELINE(world, id, ...) |
Convenience macro to create a pipeline. | |
#define | ecs_pipeline(world, ...) ecs_pipeline_init(world, &(ecs_pipeline_desc_t) __VA_ARGS__ ) |
Convenience macro to create a pipeline. | |
Typedefs | |
typedef struct ecs_pipeline_desc_t | ecs_pipeline_desc_t |
Pipeline descriptor, used with ecs_pipeline_init(). | |
Functions | |
FLECS_API ecs_entity_t | ecs_pipeline_init (ecs_world_t *world, const ecs_pipeline_desc_t *desc) |
Create a custom pipeline. | |
FLECS_API void | ecs_set_pipeline (ecs_world_t *world, ecs_entity_t pipeline) |
Set a custom pipeline. | |
FLECS_API ecs_entity_t | ecs_get_pipeline (const ecs_world_t *world) |
Get the current pipeline. | |
FLECS_API bool | ecs_progress (ecs_world_t *world, ecs_ftime_t delta_time) |
Progress a world. | |
FLECS_API void | ecs_set_time_scale (ecs_world_t *world, ecs_ftime_t scale) |
Set time scale. | |
FLECS_API void | ecs_reset_clock (ecs_world_t *world) |
Reset world clock. | |
FLECS_API void | ecs_run_pipeline (ecs_world_t *world, ecs_entity_t pipeline, ecs_ftime_t delta_time) |
Run pipeline. | |
FLECS_API void | ecs_set_threads (ecs_world_t *world, int32_t threads) |
Set number of worker threads. | |
FLECS_API void | ecs_set_task_threads (ecs_world_t *world, int32_t task_threads) |
Set number of worker task threads. | |
FLECS_API bool | ecs_using_task_threads (ecs_world_t *world) |
Returns true if task thread use have been requested. | |
FLECS_API void | FlecsPipelineImport (ecs_world_t *world) |
Pipeline module import function. | |
Pipelines order and schedule systems for execution.
#define ECS_PIPELINE | ( | world, | |
id, | |||
... ) |
Convenience macro to create a pipeline.
Usage:
Definition at line 74 of file pipeline.h.
#define ecs_pipeline | ( | world, | |
... ) ecs_pipeline_init(world, &(ecs_pipeline_desc_t) __VA_ARGS__ ) |
Convenience macro to create a pipeline.
See ecs_pipeline_init().
Definition at line 82 of file pipeline.h.
#define ECS_PIPELINE_DEFINE | ( | world, | |
id_, | |||
... ) |
Convenience macro to create a predeclared pipeline.
Usage:
Definition at line 54 of file pipeline.h.
#define FLECS_PIPELINE_H |
Definition at line 39 of file pipeline.h.
FLECS_API ecs_entity_t ecs_get_pipeline | ( | const ecs_world_t * | world | ) |
Get the current pipeline.
This operation gets the current pipeline.
world | The world. |
FLECS_API ecs_entity_t ecs_pipeline_init | ( | ecs_world_t * | world, |
const ecs_pipeline_desc_t * | desc ) |
Create a custom pipeline.
world | The world. |
desc | The pipeline descriptor. |
FLECS_API bool ecs_progress | ( | ecs_world_t * | world, |
ecs_ftime_t | delta_time ) |
Progress a world.
This operation progresses the world by running all systems that are both enabled and periodic on their matching entities.
An application can pass a delta_time into the function, which is the time passed since the last frame. This value is passed to systems so they can update entity values proportional to the elapsed time since their last invocation.
When an application passes 0 to delta_time, ecs_progress() will automatically measure the time passed since the last frame. If an application does not uses time management, it should pass a non-zero value for delta_time (1.0 is recommended). That way, no time will be wasted measuring the time.
world | The world to progress. |
delta_time | The time passed since the last frame. |
FLECS_API void ecs_reset_clock | ( | ecs_world_t * | world | ) |
Reset world clock.
Reset the clock that keeps track of the total time passed in the simulation.
world | The world. |
FLECS_API void ecs_run_pipeline | ( | ecs_world_t * | world, |
ecs_entity_t | pipeline, | ||
ecs_ftime_t | delta_time ) |
Run pipeline.
This will run all systems in the provided pipeline. This operation may be invoked from multiple threads, and only when staging is disabled, as the pipeline manages staging and, if necessary, synchronization between threads.
If 0 is provided for the pipeline id, the default pipeline will be ran (this is either the builtin pipeline or the pipeline set with set_pipeline()).
When using progress() this operation will be invoked automatically for the default pipeline (either the builtin pipeline or the pipeline set with set_pipeline()). An application may run additional pipelines.
world | The world. |
pipeline | The pipeline to run. |
delta_time | The delta_time to pass to systems. |
FLECS_API void ecs_set_pipeline | ( | ecs_world_t * | world, |
ecs_entity_t | pipeline ) |
Set a custom pipeline.
This operation sets the pipeline to run when ecs_progress() is invoked.
world | The world. |
pipeline | The pipeline to set. |
FLECS_API void ecs_set_task_threads | ( | ecs_world_t * | world, |
int32_t | task_threads ) |
Set number of worker task threads.
ecs_set_task_threads() is similar to ecs_set_threads(), except threads are treated as short-lived tasks and will be created and joined around each update of the world. Creation and joining of these tasks will use the os_api_t tasks APIs rather than the the standard thread API functions, although they may be the same if desired. This function is useful for multithreading world updates using an external asynchronous job system rather than long running threads by providing the APIs to create tasks for your job system and then wait on their conclusion. The operation may be called multiple times to reconfigure the number of task threads used, but never while running a system / pipeline. Calling ecs_set_task_threads() will also end the use of threads setup with ecs_set_threads() and vice-versa
world | The world. |
task_threads | The number of task threads to create. |
FLECS_API void ecs_set_threads | ( | ecs_world_t * | world, |
int32_t | threads ) |
Set number of worker threads.
Setting this value to a value higher than 1 will start as many threads and will cause systems to evenly distribute matched entities across threads. The operation may be called multiple times to reconfigure the number of threads used, but never while running a system / pipeline. Calling ecs_set_threads() will also end the use of task threads setup with ecs_set_task_threads() and vice-versa.
world | The world. |
threads | The number of threads to create. |
FLECS_API void ecs_set_time_scale | ( | ecs_world_t * | world, |
ecs_ftime_t | scale ) |
Set time scale.
Increase or decrease simulation speed by the provided multiplier.
world | The world. |
scale | The scale to apply (default = 1). |
FLECS_API bool ecs_using_task_threads | ( | ecs_world_t * | world | ) |
Returns true if task thread use have been requested.
world | The world. |
FLECS_API void FlecsPipelineImport | ( | ecs_world_t * | world | ) |