mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-20 08:24:32 +00:00
[scene] Support extra component systems
I've finally come across the need for "client" (hah) code to have additional components on scene entities.
This commit is contained in:
parent
0d4ffb02bc
commit
fb818d15d9
5 changed files with 18 additions and 5 deletions
|
@ -77,7 +77,13 @@ typedef struct scene_s {
|
|||
struct lightingdata_s *lights;
|
||||
} scene_t;
|
||||
|
||||
scene_t *Scene_NewScene (void);
|
||||
typedef struct scene_system_s {
|
||||
struct ecs_system_s *system;
|
||||
const struct component_s *components;
|
||||
uint32_t component_count;
|
||||
} scene_system_t;
|
||||
|
||||
scene_t *Scene_NewScene (scene_system_t *extra_systems);
|
||||
void Scene_DeleteScene (scene_t *scene);
|
||||
struct entity_s Scene_CreateEntity (scene_t *scene);
|
||||
void Scene_DestroyEntity (scene_t *scene, struct entity_s entity);
|
||||
|
|
|
@ -64,7 +64,7 @@ worldscene_t cl_world = {
|
|||
void
|
||||
CL_World_Init (void)
|
||||
{
|
||||
cl_world.scene = Scene_NewScene ();
|
||||
cl_world.scene = Scene_NewScene (0);
|
||||
cl_world.scene->lights = Light_CreateLightingData (cl_world.scene);
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ Con_Debug_Init (void)
|
|||
IMUI_SetVisible (debug_imui, con_debug);
|
||||
IMUI_Style_Fetch (debug_imui, ¤t_style);
|
||||
|
||||
debug_scene = Scene_NewScene ();
|
||||
debug_scene = Scene_NewScene (0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -199,7 +199,7 @@ bi_Scene_NewScene (progs_t *pr, void *_res)
|
|||
|
||||
rua_scene_t *scene = rua_scene_new (res);
|
||||
|
||||
scene->scene = Scene_NewScene ();
|
||||
scene->scene = Scene_NewScene (0);
|
||||
|
||||
scene->next = res->scenes;
|
||||
if (res->scenes) {
|
||||
|
|
|
@ -253,12 +253,19 @@ static model_t empty_world = {
|
|||
};
|
||||
|
||||
scene_t *
|
||||
Scene_NewScene (void)
|
||||
Scene_NewScene (scene_system_t *extra_systems)
|
||||
{
|
||||
scene_t *scene = calloc (1, sizeof (scene_t));
|
||||
|
||||
scene->reg = ECS_NewRegistry ();
|
||||
ECS_RegisterComponents (scene->reg, scene_components, scene_comp_count);
|
||||
for (auto extra = extra_systems; extra && extra->system; extra++) {
|
||||
uint32_t base = ECS_RegisterComponents (scene->reg,
|
||||
extra->components,
|
||||
extra->component_count);
|
||||
extra->system->reg = scene->reg;
|
||||
extra->system->base = base;
|
||||
}
|
||||
ECS_CreateComponentPools (scene->reg);
|
||||
|
||||
scene->worldmodel = &empty_world;
|
||||
|
|
Loading…
Reference in a new issue