mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 05:50:00 +00:00
add w to CVector; adjust col structs a bit
This commit is contained in:
parent
bb47f3a8e4
commit
3f60034c39
|
@ -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; };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ struct CColTrianglePlane
|
|||
}
|
||||
#endif
|
||||
#else
|
||||
// TODO(LCS): LCS actually uses CompressedVector too
|
||||
CVector normal;
|
||||
float dist;
|
||||
uint8 dir;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -44,3 +44,18 @@ operator*(const CMatrix &mat, const CVector &vec)
|
|||
mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z + mat.py,
|
||||
mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z + mat.pz);
|
||||
}
|
||||
|
||||
void
|
||||
RwV3dTransformPoints(CVector * pointsOut, const CVector * pointsIn, RwInt32 numPoints, const RwMatrix * matrix)
|
||||
{
|
||||
while(numPoints--){
|
||||
float x = pointsIn->x*matrix->right.x + pointsIn->y*matrix->up.x + pointsIn->z*matrix->at.x + matrix->pos.x;
|
||||
float y = pointsIn->x*matrix->right.y + pointsIn->y*matrix->up.y + pointsIn->z*matrix->at.y + matrix->pos.y;
|
||||
float z = pointsIn->x*matrix->right.z + pointsIn->y*matrix->up.z + pointsIn->z*matrix->at.z + matrix->pos.z;
|
||||
pointsOut->x = x;
|
||||
pointsOut->y = y;
|
||||
pointsOut->z = z;
|
||||
pointsOut++;
|
||||
pointsIn++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
// TODO(LCS): this should have 16 byte alignment but VS doesn't like passing aligned values by value
|
||||
// need a solution for this eventually if we ever want to load original assets
|
||||
class CVector : public RwV3d
|
||||
{
|
||||
public:
|
||||
float w;
|
||||
|
||||
CVector(void) {}
|
||||
CVector(float x, float y, float z)
|
||||
{
|
||||
|
@ -127,3 +131,6 @@ class CMatrix;
|
|||
CVector Multiply3x3(const CMatrix &mat, const CVector &vec);
|
||||
CVector Multiply3x3(const CVector &vec, const CMatrix &mat);
|
||||
CVector operator*(const CMatrix &mat, const CVector &vec);
|
||||
|
||||
// we need this because CVector and RwV3d have different size now
|
||||
void RwV3dTransformPoints(CVector * pointsOut, const CVector * pointsIn, RwInt32 numPoints, const RwMatrix * matrix);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
class TYPEALIGN(16) CVuVector : public CVector
|
||||
{
|
||||
public:
|
||||
float w;
|
||||
// float w; // in CVector now
|
||||
CVuVector(void) {}
|
||||
CVuVector(float x, float y, float z) : CVector(x, y, z) {}
|
||||
CVuVector(float x, float y, float z, float w) : CVector(x, y, z), w(w) {}
|
||||
CVuVector(float x, float y, float z, float w) : CVector(x, y, z)/*, w(w)*/ { this->w = w;}
|
||||
CVuVector(const CVector &v) : CVector(v.x, v.y, v.z) {}
|
||||
CVuVector(const RwV3d &v) : CVector(v) {}
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue