Skip to content

Commit 9e03e68

Browse files
committed
Add area AABB rendering
1 parent 5650dc1 commit 9e03e68

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

prime_defs/prime1/CGameArea.bs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct CGameArea {
3939
u32 vtable 0x0
4040
u32 selfIDX 0x4
4141
u32 nameStrg 0x8
42+
CTransform transform 0xC
43+
CAABB aabb 0x6C
4244
u32 mrea 0x84
4345
u32 areaID 0x88
4446
rstl::vector<u16> attachedAreaIndices 0x90
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
struct CFlyingPirate: CPatterned {
2+
CFlyingPirateData data 0x568
3+
}
24

5+
struct CFlyingPirateData {
6+
f32 maxCoverDistance 0x0
7+
f32 hearingDistance 0x4
38
}

src/main.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#include <iostream>
22

3-
#include <cstdio>
4-
#include <glad/glad.h>
5-
#include <GLFW/glfw3.h>
63
#include "PrimeWatch.hpp"
74

85
int main() {

src/world/CollisionMesh.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class CollisionMesh {
6565
std::vector<glm::vec<3, glm::uint16_t, glm::defaultp>> raw_polys;
6666
std::vector<uint16_t> raw_poly_materials;
6767

68+
glm::vec3 min;
69+
glm::vec3 max;
6870

6971
std::vector<ECollisionMaterial> materials;
7072

src/world/WorldRenderer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ optional<CollisionMesh> WorldRenderer::loadMesh(const GameMember &area) {
220220
);
221221
}
222222

223+
res.min = MathUtils::readAsCVector3f(area["aabb"]["min"]);
224+
res.max = MathUtils::readAsCVector3f(area["aabb"]["max"]);
225+
223226
res.initGlMesh();
224227

225228
return res;
@@ -365,6 +368,12 @@ void WorldRenderer::render(const std::map<TUniqueID, GameDefinitions::GameMember
365368

366369
for (auto &[k, v]: mesh_by_mrea) {
367370
v.draw();
371+
372+
renderBuff->addLines(ShapeGenerator::generateCubeLines(
373+
v.min,
374+
v.max,
375+
glm::vec4{1, 1, 1, 1}
376+
));
368377
}
369378

370379
// then player

0 commit comments

Comments
 (0)