Skip to content

Commit 0891e0f

Browse files
committed
improve debug draw
1 parent d335862 commit 0891e0f

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

game/world/collisionzone.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "game/serialize.h"
88
#include "graphics/pfx/particlefx.h"
99

10+
#include "utils/dbgpainter.h"
11+
1012
CollisionZone::CollisionZone() {
1113
}
1214

@@ -57,6 +59,18 @@ CollisionZone::~CollisionZone() {
5759
owner->disableCollizionZone(*this);
5860
}
5961

62+
void CollisionZone::drawVobBox(DbgPainter& p) const {
63+
switch(type) {
64+
case T_BBox:
65+
p.setPen(Tempest::Color(1,0,1));
66+
p.drawAabb(pos-size, pos+size);
67+
break;
68+
case T_Capsule:
69+
break;
70+
}
71+
72+
}
73+
6074
void CollisionZone::save(Serialize& fout) const {
6175
fout.write(uint32_t(intersect.size()));
6276
for(auto i:intersect)

game/world/collisionzone.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class World;
99
class ParticleFx;
1010
class Serialize;
11+
class DbgPainter;
1112
class Npc;
1213

1314
class CollisionZone final {
@@ -19,6 +20,8 @@ class CollisionZone final {
1920
CollisionZone& operator = (CollisionZone&& other);
2021
~CollisionZone();
2122

23+
void drawVobBox(DbgPainter& p) const;
24+
2225
void save(Serialize& fout) const;
2326
void load(Serialize &fin);
2427

game/world/objects/npc.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4408,12 +4408,29 @@ void Npc::stopWalking() {
44084408
void Npc::drawVobBox(DbgPainter& p) const {
44094409
physic.debugDraw(p);
44104410

4411+
p.setBrush(Tempest::Color(0,1,0));
4412+
p.drawPoint(position());
4413+
4414+
const auto cen = centerPosition();
4415+
p.setBrush(Tempest::Color(0,0,1));
4416+
p.drawPoint(cen);
4417+
4418+
p.setPen(Tempest::Color(1,1,1));
4419+
p.drawLine(cen, cen+Tempest::Vec3(0,25,0));
4420+
p.setPen(Tempest::Color(1,1,0));
4421+
p.drawLine(cen, cen+Tempest::Vec3(25,0,0));
4422+
p.setPen(Tempest::Color(1,0.5f,0));
4423+
p.drawLine(cen, cen+Tempest::Vec3(0,0,25));
4424+
44114425
if(auto sk = visual.visualSkeleton()) {
4426+
auto bbox = sk->bboxCol;
4427+
44124428
auto tr = transform();
44134429
tr.translate(0,visual.pose().translateY(),0);
4430+
//tr.translate(0, -bbox[0].y, 0);
44144431

44154432
p.setPen(Color(1,0,0));
4416-
p.drawObb(tr, sk->bboxCol);
4433+
p.drawObb(tr, bbox);
44174434
}
44184435
}
44194436

game/world/worldobjects.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,13 @@ void WorldObjects::drawVobBoxNpcNear(DbgPainter& p) const {
847847
continue;
848848
i->drawVobBox(p);
849849
}
850+
851+
for(auto& i:collisionZn) {
852+
auto pos = i->position();
853+
if((pos-camera->originLwc()).quadLength() > nearDist)
854+
continue;
855+
i->drawVobBox(p);
856+
}
850857
}
851858

852859
Interactive *WorldObjects::availableMob(const Npc &pl, std::string_view dest) {

0 commit comments

Comments
 (0)