summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-02-22 00:18:04 +0100
committerTreeki <treeki@gmail.com>2013-02-22 00:18:04 +0100
commitbe4cb117959484a37de3613a484988445c9a3d86 (patch)
treecb284b70f8b5a811a7c2e4c011390df515905a31
parent49bd90a8c871994fb66c58aef841b4f8a0b8f732 (diff)
downloadkamek-be4cb117959484a37de3613a484988445c9a3d86.tar.gz
kamek-be4cb117959484a37de3613a484988445c9a3d86.zip
update collision debug to support BasicCollider and rotated Physics
Diffstat (limited to '')
-rwxr-xr-xinclude/game.h4
-rw-r--r--kamek_pal.x1
-rw-r--r--src/apDebug.cpp95
3 files changed, 66 insertions, 34 deletions
diff --git a/include/game.h b/include/game.h
index fe7dee7..4d9def6 100755
--- a/include/game.h
+++ b/include/game.h
@@ -1892,7 +1892,7 @@ class BasicCollider {
dStageActor_c *owner;
- BasicCollider *prev, *next;
+ BasicCollider *next, *prev;
/* dRSomething */ void *ptrToRSomething;
float rightX, rightY, leftX, leftY;
@@ -1907,6 +1907,8 @@ class BasicCollider {
u8 _43;
u8 isInList;
u8 _45, _46, _47, _48, _49, _4A;
+
+ static BasicCollider *globalListHead;
};
class StandOnTopCollider : public BasicCollider {
diff --git a/kamek_pal.x b/kamek_pal.x
index 83da2f5..ba30889 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -166,6 +166,7 @@ SECTIONS {
__dt__13BasicColliderFv = 0x800DAEF0;
+ globalListHead__13BasicCollider = 0x8042A2FC;
addToList__13BasicColliderFv = 0x800DAF70;
diff --git a/src/apDebug.cpp b/src/apDebug.cpp
index bcaf33f..01669bf 100644
--- a/src/apDebug.cpp
+++ b/src/apDebug.cpp
@@ -32,7 +32,7 @@ class APDebugDrawer : public m3d::proc_c {
static APDebugDrawer defaultInstance;
-static bool enableDebugMode = false;
+static bool enableDebugMode = true;
int APDebugDraw() {
if (enableDebugMode)
@@ -60,6 +60,7 @@ void APDebugDrawer::drawMe() {
}
void APDebugDrawer::drawOpa() {
+ drawXlu();
}
void APDebugDrawer::drawXlu() {
GXClearVtxDesc();
@@ -94,8 +95,8 @@ void APDebugDrawer::drawXlu() {
GXSetZCompLoc(GX_FALSE);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
- GXSetZMode(GX_TRUE, GX_LEQUAL, GX_FALSE);
- GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0);
+ GXSetZMode(GX_TRUE, GX_ALWAYS, GX_FALSE);
+ GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0);
GXSetFog(GX_FOG_NONE, 0, 0, 0, 0, (GXColor){0,0,0,0});
GXSetFogRangeAdj(GX_FALSE, 0, 0);
@@ -108,6 +109,12 @@ void APDebugDrawer::drawXlu() {
GXSetTevColor(GX_TEVREG0, (GXColor){255,255,255,255});
GXSetTevColor(GX_TEVREG1, (GXColor){0,0,0,255});
+ nw4r::g3d::Camera cam(GetCameraByID(GetCurrentCameraID()));
+ Mtx matrix;
+ cam.GetCameraMtx(&matrix);
+ GXLoadPosMtxImm(matrix, 0);
+ GXSetCurrentMtx(0);
+
ActivePhysics *ap = ActivePhysics::globalListHead;
while (ap) {
@@ -153,33 +160,33 @@ void APDebugDrawer::drawXlu() {
}
// Top
- GXPosition3f32(tlX, tlY, 8000.0f);
+ GXPosition3f32(tlX, tlY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(trX, trY, 8000.0f);
+ GXPosition3f32(trX, trY, 9000.0f);
GXColor4u8(r,g,b,a);
// Left
- GXPosition3f32(tlX, tlY, 8000.0f);
+ GXPosition3f32(tlX, tlY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(blX, blY, 8000.0f);
+ GXPosition3f32(blX, blY, 9000.0f);
GXColor4u8(r,g,b,a);
// Right
- GXPosition3f32(trX, trY, 8000.0f);
+ GXPosition3f32(trX, trY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(brX, brY, 8000.0f);
+ GXPosition3f32(brX, brY, 9000.0f);
GXColor4u8(r,g,b,a);
// Bottom
- GXPosition3f32(blX, blY, 8000.0f);
+ GXPosition3f32(blX, blY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(brX, brY, 8000.0f);
+ GXPosition3f32(brX, brY, 9000.0f);
GXColor4u8(r,g,b,a);
// Diagonal
- GXPosition3f32(trX, trY, 8000.0f);
+ GXPosition3f32(trX, trY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(blX, blY, 8000.0f);
+ GXPosition3f32(blX, blY, 9000.0f);
GXColor4u8(r,g,b,a);
GXEnd();
@@ -198,45 +205,43 @@ void APDebugDrawer::drawXlu() {
GXBegin(GX_LINES, GX_VTXFMT0, 10);
- float centreX = p->owner->pos.x;
- float centreY = p->owner->pos.y;
- float edgeDistX = p->_88;
- float edgeDistY = p->_8C;
-
- float tlX = centreX + p->x, tlY = centreY + p->y;
- float trX = centreX + p->_88, trY = centreY + p->y;
-
- float blX = centreX + p->x, blY = centreY + p->_8C;
- float brX = centreX + p->_88, brY = centreY + p->_8C;
+ float tlX = p->unkArray[0].x;
+ float tlY = p->unkArray[0].y;
+ float trX = p->unkArray[3].x;
+ float trY = p->unkArray[3].y;
+ float blX = p->unkArray[1].x;
+ float blY = p->unkArray[1].y;
+ float brX = p->unkArray[2].x;
+ float brY = p->unkArray[2].y;
// Top
- GXPosition3f32(tlX, tlY, 8000.0f);
+ GXPosition3f32(tlX, tlY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(trX, trY, 8000.0f);
+ GXPosition3f32(trX, trY, 9000.0f);
GXColor4u8(r,g,b,a);
// Left
- GXPosition3f32(tlX, tlY, 8000.0f);
+ GXPosition3f32(tlX, tlY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(blX, blY, 8000.0f);
+ GXPosition3f32(blX, blY, 9000.0f);
GXColor4u8(r,g,b,a);
// Right
- GXPosition3f32(trX, trY, 8000.0f);
+ GXPosition3f32(trX, trY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(brX, brY, 8000.0f);
+ GXPosition3f32(brX, brY, 9000.0f);
GXColor4u8(r,g,b,a);
// Bottom
- GXPosition3f32(blX, blY, 8000.0f);
+ GXPosition3f32(blX, blY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(brX, brY, 8000.0f);
+ GXPosition3f32(brX, brY, 9000.0f);
GXColor4u8(r,g,b,a);
// Diagonal
- GXPosition3f32(trX, trY, 8000.0f);
+ GXPosition3f32(trX, trY, 9000.0f);
GXColor4u8(r,g,b,a);
- GXPosition3f32(blX, blY, 8000.0f);
+ GXPosition3f32(blX, blY, 9000.0f);
GXColor4u8(r,g,b,a);
GXEnd();
@@ -245,6 +250,30 @@ void APDebugDrawer::drawXlu() {
}
+ // Basic Colliders
+ BasicCollider *bc = BasicCollider::globalListHead;
+ while (bc) {
+ u32 uptr = (u32)bc;
+ u8 r = (uptr>>16)&0xFF;
+ u8 g = (uptr>>8)&0xFF;
+ u8 b = uptr&0xFF;
+ u8 a = 0xFF;
+
+ switch (bc->type) {
+ case 0: case 2:
+ GXBegin(GX_LINES, GX_VTXFMT0, 2);
+ GXPosition3f32(bc->leftX, bc->leftY, 9000.0f);
+ GXColor4u8(r,g,b,a);
+ GXPosition3f32(bc->rightX, bc->rightY, 9000.0f);
+ GXColor4u8(r,g,b,a);
+ GXEnd();
+ break;
+ }
+
+ bc = bc->next;
+ }
+
+
// Now, the hardest one.. CollisionMgr_c!
fBase_c *fb = 0;
while ((fb = fBase_c::searchByBaseType(2, fb))) {