2021-07-24 05:19:52 +00:00
|
|
|
/*
|
2022-10-08 16:08:48 +00:00
|
|
|
hierarchy.h
|
2021-07-24 05:19:52 +00:00
|
|
|
|
|
|
|
Hierarchy management
|
|
|
|
|
|
|
|
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2021/02/26
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-10-26 06:22:09 +00:00
|
|
|
#ifndef __QF_ecs_hierarchy_h
|
|
|
|
#define __QF_ecs_hierarchy_h
|
2021-07-24 05:19:52 +00:00
|
|
|
|
|
|
|
#include "QF/qtypes.h"
|
|
|
|
|
|
|
|
/** \defgroup entity Hierarchy management
|
|
|
|
\ingroup utils
|
|
|
|
*/
|
|
|
|
///@{
|
|
|
|
|
2022-10-09 17:00:33 +00:00
|
|
|
/** Descriptors for components attached to every entity in the hierarchy.
|
|
|
|
*/
|
|
|
|
typedef struct hierarchy_type_s {
|
|
|
|
uint32_t num_components;
|
|
|
|
const struct component_s *components;
|
|
|
|
} hierarchy_type_t;
|
|
|
|
|
|
|
|
typedef struct hierref_s {
|
|
|
|
struct hierarchy_s *hierarchy;
|
|
|
|
uint32_t index; ///< index in hierarchy
|
|
|
|
} hierref_t;
|
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
typedef struct hierarchy_s {
|
2022-10-26 06:22:09 +00:00
|
|
|
struct ecs_registry_s *reg;
|
2022-10-09 17:00:33 +00:00
|
|
|
uint32_t num_objects;
|
|
|
|
uint32_t max_objects;
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
uint32_t *ent;
|
2022-10-09 17:00:33 +00:00
|
|
|
uint32_t *childCount;
|
|
|
|
uint32_t *childIndex;
|
|
|
|
uint32_t *parentIndex;
|
|
|
|
const hierarchy_type_t *type;
|
|
|
|
void **components;
|
2021-07-24 05:19:52 +00:00
|
|
|
} hierarchy_t;
|
|
|
|
|
2022-10-26 06:22:09 +00:00
|
|
|
hierarchy_t *Hierarchy_New (struct ecs_registry_s *reg,
|
2022-10-09 17:00:33 +00:00
|
|
|
const hierarchy_type_t *type, int createRoot);
|
2022-05-08 02:14:00 +00:00
|
|
|
void Hierarchy_Reserve (hierarchy_t *hierarchy, uint32_t count);
|
2022-10-26 06:22:09 +00:00
|
|
|
hierarchy_t *Hierarchy_Copy (struct ecs_registry_s *reg,
|
|
|
|
const hierarchy_t *src);
|
2021-07-24 05:19:52 +00:00
|
|
|
void Hierarchy_Delete (hierarchy_t *hierarchy);
|
|
|
|
|
|
|
|
uint32_t Hierarchy_InsertHierarchy (hierarchy_t *dst, const hierarchy_t *src,
|
|
|
|
uint32_t dstParent, uint32_t srcRoot);
|
|
|
|
void Hierarchy_RemoveHierarchy (hierarchy_t *hierarchy, uint32_t index);
|
2022-11-05 08:38:14 +00:00
|
|
|
|
|
|
|
hierref_t Hierarchy_SetParent (hierarchy_t *dst, uint32_t dstParent,
|
|
|
|
hierarchy_t *src, uint32_t srcIndex);
|
2021-07-24 05:19:52 +00:00
|
|
|
///@}
|
|
|
|
|
2022-10-26 06:22:09 +00:00
|
|
|
#endif//__QF_ecs_hierarchy_h
|