diff options
author | aap <aap@papnet.eu> | 2021-02-01 10:57:55 +0100 |
---|---|---|
committer | aap <aap@papnet.eu> | 2021-02-01 10:57:55 +0100 |
commit | 3f60034c391fd5da66639e4a29f121f18ead6255 (patch) | |
tree | f7d5c6b8ac6c7fba1a7a499c600ea551653f6f23 /src/collision | |
parent | fix realloc (diff) | |
download | re3-3f60034c391fd5da66639e4a29f121f18ead6255.tar re3-3f60034c391fd5da66639e4a29f121f18ead6255.tar.gz re3-3f60034c391fd5da66639e4a29f121f18ead6255.tar.bz2 re3-3f60034c391fd5da66639e4a29f121f18ead6255.tar.lz re3-3f60034c391fd5da66639e4a29f121f18ead6255.tar.xz re3-3f60034c391fd5da66639e4a29f121f18ead6255.tar.zst re3-3f60034c391fd5da66639e4a29f121f18ead6255.zip |
Diffstat (limited to 'src/collision')
-rw-r--r-- | src/collision/ColLine.h | 4 | ||||
-rw-r--r-- | src/collision/ColPoint.h | 4 | ||||
-rw-r--r-- | src/collision/ColSphere.h | 5 | ||||
-rw-r--r-- | src/collision/ColTriangle.h | 1 | ||||
-rw-r--r-- | src/collision/Collision.cpp | 18 |
5 files changed, 19 insertions, 13 deletions
diff --git a/src/collision/ColLine.h b/src/collision/ColLine.h index 21587a06..a2cb9a0b 100644 --- a/src/collision/ColLine.h +++ b/src/collision/ColLine.h @@ -4,9 +4,9 @@ struct CColLine { // NB: this has to be compatible with two CVuVectors CVector p0; - int pad0; +// int pad0; CVector p1; - int pad1; +// int pad1; CColLine(void) { }; CColLine(const CVector &p0, const CVector &p1) { this->p0 = p0; this->p1 = p1; }; diff --git a/src/collision/ColPoint.h b/src/collision/ColPoint.h index a15b2345..f978720d 100644 --- a/src/collision/ColPoint.h +++ b/src/collision/ColPoint.h @@ -3,10 +3,10 @@ struct CColPoint { CVector point; - int pad1; + int pad1; // this is stupid // the surface normal on the surface of point CVector normal; - int pad2; + //int pad2; uint8 surfaceA; uint8 pieceA; uint8 surfaceB; diff --git a/src/collision/ColSphere.h b/src/collision/ColSphere.h index f86b282a..3f18d8c0 100644 --- a/src/collision/ColSphere.h +++ b/src/collision/ColSphere.h @@ -2,10 +2,11 @@ #include "SurfaceTable.h" -struct CSphere +// TODO(LCS): maybe this was in a union with CVuVector? or is the alignment manual? +struct TYPEALIGN(16) CSphere { // NB: this has to be compatible with a CVuVector - CVector center; + RwV3d center; float radius; void Set(float radius, const CVector ¢er) { this->center = center; this->radius = radius; } }; diff --git a/src/collision/ColTriangle.h b/src/collision/ColTriangle.h index a2580c58..5ce543b5 100644 --- a/src/collision/ColTriangle.h +++ b/src/collision/ColTriangle.h @@ -62,6 +62,7 @@ struct CColTrianglePlane } #endif #else + // TODO(LCS): LCS actually uses CompressedVector too CVector normal; float dist; uint8 dir; diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp index bead5183..82681645 100644 --- a/src/collision/Collision.cpp +++ b/src/collision/Collision.cpp @@ -24,6 +24,10 @@ #include "Camera.h" #include "ColStore.h" +// gotta figure out how they handled CSphere exactly +// so using this to remind me to look into it again. +#define CVECTORHACK(rwv3d) CVector(rwv3d) + #ifdef VU_COLLISION #include "VuCollision.h" @@ -391,7 +395,7 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph) // The length of the tangent would be this: Sqrt((c-p0)^2 - r^2). // Negative if p0 is inside the sphere! This breaks the test! float tansq = 4.0f * linesq * - (sph.center.MagnitudeSqr() - 2.0f*DotProduct(sph.center, line.p0) + line.p0.MagnitudeSqr() - sph.radius*sph.radius); + (CVECTORHACK(sph.center).MagnitudeSqr() - 2.0f*DotProduct(sph.center, line.p0) + line.p0.MagnitudeSqr() - sph.radius*sph.radius); float diffsq = projline*projline - tansq; // if diffsq < 0 that means the line is a passant, so no intersection if(diffsq < 0.0f) @@ -470,9 +474,9 @@ CCollision::TestSphereTriangle(const CColSphere &sphere, case 2: // closest to an edge // looks like original game as DistToLine manually inlined - if(!insideAB) dist = DistToLine(&va, &vb, &sphere.center); - else if(!insideAC) dist = DistToLine(&va, &vc, &sphere.center); - else if(!insideBC) dist = DistToLine(&vb, &vc, &sphere.center); + if(!insideAB) dist = DistToLine(&va, &vb, &CVECTORHACK(sphere.center)); + else if(!insideAC) dist = DistToLine(&va, &vc, &CVECTORHACK(sphere.center)); + else if(!insideBC) dist = DistToLine(&vb, &vc, &CVECTORHACK(sphere.center)); else assert(0); break; case 3: @@ -1279,9 +1283,9 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere, case 2: // closest to an edge // looks like original game as DistToLine manually inlined - if(!insideAB) dist = DistToLine(&va, &vb, &sphere.center, p); - else if(!insideAC) dist = DistToLine(&va, &vc, &sphere.center, p); - else if(!insideBC) dist = DistToLine(&vb, &vc, &sphere.center, p); + if(!insideAB) dist = DistToLine(&va, &vb, &CVECTORHACK(sphere.center), p); + else if(!insideAC) dist = DistToLine(&va, &vc, &CVECTORHACK(sphere.center), p); + else if(!insideBC) dist = DistToLine(&vb, &vc, &CVECTORHACK(sphere.center), p); else assert(0); break; case 3: |