1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00

Improve match for DbCamera_CalcUpFromPitchYawRoll, add docs (#1408)

* improve match

* found solution without void
This commit is contained in:
engineer124 2022-10-15 11:51:55 -04:00 committed by GitHub
parent eb9b707157
commit d42307561a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,61 +111,54 @@ Vec3f* DbCamera_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) {
return dest; return dest;
} }
Vec3f* DbCamera_CalcUpFromPitchYawRoll(Vec3f* dest, s16 pitch, s16 yaw, s16 roll) { /**
f32 sinPitch; * Calculates a new Up vector from the pitch, yaw, roll
f32 cosPitch; */
f32 sinYaw; Vec3f* DbCamera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll) {
f32 cosYaw; f32 sinP = Math_SinS(pitch);
f32 sinNegRoll; f32 cosP = Math_CosS(pitch);
f32 cosNegRoll; f32 sinY = Math_SinS(yaw);
Vec3f spA4; f32 cosY = Math_CosS(yaw);
f32 sp54; f32 sinR = Math_SinS(-roll);
f32 sp4C; f32 cosR = Math_CosS(-roll);
f32 cosPitchCosYawSinRoll; Vec3f up;
f32 negSinPitch; Vec3f baseUp;
f32 temp_f10_2; Vec3f u;
f32 cosPitchcosYaw; Vec3f rollMtxRow1;
f32 temp_f14; Vec3f rollMtxRow2;
f32 negSinPitchSinYaw; Vec3f rollMtxRow3;
f32 negSinPitchCosYaw;
f32 cosPitchSinYaw;
f32 temp_f4_2;
f32 temp_f6;
f32 temp_f8;
f32 temp_f8_2;
f32 temp_f8_3;
sinPitch = Math_SinS(pitch); // Axis to roll around
cosPitch = Math_CosS(pitch); u.x = cosP * sinY;
sinYaw = Math_SinS(yaw); u.y = sinP;
cosYaw = Math_CosS(yaw); u.z = cosP * cosY;
sinNegRoll = Math_SinS(-roll);
cosNegRoll = Math_CosS(-roll); // Up without roll
negSinPitch = -sinPitch; baseUp.x = -sinP * sinY;
negSinPitchSinYaw = negSinPitch * sinYaw; baseUp.y = cosP;
negSinPitchCosYaw = negSinPitch * cosYaw; baseUp.z = -sinP * cosY;
temp_f14 = 1.0f - cosNegRoll;
cosPitchSinYaw = cosPitch * sinYaw; // Matrix to apply the roll to the Up vector without roll
sp54 = SQ(cosPitchSinYaw); rollMtxRow1.x = ((1.0f - SQ(u.x)) * cosR) + SQ(u.x);
sp4C = (cosPitchSinYaw * sinPitch) * ((void)0, temp_f14); rollMtxRow1.y = ((1.0f - cosR) * (u.x * u.y)) - (u.z * sinR);
cosPitchcosYaw = cosPitch * cosYaw; rollMtxRow1.z = ((1.0f - cosR) * (u.z * u.x)) + (u.y * sinR);
temp_f4_2 = ((1.0f - sp54) * cosNegRoll) + sp54;
cosPitchCosYawSinRoll = cosPitchcosYaw * sinNegRoll; rollMtxRow2.x = ((1.0f - cosR) * (u.x * u.y)) + (u.z * sinR);
temp_f6 = (cosPitchcosYaw * cosPitchSinYaw) * ((void)0, temp_f14); rollMtxRow2.y = ((1.0f - SQ(u.y)) * cosR) + SQ(u.y);
temp_f10_2 = sinPitch * sinNegRoll; rollMtxRow2.z = ((1.0f - cosR) * (u.y * u.z)) - (u.x * sinR);
spA4.x = ((negSinPitchSinYaw * temp_f4_2) + (cosPitch * (sp4C - cosPitchCosYawSinRoll))) +
(negSinPitchCosYaw * (temp_f6 + temp_f10_2)); rollMtxRow3.x = ((1.0f - cosR) * (u.z * u.x)) - (u.y * sinR);
sp54 = SQ(sinPitch); rollMtxRow3.y = ((1.0f - cosR) * (u.y * u.z)) + (u.x * sinR);
temp_f4_2 = (sinPitch * cosPitchcosYaw) * ((void)0, temp_f14); rollMtxRow3.z = ((1.0f - SQ(u.z)) * cosR) + SQ(u.z);
temp_f8_3 = cosPitchSinYaw * sinNegRoll;
temp_f8 = sp4C + cosPitchCosYawSinRoll; // rollMtx * baseUp
spA4.y = ((negSinPitchSinYaw * temp_f8) + (cosPitch * (((1.0f - sp54) * cosNegRoll) + sp54))) + up.x = DOTXYZ(baseUp, rollMtxRow1);
(negSinPitchCosYaw * (temp_f4_2 - temp_f8_3)); up.y = DOTXYZ(baseUp, rollMtxRow2);
temp_f8_2 = temp_f6 - temp_f10_2; up.z = DOTXYZ(baseUp, rollMtxRow3);
spA4.z = ((negSinPitchSinYaw * temp_f8_2) + (cosPitch * (temp_f4_2 + temp_f8_3))) +
(negSinPitchCosYaw * (((1.0f - SQ(cosPitchcosYaw)) * cosNegRoll) + SQ(cosPitchcosYaw))); *viewUp = up;
*dest = spA4;
return dest; return viewUp;
} }
char* DbCamera_SetTextValue(s16 value, char* str, u8 endIdx) { char* DbCamera_SetTextValue(s16 value, char* str, u8 endIdx) {