1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 17:54:15 +00:00

Improve match for Camera_CalcUpFromPitchYawRoll, add docs (#1361)

* doc Camera_CalcUpFromPitchYawRoll

* reword comments
This commit is contained in:
engineer124 2022-08-29 14:26:10 -04:00 committed by GitHub
parent 7cfee3d8a9
commit 0b531fd1ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -641,62 +641,55 @@ s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) {
return temp_s0 + temp_s1; return temp_s0 + temp_s1;
} }
Vec3f* Camera_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* Camera_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 sinR = Math_SinS(-roll);
f32 cosR = Math_CosS(-roll);
Vec3f up;
Vec3f baseUp;
Vec3f u;
Vec3f rollMtxRow1;
Vec3f rollMtxRow2;
Vec3f rollMtxRow3;
f32 pad; f32 pad;
f32 sp54;
f32 sp4C;
f32 cosPitchCosYawSinRoll;
f32 negSinPitch;
f32 temp_f10_2;
f32 cosPitchcosYaw;
f32 temp_f14;
f32 negSinPitchSinYaw;
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;
negSinPitch = -sinPitch;
sinNegRoll = Math_SinS(-roll); // Matrix to apply the roll to the Up vector without roll
cosNegRoll = Math_CosS(-roll); rollMtxRow1.x = ((1.0f - SQ(u.x)) * cosR) + SQ(u.x);
negSinPitchSinYaw = negSinPitch * sinYaw; rollMtxRow1.y = ((u.x * u.y) * (1.0f - cosR)) - (u.z * sinR);
temp_f14 = 1.0f - cosNegRoll; rollMtxRow1.z = ((u.z * u.x) * (1.0f - cosR)) + (u.y * sinR);
cosPitchSinYaw = cosPitch * sinYaw;
sp54 = SQ(cosPitchSinYaw); rollMtxRow2.x = ((u.x * u.y) * (1.0f - cosR)) + (u.z * sinR);
sp4C = (cosPitchSinYaw * sinPitch) * temp_f14; rollMtxRow2.y = ((1.0f - SQ(u.y)) * cosR) + SQ(u.y);
cosPitchcosYaw = cosPitch * cosYaw; rollMtxRow2.z = ((u.y * u.z) * (1.0f - cosR)) - (u.x * sinR);
temp_f4_2 = ((1.0f - sp54) * cosNegRoll) + sp54;
cosPitchCosYawSinRoll = cosPitchcosYaw * sinNegRoll; rollMtxRow3.x = ((u.z * u.x) * (1.0f - cosR)) - (u.y * sinR);
negSinPitchCosYaw = negSinPitch * cosYaw; rollMtxRow3.y = ((u.y * u.z) * (1.0f - cosR)) + (u.x * sinR);
temp_f6 = (cosPitchcosYaw * cosPitchSinYaw) * temp_f14; rollMtxRow3.z = ((1.0f - SQ(u.z)) * cosR) + SQ(u.z);
temp_f10_2 = sinPitch * sinNegRoll;
spA4.x = ((negSinPitchSinYaw * temp_f4_2) + (cosPitch * (sp4C - cosPitchCosYawSinRoll))) + // Up without roll
(negSinPitchCosYaw * (temp_f6 + temp_f10_2)); baseUp.x = -sinP * sinY;
sp54 = SQ(sinPitch); baseUp.y = cosP;
temp_f4_2 = (sinPitch * cosPitchcosYaw) * temp_f14; baseUp.z = -sinP * cosY;
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;
} }
f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) { f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) {