aboutsummaryrefslogtreecommitdiffstats
path: root/src/entity.c
diff options
context:
space:
mode:
authornathan <nathan@disroot.org>2025-07-09 09:46:18 +0000
committernathan <nathan@disroot.org>2025-07-09 09:46:18 +0000
commit204ad4a59f782ce7faf2f0418b33538cf15a84cb (patch)
tree263b6d149585ab6585b01cc7ca39a46ddac3f4d7 /src/entity.c
parentd594afee3b6c55f24ecf05663b688ea488f073e6 (diff)
downloadFindThings-204ad4a59f782ce7faf2f0418b33538cf15a84cb.tar.gz
FindThings-204ad4a59f782ce7faf2f0418b33538cf15a84cb.tar.bz2
FindThings-204ad4a59f782ce7faf2f0418b33538cf15a84cb.zip
Using the entity bounding box for something now
Diffstat (limited to 'src/entity.c')
-rw-r--r--src/entity.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/entity.c b/src/entity.c
index 0fe6366..e510a01 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -6,11 +6,13 @@ Entity createEntity(EntityId id, Vector3 position)
{
Entity entity;
entity.id = id;
- entity.position = position;
- // Test boundingbox.
- entity.box.min = Vector3SubtractValue(position, 1.0);
- entity.box.max = Vector3AddValue(position, 1.0);
+ // Test box.
+ float boxSize = 0.4;
+ entity.box.min = (Vector3){-boxSize, -boxSize, -boxSize};
+ entity.box.max = (Vector3){boxSize, boxSize, boxSize};
+
+ setEntityPosition(&entity, position);
return entity;
}
@@ -31,3 +33,10 @@ void updateEntity(Entity* entity, Game* game)
break;
}
}
+
+void setEntityPosition(Entity* entity, Vector3 position)
+{
+ entity->position = position;
+ entity->box.min = Vector3Add(entity->box.min, position);
+ entity->box.max = Vector3Add(entity->box.max, position);
+}