Back to floats.

This commit is contained in:
2025-10-10 09:16:08 -05:00
parent c4c43b23ad
commit 349e6e7c94
16 changed files with 164 additions and 220 deletions

View File

@@ -51,27 +51,16 @@ void entityUpdate(entity_t *entity) {
playerMovement(entity);
}
// Velocity
for(uint8_t i = 0; i < WORLD_DIMENSIONS; i++) {
if(entity->velocity[i] == 0) continue;
// Add velcoity
glm_vec3_muladds(entity->velocity, TIME.delta, entity->position);
worldPosAddSubtile(&entity->position[i], entity->velocity[i]);
// Apply friction
glm_vec3_muladds(
entity->velocity, -ENTITY_FRICTION * TIME.delta, entity->velocity
);
// Friction
worldsubtile_t v = entity->velocity[i];
if (v > 0) {
v -= ENTITY_FRICTION;
if (v < ENTITY_MIN_VELOCITY) v = 0;
} else if (v < 0) {
v += ENTITY_FRICTION;
if (v > -ENTITY_MIN_VELOCITY) v = 0;
}
if ((v > 0 && v < ENTITY_FRICTION) || (v < 0 && v > -ENTITY_FRICTION)) {
v = 0;
}
entity->velocity[i] = v;
// Clamp small velocities to zero
if(glm_vec3_norm(entity->velocity) < ENTITY_MIN_VELOCITY) {
glm_vec3_zero(entity->velocity);
}
}