1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-10 01:44:36 +00:00

Document EnGoroiwa and BgJyaGoroiwa (#860)

* Document EnGoroiwa and BgJyaGoroiwa

* Run format.sh

* Add renamed functions to actorfixer script

* no more calling out "the devs" for bad code

* `EnGoroiwa#flags` -> `stateFlags`

* `Matrix_MtxFToRotS` -> `Matrix_MtxFToYXZRotS` (and not ZXY oops), `func_800D2264` -> `Matrix_MtxFToZYXRotS`
This commit is contained in:
Dragorn421 2021-08-22 17:25:17 +02:00 committed by GitHub
parent 18c84b0be7
commit 743f42f651
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 425 additions and 394 deletions

View file

@ -680,7 +680,7 @@ void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf) {
dest->z = mf->wz + (mf->xz * src->x + mf->yz * src->y + mf->zz * src->z);
}
void Matrix_Reverse(MtxF* mf) {
void Matrix_Transpose(MtxF* mf) {
f32 temp;
temp = mf->xy;
@ -739,7 +739,11 @@ void func_800D1FD4(MtxF* mf) {
cmf->zz = mf->zz * temp3;
}
void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
/**
* Gets the rotation the specified matrix represents, using Euler YXZ.
* The flag value doesn't matter for a rotation matrix. Not 0 does extra calculation.
*/
void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag) {
f32 temp;
f32 temp2;
f32 temp3;
@ -748,17 +752,17 @@ void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
temp = mf->zx;
temp *= temp;
temp += SQ(mf->zz);
vec->x = Math_FAtan2F(-mf->zy, sqrtf(temp)) * (32768 / M_PI);
rotDest->x = Math_FAtan2F(-mf->zy, sqrtf(temp)) * (0x8000 / M_PI);
if ((vec->x == 0x4000) || (vec->x == -0x4000)) {
vec->z = 0;
if ((rotDest->x == 0x4000) || (rotDest->x == -0x4000)) {
rotDest->z = 0;
vec->y = Math_FAtan2F(-mf->xz, mf->xx) * (32768 / M_PI);
rotDest->y = Math_FAtan2F(-mf->xz, mf->xx) * (0x8000 / M_PI);
} else {
vec->y = Math_FAtan2F(mf->zx, mf->zz) * (32768 / M_PI);
rotDest->y = Math_FAtan2F(mf->zx, mf->zz) * (0x8000 / M_PI);
if (!flag) {
vec->z = Math_FAtan2F(mf->xy, mf->yy) * (32768 / M_PI);
rotDest->z = Math_FAtan2F(mf->xy, mf->yy) * (0x8000 / M_PI);
} else {
temp = mf->xx;
temp2 = mf->xz;
@ -768,6 +772,7 @@ void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
temp += SQ(temp2);
temp2 = mf->xy;
temp += SQ(temp2);
/* temp = xx^2+xz^2+xy^2 == 1 for a rotation matrix */
temp = sqrtf(temp);
temp = temp2 / temp;
@ -776,15 +781,22 @@ void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
temp2 += SQ(temp3);
temp3 = mf->yy;
temp2 += SQ(temp3);
/* temp2 = yx^2+yz^2+yy^2 == 1 for a rotation matrix */
temp2 = sqrtf(temp2);
temp2 = temp3 / temp2;
vec->z = Math_FAtan2F(temp, temp2) * (32768 / M_PI);
/* for a rotation matrix, temp == xy and temp2 == yy
* which is the same as in the !flag branch */
rotDest->z = Math_FAtan2F(temp, temp2) * (0x8000 / M_PI);
}
}
}
void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag) {
/**
* Gets the rotation the specified matrix represents, using Euler ZYX.
* The flag value doesn't matter for a rotation matrix. Not 0 does extra calculation.
*/
void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag) {
f32 temp;
f32 temp2;
f32 temp3;
@ -793,43 +805,47 @@ void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag) {
temp = mf->xx;
temp *= temp;
temp += SQ(mf->xy);
vec->y = Math_FAtan2F(-mf->xz, sqrtf(temp)) * (32768 / M_PI);
rotDest->y = Math_FAtan2F(-mf->xz, sqrtf(temp)) * (0x8000 / M_PI);
if ((vec->y == 0x4000) || (vec->y == -0x4000)) {
vec->x = 0;
vec->z = Math_FAtan2F(-mf->yx, mf->yy) * (32768 / M_PI);
return;
}
vec->z = Math_FAtan2F(mf->xy, mf->xx) * (32768 / M_PI);
if (!flag) {
vec->x = Math_FAtan2F(mf->yz, mf->zz) * (32768 / M_PI);
if ((rotDest->y == 0x4000) || (rotDest->y == -0x4000)) {
rotDest->x = 0;
rotDest->z = Math_FAtan2F(-mf->yx, mf->yy) * (0x8000 / M_PI);
} else {
temp = mf->yx;
temp2 = mf->yy;
temp3 = mf->zy;
rotDest->z = Math_FAtan2F(mf->xy, mf->xx) * (0x8000 / M_PI);
temp *= temp;
temp += SQ(temp2);
temp2 = mf->yz;
temp += SQ(temp2);
temp = sqrtf(temp);
temp = temp2 / temp;
if (!flag) {
rotDest->x = Math_FAtan2F(mf->yz, mf->zz) * (0x8000 / M_PI);
} else {
// see Matrix_MtxFToYXZRotS
temp = mf->yx;
temp2 = mf->yy;
temp3 = mf->zy;
temp2 = mf->zx;
temp2 *= temp2;
temp2 += SQ(temp3);
temp3 = mf->zz;
temp2 += SQ(temp3);
temp2 = sqrtf(temp2);
temp2 = temp3 / temp2;
temp *= temp;
temp += SQ(temp2);
temp2 = mf->yz;
temp += SQ(temp2);
temp = sqrtf(temp);
temp = temp2 / temp;
vec->x = Math_FAtan2F(temp, temp2) * (32768 / M_PI);
temp2 = mf->zx;
temp2 *= temp2;
temp2 += SQ(temp3);
temp3 = mf->zz;
temp2 += SQ(temp3);
temp2 = sqrtf(temp2);
temp2 = temp3 / temp2;
rotDest->x = Math_FAtan2F(temp, temp2) * (0x8000 / M_PI);
}
}
}
void func_800D23FC(f32 f, Vec3f* vec, u8 mode) {
/*
* Rotate the matrix by `f` radians around a unit vector `vec`.
* NB: vec is assumed to be a unit vector.
*/
void Matrix_RotateAxis(f32 f, Vec3f* vec, u8 mode) {
MtxF* cmf;
f32 sin;
f32 cos;