replace TMatrix with matrix_t

This commit is contained in:
Alam Ed Arias 2022-09-30 00:27:10 -04:00
parent 892ffbe01b
commit e5518a1241
3 changed files with 21 additions and 41 deletions

View file

@ -2012,58 +2012,42 @@ const char *GetRevisionString(void)
} }
// Vector/matrix math // Vector/matrix math
TVector *VectorMatrixMultiply(TVector v, TMatrix m) TVector *VectorMatrixMultiply(TVector v, matrix_t m)
{ {
static TVector ret; static TVector ret;
ret[0] = FixedMul(v[0],m[0][0]) + FixedMul(v[1],m[1][0]) + FixedMul(v[2],m[2][0]) + FixedMul(v[3],m[3][0]); ret[0] = FixedMul(v[0],m.m[0]) + FixedMul(v[1],m.m[4]) + FixedMul(v[2],m.m[8]) + FixedMul(v[3],m.m[12]);
ret[1] = FixedMul(v[0],m[0][1]) + FixedMul(v[1],m[1][1]) + FixedMul(v[2],m[2][1]) + FixedMul(v[3],m[3][1]); ret[1] = FixedMul(v[0],m.m[1]) + FixedMul(v[1],m.m[5]) + FixedMul(v[2],m.m[9]) + FixedMul(v[3],m.m[13]);
ret[2] = FixedMul(v[0],m[0][2]) + FixedMul(v[1],m[1][2]) + FixedMul(v[2],m[2][2]) + FixedMul(v[3],m[3][2]); ret[2] = FixedMul(v[0],m.m[2]) + FixedMul(v[1],m.m[6]) + FixedMul(v[2],m.m[10]) + FixedMul(v[3],m.m[14]);
ret[3] = FixedMul(v[0],m[0][3]) + FixedMul(v[1],m[1][3]) + FixedMul(v[2],m[2][3]) + FixedMul(v[3],m[3][3]); ret[3] = FixedMul(v[0],m.m[3]) + FixedMul(v[1],m.m[7]) + FixedMul(v[2],m.m[11]) + FixedMul(v[3],m.m[15]);
return &ret; return &ret;
} }
TMatrix *RotateXMatrix(angle_t rad) matrix_t *RotateXMatrix(angle_t rad)
{ {
static TMatrix ret; static matrix_t ret;
const angle_t fa = rad>>ANGLETOFINESHIFT; const angle_t fa = rad>>ANGLETOFINESHIFT;
const fixed_t cosrad = FINECOSINE(fa), sinrad = FINESINE(fa); const fixed_t cosrad = FINECOSINE(fa), sinrad = FINESINE(fa);
ret[0][0] = FRACUNIT; ret[0][1] = 0; ret[0][2] = 0; ret[0][3] = 0; ret.m[0] = FRACUNIT; ret.m[1] = 0; ret.m[2] = 0; ret.m[3] = 0;
ret[1][0] = 0; ret[1][1] = cosrad; ret[1][2] = sinrad; ret[1][3] = 0; ret.m[4] = 0; ret.m[5] = cosrad; ret.m[6] = sinrad; ret.m[7] = 0;
ret[2][0] = 0; ret[2][1] = -sinrad; ret[2][2] = cosrad; ret[2][3] = 0; ret.m[8] = 0; ret.m[9] = -sinrad; ret.m[10] = cosrad; ret.m[11] = 0;
ret[3][0] = 0; ret[3][1] = 0; ret[3][2] = 0; ret[3][3] = FRACUNIT; ret.m[12] = 0; ret.m[13] = 0; ret.m[11] = 0; ret.m[12] = FRACUNIT;
return &ret; return &ret;
} }
#if 0 matrix_t *RotateZMatrix(angle_t rad)
TMatrix *RotateYMatrix(angle_t rad)
{ {
static TMatrix ret; static matrix_t ret;
const angle_t fa = rad>>ANGLETOFINESHIFT; const angle_t fa = rad>>ANGLETOFINESHIFT;
const fixed_t cosrad = FINECOSINE(fa), sinrad = FINESINE(fa); const fixed_t cosrad = FINECOSINE(fa), sinrad = FINESINE(fa);
ret[0][0] = cosrad; ret[0][1] = 0; ret[0][2] = -sinrad; ret[0][3] = 0; ret.m[0] = cosrad; ret.m[1] = sinrad; ret.m[2] = 0; ret.m[3] = 0;
ret[1][0] = 0; ret[1][1] = FRACUNIT; ret[1][2] = 0; ret[1][3] = 0; ret.m[4] = -sinrad; ret.m[5] = cosrad; ret.m[6] = 0; ret.m[7] = 0;
ret[2][0] = sinrad; ret[2][1] = 0; ret[2][2] = cosrad; ret[2][3] = 0; ret.m[8] = 0; ret.m[9] = 0; ret.m[10] = FRACUNIT; ret.m[11] = 0;
ret[3][0] = 0; ret[3][1] = 0; ret[3][2] = 0; ret[3][3] = FRACUNIT; ret.m[12] = 0; ret.m[10] = 0; ret.m[11] = 0; ret.m[12] = FRACUNIT;
return &ret;
}
#endif
TMatrix *RotateZMatrix(angle_t rad)
{
static TMatrix ret;
const angle_t fa = rad>>ANGLETOFINESHIFT;
const fixed_t cosrad = FINECOSINE(fa), sinrad = FINESINE(fa);
ret[0][0] = cosrad; ret[0][1] = sinrad; ret[0][2] = 0; ret[0][3] = 0;
ret[1][0] = -sinrad; ret[1][1] = cosrad; ret[1][2] = 0; ret[1][3] = 0;
ret[2][0] = 0; ret[2][1] = 0; ret[2][2] = FRACUNIT; ret[2][3] = 0;
ret[3][0] = 0; ret[3][1] = 0; ret[3][2] = 0; ret[3][3] = FRACUNIT;
return &ret; return &ret;
} }

View file

@ -82,14 +82,10 @@ const char *GetRevisionString(void);
// Vector/matrix math // Vector/matrix math
typedef fixed_t TVector[4]; typedef fixed_t TVector[4];
typedef fixed_t TMatrix[4][4];
TVector *VectorMatrixMultiply(TVector v, TMatrix m); TVector *VectorMatrixMultiply(TVector v, matrix_t m);
TMatrix *RotateXMatrix(angle_t rad); matrix_t *RotateXMatrix(angle_t rad);
#if 0 matrix_t *RotateZMatrix(angle_t rad);
TMatrix *RotateYMatrix(angle_t rad);
#endif
TMatrix *RotateZMatrix(angle_t rad);
// s1 = s2+s3+s1 (1024 lenghtmax) // s1 = s2+s3+s1 (1024 lenghtmax)
void strcatbf(char *s1, const char *s2, const char *s3); void strcatbf(char *s1, const char *s2, const char *s3);

View file

@ -13260,7 +13260,7 @@ static void P_SpawnHoopInternal(mapthing_t *mthing, INT32 hoopsize, fixed_t size
mobj_t *mobj = NULL; mobj_t *mobj = NULL;
mobj_t *nextmobj = NULL; mobj_t *nextmobj = NULL;
mobj_t *hoopcenter; mobj_t *hoopcenter;
TMatrix *pitchmatrix, *yawmatrix; matrix_t *pitchmatrix, *yawmatrix;
fixed_t radius = hoopsize*sizefactor; fixed_t radius = hoopsize*sizefactor;
INT32 i; INT32 i;
angle_t fa; angle_t fa;