mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-16 08:52:23 +00:00
[ecs] Move ECS core into its own library
While the libraries are probably getting a little out of hand, the separation into its own directory is probably a good thing as an ECS should not be tied to scenes. This should make the ECS more generally useful.
This commit is contained in:
parent
4df145d76a
commit
db7f8a461e
56 changed files with 112 additions and 165 deletions
|
@ -75,6 +75,10 @@ include_qf = \
|
|||
include/QF/winding.h \
|
||||
include/QF/zone.h
|
||||
|
||||
include_qf_ecs = \
|
||||
include/QF/ecs/component.h \
|
||||
include/QF/ecs/hierarchy.h
|
||||
|
||||
include_qf_gl = \
|
||||
include/QF/GL/ati.h \
|
||||
include/QF/GL/defines.h \
|
||||
|
@ -148,7 +152,6 @@ include_qf_progs = \
|
|||
include_qf_scene = \
|
||||
include/QF/scene/camera.h \
|
||||
include/QF/scene/entity.h \
|
||||
include/QF/scene/hierarchy.h \
|
||||
include/QF/scene/light.h \
|
||||
include/QF/scene/transform.h \
|
||||
include/QF/scene/scene.h \
|
||||
|
@ -246,6 +249,7 @@ ruamoko_qf_progs_include_HEADERS = @qfac_qfcc_include_qf_progs@
|
|||
|
||||
EXTRA_DIST += \
|
||||
$(include_qf) \
|
||||
$(include_qf_ecs) \
|
||||
$(include_qf_gl) \
|
||||
$(include_qf_glsl) \
|
||||
$(include_qf_input) \
|
||||
|
|
|
@ -28,13 +28,16 @@
|
|||
|
||||
*/
|
||||
|
||||
#ifndef __QF_scene_component_h
|
||||
#define __QF_scene_component_h
|
||||
#ifndef __QF_ecs_component_h
|
||||
#define __QF_ecs_component_h
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/progs.h"//FIXME for PR_RESMAP
|
||||
|
||||
#include "QF/ecs/hierarchy.h"
|
||||
|
||||
/** \defgroup component Entity Component System
|
||||
\ingroup utils
|
||||
|
@ -70,6 +73,8 @@ typedef struct ecs_registry_s {
|
|||
const component_t *components;
|
||||
ecs_pool_t *comp_pools;
|
||||
uint32_t num_components;
|
||||
uint32_t href_comp;//FIXME find a better way
|
||||
PR_RESMAP (hierarchy_t) hierarchies;//FIXME find a better way
|
||||
} ecs_registry_t;
|
||||
|
||||
#define COMPINLINE GNU89INLINE inline
|
||||
|
@ -234,4 +239,4 @@ Ent_SetComponent (uint32_t ent, uint32_t comp, ecs_registry_t *registry,
|
|||
|
||||
///@}
|
||||
|
||||
#endif//__QF_scene_component_h
|
||||
#endif//__QF_ecs_component_h
|
|
@ -28,14 +28,10 @@
|
|||
|
||||
*/
|
||||
|
||||
#ifndef __QF_scene_hierarchy_h
|
||||
#define __QF_scene_hierarchy_h
|
||||
#ifndef __QF_ecs_hierarchy_h
|
||||
#define __QF_ecs_hierarchy_h
|
||||
|
||||
#include "QF/darray.h"
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/scene/types.h"
|
||||
#include "QF/simd/vec4f.h"
|
||||
#include "QF/simd/mat4f.h"
|
||||
|
||||
/** \defgroup entity Hierarchy management
|
||||
\ingroup utils
|
||||
|
@ -55,9 +51,7 @@ typedef struct hierref_s {
|
|||
} hierref_t;
|
||||
|
||||
typedef struct hierarchy_s {
|
||||
struct hierarchy_s *next;
|
||||
struct hierarchy_s **prev;
|
||||
struct scene_s *scene;
|
||||
struct ecs_registry_s *reg;
|
||||
uint32_t num_objects;
|
||||
uint32_t max_objects;
|
||||
uint32_t *ent;
|
||||
|
@ -68,10 +62,11 @@ typedef struct hierarchy_s {
|
|||
void **components;
|
||||
} hierarchy_t;
|
||||
|
||||
hierarchy_t *Hierarchy_New (struct scene_s *scene,
|
||||
hierarchy_t *Hierarchy_New (struct ecs_registry_s *reg,
|
||||
const hierarchy_type_t *type, int createRoot);
|
||||
void Hierarchy_Reserve (hierarchy_t *hierarchy, uint32_t count);
|
||||
hierarchy_t *Hierarchy_Copy (struct scene_s *scene, const hierarchy_t *src);
|
||||
hierarchy_t *Hierarchy_Copy (struct ecs_registry_s *reg,
|
||||
const hierarchy_t *src);
|
||||
void Hierarchy_Delete (hierarchy_t *hierarchy);
|
||||
|
||||
uint32_t Hierarchy_InsertHierarchy (hierarchy_t *dst, const hierarchy_t *src,
|
||||
|
@ -79,4 +74,4 @@ uint32_t Hierarchy_InsertHierarchy (hierarchy_t *dst, const hierarchy_t *src,
|
|||
void Hierarchy_RemoveHierarchy (hierarchy_t *hierarchy, uint32_t index);
|
||||
///@}
|
||||
|
||||
#endif//__QF_scene_hierarchy_h
|
||||
#endif//__QF_ecs_hierarchy_h
|
|
@ -33,8 +33,9 @@
|
|||
|
||||
#include "QF/darray.h"
|
||||
#include "QF/qtypes.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/hierarchy.h"
|
||||
#include "QF/ecs/component.h"
|
||||
#include "QF/ecs/hierarchy.h"
|
||||
#include "QF/ecs/hierarchy.h"
|
||||
#include "QF/simd/vec4f.h"
|
||||
#include "QF/simd/mat4f.h"
|
||||
|
||||
|
@ -71,17 +72,16 @@ typedef struct transform_s {
|
|||
|
||||
XFORMINLINE int Transform_Valid (transform_t transform);
|
||||
|
||||
transform_t Transform_New (struct scene_s *scene, transform_t parent);
|
||||
transform_t Transform_New (ecs_registry_t *reg, transform_t parent);
|
||||
/* Deletes all child transforms, and transform names */
|
||||
void Transform_Delete (struct scene_s *scene, transform_t transform);
|
||||
transform_t Transform_NewNamed (struct scene_s *scene, transform_t parent,
|
||||
void Transform_Delete (transform_t transform);
|
||||
transform_t Transform_NewNamed (ecs_registry_t *reg, transform_t parent,
|
||||
const char *name);
|
||||
XFORMINLINE hierref_t *Transform_GetRef (transform_t transform);
|
||||
XFORMINLINE uint32_t Transform_ChildCount (transform_t transform);
|
||||
XFORMINLINE transform_t Transform_GetChild (transform_t transform,
|
||||
uint32_t childIndex);
|
||||
void Transform_SetParent (struct scene_s *scene,
|
||||
transform_t transform, transform_t parent);
|
||||
void Transform_SetParent (transform_t transform, transform_t parent);
|
||||
XFORMINLINE transform_t Transform_GetParent (transform_t transform);
|
||||
void Transform_SetName (transform_t transform, const char *name);
|
||||
XFORMINLINE const char *Transform_GetName (transform_t transform);
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
#ifndef __scn_internal_h
|
||||
#define __scn_internal_h
|
||||
|
||||
#include "QF/progs.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/hierarchy.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/scene/transform.h"
|
||||
#include "QF/ecs/hierarchy.h"
|
||||
|
||||
typedef struct scene_resources_s {
|
||||
PR_RESMAP (hierarchy_t) hierarchies;
|
||||
} scene_resources_t;
|
||||
|
||||
#endif//__scn_internal_h
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
include libs/util/Makemodule.am
|
||||
include libs/ecs/Makemodule.am
|
||||
include libs/ui/Makemodule.am
|
||||
include libs/gamecode/Makemodule.am
|
||||
include libs/ruamoko/Makemodule.am
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "QF/render.h"
|
||||
|
||||
#include "QF/plugin/vid_render.h" //FIXME
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
#include "QF/plugin/vid_render.h" //FIXME
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
|
||||
#include "QF/plugin/vid_render.h" //FIXME
|
||||
//
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "QF/screen.h"
|
||||
|
||||
#include "QF/plugin/vid_render.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/simd/vec4f.h"
|
||||
|
@ -961,7 +960,8 @@ V_Init (viewstate_t *viewstate)
|
|||
"Used when you are underwater, hit, have the Ring of "
|
||||
"Shadows, or Quad Damage. (v_cshift r g b intensity)");
|
||||
|
||||
viewstate->camera_transform = Transform_New (cl_world.scene, nulltransform);
|
||||
viewstate->camera_transform = Transform_New (cl_world.scene->reg,
|
||||
nulltransform);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "QF/progs.h"
|
||||
#include "QF/msg.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/light.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
|
12
libs/ecs/Makemodule.am
Normal file
12
libs/ecs/Makemodule.am
Normal file
|
@ -0,0 +1,12 @@
|
|||
include libs/ecs/test/Makemodule.am
|
||||
|
||||
ecs_deps=libs/models/libQFmodels.la libs/util/libQFutil.la
|
||||
|
||||
lib_LTLIBRARIES += libs/ecs/libQFecs.la
|
||||
|
||||
libs_ecs_libQFecs_la_LDFLAGS= $(lib_ldflags)
|
||||
libs_ecs_libQFecs_la_LIBADD= $(ecs_deps)
|
||||
libs_ecs_libQFecs_la_DEPENDENCIES= $(ecs_deps)
|
||||
libs_ecs_libQFecs_la_SOURCES= \
|
||||
libs/ecs/component.c \
|
||||
libs/ecs/hierarchy.c
|
|
@ -31,7 +31,7 @@
|
|||
#include "QF/sys.h"
|
||||
|
||||
#define IMPLEMENT_COMPONENT_Funcs
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/ecs/component.h"
|
||||
|
||||
VISIBLE ecs_registry_t *
|
||||
ECS_NewRegistry (void)
|
|
@ -35,11 +35,10 @@
|
|||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/hierarchy.h"
|
||||
#include "QF/scene/transform.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "scn_internal.h"
|
||||
#include "QF/ecs/component.h"
|
||||
#include "QF/ecs/hierarchy.h"
|
||||
|
||||
static component_t ent_component = { .size = sizeof (uint32_t) };
|
||||
static component_t childCount_component = { .size = sizeof (uint32_t) };
|
||||
|
@ -50,9 +49,10 @@ static void
|
|||
hierarchy_UpdateTransformIndices (hierarchy_t *hierarchy, uint32_t start,
|
||||
int offset)
|
||||
{
|
||||
ecs_registry_t *reg = hierarchy->scene->reg;
|
||||
ecs_registry_t *reg = hierarchy->reg;
|
||||
uint32_t href = reg->href_comp;
|
||||
for (size_t i = start; i < hierarchy->num_objects; i++) {
|
||||
hierref_t *ref = Ent_GetComponent (hierarchy->ent[i], scene_href, reg);
|
||||
hierref_t *ref = Ent_GetComponent (hierarchy->ent[i], href, reg);
|
||||
ref->index += offset;
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,8 @@ static void
|
|||
hierarchy_move (hierarchy_t *dst, const hierarchy_t *src,
|
||||
uint32_t dstIndex, uint32_t srcIndex, uint32_t count)
|
||||
{
|
||||
ecs_registry_t *reg = dst->scene->reg;
|
||||
ecs_registry_t *reg = dst->reg;
|
||||
uint32_t href = reg->href_comp;
|
||||
Component_CopyElements (&ent_component,
|
||||
dst->ent, dstIndex,
|
||||
src->ent, srcIndex, count);
|
||||
|
@ -162,7 +163,7 @@ hierarchy_move (hierarchy_t *dst, const hierarchy_t *src,
|
|||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
uint32_t ent = dst->ent[dstIndex + i];
|
||||
hierref_t *ref = Ent_GetComponent (ent, scene_href, reg);
|
||||
hierref_t *ref = Ent_GetComponent (ent, href, reg);
|
||||
ref->hierarchy = dst;
|
||||
ref->index = dstIndex + i;
|
||||
}
|
||||
|
@ -333,18 +334,11 @@ Hierarchy_RemoveHierarchy (hierarchy_t *hierarchy, uint32_t index)
|
|||
}
|
||||
|
||||
hierarchy_t *
|
||||
Hierarchy_New (scene_t *scene, const hierarchy_type_t *type, int createRoot)
|
||||
Hierarchy_New (ecs_registry_t *reg, const hierarchy_type_t *type,
|
||||
int createRoot)
|
||||
{
|
||||
scene_resources_t *res = scene->resources;
|
||||
hierarchy_t *hierarchy = PR_RESNEW (res->hierarchies);
|
||||
hierarchy->scene = scene;
|
||||
|
||||
hierarchy->prev = &scene->hierarchies;
|
||||
hierarchy->next = scene->hierarchies;
|
||||
if (scene->hierarchies) {
|
||||
scene->hierarchies->prev = &hierarchy->next;
|
||||
}
|
||||
scene->hierarchies = hierarchy;
|
||||
hierarchy_t *hierarchy = PR_RESNEW (reg->hierarchies);
|
||||
hierarchy->reg = reg;
|
||||
|
||||
hierarchy->type = type;
|
||||
hierarchy->components = calloc (hierarchy->type->num_components,
|
||||
|
@ -361,11 +355,6 @@ Hierarchy_New (scene_t *scene, const hierarchy_type_t *type, int createRoot)
|
|||
void
|
||||
Hierarchy_Delete (hierarchy_t *hierarchy)
|
||||
{
|
||||
if (hierarchy->next) {
|
||||
hierarchy->next->prev = hierarchy->prev;
|
||||
}
|
||||
*hierarchy->prev = hierarchy->next;
|
||||
|
||||
free (hierarchy->ent);
|
||||
free (hierarchy->childCount);
|
||||
free (hierarchy->childIndex);
|
||||
|
@ -375,23 +364,23 @@ Hierarchy_Delete (hierarchy_t *hierarchy)
|
|||
}
|
||||
free (hierarchy->components);
|
||||
|
||||
scene_resources_t *res = hierarchy->scene->resources;
|
||||
PR_RESFREE (res->hierarchies, hierarchy);
|
||||
ecs_registry_t *reg = hierarchy->reg;
|
||||
PR_RESFREE (reg->hierarchies, hierarchy);
|
||||
}
|
||||
|
||||
hierarchy_t *
|
||||
Hierarchy_Copy (scene_t *scene, const hierarchy_t *src)
|
||||
Hierarchy_Copy (ecs_registry_t *dstReg, const hierarchy_t *src)
|
||||
{
|
||||
ecs_registry_t *dstReg = scene->reg;
|
||||
//ecs_registry_t *srcReg = src->scene->reg;
|
||||
hierarchy_t *dst = Hierarchy_New (scene, src->type, 0);
|
||||
uint32_t href = dstReg->href_comp;
|
||||
//ecs_registry_t *srcReg = src->reg;
|
||||
hierarchy_t *dst = Hierarchy_New (dstReg, src->type, 0);
|
||||
size_t count = src->num_objects;
|
||||
|
||||
Hierarchy_Reserve (dst, count);
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
dst->ent[i] = ECS_NewEntity (dstReg);
|
||||
hierref_t *ref = Ent_AddComponent (dst->ent[i], scene_href, dstReg);
|
||||
hierref_t *ref = Ent_AddComponent (dst->ent[i], href, dstReg);
|
||||
ref->hierarchy = dst;
|
||||
ref->index = i;
|
||||
}
|
25
libs/ecs/test/Makemodule.am
Normal file
25
libs/ecs/test/Makemodule.am
Normal file
|
@ -0,0 +1,25 @@
|
|||
libs_ecs_tests = \
|
||||
libs/ecs/test/test-components \
|
||||
libs/ecs/test/test-registry
|
||||
|
||||
TESTS += $(libs_ecs_tests)
|
||||
|
||||
check_PROGRAMS += $(libs_ecs_tests)
|
||||
|
||||
libs_ecs_test_libs= \
|
||||
libs/ecs/libQFecs.la \
|
||||
libs/util/libQFutil.la
|
||||
|
||||
libs_ecs_test_test_components_SOURCES= \
|
||||
libs/ecs/test/test-components.c
|
||||
libs_ecs_test_test_components_LDADD= \
|
||||
$(libs_ecs_test_libs)
|
||||
libs_ecs_test_test_components_DEPENDENCIES= \
|
||||
$(libs_ecs_test_libs)
|
||||
|
||||
libs_ecs_test_test_registry_SOURCES= \
|
||||
libs/ecs/test/test-registry.c
|
||||
libs_ecs_test_test_registry_LDADD= \
|
||||
$(libs_ecs_test_libs)
|
||||
libs_ecs_test_test_registry_DEPENDENCIES= \
|
||||
$(libs_ecs_test_libs)
|
|
@ -44,7 +44,6 @@
|
|||
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/light.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
@ -333,9 +332,8 @@ bi_Transform_SetParent (progs_t *pr, void *_res)
|
|||
rua_scene_resources_t *res = _res;
|
||||
transform_t transform = rua_transform_get (res, P_ULONG (pr, 0));
|
||||
transform_t parent = rua_transform_get (res, P_ULONG (pr, 1));
|
||||
rua_scene_t *scene = rua_scene_get (res, P_ULONG (pr, 1));
|
||||
|
||||
Transform_SetParent (scene->scene, transform, parent);
|
||||
Transform_SetParent (transform, parent);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
include libs/scene/test/Makemodule.am
|
||||
|
||||
scene_deps=libs/models/libQFmodels.la libs/util/libQFutil.la
|
||||
scene_deps=\
|
||||
libs/models/libQFmodels.la \
|
||||
libs/ecs/libQFecs.la \
|
||||
libs/util/libQFutil.la
|
||||
|
||||
lib_LTLIBRARIES += libs/scene/libQFscene.la
|
||||
|
||||
|
@ -9,9 +12,7 @@ libs_scene_libQFscene_la_LIBADD= $(scene_deps)
|
|||
libs_scene_libQFscene_la_DEPENDENCIES= $(scene_deps)
|
||||
libs_scene_libQFscene_la_SOURCES= \
|
||||
libs/scene/camera.c \
|
||||
libs/scene/component.c \
|
||||
libs/scene/entity.c \
|
||||
libs/scene/hierarchy.c \
|
||||
libs/scene/light.c \
|
||||
libs/scene/scene.c \
|
||||
libs/scene/transform.c
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#endif
|
||||
|
||||
#include "QF/scene/camera.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/scene/transform.h"
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "QF/sys.h"
|
||||
#include "QF/model.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/scene/transform.h"
|
||||
|
@ -192,6 +191,7 @@ Scene_NewScene (void)
|
|||
|
||||
scene->reg = ECS_NewRegistry ();
|
||||
ECS_RegisterComponents (scene->reg, scene_components, scene_num_components);
|
||||
scene->reg->href_comp = scene_href;
|
||||
|
||||
scene_resources_t *res = calloc (1, sizeof (scene_resources_t));
|
||||
*(scene_resources_t **)&scene->resources = res;
|
||||
|
@ -215,7 +215,7 @@ Scene_CreateEntity (scene_t *scene)
|
|||
{
|
||||
// Transform_New creates an entity and adds a scene_href component to the
|
||||
// entity
|
||||
transform_t trans = Transform_New (scene, nulltransform);
|
||||
transform_t trans = Transform_New (scene->reg, nulltransform);
|
||||
uint32_t id = trans.id;
|
||||
|
||||
Ent_SetComponent (id, scene_animation, scene->reg, 0);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
libs_scene_tests = \
|
||||
libs/scene/test/test-components \
|
||||
libs/scene/test/test-hierarchy \
|
||||
libs/scene/test/test-registry
|
||||
libs/scene/test/test-hierarchy
|
||||
|
||||
TESTS += $(libs_scene_tests)
|
||||
|
||||
|
@ -9,25 +7,12 @@ check_PROGRAMS += $(libs_scene_tests)
|
|||
|
||||
libs_scene_test_libs= \
|
||||
libs/scene/libQFscene.la \
|
||||
libs/ecs/libQFecs.la \
|
||||
libs/util/libQFutil.la
|
||||
|
||||
libs_scene_test_test_components_SOURCES= \
|
||||
libs/scene/test/test-components.c
|
||||
libs_scene_test_test_components_LDADD= \
|
||||
$(libs_scene_test_libs)
|
||||
libs_scene_test_test_components_DEPENDENCIES= \
|
||||
$(libs_scene_test_libs)
|
||||
|
||||
libs_scene_test_test_hierarchy_SOURCES= \
|
||||
libs/scene/test/test-hierarchy.c
|
||||
libs_scene_test_test_hierarchy_LDADD= \
|
||||
$(libs_scene_test_libs)
|
||||
libs_scene_test_test_hierarchy_DEPENDENCIES= \
|
||||
$(libs_scene_test_libs)
|
||||
|
||||
libs_scene_test_test_registry_SOURCES= \
|
||||
libs/scene/test/test-registry.c
|
||||
libs_scene_test_test_registry_LDADD= \
|
||||
$(libs_scene_test_libs)
|
||||
libs_scene_test_test_registry_DEPENDENCIES= \
|
||||
$(libs_scene_test_libs)
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
|
||||
#define IMPLEMENT_TRANSFORM_Funcs
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/hierarchy.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/scene/transform.h"
|
||||
|
||||
|
@ -221,9 +219,8 @@ Transform_UpdateMatrices (hierarchy_t *h)
|
|||
}
|
||||
|
||||
transform_t
|
||||
Transform_New (scene_t *scene, transform_t parent)
|
||||
Transform_New (ecs_registry_t *reg, transform_t parent)
|
||||
{
|
||||
ecs_registry_t *reg = scene->reg;
|
||||
uint32_t transform = ECS_NewEntity (reg);
|
||||
hierref_t *ref = Ent_AddComponent (transform, scene_href, reg);
|
||||
|
||||
|
@ -233,7 +230,7 @@ Transform_New (scene_t *scene, transform_t parent)
|
|||
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
||||
pref->index, 0);
|
||||
} else {
|
||||
ref->hierarchy = Hierarchy_New (scene, &transform_type, 1);
|
||||
ref->hierarchy = Hierarchy_New (reg, &transform_type, 1);
|
||||
ref->index = 0;
|
||||
}
|
||||
ref->hierarchy->ent[ref->index] = transform;
|
||||
|
@ -242,29 +239,28 @@ Transform_New (scene_t *scene, transform_t parent)
|
|||
}
|
||||
|
||||
void
|
||||
Transform_Delete (scene_t *scene, transform_t transform)
|
||||
Transform_Delete (transform_t transform)
|
||||
{
|
||||
hierref_t *ref = Transform_GetRef (transform);
|
||||
if (ref->index != 0) {
|
||||
// The transform is not the root, so pull it out of its current
|
||||
// hierarchy so deleting it is easier
|
||||
Transform_SetParent (scene, transform, (transform_t) {});
|
||||
Transform_SetParent (transform, (transform_t) {});
|
||||
}
|
||||
// Takes care of freeing the transforms
|
||||
Hierarchy_Delete (ref->hierarchy);
|
||||
}
|
||||
|
||||
transform_t
|
||||
Transform_NewNamed (scene_t *scene, transform_t parent, const char *name)
|
||||
Transform_NewNamed (ecs_registry_t *reg, transform_t parent, const char *name)
|
||||
{
|
||||
transform_t transform = Transform_New (scene, parent);
|
||||
transform_t transform = Transform_New (reg, parent);
|
||||
Transform_SetName (transform, name);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void
|
||||
Transform_SetParent (scene_t *scene, transform_t transform,
|
||||
transform_t parent)
|
||||
Transform_SetParent (transform_t transform, transform_t parent)
|
||||
{
|
||||
if (parent.reg && parent.id != nullent) {
|
||||
__auto_type ref = Transform_GetRef (transform);
|
||||
|
@ -286,7 +282,7 @@ Transform_SetParent (scene_t *scene, transform_t transform,
|
|||
// already root
|
||||
return;
|
||||
}
|
||||
ref->hierarchy = Hierarchy_New (scene, &transform_type, 0);
|
||||
ref->hierarchy = Hierarchy_New (transform.reg, &transform_type, 0);
|
||||
Hierarchy_InsertHierarchy (ref->hierarchy, tref.hierarchy, nullent,
|
||||
tref.index);
|
||||
Hierarchy_RemoveHierarchy (tref.hierarchy, tref.index);
|
||||
|
|
|
@ -41,9 +41,7 @@
|
|||
|
||||
#include "QF/skin.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GL/defines.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
|
|
|
@ -49,9 +49,7 @@
|
|||
#include "QF/GL/qf_iqm.h"
|
||||
#include "QF/GL/qf_rmain.h"
|
||||
#include "QF/GL/qf_vid.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#include "QF/render.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GL/defines.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GL/defines.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
#include "QF/render.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GL/defines.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
|
|
|
@ -44,9 +44,7 @@
|
|||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GLSL/defines.h"
|
||||
#include "QF/GLSL/funcs.h"
|
||||
|
|
|
@ -48,9 +48,7 @@
|
|||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GLSL/defines.h"
|
||||
#include "QF/GLSL/funcs.h"
|
||||
|
|
|
@ -44,9 +44,7 @@
|
|||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GLSL/defines.h"
|
||||
#include "QF/GLSL/funcs.h"
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
#include "QF/screen.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GLSL/defines.h"
|
||||
#include "QF/GLSL/funcs.h"
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
#include "QF/sys.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/GLSL/defines.h"
|
||||
#include "QF/GLSL/funcs.h"
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/render.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
|
|
|
@ -33,9 +33,7 @@
|
|||
#include "QF/qargs.h"
|
||||
#include "QF/render.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "d_local.h"
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "d_ifacea.h"
|
||||
#include "r_internal.h"
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
#include "QF/render.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include "QF/render.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "d_ifacea.h"
|
||||
#include "r_internal.h"
|
||||
|
|
|
@ -42,9 +42,7 @@
|
|||
|
||||
#include "QF/cmd.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "mod_internal.h"
|
||||
|
|
|
@ -40,9 +40,7 @@
|
|||
#include "QF/render.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "QF/plugin/general.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
|
||||
#include "QF/ui/view.h"
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/Vulkan/qf_alias.h"
|
||||
#include "QF/Vulkan/qf_matrices.h"
|
||||
|
|
|
@ -52,9 +52,7 @@
|
|||
#include "QF/va.h"
|
||||
|
||||
#include "QF/math/bitop.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/Vulkan/qf_bsp.h"
|
||||
#include "QF/Vulkan/qf_lightmap.h"
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
#include "QF/iqm.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/Vulkan/qf_iqm.h"
|
||||
#include "QF/Vulkan/qf_matrices.h"
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
#include "QF/screen.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/Vulkan/qf_alias.h"
|
||||
#include "QF/Vulkan/qf_bsp.h"
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
#include "QF/set.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/Vulkan/qf_scene.h"
|
||||
#include "QF/Vulkan/debug.h"
|
||||
|
|
|
@ -51,9 +51,7 @@
|
|||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "QF/Vulkan/qf_matrices.h"
|
||||
#include "QF/Vulkan/qf_renderpass.h"
|
||||
|
|
|
@ -42,9 +42,7 @@
|
|||
#include "QF/heapsort.h"
|
||||
#include "QF/plist.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/Vulkan/capture.h"
|
||||
#include "QF/Vulkan/command.h"
|
||||
#include "QF/Vulkan/debug.h"
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "QF/quakefs.h"
|
||||
#include "QF/render.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
|
||||
#include "client/chase.h"
|
||||
|
|
|
@ -63,6 +63,7 @@ nq_common_LIBFILES= \
|
|||
libs/ruamoko/libQFruamoko.la \
|
||||
libs/gamecode/libQFgamecode.la \
|
||||
libs/ui/libQFui.la \
|
||||
libs/ecs/libQFecs.la \
|
||||
libs/util/libQFutil.la
|
||||
|
||||
nq_client_LIBS= $(nq_client_LIBFILES) $(nq_common_LIBFILES)
|
||||
|
|
|
@ -98,6 +98,7 @@ qw_client_LIBS= \
|
|||
libs/ruamoko/libQFruamoko.la \
|
||||
libs/ui/libQFui.la \
|
||||
libs/input/libQFinput.la \
|
||||
libs/ecs/libQFecs.la \
|
||||
libs/util/libQFutil.la
|
||||
qw_client_libs= qw/source/libqw_client.a qw/source/libqw_common.a \
|
||||
libs/client/libQFclient.la
|
||||
|
|
|
@ -41,9 +41,7 @@
|
|||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@
|
|||
#include "QF/skin.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
|
@ -369,7 +367,7 @@ CL_AddFlagModels (entity_t ent, int team, int key)
|
|||
transform_t ftransform = Entity_Transform (fent);
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
if (!Transform_Valid (Transform_GetParent (ftransform))) {
|
||||
Transform_SetParent (cl_world.scene, ftransform, transform);
|
||||
Transform_SetParent (ftransform, transform);
|
||||
}
|
||||
CL_UpdateFlagModels (ent, key);
|
||||
|
||||
|
@ -391,7 +389,7 @@ CL_RemoveFlagModels (int key)
|
|||
cl_world.scene->reg);
|
||||
transform_t transform = Entity_Transform (fent);
|
||||
*active = 0;
|
||||
Transform_SetParent (cl_world.scene, transform, nulltransform);
|
||||
Transform_SetParent (transform, nulltransform);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -91,9 +91,7 @@
|
|||
#include "QF/gib.h"
|
||||
|
||||
#include "QF/plugin/console.h"
|
||||
#include "QF/scene/component.h"
|
||||
#include "QF/scene/transform.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
||||
#include "buildnum.h"
|
||||
#include "compat.h"
|
||||
|
|
|
@ -100,6 +100,7 @@ qwaq_client_libs= \
|
|||
$(top_builddir)/libs/scene/libQFscene.la \
|
||||
$(top_builddir)/libs/console/libQFconsole.la \
|
||||
$(top_builddir)/libs/ui/libQFui.la \
|
||||
$(top_builddir)/libs/ecs/libQFecs.la \
|
||||
$(top_builddir)/libs/input/libQFinput.la \
|
||||
$(top_builddir)/libs/audio/libQFcd.la \
|
||||
$(top_builddir)/libs/audio/libQFsound.la \
|
||||
|
|
Loading…
Reference in a new issue