| 37 | namespace crown |
| 38 | { |
| 39 | static void create_components(World &w |
| 40 | , const UnitResource *ur |
| 41 | , const UnitId *unit_lookup |
| 42 | , u32 spawn_flags |
| 43 | , const Vector3 &pos |
| 44 | , const Quaternion &rot |
| 45 | , const Vector3 &scl |
| 46 | ) |
| 47 | { |
| 48 | SceneGraph *scene_graph = w._scene_graph; |
| 49 | RenderWorld *render_world = w._render_world; |
| 50 | PhysicsWorld *physics_world = w._physics_world; |
| 51 | ScriptWorld *script_world = w._script_world; |
| 52 | AnimationStateMachine *animation_state_machine = w._animation_state_machine; |
| 53 | |
| 54 | const u32 *unit_parents = unit_resource::parents(ur); |
| 55 | const ComponentData *component = unit_resource::component_type_data(ur, NULL); |
| 56 | for (u32 cc = 0; cc < ur->num_component_types; ++cc) { |
| 57 | const u32 *unit_index = unit_resource::component_unit_index(component); |
| 58 | const char *data = unit_resource::component_payload(component); |
| 59 | |
| 60 | if (component->type == STRING_ID_32("transform", UINT32_C(0xad9b5315))) { |
| 61 | scene_graph->create_instances(data |
| 62 | , component->num_instances |
| 63 | , unit_lookup |
| 64 | , unit_index |
| 65 | , unit_parents |
| 66 | , spawn_flags |
| 67 | , pos |
| 68 | , rot |
| 69 | , scl |
| 70 | ); |
| 71 | } else if (component->type == STRING_ID_32("camera", UINT32_C(0x31822dc7))) { |
| 72 | w.camera_create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 73 | } else if (component->type == STRING_ID_32("collider", UINT32_C(0x2129d74e))) { |
| 74 | physics_world->collider_create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 75 | } else if (component->type == STRING_ID_32("actor", UINT32_C(0x374cf583))) { |
| 76 | physics_world->actor_create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 77 | } else if (component->type == STRING_ID_32("mover", UINT32_C(0xac07d371))) { |
| 78 | physics_world->mover_create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 79 | } else if (component->type == STRING_ID_32("fixed_joint", UINT32_C(0x9ada03c1)) |
| 80 | || component->type == STRING_ID_32("hinge_joint", UINT32_C(0xbb32c4e8)) |
| 81 | || component->type == STRING_ID_32("spherical_joint", UINT32_C(0x066c63e3)) |
| 82 | || component->type == STRING_ID_32("limb_joint", UINT32_C(0x7068fff7)) |
| 83 | || component->type == STRING_ID_32("spring_joint", UINT32_C(0x6ccbbba7)) |
| 84 | || component->type == STRING_ID_32("d6_joint", UINT32_C(0x1099cc71))) { |
| 85 | physics_world->joint_create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 86 | } else if (component->type == STRING_ID_32("mesh_renderer", UINT32_C(0xdf017893))) { |
| 87 | render_world->_mesh_manager.create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 88 | } else if (component->type == STRING_ID_32("sprite_renderer", UINT32_C(0x6a1c2a3b))) { |
| 89 | render_world->_sprite_manager.create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 90 | } else if (component->type == STRING_ID_32("lod_group", UINT32_C(0x22a1a9f0))) { |
| 91 | render_world->_lod_group_manager.create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 92 | } else if (component->type == STRING_ID_32("light", UINT32_C(0xbb9f08c2))) { |
| 93 | render_world->_light_manager.create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 94 | } else if (component->type == STRING_ID_32("fog", UINT32_C(0xf007ef0d))) { |
| 95 | render_world->fog_create_instances(data, component->num_instances, unit_lookup, unit_index); |
| 96 | } else if (component->type == STRING_ID_32("global_lighting", UINT32_C(0x718af7fe))) { |
no test coverage detected