Disable old ent code

This commit is contained in:
2026-05-21 10:18:20 -05:00
parent 6502822583
commit efd31237be
30 changed files with 104 additions and 124 deletions
-1
View File
@@ -56,7 +56,6 @@ add_subdirectory(console)
add_subdirectory(display) add_subdirectory(display)
add_subdirectory(log) add_subdirectory(log)
add_subdirectory(engine) add_subdirectory(engine)
add_subdirectory(entity)
add_subdirectory(error) add_subdirectory(error)
add_subdirectory(input) add_subdirectory(input)
add_subdirectory(locale) add_subdirectory(locale)
-4
View File
@@ -17,8 +17,6 @@
#include "ui/ui.h" #include "ui/ui.h"
#include "ui/uitextbox.h" #include "ui/uitextbox.h"
#include "assert/assert.h" #include "assert/assert.h"
#include "entity/entitymanager.h"
#include "entity/component/physics/entityphysics.h"
#include "physics/physicsmanager.h" #include "physics/physicsmanager.h"
#include "network/network.h" #include "network/network.h"
#include "system/system.h" #include "system/system.h"
@@ -50,7 +48,6 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
errorChain(cutsceneInit()); errorChain(cutsceneInit());
errorChain(sceneInit()); errorChain(sceneInit());
entityManagerInit();
backpackInit(); backpackInit();
physicsManagerInit(); physicsManagerInit();
errorChain(networkInit()); errorChain(networkInit());
@@ -92,7 +89,6 @@ errorret_t engineDispose(void) {
cutsceneDispose(); cutsceneDispose();
sceneDispose(); sceneDispose();
errorChain(networkDispose()); errorChain(networkDispose());
entityManagerDispose();
localeManagerDispose(); localeManagerDispose();
uiDispose(); uiDispose();
consoleDispose(); consoleDispose();
-9
View File
@@ -7,16 +7,12 @@
#include "mapchunk.h" #include "mapchunk.h"
#include "map.h" #include "map.h"
#include "entity/entitymanager.h"
#include "util/memory.h" #include "util/memory.h"
#include "util/string.h" #include "util/string.h"
#include "asset/asset.h" #include "asset/asset.h"
#include "console/console.h" #include "console/console.h"
errorret_t mapChunkLoad(mapchunk_t *chunk) { errorret_t mapChunkLoad(mapchunk_t *chunk) {
chunk->entityCount = 0;
memoryZero(chunk->entities, sizeof(chunk->entities));
if(MAP.handle[0] == '\0') errorOk(); if(MAP.handle[0] == '\0') errorOk();
char_t path[ASSET_FILE_NAME_MAX]; char_t path[ASSET_FILE_NAME_MAX];
@@ -48,9 +44,4 @@ void mapChunkUnload(mapchunk_t *chunk) {
(int)chunk->position.y, (int)chunk->position.y,
(int)chunk->position.z (int)chunk->position.z
); );
for(uint8_t i = 0; i < chunk->entityCount; i++) {
entityDispose(chunk->entities[i]);
}
chunk->entityCount = 0;
} }
-3
View File
@@ -7,15 +7,12 @@
#pragma once #pragma once
#include "maptypes.h" #include "maptypes.h"
#include "entity/entitybase.h"
#include "error/error.h" #include "error/error.h"
#define MAP_CHUNK_ENTITY_COUNT_MAX 64 #define MAP_CHUNK_ENTITY_COUNT_MAX 64
typedef struct { typedef struct {
chunkpos_t position; chunkpos_t position;
entityid_t entities[MAP_CHUNK_ENTITY_COUNT_MAX];
uint8_t entityCount;
} mapchunk_t; } mapchunk_t;
/** /**
+104 -104
View File
@@ -8,8 +8,8 @@
#include "physicsworld.h" #include "physicsworld.h"
#include "assert/assert.h" #include "assert/assert.h"
#include "util/memory.h" #include "util/memory.h"
#include "entity/entity.h" // #include "entity/entity.h"
#include "entity/component.h" // #include "entity/component.h"
#include "physicstest.h" #include "physicstest.h"
physicsworld_t PHYSICS_WORLD; physicsworld_t PHYSICS_WORLD;
@@ -23,129 +23,129 @@ void physicsWorldInit() {
} }
void physicsWorldStep(const float_t dt) { 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]; // entityid_t physEnts[ENTITY_COUNT_MAX];
componentid_t physComps[ENTITY_COUNT_MAX]; // componentid_t physComps[ENTITY_COUNT_MAX];
entityid_t physCount = componentGetEntitiesWithComponent( // entityid_t physCount = componentGetEntitiesWithComponent(
COMPONENT_TYPE_PHYSICS, physEnts, physComps // COMPONENT_TYPE_PHYSICS, physEnts, physComps
); // );
/* Pre-fetch all position and physics pointers once. */ // /* Pre-fetch all position and physics pointers once. */
entityposition_t *positions[ENTITY_COUNT_MAX]; // entityposition_t *positions[ENTITY_COUNT_MAX];
entityphysics_t *physBodies[ENTITY_COUNT_MAX]; // entityphysics_t *physBodies[ENTITY_COUNT_MAX];
for(entityid_t i = 0; i < physCount; i++) { // for(entityid_t i = 0; i < physCount; i++) {
componentid_t posComp = entityGetComponent( // componentid_t posComp = entityGetComponent(
physEnts[i], COMPONENT_TYPE_POSITION // physEnts[i], COMPONENT_TYPE_POSITION
); // );
positions[i] = (posComp != 0xFF) // positions[i] = (posComp != 0xFF)
? entityPositionGet(physEnts[i], posComp) // ? entityPositionGet(physEnts[i], posComp)
: NULL; // : NULL;
physBodies[i] = entityPhysicsGet(physEnts[i], physComps[i]); // physBodies[i] = entityPhysicsGet(physEnts[i], physComps[i]);
} // }
/* Phase 1: integrate dynamic bodies (gravity + velocity → position). // /* Phase 1: integrate dynamic bodies (gravity + velocity → position).
* Writes directly to pos->position, matrix rebuilt at end. */ // * Writes directly to pos->position, matrix rebuilt at end. */
for(entityid_t i = 0; i < physCount; i++) { // for(entityid_t i = 0; i < physCount; i++) {
if(!positions[i]) continue; // if(!positions[i]) continue;
entityphysics_t *phys = physBodies[i]; // entityphysics_t *phys = physBodies[i];
if(phys->type != PHYSICS_BODY_DYNAMIC) continue; // 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[0] += PHYSICS_WORLD.gravity[0] * phys->gravityScale * dt;
phys->velocity[1] += PHYSICS_WORLD.gravity[1] * 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[2] += PHYSICS_WORLD.gravity[2] * phys->gravityScale * dt;
float_t *pos = positions[i]->position; // float_t *pos = positions[i]->position;
pos[0] += phys->velocity[0] * dt; // pos[0] += phys->velocity[0] * dt;
pos[1] += phys->velocity[1] * dt; // pos[1] += phys->velocity[1] * dt;
pos[2] += phys->velocity[2] * dt; // pos[2] += phys->velocity[2] * dt;
} // }
/* Phase 2: dynamic vs static/kinematic. */ // /* Phase 2: dynamic vs static/kinematic. */
for(entityid_t i = 0; i < physCount; i++) { // for(entityid_t i = 0; i < physCount; i++) {
if(!positions[i]) continue; // if(!positions[i]) continue;
entityphysics_t *phys = physBodies[i]; // entityphysics_t *phys = physBodies[i];
if(phys->type != PHYSICS_BODY_DYNAMIC) continue; // 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++) { // for(entityid_t j = 0; j < physCount; j++) {
if(i == j || !positions[j]) continue; // if(i == j || !positions[j]) continue;
entityphysics_t *otherPhys = physBodies[j]; // entityphysics_t *otherPhys = physBodies[j];
if(otherPhys->type == PHYSICS_BODY_DYNAMIC) continue; // if(otherPhys->type == PHYSICS_BODY_DYNAMIC) continue;
vec3 normal; float_t depth; // vec3 normal; float_t depth;
if(!physicsTestShapeVsShape( // if(!physicsTestShapeVsShape(
pos, phys->shape, // pos, phys->shape,
positions[j]->position, otherPhys->shape, // positions[j]->position, otherPhys->shape,
normal, &depth // normal, &depth
)) continue; // )) continue;
pos[0] += normal[0] * depth; // pos[0] += normal[0] * depth;
pos[1] += normal[1] * depth; // pos[1] += normal[1] * depth;
pos[2] += normal[2] * depth; // pos[2] += normal[2] * depth;
float_t vn = glm_vec3_dot(phys->velocity, normal); // float_t vn = glm_vec3_dot(phys->velocity, normal);
if(vn < 0.0f) { // if(vn < 0.0f) {
phys->velocity[0] -= vn * normal[0]; // phys->velocity[0] -= vn * normal[0];
phys->velocity[1] -= vn * normal[1]; // phys->velocity[1] -= vn * normal[1];
phys->velocity[2] -= vn * normal[2]; // 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. */ // /* Phase 3: dynamic vs dynamic. */
for(entityid_t i = 0; i < physCount; i++) { // for(entityid_t i = 0; i < physCount; i++) {
if(!positions[i]) continue; // if(!positions[i]) continue;
entityphysics_t *physA = physBodies[i]; // entityphysics_t *physA = physBodies[i];
if(physA->type != PHYSICS_BODY_DYNAMIC) continue; // 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++) { // for(entityid_t j = i + 1; j < physCount; j++) {
if(!positions[j]) continue; // if(!positions[j]) continue;
entityphysics_t *physB = physBodies[j]; // entityphysics_t *physB = physBodies[j];
if(physB->type != PHYSICS_BODY_DYNAMIC) continue; // if(physB->type != PHYSICS_BODY_DYNAMIC) continue;
float_t *posB = positions[j]->position; // float_t *posB = positions[j]->position;
vec3 normal; float_t depth; // vec3 normal; float_t depth;
if(!physicsTestShapeVsShape( // if(!physicsTestShapeVsShape(
posA, physA->shape, posB, physB->shape, normal, &depth // posA, physA->shape, posB, physB->shape, normal, &depth
)) continue; // )) continue;
posA[0] += normal[0] * depth * 0.5f; // posA[0] += normal[0] * depth * 0.5f;
posA[1] += normal[1] * depth * 0.5f; // posA[1] += normal[1] * depth * 0.5f;
posA[2] += normal[2] * depth * 0.5f; // posA[2] += normal[2] * depth * 0.5f;
posB[0] -= normal[0] * depth * 0.5f; // posB[0] -= normal[0] * depth * 0.5f;
posB[1] -= normal[1] * depth * 0.5f; // posB[1] -= normal[1] * depth * 0.5f;
posB[2] -= normal[2] * depth * 0.5f; // posB[2] -= normal[2] * depth * 0.5f;
float_t v_rel = glm_vec3_dot(physA->velocity, normal) // float_t v_rel = glm_vec3_dot(physA->velocity, normal)
- glm_vec3_dot(physB->velocity, normal); // - glm_vec3_dot(physB->velocity, normal);
if(v_rel < 0.0f) { // if(v_rel < 0.0f) {
physA->velocity[0] -= v_rel * normal[0]; // physA->velocity[0] -= v_rel * normal[0];
physA->velocity[1] -= v_rel * normal[1]; // physA->velocity[1] -= v_rel * normal[1];
physA->velocity[2] -= v_rel * normal[2]; // physA->velocity[2] -= v_rel * normal[2];
physB->velocity[0] += v_rel * normal[0]; // physB->velocity[0] += v_rel * normal[0];
physB->velocity[1] += v_rel * normal[1]; // physB->velocity[1] += v_rel * normal[1];
physB->velocity[2] += v_rel * normal[2]; // physB->velocity[2] += v_rel * normal[2];
} // }
if( normal[1] > PHYSICS_GROUND_THRESHOLD) physA->onGround = true; // if( normal[1] > PHYSICS_GROUND_THRESHOLD) physA->onGround = true;
if(-normal[1] > PHYSICS_GROUND_THRESHOLD) physB->onGround = true; // if(-normal[1] > PHYSICS_GROUND_THRESHOLD) physB->onGround = true;
} // }
} // }
/* Rebuild transforms for all dynamic bodies once, after all phases. */ // /* Rebuild transforms for all dynamic bodies once, after all phases. */
for(entityid_t i = 0; i < physCount; i++) { // for(entityid_t i = 0; i < physCount; i++) {
if(!positions[i]) continue; // if(!positions[i]) continue;
if(physBodies[i]->type != PHYSICS_BODY_DYNAMIC) continue; // if(physBodies[i]->type != PHYSICS_BODY_DYNAMIC) continue;
entityPositionRebuild(positions[i]); // entityPositionRebuild(positions[i]);
} // }
} }
-3
View File
@@ -9,12 +9,9 @@
#include "log/log.h" #include "log/log.h"
#include "time/time.h" #include "time/time.h"
#include "display/screen/screen.h" #include "display/screen/screen.h"
#include "entity/entitymanager.h"
#include "entity/component/display/entityrenderable.h"
#include "display/shader/shaderunlit.h" #include "display/shader/shaderunlit.h"
#include "display/spritebatch/spritebatch.h" #include "display/spritebatch/spritebatch.h"
#include "display/screen/screen.h" #include "display/screen/screen.h"
#include "console/console.h"
#include "util/string.h" #include "util/string.h"
#include "ui/ui.h" #include "ui/ui.h"