diff --git a/src/dusk/entity/CMakeLists.txt b/archive/entity/CMakeLists.txt similarity index 100% rename from src/dusk/entity/CMakeLists.txt rename to archive/entity/CMakeLists.txt diff --git a/src/dusk/entity/component.c b/archive/entity/component.c similarity index 100% rename from src/dusk/entity/component.c rename to archive/entity/component.c diff --git a/src/dusk/entity/component.h b/archive/entity/component.h similarity index 100% rename from src/dusk/entity/component.h rename to archive/entity/component.h diff --git a/src/dusk/entity/component/CMakeLists.txt b/archive/entity/component/CMakeLists.txt similarity index 100% rename from src/dusk/entity/component/CMakeLists.txt rename to archive/entity/component/CMakeLists.txt diff --git a/src/dusk/entity/component/display/CMakeLists.txt b/archive/entity/component/display/CMakeLists.txt similarity index 100% rename from src/dusk/entity/component/display/CMakeLists.txt rename to archive/entity/component/display/CMakeLists.txt diff --git a/src/dusk/entity/component/display/entitycamera.c b/archive/entity/component/display/entitycamera.c similarity index 100% rename from src/dusk/entity/component/display/entitycamera.c rename to archive/entity/component/display/entitycamera.c diff --git a/src/dusk/entity/component/display/entitycamera.h b/archive/entity/component/display/entitycamera.h similarity index 100% rename from src/dusk/entity/component/display/entitycamera.h rename to archive/entity/component/display/entitycamera.h diff --git a/src/dusk/entity/component/display/entityposition.c b/archive/entity/component/display/entityposition.c similarity index 100% rename from src/dusk/entity/component/display/entityposition.c rename to archive/entity/component/display/entityposition.c diff --git a/src/dusk/entity/component/display/entityposition.h b/archive/entity/component/display/entityposition.h similarity index 100% rename from src/dusk/entity/component/display/entityposition.h rename to archive/entity/component/display/entityposition.h diff --git a/src/dusk/entity/component/display/entityrenderable.c b/archive/entity/component/display/entityrenderable.c similarity index 100% rename from src/dusk/entity/component/display/entityrenderable.c rename to archive/entity/component/display/entityrenderable.c diff --git a/src/dusk/entity/component/display/entityrenderable.h b/archive/entity/component/display/entityrenderable.h similarity index 100% rename from src/dusk/entity/component/display/entityrenderable.h rename to archive/entity/component/display/entityrenderable.h diff --git a/src/dusk/entity/component/physics/CMakeLists.txt b/archive/entity/component/physics/CMakeLists.txt similarity index 100% rename from src/dusk/entity/component/physics/CMakeLists.txt rename to archive/entity/component/physics/CMakeLists.txt diff --git a/src/dusk/entity/component/physics/entityphysics.c b/archive/entity/component/physics/entityphysics.c similarity index 100% rename from src/dusk/entity/component/physics/entityphysics.c rename to archive/entity/component/physics/entityphysics.c diff --git a/src/dusk/entity/component/physics/entityphysics.h b/archive/entity/component/physics/entityphysics.h similarity index 100% rename from src/dusk/entity/component/physics/entityphysics.h rename to archive/entity/component/physics/entityphysics.h diff --git a/src/dusk/entity/component/script/CMakeLists.txt b/archive/entity/component/script/CMakeLists.txt similarity index 100% rename from src/dusk/entity/component/script/CMakeLists.txt rename to archive/entity/component/script/CMakeLists.txt diff --git a/src/dusk/entity/component/trigger/CMakeLists.txt b/archive/entity/component/trigger/CMakeLists.txt similarity index 100% rename from src/dusk/entity/component/trigger/CMakeLists.txt rename to archive/entity/component/trigger/CMakeLists.txt diff --git a/src/dusk/entity/component/trigger/entitytrigger.c b/archive/entity/component/trigger/entitytrigger.c similarity index 100% rename from src/dusk/entity/component/trigger/entitytrigger.c rename to archive/entity/component/trigger/entitytrigger.c diff --git a/src/dusk/entity/component/trigger/entitytrigger.h b/archive/entity/component/trigger/entitytrigger.h similarity index 100% rename from src/dusk/entity/component/trigger/entitytrigger.h rename to archive/entity/component/trigger/entitytrigger.h diff --git a/src/dusk/entity/componentlist.h b/archive/entity/componentlist.h similarity index 100% rename from src/dusk/entity/componentlist.h rename to archive/entity/componentlist.h diff --git a/src/dusk/entity/entity.c b/archive/entity/entity.c similarity index 100% rename from src/dusk/entity/entity.c rename to archive/entity/entity.c diff --git a/src/dusk/entity/entity.h b/archive/entity/entity.h similarity index 100% rename from src/dusk/entity/entity.h rename to archive/entity/entity.h diff --git a/src/dusk/entity/entitybase.h b/archive/entity/entitybase.h similarity index 100% rename from src/dusk/entity/entitybase.h rename to archive/entity/entitybase.h diff --git a/src/dusk/entity/entitymanager.c b/archive/entity/entitymanager.c similarity index 100% rename from src/dusk/entity/entitymanager.c rename to archive/entity/entitymanager.c diff --git a/src/dusk/entity/entitymanager.h b/archive/entity/entitymanager.h similarity index 100% rename from src/dusk/entity/entitymanager.h rename to archive/entity/entitymanager.h diff --git a/src/dusk/CMakeLists.txt b/src/dusk/CMakeLists.txt index 21bf7951..3b9db158 100644 --- a/src/dusk/CMakeLists.txt +++ b/src/dusk/CMakeLists.txt @@ -56,7 +56,6 @@ add_subdirectory(console) add_subdirectory(display) add_subdirectory(log) add_subdirectory(engine) -add_subdirectory(entity) add_subdirectory(error) add_subdirectory(input) add_subdirectory(locale) diff --git a/src/dusk/engine/engine.c b/src/dusk/engine/engine.c index 32649669..d055883b 100644 --- a/src/dusk/engine/engine.c +++ b/src/dusk/engine/engine.c @@ -17,8 +17,6 @@ #include "ui/ui.h" #include "ui/uitextbox.h" #include "assert/assert.h" -#include "entity/entitymanager.h" -#include "entity/component/physics/entityphysics.h" #include "physics/physicsmanager.h" #include "network/network.h" #include "system/system.h" @@ -50,7 +48,6 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) { errorChain(cutsceneInit()); errorChain(sceneInit()); - entityManagerInit(); backpackInit(); physicsManagerInit(); errorChain(networkInit()); @@ -92,7 +89,6 @@ errorret_t engineDispose(void) { cutsceneDispose(); sceneDispose(); errorChain(networkDispose()); - entityManagerDispose(); localeManagerDispose(); uiDispose(); consoleDispose(); diff --git a/src/dusk/overworld/mapchunk.c b/src/dusk/overworld/mapchunk.c index a7fa78f3..36c45822 100644 --- a/src/dusk/overworld/mapchunk.c +++ b/src/dusk/overworld/mapchunk.c @@ -7,16 +7,12 @@ #include "mapchunk.h" #include "map.h" -#include "entity/entitymanager.h" #include "util/memory.h" #include "util/string.h" #include "asset/asset.h" #include "console/console.h" errorret_t mapChunkLoad(mapchunk_t *chunk) { - chunk->entityCount = 0; - memoryZero(chunk->entities, sizeof(chunk->entities)); - if(MAP.handle[0] == '\0') errorOk(); char_t path[ASSET_FILE_NAME_MAX]; @@ -48,9 +44,4 @@ void mapChunkUnload(mapchunk_t *chunk) { (int)chunk->position.y, (int)chunk->position.z ); - - for(uint8_t i = 0; i < chunk->entityCount; i++) { - entityDispose(chunk->entities[i]); - } - chunk->entityCount = 0; } diff --git a/src/dusk/overworld/mapchunk.h b/src/dusk/overworld/mapchunk.h index 7513220f..dc66ea0c 100644 --- a/src/dusk/overworld/mapchunk.h +++ b/src/dusk/overworld/mapchunk.h @@ -7,15 +7,12 @@ #pragma once #include "maptypes.h" -#include "entity/entitybase.h" #include "error/error.h" #define MAP_CHUNK_ENTITY_COUNT_MAX 64 typedef struct { chunkpos_t position; - entityid_t entities[MAP_CHUNK_ENTITY_COUNT_MAX]; - uint8_t entityCount; } mapchunk_t; /** diff --git a/src/dusk/physics/physicsworld.c b/src/dusk/physics/physicsworld.c index 02e24ec7..a1b81362 100644 --- a/src/dusk/physics/physicsworld.c +++ b/src/dusk/physics/physicsworld.c @@ -8,8 +8,8 @@ #include "physicsworld.h" #include "assert/assert.h" #include "util/memory.h" -#include "entity/entity.h" -#include "entity/component.h" +// #include "entity/entity.h" +// #include "entity/component.h" #include "physicstest.h" physicsworld_t PHYSICS_WORLD; @@ -23,129 +23,129 @@ void physicsWorldInit() { } void physicsWorldStep(const float_t dt) { - assertTrue(dt > 0.0f, "Delta time must be positive"); + // assertTrue(dt > 0.0f, "Delta time must be positive"); - entityid_t physEnts[ENTITY_COUNT_MAX]; - componentid_t physComps[ENTITY_COUNT_MAX]; - entityid_t physCount = componentGetEntitiesWithComponent( - COMPONENT_TYPE_PHYSICS, physEnts, physComps - ); + // entityid_t physEnts[ENTITY_COUNT_MAX]; + // componentid_t physComps[ENTITY_COUNT_MAX]; + // entityid_t physCount = componentGetEntitiesWithComponent( + // COMPONENT_TYPE_PHYSICS, physEnts, physComps + // ); - /* Pre-fetch all position and physics pointers once. */ - entityposition_t *positions[ENTITY_COUNT_MAX]; - entityphysics_t *physBodies[ENTITY_COUNT_MAX]; - for(entityid_t i = 0; i < physCount; i++) { - componentid_t posComp = entityGetComponent( - physEnts[i], COMPONENT_TYPE_POSITION - ); - positions[i] = (posComp != 0xFF) - ? entityPositionGet(physEnts[i], posComp) - : NULL; - physBodies[i] = entityPhysicsGet(physEnts[i], physComps[i]); - } + // /* Pre-fetch all position and physics pointers once. */ + // entityposition_t *positions[ENTITY_COUNT_MAX]; + // entityphysics_t *physBodies[ENTITY_COUNT_MAX]; + // for(entityid_t i = 0; i < physCount; i++) { + // componentid_t posComp = entityGetComponent( + // physEnts[i], COMPONENT_TYPE_POSITION + // ); + // positions[i] = (posComp != 0xFF) + // ? entityPositionGet(physEnts[i], posComp) + // : NULL; + // physBodies[i] = entityPhysicsGet(physEnts[i], physComps[i]); + // } - /* Phase 1: integrate dynamic bodies (gravity + velocity → position). - * Writes directly to pos->position, matrix rebuilt at end. */ - for(entityid_t i = 0; i < physCount; i++) { - if(!positions[i]) continue; - entityphysics_t *phys = physBodies[i]; - if(phys->type != PHYSICS_BODY_DYNAMIC) continue; + // /* Phase 1: integrate dynamic bodies (gravity + velocity → position). + // * Writes directly to pos->position, matrix rebuilt at end. */ + // for(entityid_t i = 0; i < physCount; i++) { + // if(!positions[i]) continue; + // entityphysics_t *phys = physBodies[i]; + // if(phys->type != PHYSICS_BODY_DYNAMIC) continue; - phys->onGround = false; + // phys->onGround = false; - phys->velocity[0] += PHYSICS_WORLD.gravity[0] * phys->gravityScale * dt; - phys->velocity[1] += PHYSICS_WORLD.gravity[1] * phys->gravityScale * dt; - phys->velocity[2] += PHYSICS_WORLD.gravity[2] * phys->gravityScale * dt; + // phys->velocity[0] += PHYSICS_WORLD.gravity[0] * phys->gravityScale * dt; + // phys->velocity[1] += PHYSICS_WORLD.gravity[1] * phys->gravityScale * dt; + // phys->velocity[2] += PHYSICS_WORLD.gravity[2] * phys->gravityScale * dt; - float_t *pos = positions[i]->position; - pos[0] += phys->velocity[0] * dt; - pos[1] += phys->velocity[1] * dt; - pos[2] += phys->velocity[2] * dt; - } + // float_t *pos = positions[i]->position; + // pos[0] += phys->velocity[0] * dt; + // pos[1] += phys->velocity[1] * dt; + // pos[2] += phys->velocity[2] * dt; + // } - /* Phase 2: dynamic vs static/kinematic. */ - for(entityid_t i = 0; i < physCount; i++) { - if(!positions[i]) continue; - entityphysics_t *phys = physBodies[i]; - if(phys->type != PHYSICS_BODY_DYNAMIC) continue; + // /* Phase 2: dynamic vs static/kinematic. */ + // for(entityid_t i = 0; i < physCount; i++) { + // if(!positions[i]) continue; + // entityphysics_t *phys = physBodies[i]; + // if(phys->type != PHYSICS_BODY_DYNAMIC) continue; - float_t *pos = positions[i]->position; + // float_t *pos = positions[i]->position; - for(entityid_t j = 0; j < physCount; j++) { - if(i == j || !positions[j]) continue; - entityphysics_t *otherPhys = physBodies[j]; - if(otherPhys->type == PHYSICS_BODY_DYNAMIC) continue; + // for(entityid_t j = 0; j < physCount; j++) { + // if(i == j || !positions[j]) continue; + // entityphysics_t *otherPhys = physBodies[j]; + // if(otherPhys->type == PHYSICS_BODY_DYNAMIC) continue; - vec3 normal; float_t depth; - if(!physicsTestShapeVsShape( - pos, phys->shape, - positions[j]->position, otherPhys->shape, - normal, &depth - )) continue; + // vec3 normal; float_t depth; + // if(!physicsTestShapeVsShape( + // pos, phys->shape, + // positions[j]->position, otherPhys->shape, + // normal, &depth + // )) continue; - pos[0] += normal[0] * depth; - pos[1] += normal[1] * depth; - pos[2] += normal[2] * depth; + // pos[0] += normal[0] * depth; + // pos[1] += normal[1] * depth; + // pos[2] += normal[2] * depth; - float_t vn = glm_vec3_dot(phys->velocity, normal); - if(vn < 0.0f) { - phys->velocity[0] -= vn * normal[0]; - phys->velocity[1] -= vn * normal[1]; - phys->velocity[2] -= vn * normal[2]; - } + // float_t vn = glm_vec3_dot(phys->velocity, normal); + // if(vn < 0.0f) { + // phys->velocity[0] -= vn * normal[0]; + // phys->velocity[1] -= vn * normal[1]; + // phys->velocity[2] -= vn * normal[2]; + // } - if(normal[1] > PHYSICS_GROUND_THRESHOLD) phys->onGround = true; - } - } + // if(normal[1] > PHYSICS_GROUND_THRESHOLD) phys->onGround = true; + // } + // } - /* Phase 3: dynamic vs dynamic. */ - for(entityid_t i = 0; i < physCount; i++) { - if(!positions[i]) continue; - entityphysics_t *physA = physBodies[i]; - if(physA->type != PHYSICS_BODY_DYNAMIC) continue; + // /* Phase 3: dynamic vs dynamic. */ + // for(entityid_t i = 0; i < physCount; i++) { + // if(!positions[i]) continue; + // entityphysics_t *physA = physBodies[i]; + // if(physA->type != PHYSICS_BODY_DYNAMIC) continue; - float_t *posA = positions[i]->position; + // float_t *posA = positions[i]->position; - for(entityid_t j = i + 1; j < physCount; j++) { - if(!positions[j]) continue; - entityphysics_t *physB = physBodies[j]; - if(physB->type != PHYSICS_BODY_DYNAMIC) continue; + // for(entityid_t j = i + 1; j < physCount; j++) { + // if(!positions[j]) continue; + // entityphysics_t *physB = physBodies[j]; + // if(physB->type != PHYSICS_BODY_DYNAMIC) continue; - float_t *posB = positions[j]->position; + // float_t *posB = positions[j]->position; - vec3 normal; float_t depth; - if(!physicsTestShapeVsShape( - posA, physA->shape, posB, physB->shape, normal, &depth - )) continue; + // vec3 normal; float_t depth; + // if(!physicsTestShapeVsShape( + // posA, physA->shape, posB, physB->shape, normal, &depth + // )) continue; - posA[0] += normal[0] * depth * 0.5f; - posA[1] += normal[1] * depth * 0.5f; - posA[2] += normal[2] * depth * 0.5f; + // posA[0] += normal[0] * depth * 0.5f; + // posA[1] += normal[1] * depth * 0.5f; + // posA[2] += normal[2] * depth * 0.5f; - posB[0] -= normal[0] * depth * 0.5f; - posB[1] -= normal[1] * depth * 0.5f; - posB[2] -= normal[2] * depth * 0.5f; + // posB[0] -= normal[0] * depth * 0.5f; + // posB[1] -= normal[1] * depth * 0.5f; + // posB[2] -= normal[2] * depth * 0.5f; - float_t v_rel = glm_vec3_dot(physA->velocity, normal) - - glm_vec3_dot(physB->velocity, normal); - if(v_rel < 0.0f) { - physA->velocity[0] -= v_rel * normal[0]; - physA->velocity[1] -= v_rel * normal[1]; - physA->velocity[2] -= v_rel * normal[2]; - physB->velocity[0] += v_rel * normal[0]; - physB->velocity[1] += v_rel * normal[1]; - physB->velocity[2] += v_rel * normal[2]; - } + // float_t v_rel = glm_vec3_dot(physA->velocity, normal) + // - glm_vec3_dot(physB->velocity, normal); + // if(v_rel < 0.0f) { + // physA->velocity[0] -= v_rel * normal[0]; + // physA->velocity[1] -= v_rel * normal[1]; + // physA->velocity[2] -= v_rel * normal[2]; + // physB->velocity[0] += v_rel * normal[0]; + // physB->velocity[1] += v_rel * normal[1]; + // physB->velocity[2] += v_rel * normal[2]; + // } - if( normal[1] > PHYSICS_GROUND_THRESHOLD) physA->onGround = true; - if(-normal[1] > PHYSICS_GROUND_THRESHOLD) physB->onGround = true; - } - } + // if( normal[1] > PHYSICS_GROUND_THRESHOLD) physA->onGround = true; + // if(-normal[1] > PHYSICS_GROUND_THRESHOLD) physB->onGround = true; + // } + // } - /* Rebuild transforms for all dynamic bodies once, after all phases. */ - for(entityid_t i = 0; i < physCount; i++) { - if(!positions[i]) continue; - if(physBodies[i]->type != PHYSICS_BODY_DYNAMIC) continue; - entityPositionRebuild(positions[i]); - } + // /* Rebuild transforms for all dynamic bodies once, after all phases. */ + // for(entityid_t i = 0; i < physCount; i++) { + // if(!positions[i]) continue; + // if(physBodies[i]->type != PHYSICS_BODY_DYNAMIC) continue; + // entityPositionRebuild(positions[i]); + // } } diff --git a/src/dusk/scene/scene.c b/src/dusk/scene/scene.c index 0473eca5..c215dc19 100644 --- a/src/dusk/scene/scene.c +++ b/src/dusk/scene/scene.c @@ -9,12 +9,9 @@ #include "log/log.h" #include "time/time.h" #include "display/screen/screen.h" -#include "entity/entitymanager.h" -#include "entity/component/display/entityrenderable.h" #include "display/shader/shaderunlit.h" #include "display/spritebatch/spritebatch.h" #include "display/screen/screen.h" -#include "console/console.h" #include "util/string.h" #include "ui/ui.h"