aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/world.c b/src/world.c
index 94b6400..3d4682d 100644
--- a/src/world.c
+++ b/src/world.c
@@ -46,16 +46,16 @@ size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world)
entities[index].position);
overlapBox.min = Vector3Min(
overlapBox.min,
- entities[leaf.entities[innerIndex]].position);
+ entities[leaf.entities[innerIndex]].box.min);
overlapBox.min = Vector3Min(
overlapBox.min,
- entities[index].position);
+ entities[index].box.min);
overlapBox.max = Vector3Max(
overlapBox.max,
- entities[leaf.entities[innerIndex]].position);
+ entities[leaf.entities[innerIndex]].box.max);
overlapBox.max = Vector3Max(
overlapBox.max,
- entities[index].position);
+ entities[index].box.max);
}
distance /= (float)leafIndex;
@@ -100,8 +100,8 @@ size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world)
}
// Get bounding box.
- leaf.box.min = world->entities[leaf.entities[0]].position;
- leaf.box.max = world->entities[leaf.entities[0]].position;
+ leaf.box.min = world->entities[leaf.entities[0]].box.min;
+ leaf.box.max = world->entities[leaf.entities[0]].box.max;
for (int index = 1; index < BVH_MAX; ++index)
{
@@ -112,10 +112,10 @@ size_t buildWorldBVHLeafs(BVHNode leafs[WORLD_ENTITY_MAX], const World* world)
leaf.box.min = Vector3Min(
leaf.box.min,
- world->entities[leaf.entities[index]].position);
+ world->entities[leaf.entities[index]].box.min);
leaf.box.max = Vector3Max(
leaf.box.max,
- world->entities[leaf.entities[index]].position);
+ world->entities[leaf.entities[index]].box.max);
}
leafs[leafsSize] = leaf;
@@ -193,10 +193,13 @@ World createWorld(int seed)
FT_RANDOM16(seed);
Entity entity = createEntity(seed % ENTITY_COUNT, Vector3Zero());
- entity.position.x = FT_RANDOM16(seed) % (int)world.size.x;
- entity.position.z = FT_RANDOM16(seed) % (int)world.size.z;
- entity.position.y = getWorldHeightAtLocation(&world, entity.position.x,
- entity.position.z) + 1.0;
+ Vector3 position;
+ position.x = FT_RANDOM16(seed) % (int)world.size.x;
+ position.z = FT_RANDOM16(seed) % (int)world.size.z;
+ position.y = getWorldHeightAtLocation(&world,
+ position.x, position.z) + 1.0;
+ setEntityPosition(&entity, position);
+
world.entities[index] = entity;
}