Flecs: include/flecs/addons/pipeline.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
pipeline.h
Go to the documentation of this file.
1
15
16#ifdef FLECS_PIPELINE
17
25
26#ifndef FLECS_MODULE
27#define FLECS_MODULE
28#endif
29
30#ifndef FLECS_SYSTEM
31#define FLECS_SYSTEM
32#endif
33
34#if !defined(FLECS_OS_API_IMPL) && !defined(FLECS_NO_OS_API_IMPL)
35#define FLECS_OS_API_IMPL
36#endif
37
38#ifndef FLECS_PIPELINE_H
39#define FLECS_PIPELINE_H
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#ifndef FLECS_LEGACY
46
54#define ECS_PIPELINE_DEFINE(world, id_, ...) \
55 { \
56 ecs_pipeline_desc_t desc = {0}; \
57 ecs_entity_desc_t edesc = {0}; \
58 edesc.id = id_;\
59 edesc.name = #id_;\
60 desc.entity = ecs_entity_init(world, &edesc);\
61 desc.query.expr = #__VA_ARGS__; \
62 id_ = ecs_pipeline_init(world, &desc); \
63 ecs_id(id_) = id_;\
64 } \
65 ecs_assert(id_ != 0, ECS_INVALID_PARAMETER, "failed to create pipeline");
66
74#define ECS_PIPELINE(world, id, ...) \
75 ecs_entity_t id = 0, ecs_id(id) = 0; ECS_PIPELINE_DEFINE(world, id, __VA_ARGS__);\
76 (void)id;\
77 (void)ecs_id(id);
78
82#define ecs_pipeline(world, ...)\
83 ecs_pipeline_init(world, &(ecs_pipeline_desc_t) __VA_ARGS__ )
84
85#endif
86
88 typedef struct ecs_pipeline_desc_t {
90 ecs_entity_t entity;
91
115 ecs_query_desc_t query;
116} ecs_pipeline_desc_t;
117
124FLECS_API
125 ecs_entity_t ecs_pipeline_init(
126 ecs_world_t *world,
127 const ecs_pipeline_desc_t *desc);
128
135FLECS_API
136 void ecs_set_pipeline(
137 ecs_world_t *world,
138 ecs_entity_t pipeline);
139
146FLECS_API
147 ecs_entity_t ecs_get_pipeline(
148 const ecs_world_t *world);
149
168FLECS_API
169 bool ecs_progress(
170 ecs_world_t *world,
171 ecs_ftime_t delta_time);
172
179FLECS_API
180 void ecs_set_time_scale(
181 ecs_world_t *world,
182 ecs_ftime_t scale);
183
189FLECS_API
190 void ecs_reset_clock(
191 ecs_world_t *world);
192
209FLECS_API
210 void ecs_run_pipeline(
211 ecs_world_t *world,
212 ecs_entity_t pipeline,
213 ecs_ftime_t delta_time);
214
215
219
231FLECS_API
232 void ecs_set_threads(
233 ecs_world_t *world,
234 int32_t threads);
235
252FLECS_API
253 void ecs_set_task_threads(
254 ecs_world_t *world,
255 int32_t task_threads);
256
262FLECS_API
263 bool ecs_using_task_threads(
264 ecs_world_t *world);
265
269
278FLECS_API
279 void FlecsPipelineImport(
280 ecs_world_t *world);
281
282#ifdef __cplusplus
283}
284#endif
285
286#endif
287
289
290#endif
ecs_set_threads
FLECS_API void ecs_set_threads(ecs_world_t *world, int32_t threads)
Set number of worker threads.
ecs_set_time_scale
FLECS_API void ecs_set_time_scale(ecs_world_t *world, ecs_ftime_t scale)
Set time scale.
ecs_set_pipeline
FLECS_API void ecs_set_pipeline(ecs_world_t *world, ecs_entity_t pipeline)
Set a custom pipeline.
ecs_get_pipeline
FLECS_API ecs_entity_t ecs_get_pipeline(const ecs_world_t *world)
Get the current pipeline.
ecs_progress
FLECS_API bool ecs_progress(ecs_world_t *world, ecs_ftime_t delta_time)
Progress a world.
ecs_reset_clock
FLECS_API void ecs_reset_clock(ecs_world_t *world)
Reset world clock.
ecs_run_pipeline
FLECS_API void ecs_run_pipeline(ecs_world_t *world, ecs_entity_t pipeline, ecs_ftime_t delta_time)
Run pipeline.
ecs_using_task_threads
FLECS_API bool ecs_using_task_threads(ecs_world_t *world)
Returns true if task thread use have been requested.
ecs_set_task_threads
FLECS_API void ecs_set_task_threads(ecs_world_t *world, int32_t task_threads)
Set number of worker task threads.
FlecsPipelineImport
FLECS_API void FlecsPipelineImport(ecs_world_t *world)
Pipeline module import function.
ecs_pipeline_init
FLECS_API ecs_entity_t ecs_pipeline_init(ecs_world_t *world, const ecs_pipeline_desc_t *desc)
Create a custom pipeline.
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
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:425
ecs_ftime_t
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
ecs_pipeline_desc_t
Pipeline descriptor, used with ecs_pipeline_init().
Definition pipeline.h:88
ecs_pipeline_desc_t::entity
ecs_entity_t entity
Existing entity to associate with pipeline (optional).
Definition pipeline.h:90
ecs_pipeline_desc_t::query
ecs_query_desc_t query
The pipeline query.
Definition pipeline.h:115
ecs_query_desc_t
Used with ecs_query_init().
Definition flecs.h:1236