Bladeren bron

world: cleanup

Daniele Bartolini 2 jaren geleden
bovenliggende
commit
ebb9d22665
2 gewijzigde bestanden met toevoegingen van 9 en 19 verwijderingen
  1. 0 10
      src/world/types.h
  2. 9 9
      src/world/world.cpp

+ 0 - 10
src/world/types.h

@@ -43,16 +43,6 @@ typedef u32 SoundInstanceId;
 #define PHYSICS_WORLD_MARKER           UINT32_C(0x1cf49bae)
 #define ANIMATION_STATE_MACHINE_MARKER UINT32_C(0x59a1c462)
 
-#define COMPONENT_TYPE_ACTOR                   STRING_ID_32("actor",                   UINT32_C(0x13958a55))
-#define COMPONENT_TYPE_CAMERA                  STRING_ID_32("camera",                  UINT32_C(0x5005ac7a))
-#define COMPONENT_TYPE_COLLIDER                STRING_ID_32("collider",                UINT32_C(0x3b9259cb))
-#define COMPONENT_TYPE_LIGHT                   STRING_ID_32("light",                   UINT32_C(0x4cf76c7b))
-#define COMPONENT_TYPE_MESH_RENDERER           STRING_ID_32("mesh_renderer",           UINT32_C(0x2554ca17))
-#define COMPONENT_TYPE_SPRITE_RENDERER         STRING_ID_32("sprite_renderer",         UINT32_C(0x7b4af6de))
-#define COMPONENT_TYPE_TRANSFORM               STRING_ID_32("transform",               UINT32_C(0xb4363995))
-#define COMPONENT_TYPE_SCRIPT                  STRING_ID_32("script",                  UINT32_C(0x2cf63026))
-#define COMPONENT_TYPE_ANIMATION_STATE_MACHINE STRING_ID_32("animation_state_machine", UINT32_C(0xe3970e6b))
-
 /// Enumerates camera projection types.
 ///
 /// @ingroup World

+ 9 - 9
src/world/world.cpp

@@ -599,7 +599,7 @@ void spawn_units(World &w, const UnitResource *ur, const Vector3 &pos, const Qua
 		const u32 *unit_index = unit_resource::component_unit_index(component);
 		const char *data = unit_resource::component_payload(component);
 
-		if (component->type == COMPONENT_TYPE_TRANSFORM) {
+		if (component->type == STRING_ID_32("transform", UINT32_C(0xb4363995))) {
 			const TransformDesc *td = (const TransformDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++td) {
 				// FIXME: add SceneGraph::allocate() to reserve an instance
@@ -622,12 +622,12 @@ void spawn_units(World &w, const UnitResource *ur, const Vector3 &pos, const Qua
 					scene_graph->set_local_scale(ti, scale);
 				}
 			}
-		} else if (component->type == COMPONENT_TYPE_CAMERA) {
+		} else if (component->type == STRING_ID_32("camera", UINT32_C(0x5005ac7a))) {
 			const CameraDesc *cd = (const CameraDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++cd) {
 				w.camera_create(unit_lookup[unit_index[i]], *cd, MATRIX4X4_IDENTITY);
 			}
-		} else if (component->type == COMPONENT_TYPE_COLLIDER) {
+		} else if (component->type == STRING_ID_32("collider", UINT32_C(0x3b9259cb))) {
 			const ColliderDesc *cd = (const ColliderDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i) {
 				TransformInstance ti = scene_graph->instance(unit_lookup[unit_index[i]]);
@@ -635,40 +635,40 @@ void spawn_units(World &w, const UnitResource *ur, const Vector3 &pos, const Qua
 				physics_world->collider_create(unit_lookup[unit_index[i]], cd, scale(tm));
 				cd = (ColliderDesc *)((char *)(cd + 1) + cd->size);
 			}
-		} else if (component->type == COMPONENT_TYPE_ACTOR) {
+		} else if (component->type == STRING_ID_32("actor", UINT32_C(0x13958a55))) {
 			const ActorResource *ar = (const ActorResource *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++ar) {
 				TransformInstance ti = scene_graph->instance(unit_lookup[unit_index[i]]);
 				Matrix4x4 tm = scene_graph->world_pose(ti);
 				physics_world->actor_create(unit_lookup[unit_index[i]], ar, from_quaternion_translation(rotation(tm), translation(tm)));
 			}
-		} else if (component->type == COMPONENT_TYPE_MESH_RENDERER) {
+		} else if (component->type == STRING_ID_32("mesh_renderer", UINT32_C(0x2554ca17))) {
 			const MeshRendererDesc *mrd = (const MeshRendererDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++mrd) {
 				TransformInstance ti = scene_graph->instance(unit_lookup[unit_index[i]]);
 				Matrix4x4 tm = scene_graph->world_pose(ti);
 				render_world->mesh_create(unit_lookup[unit_index[i]], *mrd, tm);
 			}
-		} else if (component->type == COMPONENT_TYPE_SPRITE_RENDERER) {
+		} else if (component->type == STRING_ID_32("sprite_renderer", UINT32_C(0x7b4af6de))) {
 			const SpriteRendererDesc *srd = (const SpriteRendererDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++srd) {
 				TransformInstance ti = scene_graph->instance(unit_lookup[unit_index[i]]);
 				Matrix4x4 tm = scene_graph->world_pose(ti);
 				render_world->sprite_create(unit_lookup[unit_index[i]], *srd, tm);
 			}
-		} else if (component->type == COMPONENT_TYPE_LIGHT) {
+		} else if (component->type == STRING_ID_32("light", UINT32_C(0x4cf76c7b))) {
 			const LightDesc *ld = (const LightDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++ld) {
 				TransformInstance ti = scene_graph->instance(unit_lookup[unit_index[i]]);
 				Matrix4x4 tm = scene_graph->world_pose(ti);
 				render_world->light_create(unit_lookup[unit_index[i]], *ld, tm);
 			}
-		} else if (component->type == COMPONENT_TYPE_SCRIPT) {
+		} else if (component->type == STRING_ID_32("script", UINT32_C(0x2cf63026))) {
 			const ScriptDesc *sd = (const ScriptDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++sd) {
 				script_world::create(*script_world, unit_lookup[unit_index[i]], *sd);
 			}
-		} else if (component->type == COMPONENT_TYPE_ANIMATION_STATE_MACHINE) {
+		} else if (component->type == STRING_ID_32("animation_state_machine", UINT32_C(0xe3970e6b))) {
 			const AnimationStateMachineDesc *asmd = (const AnimationStateMachineDesc *)data;
 			for (u32 i = 0, n = component->num_instances; i < n; ++i, ++asmd) {
 				animation_state_machine->create(unit_lookup[unit_index[i]], *asmd);