diff options
author | aap <aap@papnet.eu> | 2020-08-03 12:58:37 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-08-03 17:32:06 +0200 |
commit | abb640c6b6b1c4c1b699d18509c8a344e2be2dd5 (patch) | |
tree | 58cecb7517dfd70a4ce5e2f646ff23aa4fa4084d /src/core/Collision.h | |
parent | Move sdk and eax (diff) | |
download | re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.tar re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.tar.gz re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.tar.bz2 re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.tar.lz re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.tar.xz re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.tar.zst re3-abb640c6b6b1c4c1b699d18509c8a344e2be2dd5.zip |
Diffstat (limited to 'src/core/Collision.h')
-rw-r--r-- | src/core/Collision.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/core/Collision.h b/src/core/Collision.h index d988f0c2..ccc99244 100644 --- a/src/core/Collision.h +++ b/src/core/Collision.h @@ -2,6 +2,9 @@ #include "templates.h" #include "Game.h" // for eLevelName +#ifdef VU_COLLISION +#include "VuVector.h" +#endif // If you spawn many tanks at once, you will see that collisions of two entity exceeds 32. #ifdef FIX_BUGS @@ -16,6 +19,28 @@ struct CompressedVector int16 x, y, z; CVector Get(void) const { return CVector(x, y, z)/128.0f; }; void Set(float x, float y, float z) { this->x = x*128.0f; this->y = y*128.0f; this->z = z*128.0f; }; +#ifdef GTA_PS2 + void Unpack(uint128 &qword) const { + __asm__ volatile ( + "lh $8, 0(%1)\n" + "lh $9, 2(%1)\n" + "lh $10, 4(%1)\n" + "pextlw $10, $8\n" + "pextlw $2, $9, $10\n" + "sq $2, %0\n" + : "=m" (qword) + : "r" (this) + : "$8", "$9", "$10", "$2" + ); + } +#else + void Unpack(int32 *qword) const { + qword[0] = x; + qword[1] = y; + qword[2] = z; + qword[3] = 0; // junk + } +#endif #else float x, y, z; CVector Get(void) const { return CVector(x, y, z); }; @@ -25,6 +50,7 @@ struct CompressedVector struct CColSphere { + // NB: this has to be compatible with a CVuVector CVector center; float radius; uint8 surface; @@ -47,6 +73,7 @@ struct CColBox struct CColLine { + // NB: this has to be compatible with two CVuVectors CVector p0; int pad0; CVector p1; @@ -69,6 +96,39 @@ struct CColTriangle struct CColTrianglePlane { +#ifdef VU_COLLISION + CompressedVector normal; + int16 dist; + + void Set(const CVector &va, const CVector &vb, const CVector &vc); + void Set(const CompressedVector *v, CColTriangle &tri) { Set(v[tri.a].Get(), v[tri.b].Get(), v[tri.c].Get()); } + void GetNormal(CVector &n) const { n.x = normal.x/4096.0f; n.y = normal.y/4096.0f; n.z = normal.z/4096.0f; } + float CalcPoint(const CVector &v) const { CVector n; GetNormal(n); return DotProduct(n, v) - dist/128.0f; }; +#ifdef GTA_PS2 + void Unpack(uint128 &qword) const { + __asm__ volatile ( + "lh $8, 0(%1)\n" + "lh $9, 2(%1)\n" + "lh $10, 4(%1)\n" + "lh $11, 6(%1)\n" + "pextlw $10, $8\n" + "pextlw $11, $9\n" + "pextlw $2, $11, $10\n" + "sq $2, %0\n" + : "=m" (qword) + : "r" (this) + : "$8", "$9", "$10", "$11", "$2" + ); + } +#else + void Unpack(int32 *qword) const { + qword[0] = normal.x; + qword[1] = normal.y; + qword[2] = normal.z; + qword[3] = dist; + } +#endif +#else CVector normal; float dist; uint8 dir; @@ -77,6 +137,7 @@ struct CColTrianglePlane void Set(const CompressedVector *v, CColTriangle &tri) { Set(v[tri.a].Get(), v[tri.b].Get(), v[tri.c].Get()); } void GetNormal(CVector &n) const { n = normal; } float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; }; +#endif }; struct CColPoint @@ -91,11 +152,29 @@ struct CColPoint uint8 surfaceB; uint8 pieceB; float depth; + + void Set(float depth, uint8 surfA, uint8 pieceA, uint8 surfB, uint8 pieceB) { + this->depth = depth; + this->surfaceA = surfA; + this->pieceA = pieceA; + this->surfaceB = surfB; + this->pieceB = pieceB; + } + void Set(uint8 surfA, uint8 pieceA, uint8 surfB, uint8 pieceB) { + this->surfaceA = surfA; + this->pieceA = pieceA; + this->surfaceB = surfB; + this->pieceB = pieceB; + } }; struct CStoredCollPoly { +#ifdef VU_COLLISION + CVuVector verts[3]; +#else CVector verts[3]; +#endif bool valid; }; |