From aef0335681545718299ba3c0c0d63eddef840a11 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 20 Nov 2023 03:17:31 +1100 Subject: [PATCH] Struct Returns (#1574) * change args * PR Review * format --- include/functions.h | 22 +- src/code/db_camera.c | 98 ++- src/code/z_actor.c | 23 +- src/code/z_camera.c | 568 +++++++++--------- src/code/z_olib.c | 60 +- src/code/z_onepointdemo.c | 76 ++- src/code/z_play.c | 2 +- src/code/z_quake.c | 25 +- src/code/z_room.c | 4 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 18 +- src/overlays/actors/ovl_En_Butte/z_en_butte.c | 2 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 2 +- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 2 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 2 +- .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 2 +- 15 files changed, 425 insertions(+), 481 deletions(-) diff --git a/include/functions.h b/include/functions.h index adb31bb377..1fa82e044f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -391,9 +391,9 @@ Hilite* func_8002EABC(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContex Hilite* func_8002EB44(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); void func_8002EBCC(Actor* actor, PlayState* play, s32 flag); void func_8002ED80(Actor* actor, PlayState* play, s32 flag); -PosRot* Actor_GetFocus(PosRot* dest, Actor* actor); -PosRot* Actor_GetWorld(PosRot* dest, Actor* actor); -PosRot* Actor_GetWorldPosShapeRot(PosRot* arg0, Actor* actor); +PosRot Actor_GetFocus(Actor* actor); +PosRot Actor_GetWorld(Actor* actor); +PosRot Actor_GetWorldPosShapeRot(Actor* actor); s32 func_8002F0C8(Actor* actor, Player* player, s32 flag); s32 Actor_TalkOfferAccepted(Actor* actor, PlayState* play); s32 Actor_OfferTalkExchange(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, u32 exchangeItemId); @@ -639,7 +639,7 @@ s32 Camera_CheckValidMode(Camera* camera, s16 mode); s32 Camera_RequestSetting(Camera* camera, s16 setting); s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex); s16 Camera_GetInputDirYaw(Camera* camera); -Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera); +Vec3s Camera_GetCamDir(Camera* camera); s16 Camera_GetCamDirPitch(Camera* camera); s16 Camera_GetCamDirYaw(Camera* camera); s32 Camera_RequestQuake(Camera* camera, s32 unused, s16 y, s32 duration); @@ -653,7 +653,7 @@ s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCa s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2, s16 timer3); s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera); -Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera); +Vec3f Camera_GetQuakeOffset(Camera* camera); void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, UNK_TYPE arg6); s32 func_8005B198(void); @@ -923,12 +923,12 @@ f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); f32 OLib_ClampMinDist(f32 val, f32 min); f32 OLib_ClampMaxDist(f32 val, f32 max); -Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b); -Vec3f* OLib_VecGeoToVec3f(Vec3f* dest, VecGeo* geo); -VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec); -VecGeo* OLib_Vec3fToVecGeo(VecGeo* dest, Vec3f* vec); -VecGeo* OLib_Vec3fDiffToVecGeo(VecGeo* dest, Vec3f* a, Vec3f* b); -Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b); +Vec3f OLib_Vec3fDistNormalize(Vec3f* a, Vec3f* b); +Vec3f OLib_VecGeoToVec3f(VecGeo* geo); +VecSph OLib_Vec3fToVecSph(Vec3f* vec); +VecGeo OLib_Vec3fToVecGeo(Vec3f* vec); +VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b); +Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b); s16 OnePointCutscene_Init(PlayState* play, s16 csId, s16 timer, Actor* actor, s16 parentCamId); s16 OnePointCutscene_EndCutscene(PlayState* play, s16 subCamId); s32 OnePointCutscene_Attention(PlayState* play, Actor* actor); diff --git a/src/code/db_camera.c b/src/code/db_camera.c index 12e400bfeb..05fcd43666 100644 --- a/src/code/db_camera.c +++ b/src/code/db_camera.c @@ -95,25 +95,21 @@ static DebugCam* sDebugCamPtr; static s16 D_8016110C; static DebugCamAnim sDebugCamAnim; -Vec3f* DebugCamera_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) { +Vec3f DebugCamera_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo) { Vec3f sum; - Vec3f b; - - OLib_VecGeoToVec3f(&b, geo); + Vec3f b = OLib_VecGeoToVec3f(geo); sum.x = a->x + b.x; sum.y = a->y + b.y; sum.z = a->z + b.z; - *dest = sum; - - return dest; + return sum; } /** * Calculates a new Up vector from the pitch, yaw, roll */ -Vec3f* DebugCamera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll) { +Vec3f DebugCamera_CalcUpFromPitchYawRoll(s16 pitch, s16 yaw, s16 roll) { f32 sinP = Math_SinS(pitch); f32 cosP = Math_CosS(pitch); f32 sinY = Math_SinS(yaw); @@ -155,9 +151,7 @@ Vec3f* DebugCamera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 up.y = DOTXYZ(baseUp, rollMtxRow2); up.z = DOTXYZ(baseUp, rollMtxRow3); - *viewUp = up; - - return viewUp; + return up; } char* DebugCamera_SetTextValue(s16 value, char* str, u8 endIdx) { @@ -221,9 +215,9 @@ void func_800B3F94(PosRot* posRot, Vec3f* vec, Vec3s* out) { VecGeo geo; Vec3f tempVec; - OLib_Vec3fDiffToVecGeo(&geo, &posRot->pos, vec); + geo = OLib_Vec3fDiffToVecGeo(&posRot->pos, vec); geo.yaw -= posRot->rot.y; - OLib_VecGeoToVec3f(&tempVec, &geo); + tempVec = OLib_VecGeoToVec3f(&geo); DebugCamera_Vec3FToS(&tempVec, out); } @@ -232,9 +226,9 @@ void func_800B3FF4(PosRot* posRot, Vec3f* vec, Vec3f* out) { Vec3f tempVec; DebugCamera_CopyVec3f(vec, &tempVec); - OLib_Vec3fToVecGeo(&geo, &tempVec); + geo = OLib_Vec3fToVecGeo(&tempVec); geo.yaw += posRot->rot.y; - DebugCamera_AddVecGeoToVec3f(out, &posRot->pos, &geo); + *out = DebugCamera_AddVecGeoToVec3f(&posRot->pos, &geo); } void func_800B404C(PosRot* posRot, Vec3s* vec, Vec3f* out) { @@ -335,7 +329,7 @@ s32 func_800B4370(DebugCam* debugCam, s16 idx, Camera* cam) { geo.pitch = 0x2000; geo.yaw -= 0x7FFF; geo.r = 250.0f; - DebugCamera_AddVecGeoToVec3f(&debugCam->eye, &debugCam->at, &geo); + debugCam->eye = DebugCamera_AddVecGeoToVec3f(&debugCam->at, &geo); debugCam->roll = lookAt->cameraRoll; debugCam->rollDegrees = debugCam->roll * (360.0f / 256.0f); debugCam->fov = lookAt->viewAngle; @@ -668,9 +662,9 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { phi_s0 = sp124; if (!D_80161144) { - OLib_Vec3fDiffToVecGeo(&sp104, sp7C, sp80); + sp104 = OLib_Vec3fDiffToVecGeo(sp7C, sp80); } else { - OLib_Vec3fDiffToVecGeo(&sp104, sp80, sp7C); + sp104 = OLib_Vec3fDiffToVecGeo(sp80, sp7C); } if (debugCam->unk_44 > 100) { @@ -706,11 +700,11 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.r = temp_f2; if (!D_80161144) { spFC.yaw = sp104.yaw; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.pitch = -spFC.pitch; spFC.yaw = sp104.yaw - 0x7FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 0xB) { debugCam->unk_44++; @@ -734,11 +728,11 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.r = -temp_f2; if (!D_80161144) { spFC.yaw = sp104.yaw; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.pitch = -spFC.pitch; spFC.yaw = sp104.yaw - 0x7FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 0xC) { debugCam->unk_44++; @@ -757,10 +751,10 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.pitch = 0; if (!D_80161144) { spFC.yaw = sp104.yaw; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.yaw = sp104.yaw - 0x7FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 1) { @@ -775,10 +769,10 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.pitch = 0; if (!D_80161144) { spFC.yaw = sp104.yaw; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.yaw = sp104.yaw - 0x7FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 2) { debugCam->unk_44++; @@ -792,9 +786,9 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.pitch = 0x3FFF; spFC.yaw = sp104.yaw; if (!D_80161144) { - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 3) { debugCam->unk_44++; @@ -808,9 +802,9 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.pitch = -0x3FFF; spFC.yaw = sp104.yaw; if (!D_80161144) { - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 4) { debugCam->unk_44++; @@ -825,10 +819,10 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.pitch = 0; if (!D_80161144) { spFC.yaw = sp104.yaw + 0x3FFF; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.yaw = sp104.yaw - 0x3FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 5) { debugCam->unk_44++; @@ -843,10 +837,10 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.pitch = 0; if (!D_80161144) { spFC.yaw = sp104.yaw - 0x3FFF; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.yaw = sp104.yaw + 0x3FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 6) { debugCam->unk_44++; @@ -870,11 +864,11 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.r = temp_f2; if (!D_80161144) { spFC.yaw = sp104.yaw; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.pitch = -spFC.pitch; spFC.yaw = sp104.yaw - 0x7FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 0xB) { debugCam->unk_44++; @@ -899,11 +893,11 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { spFC.r = -temp_f2; if (!D_80161144) { spFC.yaw = sp104.yaw; - DebugCamera_AddVecGeoToVec3f(sp7C, sp7C, &spFC); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp7C, &spFC); } else { spFC.pitch = -spFC.pitch; spFC.yaw = sp104.yaw - 0x7FFF; - DebugCamera_AddVecGeoToVec3f(sp80, sp80, &spFC); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp80, &spFC); } if (debugCam->unk_40 == 0xC) { debugCam->unk_44++; @@ -961,20 +955,20 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { if (!D_80161144) { sp104.pitch += (s16)((temp_f0_5 >= 0.0f) ? pitch : -pitch); sp104.yaw += (s16)((temp_f2_2 >= 0.0f) ? yaw : -yaw); - DebugCamera_AddVecGeoToVec3f(sp80, sp7C, &sp104); + *sp80 = DebugCamera_AddVecGeoToVec3f(sp7C, &sp104); debugCam->sub.unk_104A.x = -sp104.pitch; debugCam->sub.unk_104A.y = sp104.yaw - 0x7FFF; } else { sp104.pitch += (s16)((temp_f0_5 >= 0.0f) ? -pitch : pitch); sp104.yaw += (s16)((temp_f2_2 >= 0.0f) ? -yaw : yaw); - DebugCamera_AddVecGeoToVec3f(sp7C, sp80, &sp104); + *sp7C = DebugCamera_AddVecGeoToVec3f(sp80, &sp104); debugCam->sub.unk_104A.x = sp104.pitch; debugCam->sub.unk_104A.y = sp104.yaw; } - OLib_Vec3fDiffToVecGeo(&spF4, sp80, sp7C); - DebugCamera_CalcUpFromPitchYawRoll(&debugCam->unk_1C, spF4.pitch, spF4.yaw, - CAM_DEG_TO_BINANG(debugCam->rollDegrees)); + spF4 = OLib_Vec3fDiffToVecGeo(sp80, sp7C); + debugCam->unk_1C = + DebugCamera_CalcUpFromPitchYawRoll(spF4.pitch, spF4.yaw, CAM_DEG_TO_BINANG(debugCam->rollDegrees)); if (debugCam->unk_00 == 1) { if (CHECK_BTN_ALL(sPlay->state.input[DEBUG_CAM_CONTROLLER_PORT].cur.button, BTN_CRIGHT)) { cam->inputDir = debugCam->sub.unk_104A; @@ -982,7 +976,7 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { cam->at = *sp7C; spFC = sp104; spFC.r = new_var2; - DebugCamera_AddVecGeoToVec3f(&cam->eye, &cam->at, &spFC); + cam->eye = DebugCamera_AddVecGeoToVec3f(&cam->at, &spFC); } } } @@ -1380,7 +1374,7 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { DebugCamera_ScreenTextColored(30, 25, DEBUG_CAM_TEXT_BROWN, &sp110); } else { if (D_8012CEE0[0]) {} - OLib_Vec3fDiffToVecGeo(&spFC, sp90, sp7C); + spFC = OLib_Vec3fDiffToVecGeo(sp90, sp7C); spFC.yaw -= cam->playerPosRot.rot.y; DebugCamera_ScreenTextColored( 3, 22, @@ -1394,7 +1388,7 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { DebugCamera_ScreenTextColored(3, 24, DEBUG_CAM_TEXT_ORANGE, D_8012D0F8); DebugCamera_SetTextValue(spFC.r, &D_8012D0D4[7], 6); DebugCamera_ScreenTextColored(3, 25, DEBUG_CAM_TEXT_ORANGE, D_8012D0D4); - OLib_Vec3fDiffToVecGeo(&spFC, sp90, sp80); + spFC = OLib_Vec3fDiffToVecGeo(sp90, sp80); spFC.yaw -= cam->playerPosRot.rot.y; DebugCamera_ScreenTextColored(30, 22, ((debugCam->sub.unk_08 == 1) && (debugCam->sub.unk_0A == 4) && D_80161144) @@ -1425,7 +1419,7 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { func_800B404C(temp_s6, &(debugCam->sub.lookAt + i)->pos, &spB8); func_800B404C(temp_s6, &(debugCam->sub.position + i)->pos, &spAC); } - OLib_Vec3fDiffToVecGeo(&spFC, &spAC, &spB8); + spFC = OLib_Vec3fDiffToVecGeo(&spAC, &spB8); spAA = debugCam->sub.lookAt[i].cameraRoll * 0xB6; if (i == debugCam->sub.unkIdx) { DebugDisplay_AddObject(spAC.x, spAC.y, spAC.z, spFC.pitch * -1, spFC.yaw, spAA, .5f, .5f, .5f, @@ -1496,7 +1490,7 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { D_8012D110++; D_8012D110 %= 50; - OLib_Vec3fDiffToVecGeo(&spA0, &cam->eye, &cam->at); + spA0 = OLib_Vec3fDiffToVecGeo(&cam->eye, &cam->at); DebugDisplay_AddObject(debugCam->at.x, debugCam->at.y + 1.0f, debugCam->at.z, 0, 0, 0, 0.02f, 2.0f, 0.02f, 0xFF, 0xFF, 0x7F, 0x2D, 0, cam->play->view.gfxCtx); DebugDisplay_AddObject(debugCam->at.x, debugCam->at.y + 1.0f, debugCam->at.z, 0, 0, 0, 2.0f, 0.02f, 0.02f, 0x7F, @@ -1507,7 +1501,7 @@ void DebugCamera_Update(DebugCam* debugCam, Camera* cam) { 0x7F, 0x7F, 0x80, 5, cam->play->view.gfxCtx); DebugDisplay_AddObject(cam->at.x, cam->at.y, cam->at.z, spA0.pitch * -1, spA0.yaw, 0, 1.5f, 2.0f, 1.0f, 0xFF, 0x7F, 0x7F, 0x80, 4, cam->play->view.gfxCtx); - OLib_Vec3fDiffToVecGeo(&spA0, &cam->eyeNext, &cam->at); + spA0 = OLib_Vec3fDiffToVecGeo(&cam->eyeNext, &cam->at); DebugDisplay_AddObject(cam->eyeNext.x, cam->eyeNext.y, cam->eyeNext.z, spA0.pitch * -1, spA0.yaw, 0, .5f, .5f, .5f, 0xFF, 0xC0, 0x7F, 0x50, 5, cam->play->view.gfxCtx); } @@ -2183,9 +2177,9 @@ s32 DebugCamera_UpdateDemoControl(DebugCam* debugCam, Camera* cam) { Audio_PlaySfxGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - OLib_Vec3fDiffToVecGeo(&sp5C, &debugCam->eye, &debugCam->at); - DebugCamera_CalcUpFromPitchYawRoll(&debugCam->unk_1C, sp5C.pitch, sp5C.yaw, - CAM_DEG_TO_BINANG(debugCam->rollDegrees)); + sp5C = OLib_Vec3fDiffToVecGeo(&debugCam->eye, &debugCam->at); + debugCam->unk_1C = + DebugCamera_CalcUpFromPitchYawRoll(sp5C.pitch, sp5C.yaw, CAM_DEG_TO_BINANG(debugCam->rollDegrees)); return 2; } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index e55fc95b0c..7377bc9e85 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1465,26 +1465,21 @@ void func_8002ED80(Actor* actor, PlayState* play, s32 flag) { } } -PosRot* Actor_GetFocus(PosRot* dest, Actor* actor) { - *dest = actor->focus; - - return dest; +PosRot Actor_GetFocus(Actor* actor) { + return actor->focus; } -PosRot* Actor_GetWorld(PosRot* dest, Actor* actor) { - *dest = actor->world; - - return dest; +PosRot Actor_GetWorld(Actor* actor) { + return actor->world; } -PosRot* Actor_GetWorldPosShapeRot(PosRot* arg0, Actor* actor) { - PosRot sp1C; +PosRot Actor_GetWorldPosShapeRot(Actor* actor) { + PosRot worldPosRot; - Math_Vec3f_Copy(&sp1C.pos, &actor->world.pos); - sp1C.rot = actor->shape.rot; - *arg0 = sp1C; + Math_Vec3f_Copy(&worldPosRot.pos, &actor->world.pos); + worldPosRot.rot = actor->shape.rot; - return arg0; + return worldPosRot; } f32 func_8002EFC0(Actor* actor, Player* player, s16 arg2) { diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 10283f4b71..f2b7063016 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -176,40 +176,34 @@ void func_80043B60(Camera* camera) { camera->fovUpdateRate = 0.001f; } -Vec3f* Camera_Vec3sToVec3f(Vec3f* dest, Vec3s* src) { - Vec3f copy; +Vec3f Camera_Vec3sToVec3f(Vec3s* src) { + Vec3f dest; - copy.x = src->x; - copy.y = src->y; - copy.z = src->z; + dest.x = src->x; + dest.y = src->y; + dest.z = src->z; - *dest = copy; return dest; } -Vec3f* Camera_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) { +Vec3f Camera_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo) { Vec3f sum; - Vec3f b; - - OLib_VecGeoToVec3f(&b, geo); + Vec3f b = OLib_VecGeoToVec3f(geo); sum.x = a->x + b.x; sum.y = a->y + b.y; sum.z = a->z + b.z; - *dest = sum; - - return dest; + return sum; } -Vec3f* Camera_Vec3fTranslateByUnitVector(Vec3f* dest, Vec3f* src, Vec3f* unitVector, f32 uvScale) { - Vec3f copy; +Vec3f Camera_Vec3fTranslateByUnitVector(Vec3f* src, Vec3f* unitVector, f32 uvScale) { + Vec3f dest; - copy.x = src->x + (unitVector->x * uvScale); - copy.y = src->y + (unitVector->y * uvScale); - copy.z = src->z + (unitVector->z * uvScale); + dest.x = src->x + (unitVector->x * uvScale); + dest.y = src->y + (unitVector->y * uvScale); + dest.z = src->z + (unitVector->z * uvScale); - *dest = copy; return dest; } @@ -226,13 +220,13 @@ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) { s32 floorBgId; VecGeo fromToOffset; - OLib_Vec3fDiffToVecGeo(&fromToOffset, from, &to->pos); + fromToOffset = OLib_Vec3fDiffToVecGeo(from, &to->pos); fromToOffset.r += 8.0f; - Camera_AddVecGeoToVec3f(&toPoint, from, &fromToOffset); + toPoint = Camera_AddVecGeoToVec3f(from, &fromToOffset); if (!BgCheck_CameraLineTest1(colCtx, from, &toPoint, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) { // no poly in path. - OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos); + fromToNorm = OLib_Vec3fDistNormalize(from, &to->pos); to->norm.x = -fromToNorm.x; to->norm.y = -fromToNorm.y; @@ -290,11 +284,11 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) { s32 bgId; VecGeo fromToGeo; - OLib_Vec3fDiffToVecGeo(&fromToGeo, from, &to->pos); + fromToGeo = OLib_Vec3fDiffToVecGeo(from, &to->pos); fromToGeo.r += 8.0f; - Camera_AddVecGeoToVec3f(&toPos, from, &fromToGeo); + toPos = Camera_AddVecGeoToVec3f(from, &fromToGeo); if (!BgCheck_CameraLineTest1(colCtx, from, &toPos, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) { - OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos); + fromToNorm = OLib_Vec3fDistNormalize(from, &to->pos); to->norm.x = -fromToNorm.x; to->norm.y = -fromToNorm.y; to->norm.z = -fromToNorm.z; @@ -334,7 +328,7 @@ s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) { to->pos.y = to->norm.y + toNewPos.y; to->pos.z = to->norm.z + toNewPos.z; } else { - OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos); + fromToNorm = OLib_Vec3fDistNormalize(from, &to->pos); to->norm.x = -fromToNorm.x; to->norm.y = -fromToNorm.y; to->norm.z = -fromToNorm.z; @@ -474,7 +468,7 @@ s32 Camera_GetBgCamIndex(Camera* camera, s32* bgId, CollisionPoly* poly) { PosRot playerPosRot; s32 ret; - Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); // unused. + playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); // unused. bgCamIndex = SurfaceType_GetBgCamIndex(&camera->play->colCtx, poly, *bgId); if (BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, bgCamIndex, *bgId) == CAM_SET_NONE) { @@ -496,7 +490,7 @@ Vec3s* Camera_GetBgCamFuncDataUnderPlayer(Camera* camera, u16* bgCamCount) { s32 bgId; PosRot playerPosRot; - Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); + playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); playerPosRot.pos.y += Player_GetHeight(camera->player); if (BgCheck_EntityRaycastDown3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosRot.pos) == BGCHECK_Y_MIN) { @@ -519,7 +513,7 @@ s32 Camera_GetWaterBoxBgCamIndex(Camera* camera, f32* waterY) { WaterBox* waterBox; s32 bgCamIndex; - Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); + playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); *waterY = playerPosRot.pos.y; if (!WaterBox_GetSurface1(camera->play, &camera->play->colCtx, playerPosRot.pos.x, playerPosRot.pos.z, waterY, @@ -556,7 +550,7 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* lightIndex) { f32 waterY; WaterBox* waterBox; - Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); + playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); waterY = playerPosRot.pos.y; if (!WaterBox_GetSurface1(camera->play, &camera->play->colCtx, chkPos->x, chkPos->z, &waterY, &waterBox)) { @@ -663,7 +657,7 @@ s16 Camera_GetPitchAdjFromFloorHeightDiffs(Camera* camera, s16 viewYaw, s16 init /** * Calculates a new Up vector from the pitch, yaw, roll */ -Vec3f* Camera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll) { +Vec3f Camera_CalcUpFromPitchYawRoll(s16 pitch, s16 yaw, s16 roll) { f32 sinP = Math_SinS(pitch); f32 cosP = Math_CosS(pitch); f32 sinY = Math_SinS(yaw); @@ -706,9 +700,7 @@ Vec3f* Camera_CalcUpFromPitchYawRoll(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll up.y = DOTXYZ(baseUp, rollMtxRow2); up.z = DOTXYZ(baseUp, rollMtxRow3); - *viewUp = up; - - return viewUp; + return up; } f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) { @@ -802,19 +794,16 @@ void Camera_UpdateInterface(s16 interfaceField) { } } -Vec3f* Camera_BGCheckCorner(Vec3f* dst, Vec3f* linePointA, Vec3f* linePointB, CamColChk* pointAColChk, - CamColChk* pointBColChk) { +Vec3f Camera_BGCheckCorner(Vec3f* linePointA, Vec3f* linePointB, CamColChk* pointAColChk, CamColChk* pointBColChk) { Vec3f closestPoint; if (!func_800427B4(pointAColChk->poly, pointBColChk->poly, linePointA, linePointB, &closestPoint)) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: corner check no cross point %x %x\n" VT_RST, pointAColChk, pointBColChk); - *dst = pointAColChk->pos; - return dst; + return pointAColChk->pos; } - *dst = closestPoint; - return dst; + return closestPoint; } /** @@ -845,7 +834,7 @@ s32 func_80045508(Camera* camera, VecGeo* diffGeo, CamColChk* eyeChk, CamColChk* // collision found between at->eye atChk->pos = camera->at; - OLib_Vec3fToVecGeo(&eyeChk->geoNorm, &eyeChk->norm); + eyeChk->geoNorm = OLib_Vec3fToVecGeo(&eyeChk->norm); if (eyeChk->geoNorm.pitch >= 0x2EE1) { eyeChk->geoNorm.yaw = diffGeo->yaw; @@ -875,7 +864,7 @@ s32 func_80045508(Camera* camera, VecGeo* diffGeo, CamColChk* eyeChk, CamColChk* return 3; } - OLib_Vec3fToVecGeo(&atChk->geoNorm, &atChk->norm); + atChk->geoNorm = OLib_Vec3fToVecGeo(&atChk->norm); if (atChk->geoNorm.pitch >= 0x2EE1) { atChk->geoNorm.yaw = diffGeo->yaw - 0x7FFF; @@ -905,7 +894,7 @@ f32 Camera_CalcSlopeYAdj(Vec3f* floorNorm, s16 playerYRot, s16 eyeAtYaw, f32 adj f32 tmp; VecGeo floorNormGeo; - OLib_Vec3fToVecGeo(&floorNormGeo, floorNorm); + floorNormGeo = OLib_Vec3fToVecGeo(floorNorm); tmp = Math_CosS(floorNormGeo.pitch) * Math_CosS(playerYRot - floorNormGeo.yaw); return (fabsf(tmp) * adjAmt) * Math_CosS(playerYRot - eyeAtYaw); @@ -1121,7 +1110,7 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f // tmpPos1 is player's head tmpPos1 = playerPosRot->pos; tmpPos1.y += playerHeight; - OLib_Vec3fDiffToVecGeo(outPlayerToTargetDir, &tmpPos1, targetPos); + *outPlayerToTargetDir = OLib_Vec3fDiffToVecGeo(&tmpPos1, targetPos); playerToTargetDir = *outPlayerToTargetDir; if (distance < playerToTargetDir.r) { playerToTargetDir.r = playerToTargetDir.r * CAM_DATA_SCALED(OREG(38)); @@ -1139,7 +1128,7 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f camera->xzOffsetUpdateRate = camera->yOffsetUpdateRate = .01f; } - OLib_VecGeoToVec3f(&lookFromOffset, &playerToTargetDir); + lookFromOffset = OLib_VecGeoToVec3f(&playerToTargetDir); if (PREG(89)) { osSyncPrintf("%f (%f %f %f) %f\n", playerToTargetDir.r / distance, lookFromOffset.x, lookFromOffset.y, @@ -1209,7 +1198,7 @@ s32 Camera_CalcAtForHorse(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, f32* yP Player* player = camera->player; PosRot horsePosRot; - Actor_GetWorldPosShapeRot(&horsePosRot, player->rideActor); + horsePosRot = Actor_GetWorldPosShapeRot(player->rideActor); if (EN_HORSE_CHECK_JUMPING((EnHorse*)player->rideActor)) { horsePosRot.pos.y -= 49.f; @@ -1352,7 +1341,7 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, case 1: case 2: // angle between polys is between 60 and 120 degrees. - Camera_BGCheckCorner(&anim->collisionClosePoint, at, eyeNext, &atEyeColChk, &eyeAtColChk); + anim->collisionClosePoint = Camera_BGCheckCorner(at, eyeNext, &atEyeColChk, &eyeAtColChk); peekAroundPoint.x = anim->collisionClosePoint.x + (atEyeColChk.norm.x + eyeAtColChk.norm.x); peekAroundPoint.y = anim->collisionClosePoint.y + (atEyeColChk.norm.y + eyeAtColChk.norm.y); peekAroundPoint.z = anim->collisionClosePoint.z + (atEyeColChk.norm.z + eyeAtColChk.norm.z); @@ -1363,16 +1352,16 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, anim->swingUpdateRate = CAM_DATA_SCALED(OREG(10)); anim->unk_18 = 1; anim->atEyePoly = eyeAtColChk.poly; - OLib_Vec3fDiffToVecGeo(&newEyeAdjustment, at, &peekAroundPoint); + newEyeAdjustment = OLib_Vec3fDiffToVecGeo(at, &peekAroundPoint); newEyeAdjustment.r = eyeAdjustment->r; - Camera_AddVecGeoToVec3f(eye, at, &newEyeAdjustment); + *eye = Camera_AddVecGeoToVec3f(at, &newEyeAdjustment); newEyeColChk.pos = *eye; if (Camera_BGCheckInfo(camera, at, &newEyeColChk) == 0) { // no collision found between at->newEyePos newEyeAdjustment.yaw += (s16)(eyeAdjustment->yaw - newEyeAdjustment.yaw) >> 1; newEyeAdjustment.pitch += (s16)(eyeAdjustment->pitch - newEyeAdjustment.pitch) >> 1; - Camera_AddVecGeoToVec3f(eye, at, &newEyeAdjustment); + *eye = Camera_AddVecGeoToVec3f(at, &newEyeAdjustment); if (atEyeColChk.geoNorm.pitch < 0x2AA8) { // ~ 60 degrees anim->unk_16 = newEyeAdjustment.yaw; @@ -1384,9 +1373,9 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, peekAroundPoint.x = anim->collisionClosePoint.x - (atEyeColChk.norm.x + eyeAtColChk.norm.x); peekAroundPoint.y = anim->collisionClosePoint.y - (atEyeColChk.norm.y + eyeAtColChk.norm.y); peekAroundPoint.z = anim->collisionClosePoint.z - (atEyeColChk.norm.z + eyeAtColChk.norm.z); - OLib_Vec3fDiffToVecGeo(&newEyeAdjustment, at, &peekAroundPoint); + newEyeAdjustment = OLib_Vec3fDiffToVecGeo(at, &peekAroundPoint); newEyeAdjustment.r = eyeAdjustment->r; - Camera_AddVecGeoToVec3f(eyeNext, at, &newEyeAdjustment); + *eyeNext = Camera_AddVecGeoToVec3f(at, &newEyeAdjustment); break; } @@ -1406,13 +1395,13 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, anim->swingUpdateRate = *arg4 * arg3; - Camera_Vec3fTranslateByUnitVector(eye, &atEyeColChk.pos, &atEyeColChk.norm, 1.0f); + *eye = Camera_Vec3fTranslateByUnitVector(&atEyeColChk.pos, &atEyeColChk.norm, 1.0f); anim->atEyePoly = NULL; if (temp_f0 < OREG(21)) { sp40.yaw = eyeAdjustment->yaw; sp40.pitch = Math_SinS(atEyeColChk.geoNorm.pitch + 0x3FFF) * 16380.0f; sp40.r = (OREG(21) - temp_f0) * CAM_DATA_SCALED(OREG(22)); - Camera_AddVecGeoToVec3f(eye, eye, &sp40); + *eye = Camera_AddVecGeoToVec3f(eye, &sp40); } break; default: @@ -1480,8 +1469,8 @@ s32 Camera_Normal1(Camera* camera) { sCameraInterfaceField = roData->interfaceField; - OLib_Vec3fDiffToVecGeo(&atEyeGeo, at, eye); - OLib_Vec3fDiffToVecGeo(&atEyeNextGeo, at, eyeNext); + atEyeGeo = OLib_Vec3fDiffToVecGeo(at, eye); + atEyeNextGeo = OLib_Vec3fDiffToVecGeo(at, eyeNext); switch (camera->animState) { case 20: @@ -1586,7 +1575,7 @@ s32 Camera_Normal1(Camera* camera) { Camera_CalcAtDefault(camera, &atEyeNextGeo, spA0, roData->interfaceField & NORMAL1_FLAG_0); } - OLib_Vec3fDiffToVecGeo(&eyeAdjustment, at, eyeNext); + eyeAdjustment = OLib_Vec3fDiffToVecGeo(at, eyeNext); camera->dist = eyeAdjustment.r = Camera_ClampDist(camera, eyeAdjustment.r, roData->distMin, roData->distMax, rwData->unk_28); @@ -1616,7 +1605,7 @@ s32 Camera_Normal1(Camera* camera) { eyeAdjustment.pitch = -0x3C8C; } - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeAdjustment); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeAdjustment); if ((camera->status == CAM_STAT_ACTIVE) && !(roData->interfaceField & NORMAL1_FLAG_4)) { rwData->swingYawTarget = camera->playerPosRot.rot.y - 0x7FFF; if (rwData->startSwingTimer > 0) { @@ -1644,7 +1633,7 @@ s32 Camera_Normal1(Camera* camera) { camera->inputDir.y = atEyeGeo.yaw - 0x7FFF; camera->inputDir.z = 0; } else { - OLib_Vec3fDiffToVecGeo(&eyeAdjustment, eye, at); + eyeAdjustment = OLib_Vec3fDiffToVecGeo(eye, at); camera->inputDir.x = eyeAdjustment.pitch; camera->inputDir.y = eyeAdjustment.yaw; camera->inputDir.z = 0; @@ -1725,7 +1714,7 @@ s32 Camera_Normal2(Camera* camera) { case 20: case 25: bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(&rwData->unk_00, &bgCamFuncData->pos); + rwData->unk_00 = Camera_Vec3sToVec3f(&bgCamFuncData->pos); rwData->unk_20 = bgCamFuncData->rot.x; rwData->unk_22 = bgCamFuncData->rot.y; rwData->unk_24 = playerPosRot->pos.y; @@ -1741,7 +1730,7 @@ s32 Camera_Normal2(Camera* camera) { sp88.pitch = rwData->unk_20; sp88.yaw = rwData->unk_22 + 0x3FFF; sp88.r = 100.0f; - OLib_VecGeoToVec3f(&rwData->unk_0C, &sp88); + rwData->unk_0C = OLib_VecGeoToVec3f(&sp88); } camera->animState = 1; @@ -1754,8 +1743,8 @@ s32 Camera_Normal2(Camera* camera) { break; } - OLib_Vec3fDiffToVecGeo(&atToEyeDir, at, eye); - OLib_Vec3fDiffToVecGeo(&atToEyeNextDir, at, eyeNext); + atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); + atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); camera->speedRatio *= 0.5f; spA4 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio; @@ -1785,8 +1774,8 @@ s32 Camera_Normal2(Camera* camera) { rwData->unk_00.y = playerPosRot->pos.y; - OLib_Vec3fDiffToVecGeo(&sp88, &rwData->unk_00, at); - OLib_Vec3fDiffToVecGeo(&sp90, at, eyeNext); + sp88 = OLib_Vec3fDiffToVecGeo(&rwData->unk_00, at); + sp90 = OLib_Vec3fDiffToVecGeo(at, eyeNext); phi_a1 = (rwData->unk_28 & 2 ? rwData->unk_22 : roData->unk_1C); phi_a0 = sp90.yaw - sp88.yaw; @@ -1817,7 +1806,7 @@ s32 Camera_Normal2(Camera* camera) { } } - Camera_AddVecGeoToVec3f(eyeNext, at, &adjGeo); + *eyeNext = Camera_AddVecGeoToVec3f(at, &adjGeo); if (camera->status == CAM_STAT_ACTIVE) { bgChk.pos = *eyeNext; @@ -1827,7 +1816,7 @@ s32 Camera_Normal2(Camera* camera) { } else { func_80043F94(camera, at, &bgChk); *eye = bgChk.pos; - OLib_Vec3fDiffToVecGeo(&adjGeo, eye, at); + adjGeo = OLib_Vec3fDiffToVecGeo(eye, at); camera->inputDir.x = adjGeo.pitch; camera->inputDir.y = adjGeo.yaw; camera->inputDir.z = 0; @@ -1880,8 +1869,8 @@ s32 Camera_Normal3(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&sp7C, at, eye); - OLib_Vec3fDiffToVecGeo(&sp74, at, eyeNext); + sp7C = OLib_Vec3fDiffToVecGeo(at, eye); + sp74 = OLib_Vec3fDiffToVecGeo(at, eyeNext); sUpdateCameraDirection = true; sCameraInterfaceField = roData->interfaceField; @@ -1938,7 +1927,7 @@ s32 Camera_Normal3(Camera* camera) { Camera_CalcAtForHorse(camera, &sp74, roData->yOffset, &rwData->unk_20, true); sp90 = (roData->distMax + roData->distMin) * 0.5f; - OLib_Vec3fDiffToVecGeo(&sp84, at, eyeNext); + sp84 = OLib_Vec3fDiffToVecGeo(at, eyeNext); camera->dist = sp84.r = Camera_ClampDist(camera, sp84.r, roData->distMin, roData->distMax, rwData->distTimer); if (camera->xzSpeed > 0.001f) { sp84.r += (sp90 - sp84.r) * 0.002f; @@ -1976,7 +1965,7 @@ s32 Camera_Normal3(Camera* camera) { rwData->yawTimer--; } - Camera_AddVecGeoToVec3f(eyeNext, at, &sp84); + *eyeNext = Camera_AddVecGeoToVec3f(at, &sp84); if (camera->status == CAM_STAT_ACTIVE) { func_80046E20(camera, &sp84, roData->distMin, roData->yawUpdateSpeed, &sp8C, &rwData->swing); @@ -2041,8 +2030,8 @@ s32 Camera_Parallel1(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&atToEyeDir, at, eye); - OLib_Vec3fDiffToVecGeo(&atToEyeNextDir, at, eyeNext); + atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); + atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); switch (camera->animState) { case 0: @@ -2138,7 +2127,7 @@ s32 Camera_Parallel1(Camera* camera) { } else { rwData->unk_16 = 0; camera->dist = Camera_LERPCeilF(roData->distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 2.0f); - OLib_Vec3fDiffToVecGeo(&spA8, at, eyeNext); + spA8 = OLib_Vec3fDiffToVecGeo(at, eyeNext); spA8.r = camera->dist; if (roData->interfaceField & PARALLEL1_FLAG_6) { @@ -2163,7 +2152,7 @@ s32 Camera_Parallel1(Camera* camera) { spA8.pitch = R_CAM_MIN_PITCH_1; } } - Camera_AddVecGeoToVec3f(eyeNext, at, &spA8); + *eyeNext = Camera_AddVecGeoToVec3f(at, &spA8); if (camera->status == CAM_STAT_ACTIVE) { sp6C.pos = *eyeNext; if (!camera->play->envCtx.skyboxDisabled || roData->interfaceField & PARALLEL1_FLAG_4) { @@ -2172,7 +2161,7 @@ s32 Camera_Parallel1(Camera* camera) { } else { func_80043F94(camera, at, &sp6C); *eye = sp6C.pos; - OLib_Vec3fDiffToVecGeo(&spA8, eye, at); + spA8 = OLib_Vec3fDiffToVecGeo(eye, at); camera->inputDir.x = spA8.pitch; camera->inputDir.y = spA8.yaw; camera->inputDir.z = 0; @@ -2254,10 +2243,10 @@ s32 Camera_Jump1(Camera* camera) { } // playerhead never gets used. - Actor_GetFocus(&playerhead, &camera->player->actor); + playerhead = Actor_GetFocus(&camera->player->actor); - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, at, eye); - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); sCameraInterfaceField = roData->interfaceField; @@ -2302,7 +2291,7 @@ s32 Camera_Jump1(Camera* camera) { eyeDiffGeo = eyeAtOffset; - OLib_Vec3fDiffToVecGeo(&eyeDiffTarget, at, eye); + eyeDiffTarget = OLib_Vec3fDiffToVecGeo(at, eye); eyeDiffGeo.r = Camera_LERPCeilF(eyeDiffTarget.r, eyeAtOffset.r, CAM_DATA_SCALED(OREG(29)), 1.0f); eyeDiffGeo.pitch = Camera_LERPCeilS(eyeDiffTarget.pitch, eyeAtOffset.pitch, CAM_DATA_SCALED(OREG(29)), 0xA); @@ -2331,7 +2320,7 @@ s32 Camera_Jump1(Camera* camera) { eyeDiffGeo.pitch = R_CAM_MIN_PITCH_2; } - Camera_AddVecGeoToVec3f(&newEye, at, &eyeDiffGeo); + newEye = Camera_AddVecGeoToVec3f(at, &eyeDiffGeo); eyeNext->x = newEye.x; eyeNext->z = newEye.z; eyeNext->y += (newEye.y - eyeNext->y) * CAM_DATA_SCALED(R_CAM_JUMP1_EYE_Y_STEP_SCALE); @@ -2342,7 +2331,7 @@ s32 Camera_Jump1(Camera* camera) { camera->inputDir.y = eyeAtOffset.yaw - 0x7FFF; camera->inputDir.z = 0; } else { - OLib_Vec3fDiffToVecGeo(&eyeDiffGeo, eye, at); + eyeDiffGeo = OLib_Vec3fDiffToVecGeo(eye, at); camera->inputDir.x = eyeDiffGeo.pitch; camera->inputDir.y = eyeDiffGeo.yaw; camera->inputDir.z = 0; @@ -2414,8 +2403,8 @@ s32 Camera_Jump2(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&atToEyeDir, at, eye); - OLib_Vec3fDiffToVecGeo(&atToEyeNextDir, at, eyeNext); + atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); + atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); sCameraInterfaceField = roData->interfaceField; @@ -2463,7 +2452,7 @@ s32 Camera_Jump2(Camera* camera) { camera->rUpdateRateInv = OREG(27); Camera_CalcAtDefault(camera, &atToEyeNextDir, roData->atYOffset, false); - OLib_Vec3fDiffToVecGeo(&adjAtToEyeDir, at, eye); + adjAtToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); temp_f16 = roData->minDist; sp90 = roData->maxDist + (roData->maxDist * roData->minMaxDistFactor); @@ -2523,7 +2512,7 @@ s32 Camera_Jump2(Camera* camera) { adjAtToEyeDir.pitch = -0x2AF8; } - Camera_AddVecGeoToVec3f(eyeNext, at, &adjAtToEyeDir); + *eyeNext = Camera_AddVecGeoToVec3f(at, &adjAtToEyeDir); camBgChk.pos = *eyeNext; if (Camera_BGCheckInfo(camera, at, &camBgChk)) { // Collision detected between at->eyeNext, Check if collision between @@ -2532,7 +2521,7 @@ s32 Camera_Jump2(Camera* camera) { bgChkPara.r = adjAtToEyeDir.r; bgChkPara.pitch = 0; bgChkPara.yaw = adjAtToEyeDir.yaw; - Camera_AddVecGeoToVec3f(&camBgChk.pos, at, &bgChkPara); + camBgChk.pos = Camera_AddVecGeoToVec3f(at, &bgChkPara); if (Camera_BGCheckInfo(camera, at, &camBgChk)) { // Collision found between parallel at->eyeNext, set eye position to // first collision point. @@ -2540,7 +2529,7 @@ s32 Camera_Jump2(Camera* camera) { } else { // no collision found with the parallel at->eye, animate to be parallel adjAtToEyeDir.pitch = Camera_LERPCeilS(0, adjAtToEyeDir.pitch, 0.2f, 0xA); - Camera_AddVecGeoToVec3f(eye, at, &adjAtToEyeDir); + *eye = Camera_AddVecGeoToVec3f(at, &adjAtToEyeDir); // useless? Camera_BGCheck(camera, at, eye); } @@ -2585,7 +2574,7 @@ s32 Camera_Jump3(Camera* camera) { Jump3ReadWriteData* rwData = &camera->paramData.jump3.rwData; playerHeight = Player_GetHeight(camera->player); - Actor_GetFocus(&playerhead, &camera->player->actor); + playerhead = Actor_GetFocus(&camera->player->actor); modeSwitch = false; if (((camera->waterYPos - eye->y) < OREG(44) || (camera->animState == 0))) { @@ -2598,8 +2587,8 @@ s32 Camera_Jump3(Camera* camera) { modeSwitch = true; } - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, at, eye); - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); if (RELOAD_PARAMS(camera) || modeSwitch || R_RELOAD_CAM_PARAMS) { values = sCameraSettings[camera->setting].cameraModes[rwData->mode].values; @@ -2674,7 +2663,7 @@ s32 Camera_Jump3(Camera* camera) { camera->speedRatio * 0.05f, 0.1f); Camera_CalcAtDefault(camera, &eyeNextAtOffset, roData->yOffset, roData->interfaceField); - OLib_Vec3fDiffToVecGeo(&eyeDiffGeo, at, eyeNext); + eyeDiffGeo = OLib_Vec3fDiffToVecGeo(at, eyeNext); camera->dist = eyeDiffGeo.r = Camera_ClampDist(camera, eyeDiffGeo.r, roData->distMin, roData->distMax, rwData->animTimer); @@ -2713,7 +2702,7 @@ s32 Camera_Jump3(Camera* camera) { eyeDiffGeo.pitch = R_CAM_MIN_PITCH_1; } - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeDiffGeo); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeDiffGeo); if ((camera->status == CAM_STAT_ACTIVE) && !(roData->interfaceField & JUMP3_FLAG_4)) { func_80046E20(camera, &eyeDiffGeo, roData->distMin, roData->swingUpdateRate, &spBC, &rwData->swing); if (roData->interfaceField & JUMP3_FLAG_2) { @@ -2721,7 +2710,7 @@ s32 Camera_Jump3(Camera* camera) { camera->inputDir.y = eyeAtOffset.yaw - 0x7FFF; camera->inputDir.z = 0; } else { - OLib_Vec3fDiffToVecGeo(&eyeDiffGeo, eye, at); + eyeDiffGeo = OLib_Vec3fDiffToVecGeo(eye, at); camera->inputDir.x = eyeDiffGeo.pitch; camera->inputDir.y = eyeDiffGeo.yaw; camera->inputDir.z = 0; @@ -2860,8 +2849,8 @@ s32 Camera_Battle1(Camera* camera) { camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.1f); playerHeight += roData->yOffset; - OLib_Vec3fDiffToVecGeo(&atToEyeDir, at, eye); - OLib_Vec3fDiffToVecGeo(&atToEyeNextDir, at, eyeNext); + atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); + atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); if (camera->target == NULL || camera->target->update == NULL) { if (camera->target == NULL) { osSyncPrintf( @@ -2913,7 +2902,7 @@ s32 Camera_Battle1(Camera* camera) { camera->atLERPStepScale = Camera_ClampLERPScale(camera, isOffGround ? roData->atLERPScaleOffGround : roData->atLERPScaleOnGround); } - Actor_GetFocus(&camera->targetPosRot, camera->target); + camera->targetPosRot = Actor_GetFocus(camera->target); if (rwData->target != camera->target) { osSyncPrintf("camera: battle: change target %d -> " VT_FGCOL(BLUE) "%d" VT_RST "\n", rwData->target->id, camera->target->id); @@ -2930,10 +2919,10 @@ s32 Camera_Battle1(Camera* camera) { tmpAng2 = playerToTargetDir.yaw; playerHead = playerPosRot->pos; playerHead.y += playerHeight; - OLib_Vec3fDiffToVecGeo(&playerToTargetDir, &playerHead, &camera->targetPosRot.pos); + playerToTargetDir = OLib_Vec3fDiffToVecGeo(&playerHead, &camera->targetPosRot.pos); distRatio = playerToTargetDir.r > distance ? 1 : playerToTargetDir.r / distance; targetPos = camera->targetPosRot.pos; - OLib_Vec3fDiffToVecGeo(&atToTargetDir, at, &targetPos); + atToTargetDir = OLib_Vec3fDiffToVecGeo(at, &targetPos); atToTargetDir.r = distance - ((atToTargetDir.r <= distance ? atToTargetDir.r : distance) * 0.5f); swingAngle = roData->swingYawInitial + ((roData->swingYawFinal - roData->swingYawInitial) * (1.1f - distRatio)); spF8 = OREG(13) + swingAngle; @@ -2944,7 +2933,7 @@ s32 Camera_Battle1(Camera* camera) { if (rwData->animTimer != 0) { if (rwData->animTimer >= OREG(24)) { sp86 = rwData->animTimer - OREG(24); - OLib_Vec3fDiffToVecGeo(&playerToTargetDir, at, eye); + playerToTargetDir = OLib_Vec3fDiffToVecGeo(at, eye); playerToTargetDir.yaw = tmpAng2 - 0x7FFF; var2 = 1.0f / R_CAM_DEFAULT_ANIM_TIME; @@ -2990,7 +2979,7 @@ s32 Camera_Battle1(Camera* camera) { } spB4.pitch = Camera_LERPCeilS(tmpAng1, atToEyeNextDir.pitch, rwData->unk_10, 0xA); - Camera_AddVecGeoToVec3f(eyeNext, at, &spB4); + *eyeNext = Camera_AddVecGeoToVec3f(at, &spB4); spBC.pos = *eyeNext; if (camera->status == CAM_STAT_ACTIVE) { if (!camera->play->envCtx.skyboxDisabled || roData->interfaceField & BATTLE1_FLAG_0) { @@ -2998,7 +2987,7 @@ s32 Camera_Battle1(Camera* camera) { } else if (roData->interfaceField & BATTLE1_FLAG_1) { func_80043F94(camera, at, &spBC); } else { - OLib_Vec3fDistNormalize(&sp128, at, &spBC.pos); + sp128 = OLib_Vec3fDistNormalize(at, &spBC.pos); spBC.pos.x -= sp128.x; spBC.pos.y -= sp128.y; spBC.pos.z -= sp128.z; @@ -3062,8 +3051,8 @@ s32 Camera_Battle4(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, at, eye); - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); sCameraInterfaceField = roData->interfaceField; @@ -3098,7 +3087,7 @@ s32 Camera_Battle4(Camera* camera) { eyeNextOffset.pitch = Camera_LERPCeilS(roData->pitchTarget, eyeAtOffset.pitch, roData->lerpUpdateRate, 2); eyeNextOffset.r = Camera_LERPCeilF(roData->rTarget, eyeAtOffset.r, roData->lerpUpdateRate, 0.001f); } - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeNextOffset); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeNextOffset); *eye = *eyeNext; camera->dist = eyeNextOffset.r; camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, roData->lerpUpdateRate, 1.0f); @@ -3182,8 +3171,8 @@ s32 Camera_KeepOn1(Camera* camera) { } playerHeight += roData->unk_00; - OLib_Vec3fDiffToVecGeo(&spC0, at, eye); - OLib_Vec3fDiffToVecGeo(&spB8, at, eyeNext); + spC0 = OLib_Vec3fDiffToVecGeo(at, eye); + spB8 = OLib_Vec3fDiffToVecGeo(at, eyeNext); sCameraInterfaceField = roData->interfaceField; if (RELOAD_PARAMS(camera)) { camera->animState++; @@ -3211,15 +3200,15 @@ s32 Camera_KeepOn1(Camera* camera) { if ((camera->player->actor.category == 2) && (camera->player->interactRangeActor == camera->target)) { PosRot sp54; - Actor_GetFocus(&sp54, &camera->player->actor); + sp54 = Actor_GetFocus(&camera->player->actor); spC8.r = 60.0f; spC8.yaw = camera->playerPosRot.rot.y; spC8.pitch = 0x2EE0; - Camera_AddVecGeoToVec3f(&camera->targetPosRot.pos, &sp54.pos, &spC8); + camera->targetPosRot.pos = Camera_AddVecGeoToVec3f(&sp54.pos, &spC8); } else { - Actor_GetFocus(&camera->targetPosRot, camera->target); + camera->targetPosRot = Actor_GetFocus(camera->target); } - Actor_GetFocus(&camera->targetPosRot, camera->target); + camera->targetPosRot = Actor_GetFocus(camera->target); if (rwData->unk_0C != camera->target) { rwData->unk_0C = camera->target; camera->atLERPStepScale = 0.0f; @@ -3249,7 +3238,7 @@ s32 Camera_KeepOn1(Camera* camera) { (isOffGround ? CAM_LOCKON_AT_FLAG_OFF_GROUND : 0) | roData->interfaceField); sp114 = playerPosRot->pos; sp114.y += playerHeight; - OLib_Vec3fDiffToVecGeo(&spC8, &sp114, &camera->targetPosRot.pos); + spC8 = OLib_Vec3fDiffToVecGeo(&sp114, &camera->targetPosRot.pos); sp84 = spC8.r > sp104 ? 1.0f : spC8.r / sp104; break; default: @@ -3258,7 +3247,7 @@ s32 Camera_KeepOn1(Camera* camera) { rwData->unk_0C = NULL; break; } - OLib_Vec3fDiffToVecGeo(&spD8, at, eyeNext); + spD8 = OLib_Vec3fDiffToVecGeo(at, eyeNext); if (spD8.r < roData->unk_04) { sp104 = roData->unk_04; spE8 = R_CAM_R_UPDATE_RATE_INV; @@ -3274,7 +3263,7 @@ s32 Camera_KeepOn1(Camera* camera) { Camera_LERPCeilF(spE8, camera->rUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); spD8.r = spE8 = camera->dist = Camera_LERPCeilF(sp104, camera->dist, 1.0f / camera->rUpdateRateInv, 0.2f); sp108 = camera->targetPosRot.pos; - OLib_Vec3fDiffToVecGeo(&spD0, at, &sp108); + spD0 = OLib_Vec3fDiffToVecGeo(at, &sp108); spD0.r = spE8 - ((spD0.r <= spE8 ? spD0.r : spE8) * 0.5f); spEC = roData->unk_0C + ((roData->unk_10 - roData->unk_0C) * (1.1f - sp84)); spF0 = OREG(13) + spEC; @@ -3285,7 +3274,7 @@ s32 Camera_KeepOn1(Camera* camera) { if (rwData->unk_16 >= OREG(24)) { sp82 = rwData->unk_16 - OREG(24); spE2 = spC8.yaw; - OLib_Vec3fDiffToVecGeo(&spC8, at, eye); + spC8 = OLib_Vec3fDiffToVecGeo(at, eye); spC8.yaw = spE2 - 0x7FFF; t2 = 1.0f / R_CAM_DEFAULT_ANIM_TIME; @@ -3328,7 +3317,7 @@ s32 Camera_KeepOn1(Camera* camera) { } spD8.pitch = Camera_LERPCeilS(spE2, spB8.pitch, CAM_DATA_SCALED(OREG(12)), 0xA); - Camera_AddVecGeoToVec3f(eyeNext, at, &spD8); + *eyeNext = Camera_AddVecGeoToVec3f(at, &spD8); sp8C.pos = *eyeNext; if (camera->status == CAM_STAT_ACTIVE) { if (!camera->play->envCtx.skyboxDisabled || roData->interfaceField & KEEPON1_FLAG_0) { @@ -3336,7 +3325,7 @@ s32 Camera_KeepOn1(Camera* camera) { } else if (roData->interfaceField & KEEPON1_FLAG_1) { func_80043F94(camera, at, &sp8C); } else { - OLib_Vec3fDistNormalize(&sp120, at, &sp8C.pos); + sp120 = OLib_Vec3fDistNormalize(at, &sp8C.pos); sp8C.pos.x -= sp120.x; sp8C.pos.y -= sp120.y; sp8C.pos.z -= sp120.z; @@ -3345,8 +3334,8 @@ s32 Camera_KeepOn1(Camera* camera) { } else { *eye = *eyeNext; } - OLib_Vec3fDistNormalize(&sp120, eye, at); - Camera_Vec3fTranslateByUnitVector(eye, eye, &sp120, OREG(1)); + sp120 = OLib_Vec3fDistNormalize(eye, at); + *eye = Camera_Vec3fTranslateByUnitVector(eye, &sp120, OREG(1)); } camera->fov = Camera_LERPCeilF(roData->unk_20, camera->fov, camera->fovUpdateRate, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA); @@ -3429,13 +3418,13 @@ s32 Camera_KeepOn3(Camera* camera) { } playerHeight += roData->yOffset; - OLib_Vec3fDiffToVecGeo(&atToEyeDir, at, eye); - OLib_Vec3fDiffToVecGeo(&atToEyeNextDir, at, eyeNext); - Actor_GetFocus(&camera->targetPosRot, camera->target); - Actor_GetFocus(&playerPosRot, &camera->player->actor); + atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); + atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); + camera->targetPosRot = Actor_GetFocus(camera->target); + playerPosRot = Actor_GetFocus(&camera->player->actor); playerHeadPos = camPlayerPosRot->pos; playerHeadPos.y += playerHeight; - OLib_Vec3fDiffToVecGeo(&targetToPlayerDir, &playerHeadPos, &camera->targetPosRot.pos); + targetToPlayerDir = OLib_Vec3fDiffToVecGeo(&playerHeadPos, &camera->targetPosRot.pos); sCameraInterfaceField = roData->interfaceField; if (RELOAD_PARAMS(camera)) { colChkActors[0] = camera->target; @@ -3480,12 +3469,12 @@ s32 Camera_KeepOn3(Camera* camera) { sp82 = atToEyeAdj.pitch; playerHeadPos = camPlayerPosRot->pos; playerHeadPos.y += playerHeight; - Camera_AddVecGeoToVec3f(&rwData->atTarget, &playerHeadPos, &targetToPlayerDir); + rwData->atTarget = Camera_AddVecGeoToVec3f(&playerHeadPos, &targetToPlayerDir); angleCnt = ARRAY_COUNT(D_8011D3B0); i = 0; targetToPlayerDir.r = prevTargetPlayerDist; atToEyeAdj.r = roData->minDist + (targetToPlayerDir.r * (1 - 0.5f)) - atToEyeNextDir.r + atToEyeNextDir.r; - Camera_AddVecGeoToVec3f(&lineChkPointB, &rwData->atTarget, &atToEyeAdj); + lineChkPointB = Camera_AddVecGeoToVec3f(&rwData->atTarget, &atToEyeAdj); if (!(roData->interfaceField & KEEPON3_FLAG_7)) { while (i < angleCnt) { if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &rwData->atTarget, @@ -3495,7 +3484,7 @@ s32 Camera_KeepOn3(Camera* camera) { } atToEyeAdj.yaw = sp80 + D_8011D3B0[i]; atToEyeAdj.pitch = sp82 + D_8011D3CC[i]; - Camera_AddVecGeoToVec3f(&lineChkPointB, &rwData->atTarget, &atToEyeAdj); + lineChkPointB = Camera_AddVecGeoToVec3f(&rwData->atTarget, &atToEyeAdj); i++; } } @@ -3517,7 +3506,7 @@ s32 Camera_KeepOn3(Camera* camera) { atToEyeAdj.r = ((rwData->eyeToAtTargetR * rwData->animTimer) + atToEyeNextDir.r) + 1.0f; atToEyeAdj.yaw = atToEyeNextDir.yaw + (s16)(rwData->eyeToAtTargetYaw * rwData->animTimer); atToEyeAdj.pitch = atToEyeNextDir.pitch + (s16)(rwData->eyeToAtTargetPitch * rwData->animTimer); - Camera_AddVecGeoToVec3f(eyeNext, at, &atToEyeAdj); + *eyeNext = Camera_AddVecGeoToVec3f(at, &atToEyeAdj); *eye = *eyeNext; camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, 0.5, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5, 0xA); @@ -3727,8 +3716,8 @@ s32 Camera_KeepOn4(Camera* camera) { sUpdateCameraDirection = 1; sCameraInterfaceField = roData->interfaceField; - OLib_Vec3fDiffToVecGeo(&spB0, at, eye); - OLib_Vec3fDiffToVecGeo(&spA8, at, eyeNext); + spB0 = OLib_Vec3fDiffToVecGeo(at, eye); + spA8 = OLib_Vec3fDiffToVecGeo(at, eyeNext); D_8015BD50 = playerPosRot->pos; D_8015BD50.y += playerHeight; temp_f0_2 = BgCheck_CameraRaycastDown2(&camera->play->colCtx, &spC0, &i, &D_8015BD50); @@ -3759,7 +3748,7 @@ s32 Camera_KeepOn4(Camera* camera) { } else if ((roData->interfaceField & KEEPON4_FLAG_3) && camera->target != NULL) { PosRot sp60; - Actor_GetWorldPosShapeRot(&sp60, camera->target); + sp60 = Actor_GetWorldPosShapeRot(camera->target); spA2 = CAM_DEG_TO_BINANG(roData->unk_08) - sp60.rot.x; spA0 = (s16)((s16)(sp60.rot.y - 0x7FFF) - spA8.yaw) > 0 ? (s16)(sp60.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) @@ -3769,7 +3758,7 @@ s32 Camera_KeepOn4(Camera* camera) { } else if ((roData->interfaceField & KEEPON4_FLAG_7) && camera->target != NULL) { PosRot sp4C; - Actor_GetWorld(&sp4C, camera->target); + sp4C = Actor_GetWorld(camera->target); spA2 = CAM_DEG_TO_BINANG(roData->unk_08); sp9E = Camera_XZAngle(&sp4C.pos, &playerPosRot->pos); spA0 = ((s16)(sp9E - spA8.yaw) > 0) ? sp9E + CAM_DEG_TO_BINANG(roData->unk_0C) @@ -3787,7 +3776,7 @@ s32 Camera_KeepOn4(Camera* camera) { spB8.pitch = spA2; spB8.yaw = spA0; spB8.r = roData->unk_04; - Camera_AddVecGeoToVec3f(&D_8015BD70, &D_8015BD50, &spB8); + D_8015BD70 = Camera_AddVecGeoToVec3f(&D_8015BD50, &spB8); if (!(roData->interfaceField & KEEPON4_FLAG_0)) { angleCnt = ARRAY_COUNT(D_8011D3B0); for (i = 0; i < angleCnt; i++) { @@ -3798,7 +3787,7 @@ s32 Camera_KeepOn4(Camera* camera) { } spB8.yaw = D_8011D3B0[i] + spA0; spB8.pitch = D_8011D3CC[i] + spA2; - Camera_AddVecGeoToVec3f(&D_8015BD70, &D_8015BD50, &spB8); + D_8015BD70 = Camera_AddVecGeoToVec3f(&D_8015BD50, &spB8); } osSyncPrintf("camera: item: BG&collision check %d time(s)\n", i); } @@ -3822,7 +3811,7 @@ s32 Camera_KeepOn4(Camera* camera) { spB8.r = roData->unk_10; spB8.pitch = 0; spB8.yaw = playerPosRot->rot.y; - Camera_AddVecGeoToVec3f(at, at, &spB8); + *at = Camera_AddVecGeoToVec3f(at, &spB8); } camera->atLERPStepScale = 0.0f; camera->dist = Camera_LERPCeilF(roData->unk_04, camera->dist, 0.25f, 2.0f); @@ -3855,7 +3844,7 @@ s32 Camera_KeepOn4(Camera* camera) { } spB8.yaw = Camera_LERPCeilS(rwData->unk_0C, spA8.yaw, roData->unk_14, 4); spB8.pitch = Camera_LERPCeilS(rwData->unk_0E, spA8.pitch, roData->unk_14, 4); - Camera_AddVecGeoToVec3f(eyeNext, at, &spB8); + *eyeNext = Camera_AddVecGeoToVec3f(at, &spB8); *eye = *eyeNext; Camera_BGCheck(camera, at, eye); camera->fov = Camera_LERPCeilF(roData->unk_18, camera->fov, camera->fovUpdateRate, 1.0f); @@ -3894,7 +3883,7 @@ s32 Camera_KeepOn0(Camera* camera) { } bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos); + *eyeNext = Camera_Vec3sToVec3f(&bgCamFuncData->pos); *eye = *eyeNext; bgCamRot = bgCamFuncData->rot; @@ -3914,10 +3903,10 @@ s32 Camera_KeepOn0(Camera* camera) { return true; } - Actor_GetFocus(&camera->targetPosRot, camera->target); + camera->targetPosRot = Actor_GetFocus(camera->target); - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, eye, at); - OLib_Vec3fDiffToVecGeo(&eyeTargetPosOffset, eye, &camera->targetPosRot.pos); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); + eyeTargetPosOffset = OLib_Vec3fDiffToVecGeo(eye, &camera->targetPosRot.pos); sCameraInterfaceField = roData->interfaceField; @@ -3932,7 +3921,7 @@ s32 Camera_KeepOn0(Camera* camera) { if (rwData->animTimer != 0) { eyeAtOffset.yaw += ((s16)(eyeTargetPosOffset.yaw - eyeAtOffset.yaw) / rwData->animTimer) * roData->yawScale; - Camera_AddVecGeoToVec3f(at, eye, &eyeAtOffset); + *at = Camera_AddVecGeoToVec3f(eye, &eyeAtOffset); rwData->animTimer--; } else { camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); @@ -3960,7 +3949,7 @@ s32 Camera_Fixed1(Camera* camera) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(&rwData->eyePosRotTarget.pos, &bgCamFuncData->pos); + rwData->eyePosRotTarget.pos = Camera_Vec3sToVec3f(&bgCamFuncData->pos); rwData->eyePosRotTarget.rot = bgCamFuncData->rot; rwData->fov = bgCamFuncData->fov; @@ -3989,7 +3978,7 @@ s32 Camera_Fixed1(Camera* camera) { } } - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, eye, at); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); Camera_LERPCeilVec3f(&rwData->eyePosRotTarget.pos, eye, 0.1f, 0.1f, 0.2f); adjustedPos = playerPosRot->pos; @@ -4000,7 +3989,7 @@ s32 Camera_Fixed1(Camera* camera) { eyeOffset.pitch = Camera_LERPCeilS(-rwData->eyePosRotTarget.rot.x, eyeAtOffset.pitch, roData->lerpStep, 5); eyeOffset.yaw = Camera_LERPCeilS(rwData->eyePosRotTarget.rot.y, eyeAtOffset.yaw, roData->lerpStep, 5); - Camera_AddVecGeoToVec3f(at, eye, &eyeOffset); + *at = Camera_AddVecGeoToVec3f(eye, &eyeOffset); camera->eyeNext = *eye; @@ -4044,7 +4033,7 @@ s32 Camera_Fixed2(Camera* camera) { bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); if (bgCamFuncData != NULL) { - Camera_Vec3sToVec3f(&rwData->eye, &bgCamFuncData->pos); + rwData->eye = Camera_Vec3sToVec3f(&bgCamFuncData->pos); if (bgCamFuncData->fov != -1) { rwData->fov = bgCamFuncData->fov; } @@ -4111,13 +4100,13 @@ s32 Camera_Fixed3(Camera* camera) { bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, eye, at); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->interfaceField = GET_NEXT_RO_DATA(values); - Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos); + *eyeNext = Camera_Vec3sToVec3f(&bgCamFuncData->pos); *eye = *eyeNext; rwData->rot = bgCamFuncData->rot; rwData->fov = bgCamFuncData->fov; @@ -4157,7 +4146,7 @@ s32 Camera_Fixed3(Camera* camera) { atGeo.yaw = rwData->rot.y; atGeo.pitch = -rwData->rot.x; - Camera_AddVecGeoToVec3f(at, eye, &atGeo); + *at = Camera_AddVecGeoToVec3f(eye, &atGeo); sCameraInterfaceField = roData->interfaceField; rwData->fov = R_CAM_DATA(CAM_DATA_FOV); camera->roll = 0; @@ -4201,7 +4190,7 @@ s32 Camera_Fixed4(Camera* camera) { bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); if (bgCamFuncData != NULL) { - Camera_Vec3sToVec3f(&rwData->eyeTarget, &bgCamFuncData->pos); + rwData->eyeTarget = Camera_Vec3sToVec3f(&bgCamFuncData->pos); } else { rwData->eyeTarget = *eye; } @@ -4231,15 +4220,15 @@ s32 Camera_Fixed4(Camera* camera) { playerPosWithCamOffset.z = playerPosRot->pos.z + camera->playerToAtOffset.z; VEC3F_LERPIMPDST(&atTarget, at, &playerPosWithCamOffset, 0.5f); - OLib_Vec3fDiffToVecGeo(&atEyeNextOffset, eyeNext, at); - OLib_Vec3fDiffToVecGeo(&atTargetEyeNextOffset, eyeNext, &atTarget); + atEyeNextOffset = OLib_Vec3fDiffToVecGeo(eyeNext, at); + atTargetEyeNextOffset = OLib_Vec3fDiffToVecGeo(eyeNext, &atTarget); atEyeNextOffset.r += (atTargetEyeNextOffset.r - atEyeNextOffset.r) * rwData->followSpeed; atEyeNextOffset.pitch = Camera_LERPCeilS(atTargetEyeNextOffset.pitch, atEyeNextOffset.pitch, rwData->followSpeed * camera->speedRatio, 0xA); atEyeNextOffset.yaw = Camera_LERPCeilS(atTargetEyeNextOffset.yaw, atEyeNextOffset.yaw, rwData->followSpeed * camera->speedRatio, 0xA); - Camera_AddVecGeoToVec3f(at, eyeNext, &atEyeNextOffset); + *at = Camera_AddVecGeoToVec3f(eyeNext, &atEyeNextOffset); camera->dist = OLib_Vec3fDist(at, eye); camera->roll = 0; camera->fov = roData->fov; @@ -4283,7 +4272,7 @@ s32 Camera_Subj3(Camera* camera) { Vec3f* pad2; f32 playerHeight; - Actor_GetFocus(&sp60, &camera->player->actor); + sp60 = Actor_GetFocus(&camera->player->actor); playerHeight = Player_GetHeight(camera->player); if (camera->play->view.unk_124 == 0) { @@ -4309,8 +4298,8 @@ s32 Camera_Subj3(Camera* camera) { sp98 = sp60.pos; sp98.y += roData->eyeNextYOffset; - Camera_AddVecGeoToVec3f(&sp8C, &sp98, &sp84); - OLib_Vec3fDiffToVecGeo(&sp7C, at, eye); + sp8C = Camera_AddVecGeoToVec3f(&sp98, &sp84); + sp7C = OLib_Vec3fDiffToVecGeo(at, eye); sCameraInterfaceField = roData->interfaceField; if (RELOAD_PARAMS(camera)) { @@ -4343,7 +4332,7 @@ s32 Camera_Subj3(Camera* camera) { sp7C.yaw = Camera_LERPCeilS(sp84.yaw + (sp52 * rwData->animTimer), sp7C.yaw, CAM_DATA_SCALED(OREG(28)), 0xA); sp7C.pitch = Camera_LERPCeilS(sp84.pitch + (sp50 * rwData->animTimer), sp7C.pitch, CAM_DATA_SCALED(OREG(28)), 0xA); - Camera_AddVecGeoToVec3f(eyeNext, at, &sp7C); + *eyeNext = Camera_AddVecGeoToVec3f(at, &sp7C); *eye = *eyeNext; rwData->animTimer--; @@ -4370,9 +4359,9 @@ s32 Camera_Subj3(Camera* camera) { sp7C.r = roData->eyeNextDist; sp7C.yaw = sp60.rot.y - 0x7FFF; sp7C.pitch = sp60.rot.x; - Camera_AddVecGeoToVec3f(eyeNext, at, &sp7C); + *eyeNext = Camera_AddVecGeoToVec3f(at, &sp7C); sp7C.r = roData->eyeDist; - Camera_AddVecGeoToVec3f(eye, at, &sp7C); + *eye = Camera_AddVecGeoToVec3f(at, &sp7C); } camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x; @@ -4438,8 +4427,8 @@ s32 Camera_Subj4(Camera* camera) { return true; } - Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); - OLib_Vec3fDiffToVecGeo(&atEyeOffset, at, eye); + playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); + atEyeOffset = OLib_Vec3fDiffToVecGeo(at, eye); sCameraInterfaceField = roData->interfaceField; @@ -4447,9 +4436,9 @@ s32 Camera_Subj4(Camera* camera) { if (camera->animState == 0) { crawlspacePoints = (Vec3s*)Camera_GetBgCamFuncDataUnderPlayer(camera, &crawlspaceNumPoints); // Second entry of crawlspacePoints contains the front position - Camera_Vec3sToVec3f(&rwData->crawlspaceLine.point, &crawlspacePoints[1]); + rwData->crawlspaceLine.point = Camera_Vec3sToVec3f(&crawlspacePoints[1]); // Second last entry of crawlspacePoints contains the back position - Camera_Vec3sToVec3f(&vCrawlSpaceBackPos, &crawlspacePoints[crawlspaceNumPoints - 2]); + vCrawlSpaceBackPos = Camera_Vec3sToVec3f(&crawlspacePoints[crawlspaceNumPoints - 2]); targetOffset.r = 10.0f; targetOffset.pitch = 0x238C; // ~50 degrees @@ -4483,7 +4472,7 @@ s32 Camera_Subj4(Camera* camera) { targetOffset.r = 10.0f; targetOffset.pitch = 0x238C; // ~50 degrees targetOffset.yaw = rwData->forwardYaw; - Camera_AddVecGeoToVec3f(&zoomAtTarget, &playerPosRot.pos, &targetOffset); + zoomAtTarget = Camera_AddVecGeoToVec3f(&playerPosRot.pos, &targetOffset); vZoomTimer = rwData->zoomTimer + 1.0f; at->x = F32_LERPIMPINV(at->x, zoomAtTarget.x, vZoomTimer); @@ -4493,7 +4482,7 @@ s32 Camera_Subj4(Camera* camera) { atEyeOffset.r -= (atEyeOffset.r / vZoomTimer); atEyeOffset.yaw = BINANG_LERPIMPINV(atEyeOffset.yaw, (s16)(playerPosRot.rot.y - 0x7FFF), rwData->zoomTimer); atEyeOffset.pitch = BINANG_LERPIMPINV(atEyeOffset.pitch, playerPosRot.rot.x, rwData->zoomTimer); - Camera_AddVecGeoToVec3f(eyeNext, at, &atEyeOffset); + *eyeNext = Camera_AddVecGeoToVec3f(at, &atEyeOffset); *eye = *eyeNext; rwData->zoomTimer--; return false; @@ -4503,7 +4492,7 @@ s32 Camera_Subj4(Camera* camera) { return false; } - Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); + playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); Math3D_LineClosestToPoint(&rwData->crawlspaceLine, &playerPosRot.pos, eyeNext); // *at is unused before getting overwritten later this function @@ -4517,7 +4506,7 @@ s32 Camera_Subj4(Camera* camera) { targetOffset.r = 5.0f; targetOffset.pitch = 0x238C; // ~50 degrees - Camera_AddVecGeoToVec3f(&vEyeTarget, eyeNext, &targetOffset); + vEyeTarget = Camera_AddVecGeoToVec3f(eyeNext, &targetOffset); rwData->eyeLerpPhase += 0xBB8; eyeLerp = Math_CosS(rwData->eyeLerpPhase); @@ -4605,7 +4594,7 @@ s32 Camera_Data4(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(&rwData->eyePosRot.pos, &bgCamFuncData->pos); + rwData->eyePosRot.pos = Camera_Vec3sToVec3f(&bgCamFuncData->pos); rwData->eyePosRot.rot = bgCamFuncData->rot; fov = bgCamFuncData->fov; rwData->fov = fov; @@ -4628,16 +4617,16 @@ s32 Camera_Data4(Camera* camera) { func_80043B60(camera); } - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); Camera_CalcAtDefault(camera, &eyeNextAtOffset, roData->yOffset, false); - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, eye, at); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); atOffset.r = eyeAtOffset.r; atOffset.yaw = (rwData->flags & 1) ? (CAM_DEG_TO_BINANG(camera->data2) + rwData->eyePosRot.rot.y) : eyeAtOffset.yaw; atOffset.pitch = (rwData->flags & 2) ? (CAM_DEG_TO_BINANG(camera->data3) + rwData->eyePosRot.rot.x) : eyeAtOffset.pitch; - Camera_AddVecGeoToVec3f(at, eye, &atOffset); + *at = Camera_AddVecGeoToVec3f(eye, &atOffset); lookAt = camera->playerPosRot.pos; lookAt.y += playerHeight; @@ -4692,8 +4681,8 @@ s32 Camera_Unique1(Camera* camera) { sUpdateCameraDirection = 1; - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, at, eye); - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); sCameraInterfaceField = roData->interfaceField; @@ -4702,7 +4691,7 @@ s32 Camera_Unique1(Camera* camera) { rwData->yawTarget = eyeNextAtOffset.yaw; rwData->unk_00 = 0.0f; playerWaistPos = camera->player->bodyPartsPos[PLAYER_BODYPART_WAIST]; - OLib_Vec3fDiffToVecGeo(&unk908PlayerPosOffset, &playerPosRot->pos, &playerWaistPos); + unk908PlayerPosOffset = OLib_Vec3fDiffToVecGeo(&playerPosRot->pos, &playerWaistPos); rwData->timer = R_CAM_DEFAULT_ANIM_TIME; rwData->yawTargetAdj = ABS((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw)) < 0x3A98 ? 0 @@ -4710,7 +4699,7 @@ s32 Camera_Unique1(Camera* camera) { camera->animState++; } - Actor_GetFocus(&playerhead, &camera->player->actor); // unused + playerhead = Actor_GetFocus(&camera->player->actor); // unused camera->yawUpdateRateInv = Camera_LERPCeilF(100.0f, camera->yawUpdateRateInv, R_CAM_UPDATE_RATE_STEP_SCALE_XZ * 0.01f, 0.1f); @@ -4723,7 +4712,7 @@ s32 Camera_Unique1(Camera* camera) { camera->fovUpdateRate = Camera_LERPCeilF(R_CAM_FOV_UPDATE_RATE * 0.01f, camera->fovUpdateRate, 0.05f, 0.1f); Camera_CalcAtDefault(camera, &eyeNextAtOffset, roData->yOffset, true); - OLib_Vec3fDiffToVecGeo(&sp8C, at, eyeNext); + sp8C = OLib_Vec3fDiffToVecGeo(at, eyeNext); camera->dist = Camera_LERPClampDist(camera, sp8C.r, roData->distMin, roData->distMax); @@ -4743,7 +4732,7 @@ s32 Camera_Unique1(Camera* camera) { } sp8C.yaw = Camera_LERPFloorS(rwData->yawTarget, eyeNextAtOffset.yaw, 0.5f, 0x2710); - Camera_AddVecGeoToVec3f(eyeNext, at, &sp8C); + *eyeNext = Camera_AddVecGeoToVec3f(at, &sp8C); *eye = *eyeNext; Camera_BGCheck(camera, at, eye); camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, camera->fovUpdateRate, 1.0f); @@ -4768,7 +4757,7 @@ s32 Camera_Unique2(Camera* camera) { playerHeight = Player_GetHeight(camera->player); - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, at, eye); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; @@ -4808,17 +4797,17 @@ s32 Camera_Unique2(Camera* camera) { rwData->unk_00 = F32_LERPIMP(rwData->unk_00, 2.0f, 0.05f); // unused. if (roData->interfaceField & UNIQUE2_FLAG_0) { - OLib_Vec3fDiffToVecGeo(&eyeOffset, at, eyeNext); + eyeOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); eyeOffset.r = roData->distTarget; - Camera_AddVecGeoToVec3f(&playerPos, at, &eyeOffset); + playerPos = Camera_AddVecGeoToVec3f(at, &eyeOffset); Camera_LERPCeilVec3f(&playerPos, eye, 0.25f, 0.25f, 0.2f); } else if (roData->interfaceField & UNIQUE2_FLAG_1) { if (OLib_Vec3fDistXZ(at, eyeNext) < roData->distTarget) { - OLib_Vec3fDiffToVecGeo(&eyeOffset, at, eyeNext); + eyeOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); eyeOffset.yaw = Camera_LERPCeilS(eyeOffset.yaw, eyeAtOffset.yaw, 0.1f, 0xA); eyeOffset.r = roData->distTarget; eyeOffset.pitch = 0; - Camera_AddVecGeoToVec3f(eye, at, &eyeOffset); + *eye = Camera_AddVecGeoToVec3f(at, &eyeOffset); eye->y = eyeNext->y; } else { Camera_LERPCeilVec3f(eyeNext, eye, 0.25f, 0.25f, 0.2f); @@ -4877,7 +4866,7 @@ s32 Camera_Unique3(Camera* camera) { } bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(&camera->eyeNext, &bgCamFuncData->pos); + camera->eyeNext = Camera_Vec3sToVec3f(&bgCamFuncData->pos); camera->eye = camera->eyeNext; bgCamRot = bgCamFuncData->rot; @@ -4885,7 +4874,7 @@ s32 Camera_Unique3(Camera* camera) { sp60.yaw = bgCamRot.y; sp60.pitch = -bgCamRot.x; - Camera_AddVecGeoToVec3f(at, &camera->eye, &sp60); + *at = Camera_AddVecGeoToVec3f(&camera->eye, &sp60); camera->animState++; FALLTHROUGH; case 2: @@ -4929,9 +4918,9 @@ s32 Camera_Unique3(Camera* camera) { FALLTHROUGH; case 5: camera->fov = Camera_LERPCeilF(rwData->initialFov, camera->fov, 0.4f, 0.1f); - OLib_Vec3fDiffToVecGeo(&sp60, at, &camera->eye); + sp60 = OLib_Vec3fDiffToVecGeo(at, &camera->eye); sp60.r = Camera_LERPCeilF(100.0f, sp60.r, 0.4f, 0.1f); - Camera_AddVecGeoToVec3f(&camera->eyeNext, at, &sp60); + camera->eyeNext = Camera_AddVecGeoToVec3f(at, &sp60); camera->eye = camera->eyeNext; if (doorParams->timer3-- > 0) { break; @@ -4994,7 +4983,7 @@ s32 Camera_Unique0(Camera* camera) { camera->stateFlags &= ~CAM_STATE_CHECK_BG; bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(&rwData->eyeAndDirection.point, &bgCamFuncData->pos); + rwData->eyeAndDirection.point = Camera_Vec3sToVec3f(&bgCamFuncData->pos); *eye = camera->eyeNext = rwData->eyeAndDirection.point; bgCamRot = bgCamFuncData->rot; @@ -5009,7 +4998,7 @@ s32 Camera_Unique0(Camera* camera) { atPlayerOffset.r = OLib_Vec3fDist(&playerPosWithOffset, eye); atPlayerOffset.yaw = bgCamRot.y; atPlayerOffset.pitch = -bgCamRot.x; - OLib_VecGeoToVec3f(&rwData->eyeAndDirection.dir, &atPlayerOffset); + rwData->eyeAndDirection.dir = OLib_VecGeoToVec3f(&atPlayerOffset); Math3D_LineClosestToPoint(&rwData->eyeAndDirection, &playerPosRot->pos, &camera->at); rwData->initalPos = playerPosRot->pos; camera->animState++; @@ -5158,11 +5147,11 @@ s32 Camera_Unique7(Camera* camera) { bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos); + *eyeNext = Camera_Vec3sToVec3f(&bgCamFuncData->pos); *eye = *eyeNext; bgCamRot = bgCamFuncData->rot; - OLib_Vec3fDiffToVecGeo(&playerPosEyeOffset, eye, &playerPosRot->pos); + playerPosEyeOffset = OLib_Vec3fDiffToVecGeo(eye, &playerPosRot->pos); // fov actually goes unused since it's hard set later on. fov = bgCamFuncData->fov; @@ -5189,7 +5178,7 @@ s32 Camera_Unique7(Camera* camera) { // 0x7D0 ~ 10.98 degres. rwData->unk_00.x = Camera_LERPFloorS(playerPosEyeOffset.yaw, rwData->unk_00.x, 0.4f, 0x7D0); playerPosEyeOffset.pitch = -bgCamFuncData->rot.x * Math_CosS(playerPosEyeOffset.yaw - bgCamFuncData->rot.y); - Camera_AddVecGeoToVec3f(at, eye, &playerPosEyeOffset); + *at = Camera_AddVecGeoToVec3f(eye, &playerPosEyeOffset); camera->stateFlags |= CAM_STATE_BLOCK_BG; return true; } @@ -5239,7 +5228,7 @@ s32 Camera_Unique9(Camera* camera) { sCameraInterfaceField = roData->interfaceField; - Actor_GetWorld(&playerPosRot, &camera->player->actor); + playerPosRot = Actor_GetWorld(&camera->player->actor); if (camera->animState == 0) { camera->animState++; @@ -5309,21 +5298,21 @@ s32 Camera_Unique9(Camera* camera) { } } else if (atFlags == 4 || atFlags == 0x84) { if (camera->target != NULL && camera->target->update != NULL) { - Actor_GetFocus(&targethead, camera->target); - Actor_GetFocus(&playerhead, &camera->player->actor); + targethead = Actor_GetFocus(camera->target); + playerhead = Actor_GetFocus(&camera->player->actor); playerhead.pos.x = playerPosRot.pos.x; playerhead.pos.z = playerPosRot.pos.z; - OLib_Vec3fDiffToVecGeo(&playerTargetOffset, &targethead.pos, &playerhead.pos); + playerTargetOffset = OLib_Vec3fDiffToVecGeo(&targethead.pos, &playerhead.pos); if (atFlags & (s16)0x8080) { scratchGeo.pitch = CAM_DEG_TO_BINANG(rwData->curKeyFrame->atTargetInit.x); scratchGeo.yaw = CAM_DEG_TO_BINANG(rwData->curKeyFrame->atTargetInit.y); scratchGeo.r = rwData->curKeyFrame->atTargetInit.z; } else { - OLib_Vec3fToVecGeo(&scratchGeo, &rwData->curKeyFrame->atTargetInit); + scratchGeo = OLib_Vec3fToVecGeo(&rwData->curKeyFrame->atTargetInit); } scratchGeo.yaw += playerTargetOffset.yaw; scratchGeo.pitch += playerTargetOffset.pitch; - Camera_AddVecGeoToVec3f(&rwData->atTarget, &targethead.pos, &scratchGeo); + rwData->atTarget = Camera_AddVecGeoToVec3f(&targethead.pos, &scratchGeo); } else { if (camera->target == NULL) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: warning: demo C: actor is not valid\n" VT_RST); @@ -5345,11 +5334,11 @@ s32 Camera_Unique9(Camera* camera) { if (focusActor != NULL) { if ((atFlags & 0xF) == 1) { - Actor_GetFocus(&atFocusPosRot, focusActor); + atFocusPosRot = Actor_GetFocus(focusActor); } else if ((atFlags & 0xF) == 2) { - Actor_GetWorld(&atFocusPosRot, focusActor); + atFocusPosRot = Actor_GetWorld(focusActor); } else { - Actor_GetWorldPosShapeRot(&atFocusPosRot, focusActor); + atFocusPosRot = Actor_GetWorldPosShapeRot(focusActor); } if (atFlags & (s16)0x8080) { @@ -5357,12 +5346,12 @@ s32 Camera_Unique9(Camera* camera) { scratchGeo.yaw = CAM_DEG_TO_BINANG(rwData->curKeyFrame->atTargetInit.y); scratchGeo.r = rwData->curKeyFrame->atTargetInit.z; } else { - OLib_Vec3fToVecGeo(&scratchGeo, &rwData->curKeyFrame->atTargetInit); + scratchGeo = OLib_Vec3fToVecGeo(&rwData->curKeyFrame->atTargetInit); } scratchGeo.yaw += atFocusPosRot.rot.y; scratchGeo.pitch -= atFocusPosRot.rot.x; - Camera_AddVecGeoToVec3f(&rwData->atTarget, &atFocusPosRot.pos, &scratchGeo); + rwData->atTarget = Camera_AddVecGeoToVec3f(&atFocusPosRot.pos, &scratchGeo); } else { if (camera->target == NULL) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: warning: demo C: actor is not valid\n" VT_RST); @@ -5391,11 +5380,11 @@ s32 Camera_Unique9(Camera* camera) { } } else if (eyeFlags == 0x400 || eyeFlags == (s16)0x8400 || eyeFlags == 0x500 || eyeFlags == (s16)0x8500) { if (camera->target != NULL && camera->target->update != NULL) { - Actor_GetFocus(&targethead, camera->target); - Actor_GetFocus(&playerhead, &camera->player->actor); + targethead = Actor_GetFocus(camera->target); + playerhead = Actor_GetFocus(&camera->player->actor); playerhead.pos.x = playerPosRot.pos.x; playerhead.pos.z = playerPosRot.pos.z; - OLib_Vec3fDiffToVecGeo(&playerTargetOffset, &targethead.pos, &playerhead.pos); + playerTargetOffset = OLib_Vec3fDiffToVecGeo(&targethead.pos, &playerhead.pos); if (eyeFlags == 0x400 || eyeFlags == (s16)0x8400) { eyeLookAtPos = targethead.pos; } else { @@ -5407,12 +5396,12 @@ s32 Camera_Unique9(Camera* camera) { scratchGeo.yaw = CAM_DEG_TO_BINANG(rwData->curKeyFrame->eyeTargetInit.y); scratchGeo.r = rwData->curKeyFrame->eyeTargetInit.z; } else { - OLib_Vec3fToVecGeo(&scratchGeo, &rwData->curKeyFrame->eyeTargetInit); + scratchGeo = OLib_Vec3fToVecGeo(&rwData->curKeyFrame->eyeTargetInit); } scratchGeo.yaw += playerTargetOffset.yaw; scratchGeo.pitch += playerTargetOffset.pitch; - Camera_AddVecGeoToVec3f(&rwData->eyeTarget, &eyeLookAtPos, &scratchGeo); + rwData->eyeTarget = Camera_AddVecGeoToVec3f(&eyeLookAtPos, &scratchGeo); } else { if (camera->target == NULL) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: warning: demo C: actor is not valid\n" VT_RST); @@ -5434,13 +5423,13 @@ s32 Camera_Unique9(Camera* camera) { if (focusActor != NULL) { if ((eyeFlags & 0xF00) == 0x100) { // head - Actor_GetFocus(&eyeFocusPosRot, focusActor); + eyeFocusPosRot = Actor_GetFocus(focusActor); } else if ((eyeFlags & 0xF00) == 0x200) { // world - Actor_GetWorld(&eyeFocusPosRot, focusActor); + eyeFocusPosRot = Actor_GetWorld(focusActor); } else { // world, shapeRot - Actor_GetWorldPosShapeRot(&eyeFocusPosRot, focusActor); + eyeFocusPosRot = Actor_GetWorldPosShapeRot(focusActor); } if (eyeFlags & (s16)0x8080) { @@ -5448,12 +5437,12 @@ s32 Camera_Unique9(Camera* camera) { scratchGeo.yaw = CAM_DEG_TO_BINANG(rwData->curKeyFrame->eyeTargetInit.y); scratchGeo.r = rwData->curKeyFrame->eyeTargetInit.z; } else { - OLib_Vec3fToVecGeo(&scratchGeo, &rwData->curKeyFrame->eyeTargetInit); + scratchGeo = OLib_Vec3fToVecGeo(&rwData->curKeyFrame->eyeTargetInit); } scratchGeo.yaw += eyeFocusPosRot.rot.y; scratchGeo.pitch -= eyeFocusPosRot.rot.x; - Camera_AddVecGeoToVec3f(&rwData->eyeTarget, &eyeFocusPosRot.pos, &scratchGeo); + rwData->eyeTarget = Camera_AddVecGeoToVec3f(&eyeFocusPosRot.pos, &scratchGeo); } else { if (camera->target == NULL) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: warning: demo C: actor is not valid\n" VT_RST); @@ -5518,15 +5507,15 @@ s32 Camera_Unique9(Camera* camera) { case ONEPOINT_CS_ACTION_ID_1: // linear interpolation of eye/at using the geographic coordinates - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); - OLib_Vec3fDiffToVecGeo(&rwData->atEyeOffsetTarget, &rwData->atTarget, &rwData->eyeTarget); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); + rwData->atEyeOffsetTarget = OLib_Vec3fDiffToVecGeo(&rwData->atTarget, &rwData->eyeTarget); invKeyFrameTimer = 1.0f / rwData->keyFrameTimer; scratchGeo.r = F32_LERPIMP(eyeNextAtOffset.r, rwData->atEyeOffsetTarget.r, invKeyFrameTimer); scratchGeo.pitch = eyeNextAtOffset.pitch + ((s16)(rwData->atEyeOffsetTarget.pitch - eyeNextAtOffset.pitch) * invKeyFrameTimer); scratchGeo.yaw = eyeNextAtOffset.yaw + ((s16)(rwData->atEyeOffsetTarget.yaw - eyeNextAtOffset.yaw) * invKeyFrameTimer); - Camera_AddVecGeoToVec3f(&eyeTarget, at, &scratchGeo); + eyeTarget = Camera_AddVecGeoToVec3f(at, &scratchGeo); goto setEyeNext; case ONEPOINT_CS_ACTION_ID_2: @@ -5562,15 +5551,15 @@ s32 Camera_Unique9(Camera* camera) { case ONEPOINT_CS_ACTION_ID_4: // linear interpolation of eye/at/fov/roll using the step scale, and spherical coordinates - OLib_Vec3fDiffToVecGeo(&eyeNextAtOffset, at, eyeNext); - OLib_Vec3fDiffToVecGeo(&rwData->atEyeOffsetTarget, &rwData->atTarget, &rwData->eyeTarget); + eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); + rwData->atEyeOffsetTarget = OLib_Vec3fDiffToVecGeo(&rwData->atTarget, &rwData->eyeTarget); scratchGeo.r = Camera_LERPCeilF(rwData->atEyeOffsetTarget.r, eyeNextAtOffset.r, rwData->curKeyFrame->lerpStepScale, 0.1f); scratchGeo.pitch = Camera_LERPCeilS(rwData->atEyeOffsetTarget.pitch, eyeNextAtOffset.pitch, rwData->curKeyFrame->lerpStepScale, 1); scratchGeo.yaw = Camera_LERPCeilS(rwData->atEyeOffsetTarget.yaw, eyeNextAtOffset.yaw, rwData->curKeyFrame->lerpStepScale, 1); - Camera_AddVecGeoToVec3f(eyeNext, at, &scratchGeo); + *eyeNext = Camera_AddVecGeoToVec3f(at, &scratchGeo); goto setAtFovRoll; case ONEPOINT_CS_ACTION_ID_3: @@ -5598,7 +5587,7 @@ s32 Camera_Unique9(Camera* camera) { camera->at.x = Camera_LERPCeilF(rwData->atTarget.x, camera->at.x, rwData->curKeyFrame->lerpStepScale, 1.0f); camera->at.y += camera->playerPosDelta.y * rwData->curKeyFrame->lerpStepScale; camera->at.z = Camera_LERPCeilF(rwData->atTarget.z, camera->at.z, rwData->curKeyFrame->lerpStepScale, 1.0f); - OLib_Vec3fDiffToVecGeo(&scratchGeo, at, eyeNext); + scratchGeo = OLib_Vec3fDiffToVecGeo(at, eyeNext); scratchGeo.yaw += CAM_DEG_TO_BINANG(rwData->curKeyFrame->eyeTargetInit.y); // 3A98 ~ 82.40 degrees @@ -5617,7 +5606,7 @@ s32 Camera_Unique9(Camera* camera) { rwData->curKeyFrame->lerpStepScale, 1.0f) : scratchGeo.r; - Camera_AddVecGeoToVec3f(eyeNext, at, &scratchGeo); + *eyeNext = Camera_AddVecGeoToVec3f(at, &scratchGeo); camera->fov = Camera_LERPCeilF(F32_LERPIMPINV(camera->fov, rwData->curKeyFrame->fovTargetInit, rwData->keyFrameTimer), camera->fov, rwData->curKeyFrame->lerpStepScale, 1.0f); @@ -5721,9 +5710,9 @@ void Camera_RotateAroundPoint(PosRot* at, Vec3f* pos, Vec3f* dst) { Vec3f posCopy; Camera_Vec3fCopy(pos, &posCopy); - OLib_Vec3fToVecGeo(&posGeo, &posCopy); + posGeo = OLib_Vec3fToVecGeo(&posCopy); posGeo.yaw += at->rot.y; - Camera_AddVecGeoToVec3f(dst, &at->pos, &posGeo); + *dst = Camera_AddVecGeoToVec3f(&at->pos, &posGeo); } /** @@ -5780,7 +5769,7 @@ s32 Camera_Demo1(Camera* camera) { // if the camera is set to be relative to the player, move the interpolated points // relative to the player's position if (camera->player != NULL && camera->player->actor.update != NULL) { - Actor_GetWorld(&curPlayerPosRot, &camera->player->actor); + curPlayerPosRot = Actor_GetWorld(&camera->player->actor); Camera_RotateAroundPoint(&curPlayerPosRot, &csEyeUpdate, eyeNext); Camera_RotateAroundPoint(&curPlayerPosRot, &csAtUpdate, at); } else { @@ -5842,7 +5831,7 @@ s32 Camera_Demo3(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, at, eye); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); sCameraInterfaceField = roData->interfaceField; @@ -5873,9 +5862,9 @@ s32 Camera_Demo3(Camera* camera) { if (Camera_BGCheck(camera, &sp68, &sp74)) { rwData->yawDir = -rwData->yawDir; } - OLib_Vec3fToVecGeo(&atOffset, &D_8011D678[0]); + atOffset = OLib_Vec3fToVecGeo(&D_8011D678[0]); atOffset.yaw += camPlayerPosRot->rot.y; - Camera_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + *at = Camera_AddVecGeoToVec3f(&rwData->initialAt, &atOffset); eyeOffset.r = D_8011D658[0].r; eyeOffset.pitch = D_8011D658[0].pitch; eyeOffset.yaw = (D_8011D658[0].yaw * rwData->yawDir) + camPlayerPosRot->rot.y; @@ -5888,9 +5877,9 @@ s32 Camera_Demo3(Camera* camera) { sp5C.y = F32_LERPIMP(D_8011D678[0].y, D_8011D678[1].y, temp_f0); sp5C.z = F32_LERPIMP(D_8011D678[0].z, D_8011D678[1].z, temp_f0); - OLib_Vec3fToVecGeo(&atOffset, &sp5C); + atOffset = OLib_Vec3fToVecGeo(&sp5C); atOffset.yaw = (atOffset.yaw * rwData->yawDir) + camPlayerPosRot->rot.y; - Camera_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + *at = Camera_AddVecGeoToVec3f(&rwData->initialAt, &atOffset); atOffset.r = F32_LERPIMP(D_8011D658[0].r, D_8011D658[1].r, temp_f0); atOffset.pitch = BINANG_LERPIMP(D_8011D658[0].pitch, D_8011D658[1].pitch, temp_f0); @@ -5910,9 +5899,9 @@ s32 Camera_Demo3(Camera* camera) { sp5C.y += yOffset; sp5C.z = F32_LERPIMP(D_8011D678[1].z, D_8011D678[2].z, temp_f0); - OLib_Vec3fToVecGeo(&atOffset, &sp5C); + atOffset = OLib_Vec3fToVecGeo(&sp5C); atOffset.yaw = (atOffset.yaw * rwData->yawDir) + camPlayerPosRot->rot.y; - Camera_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + *at = Camera_AddVecGeoToVec3f(&rwData->initialAt, &atOffset); atOffset.r = F32_LERPIMP(D_8011D658[1].r, D_8011D658[2].r, temp_f0); atOffset.pitch = BINANG_LERPIMP(D_8011D658[1].pitch, D_8011D658[2].pitch, temp_f0); @@ -5931,9 +5920,9 @@ s32 Camera_Demo3(Camera* camera) { sp5C.y += yOffset; sp5C.z = F32_LERPIMP(D_8011D678[2].z, D_8011D678[3].z, temp_f0); - OLib_Vec3fToVecGeo(&atOffset, &sp5C); + atOffset = OLib_Vec3fToVecGeo(&sp5C); atOffset.yaw = (atOffset.yaw * rwData->yawDir) + camPlayerPosRot->rot.y; - Camera_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + *at = Camera_AddVecGeoToVec3f(&rwData->initialAt, &atOffset); atOffset.r = F32_LERPIMP(D_8011D658[2].r, D_8011D658[3].r, temp_f0); atOffset.pitch = BINANG_LERPIMP(D_8011D658[2].pitch, D_8011D658[3].pitch, temp_f0); @@ -6011,7 +6000,7 @@ s32 Camera_Demo3(Camera* camera) { eyeOffset.r = Camera_LERPCeilF(eyeOffset.r, eyeAtOffset.r, rwData->unk_0C, 2.0f); eyeOffset.pitch = Camera_LERPCeilS(eyeOffset.pitch, eyeAtOffset.pitch, rwData->unk_0C, 0xA); eyeOffset.yaw = Camera_LERPCeilS(eyeOffset.yaw, eyeAtOffset.yaw, rwData->unk_0C, 0xA); - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeOffset); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeOffset); *eye = *eyeNext; } @@ -6047,7 +6036,7 @@ s32 Camera_Demo5(Camera* camera) { s16 t; s32 pad2; - Actor_GetFocus(&playerhead, &camera->player->actor); + playerhead = Actor_GetFocus(&camera->player->actor); player = camera->player; sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, 0); @@ -6059,12 +6048,12 @@ s32 Camera_Demo5(Camera* camera) { return true; } - Actor_GetFocus(&camera->targetPosRot, camera->target); - OLib_Vec3fDiffToVecGeo(&playerTargetGeo, &camera->targetPosRot.pos, &camera->playerPosRot.pos); + camera->targetPosRot = Actor_GetFocus(camera->target); + playerTargetGeo = OLib_Vec3fDiffToVecGeo(&camera->targetPosRot.pos, &camera->playerPosRot.pos); D_8011D3AC = camera->target->category; Actor_GetScreenPos(camera->play, camera->target, &targetScreenPosX, &targetScreenPosY); eyeTargetDist = OLib_Vec3fDist(&camera->targetPosRot.pos, &camera->eye); - OLib_Vec3fDiffToVecGeo(&eyePlayerGeo, &playerhead.pos, &camera->eyeNext); + eyePlayerGeo = OLib_Vec3fDiffToVecGeo(&playerhead.pos, &camera->eyeNext); sp4A = eyePlayerGeo.yaw - playerTargetGeo.yaw; if (camera->target->category == ACTORCAT_PLAYER) { @@ -6177,7 +6166,7 @@ s32 Camera_Demo5(Camera* camera) { temp_v0 = Rand_ZeroOne() * (sp90 * -0.2f); D_8011D954[1].rollTargetInit = temp_v0; D_8011D954[0].rollTargetInit = temp_v0; - Actor_GetFocus(&targethead, camera->target); + targethead = Actor_GetFocus(camera->target); targethead.pos.x += 50.0f * Math_SinS(sp4A - 0x7FFF); targethead.pos.z += 50.0f * Math_CosS(sp4A - 0x7FFF); if (Camera_BGCheck(camera, &playerhead.pos, &targethead.pos)) { @@ -6203,7 +6192,7 @@ s32 Camera_Demo5(Camera* camera) { } Player_GetHeight(camera->player); D_8011D9F4[0].timerInit = camera->timer; - Actor_GetFocus(&targethead, camera->target); + targethead = Actor_GetFocus(camera->target); if (Camera_BGCheck(camera, &playerhead.pos, &targethead.pos)) { D_8011D9F4[1].timerInit = 4; D_8011D9F4[1].actionFlags = ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true); @@ -6298,7 +6287,7 @@ s32 Camera_Demo6(Camera* camera) { // initializes the camera state. rwData->animTimer = 0; camera->fov = 60.0f; - Actor_GetWorld(&focusPosRot, camFocus); + focusPosRot = Actor_GetWorld(camFocus); camera->at.x = focusPosRot.pos.x; camera->at.y = focusPosRot.pos.y + 20.0f; camera->at.z = focusPosRot.pos.z; @@ -6307,14 +6296,14 @@ s32 Camera_Demo6(Camera* camera) { eyeOffset.yaw = Camera_XZAngle(&focusPosRot.pos, &mainCam->playerPosRot.pos) + 0x7D0; // -0x3E8 ~5.49 degrees eyeOffset.pitch = -0x3E8; - Camera_AddVecGeoToVec3f(eyeNext, &camera->at, &eyeOffset); + *eyeNext = Camera_AddVecGeoToVec3f(&camera->at, &eyeOffset); camera->eye = *eyeNext; camera->animState++; FALLTHROUGH; case 1: if (stateTimers[camera->animState] < rwData->animTimer) { Player_SetCsActionWithHaltedActors(camera->play, &camera->player->actor, PLAYER_CSACTION_8); - Actor_GetWorld(&focusPosRot, camFocus); + focusPosRot = Actor_GetWorld(camFocus); rwData->atTarget.x = focusPosRot.pos.x; rwData->atTarget.y = focusPosRot.pos.y - 20.0f; rwData->atTarget.z = focusPosRot.pos.z; @@ -6341,7 +6330,7 @@ s32 Camera_Demo6(Camera* camera) { } rwData->animTimer++; - Actor_GetWorld(&focusPosRot, camFocus); + focusPosRot = Actor_GetWorld(camFocus); return true; } @@ -6437,13 +6426,13 @@ s32 Camera_Demo9(Camera* camera) { Camera_RotateAroundPoint(mainCamPlayerPosRot, &csAtUpdate, &newAt); } else if (onePointCamData->actionParameters == 4) { // rotate around the current camera's player - Actor_GetWorld(&focusPosRot, &camera->player->actor); + focusPosRot = Actor_GetWorld(&camera->player->actor); Camera_RotateAroundPoint(&focusPosRot, &csEyeUpdate, &newEye); Camera_RotateAroundPoint(&focusPosRot, &csAtUpdate, &newAt); } else if (onePointCamData->actionParameters == 8) { // rotate around the current camera's target if (camera->target != NULL && camera->target->update != NULL) { - Actor_GetWorld(&focusPosRot, camera->target); + focusPosRot = Actor_GetWorld(camera->target); Camera_RotateAroundPoint(&focusPosRot, &csEyeUpdate, &newEye); Camera_RotateAroundPoint(&focusPosRot, &csAtUpdate, &newAt); } else { @@ -6536,7 +6525,7 @@ s32 Camera_Special0(Camera* camera) { return true; } - Actor_GetFocus(&camera->targetPosRot, camera->target); + camera->targetPosRot = Actor_GetFocus(camera->target); Camera_LERPCeilVec3f(&camera->targetPosRot.pos, &camera->at, roData->lerpAtScale, roData->lerpAtScale, 0.1f); camera->playerToAtOffset.x = camera->at.x - playerPosRot->pos.x; @@ -6582,7 +6571,7 @@ s32 Camera_Special4(Camera* camera) { return false; } else { camera->roll = -0x1F4; - Actor_GetWorld(&curTargetPosRot, camera->target); + curTargetPosRot = Actor_GetWorld(camera->target); camera->at = curTargetPosRot.pos; camera->at.y -= 150.0f; @@ -6640,9 +6629,9 @@ s32 Camera_Special5(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&sp64, at, eye); - OLib_Vec3fDiffToVecGeo(&sp5C, at, eyeNext); - Actor_GetWorld(&spA8, camera->target); + sp64 = OLib_Vec3fDiffToVecGeo(at, eye); + sp5C = OLib_Vec3fDiffToVecGeo(at, eyeNext); + spA8 = Actor_GetWorld(camera->target); sCameraInterfaceField = roData->interfaceField; @@ -6664,9 +6653,9 @@ s32 Camera_Special5(Camera* camera) { sp6C.yaw = playerPosRot->rot.y; sp6C.pitch = -playerPosRot->rot.x; sp6C.r = 20.0f; - Camera_AddVecGeoToVec3f(&sp7C.pos, &spA8.pos, &sp6C); + sp7C.pos = Camera_AddVecGeoToVec3f(&spA8.pos, &sp6C); Camera_BGCheckInfo(camera, at, &sp7C); - OLib_Vec3fToVecGeo(&sp6C, &sp7C.norm); + sp6C = OLib_Vec3fToVecGeo(&sp7C.norm); spA4 = playerPosRot->rot.y - sp6C.yaw; sp74.r = roData->eyeDist; temp_f0_2 = Rand_ZeroOne(); @@ -6674,7 +6663,7 @@ s32 Camera_Special5(Camera* camera) { (s16)(playerPosRot->rot.y - 0x7FFF) + (s16)(spA4 < 0 ? -(s16)(0x1553 + (s16)(temp_f0_2 * 2730.0f)) : (s16)(0x1553 + (s16)(temp_f0_2 * 2730.0f))); sp74.pitch = roData->pitch; - Camera_AddVecGeoToVec3f(eyeNext, &spA8.pos, &sp74); + *eyeNext = Camera_AddVecGeoToVec3f(&spA8.pos, &sp74); *eye = *eyeNext; Camera_BGCheck(camera, &spA8.pos, eye); } @@ -6793,10 +6782,10 @@ s32 Camera_Special6(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - OLib_Vec3fDiffToVecGeo(&eyeAtOffset, eye, at); + eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(&bgCamPos, &bgCamFuncData->pos); + bgCamPos = Camera_Vec3sToVec3f(&bgCamFuncData->pos); bgCamRot = bgCamFuncData->rot; fov = bgCamFuncData->fov; if (fov == -1) { @@ -6838,7 +6827,7 @@ s32 Camera_Special6(Camera* camera) { atOffset.r = 100.0f; atOffset.yaw = bgCamRot.y; atOffset.pitch = -bgCamRot.x; - Camera_AddVecGeoToVec3f(&atAnim, &eyeAnim, &atOffset); + atAnim = Camera_AddVecGeoToVec3f(&eyeAnim, &atOffset); timerDivisor = 1.0f / timerF; eye->x += (eyeAnim.x - eye->x) * timerDivisor; eye->y += (eyeAnim.y - eye->y) * timerDivisor; @@ -6864,7 +6853,7 @@ s32 Camera_Special6(Camera* camera) { atOffset.r = 100.0f; atOffset.yaw = bgCamRot.y; atOffset.pitch = -bgCamRot.x; - Camera_AddVecGeoToVec3f(at, eye, &atOffset); + *at = Camera_AddVecGeoToVec3f(eye, &atOffset); } return true; } @@ -6910,14 +6899,14 @@ s32 Camera_Special9(Camera* camera) { } if (doorParams->doorActor != NULL) { - Actor_GetWorldPosShapeRot(&referencePosRot, doorParams->doorActor); + referencePosRot = Actor_GetWorldPosShapeRot(doorParams->doorActor); } else { referencePosRot = *playerPosRot; referencePosRot.pos.y += playerYOffset + roData->yOffset; referencePosRot.rot.x = 0; } - OLib_Vec3fDiffToVecGeo(&atEyeOffsetGeo, at, eye); + atEyeOffsetGeo = OLib_Vec3fDiffToVecGeo(at, eye); sCameraInterfaceField = roData->interfaceField; @@ -6943,7 +6932,7 @@ s32 Camera_Special9(Camera* camera) { camera->animState++; if (roData->interfaceField & SPECIAL9_FLAG_0) { bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); - Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos); + *eyeNext = Camera_Vec3sToVec3f(&bgCamFuncData->pos); spAC = *eye = *eyeNext; } else { s16 yaw; @@ -6954,12 +6943,12 @@ s32 Camera_Special9(Camera* camera) { yaw = 0xAAA * ((camera->play->state.frames & 1) ? 1 : -1); eyeAdjustment.yaw = rwData->targetYaw + yaw; eyeAdjustment.r = 200.0f * yNormal; - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeAdjustment); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeAdjustment); spAC = *eye = *eyeNext; if (Camera_CheckOOB(camera, &spAC, &playerPosRot->pos)) { yaw = -yaw; eyeAdjustment.yaw = rwData->targetYaw + yaw; - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeAdjustment); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeAdjustment); *eye = *eyeNext; } } @@ -6987,7 +6976,7 @@ s32 Camera_Special9(Camera* camera) { eyeAdjustment.pitch = Camera_LERPCeilS(0xAAA, atEyeOffsetGeo.pitch, 0.3f, 0xA); eyeAdjustment.yaw = Camera_LERPCeilS(rwData->targetYaw, atEyeOffsetGeo.yaw, 0.3f, 0xA); eyeAdjustment.r = Camera_LERPCeilF(60.0f, atEyeOffsetGeo.r, 0.3f, 1.0f); - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeAdjustment); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeAdjustment); *eye = *eyeNext; doorParams->timer3--; if (doorParams->timer3 <= 0) { @@ -7170,7 +7159,7 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { Vec3f* at = &camera->at; Vec3f* eyeNext = &camera->eyeNext; - Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); + playerPosRot = Actor_GetWorldPosShapeRot(&player->actor); playerToAtOffsetY = Player_GetHeight(player); camera->player = player; camera->playerPosRot = playerPosRot; @@ -7189,7 +7178,7 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { camera->playerToAtOffset.y = playerToAtOffsetY; camera->playerToAtOffset.z = 0; - Camera_AddVecGeoToVec3f(eyeNext, at, &eyeNextAtOffset); + *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeNextAtOffset); *eye = *eyeNext; camera->roll = 0; @@ -7617,7 +7606,7 @@ Vec3s Camera_Update(Camera* camera) { sUpdateCameraDirection = false; if (camera->player != NULL) { - Actor_GetWorldPosShapeRot(&curPlayerPosRot, &camera->player->actor); + curPlayerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); camera->xzSpeed = playerXZSpeed = OLib_Vec3fDistXZ(&curPlayerPosRot.pos, &camera->playerPosRot.pos); camera->speedRatio = @@ -7701,7 +7690,7 @@ Vec3s Camera_Update(Camera* camera) { if (sOOBTimer < 200) { sCameraFunctions[sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx](camera); } else if (camera->player != NULL) { - OLib_Vec3fDiffToVecGeo(&eyeAtAngle, &camera->at, &camera->eye); + eyeAtAngle = OLib_Vec3fDiffToVecGeo(&camera->at, &camera->eye); Camera_CalcAtDefault(camera, &eyeAtAngle, 0.0f, false); } @@ -7775,15 +7764,15 @@ Vec3s Camera_Update(Camera* camera) { viewEye.y = camera->eye.y + camShake.eyeOffset.y; viewEye.z = camera->eye.z + camShake.eyeOffset.z; - OLib_Vec3fDiffToVecGeo(&eyeAtAngle, &viewEye, &viewAt); - Camera_CalcUpFromPitchYawRoll(&viewUp, eyeAtAngle.pitch + camShake.upPitchOffset, - eyeAtAngle.yaw + camShake.upYawOffset, camera->roll); + eyeAtAngle = OLib_Vec3fDiffToVecGeo(&viewEye, &viewAt); + viewUp = Camera_CalcUpFromPitchYawRoll(eyeAtAngle.pitch + camShake.upPitchOffset, + eyeAtAngle.yaw + camShake.upYawOffset, camera->roll); viewFov = camera->fov + CAM_BINANG_TO_DEG(camShake.fovOffset); } else { viewAt = camera->at; viewEye = camera->eye; - OLib_Vec3fDiffToVecGeo(&eyeAtAngle, &viewEye, &viewAt); - Camera_CalcUpFromPitchYawRoll(&viewUp, eyeAtAngle.pitch, eyeAtAngle.yaw, camera->roll); + eyeAtAngle = OLib_Vec3fDiffToVecGeo(&viewEye, &viewAt); + viewUp = Camera_CalcUpFromPitchYawRoll(eyeAtAngle.pitch, eyeAtAngle.yaw, camera->roll); viewFov = camera->fov; } @@ -8175,51 +8164,43 @@ s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex) { //! @note: no return here, but return is unused } -Vec3s* Camera_GetInputDir(Vec3s* dst, Camera* camera) { +Vec3s Camera_GetInputDir(Camera* camera) { if (gDebugCamEnabled) { - *dst = D_8015BD80.sub.unk_104A; - return dst; + return D_8015BD80.sub.unk_104A; } else { - *dst = camera->inputDir; - return dst; + return camera->inputDir; } } s16 Camera_GetInputDirPitch(Camera* camera) { - Vec3s dir; + Vec3s dir = Camera_GetInputDir(camera); - Camera_GetInputDir(&dir, camera); return dir.x; } s16 Camera_GetInputDirYaw(Camera* camera) { - Vec3s dir; + Vec3s dir = Camera_GetInputDir(camera); - Camera_GetInputDir(&dir, camera); return dir.y; } -Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera) { +Vec3s Camera_GetCamDir(Camera* camera) { if (gDebugCamEnabled) { - *dst = D_8015BD80.sub.unk_104A; - return dst; + return D_8015BD80.sub.unk_104A; } else { - *dst = camera->camDir; - return dst; + return camera->camDir; } } s16 Camera_GetCamDirPitch(Camera* camera) { - Vec3s camDir; + Vec3s camDir = Camera_GetCamDir(camera); - Camera_GetCamDir(&camDir, camera); return camDir.x; } s16 Camera_GetCamDirYaw(Camera* camera) { - Vec3s camDir; + Vec3s camDir = Camera_GetCamDir(camera); - Camera_GetCamDir(&camDir, camera); return camDir.y; } @@ -8309,7 +8290,7 @@ s32 Camera_SetCSParams(Camera* camera, CutsceneCameraPoint* atPoints, CutsceneCa if (camera->data2 != 0) { camera->player = player; - Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); + playerPosRot = Actor_GetWorldPosShapeRot(&player->actor); camera->playerPosRot = playerPosRot; camera->nextBgCamIndex = -1; @@ -8391,7 +8372,7 @@ s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera) { func_80043B60(dstCamera); if (dstCamera->player != NULL) { - Actor_GetWorld(&dstCamera->playerPosRot, &dstCamera->player->actor); + dstCamera->playerPosRot = Actor_GetWorld(&dstCamera->player->actor); dstCamera->playerToAtOffset.x = dstCamera->at.x - dstCamera->playerPosRot.pos.x; dstCamera->playerToAtOffset.y = dstCamera->at.y - dstCamera->playerPosRot.pos.y; dstCamera->playerToAtOffset.z = dstCamera->at.z - dstCamera->playerPosRot.pos.z; @@ -8406,9 +8387,8 @@ s32 Camera_IsDebugCamEnabled(void) { return gDebugCamEnabled; } -Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera) { - *quakeOffset = camera->quakeOffset; - return quakeOffset; +Vec3f Camera_GetQuakeOffset(Camera* camera) { + return camera->quakeOffset; } void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, diff --git a/src/code/z_olib.c b/src/code/z_olib.c index e89a0b348d..d5056e8f70 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -50,7 +50,7 @@ f32 OLib_ClampMaxDist(f32 val, f32 max) { /** * Takes the difference of points b and a, and creates a normal vector */ -Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b) { +Vec3f OLib_Vec3fDistNormalize(Vec3f* a, Vec3f* b) { Vec3f v1; Vec3f v2; f32 dist; @@ -65,15 +65,13 @@ Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b) { v2.y = v1.y / dist; v2.z = v1.z / dist; - *dest = v2; - - return dest; + return v2; } /** * Takes the spherical coordinate `sph`, and converts it into a x,y,z position */ -Vec3f* OLib_VecSphToVec3f(Vec3f* dest, VecSph* sph) { +Vec3f OLib_VecSphToVec3f(VecSph* sph) { Vec3f v; f32 sinPitch; f32 cosPitch = Math_CosS(sph->pitch); @@ -87,28 +85,26 @@ Vec3f* OLib_VecSphToVec3f(Vec3f* dest, VecSph* sph) { v.y = sph->r * cosPitch; v.z = sph->r * sinPitch * cosYaw; - *dest = v; - - return dest; + return v; } /** * Takes the geographic point `geo` and converts it into a x,y,z position */ -Vec3f* OLib_VecGeoToVec3f(Vec3f* dest, VecGeo* geo) { +Vec3f OLib_VecGeoToVec3f(VecGeo* geo) { VecSph sph; sph.r = geo->r; sph.pitch = 0x3FFF - geo->pitch; sph.yaw = geo->yaw; - return OLib_VecSphToVec3f(dest, &sph); + return OLib_VecSphToVec3f(&sph); } /** * Takes the point `vec`, and converts it into a spherical coordinate */ -VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { +VecSph OLib_Vec3fToVecSph(Vec3f* vec) { VecSph sph; f32 distXZSq = SQ(vec->x) + SQ(vec->z); f32 distXZ = sqrtf(distXZSq); @@ -126,98 +122,88 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { sph.yaw = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(vec->x, vec->z))); } - *dest = sph; - - return dest; + return sph; } /** * Takes the point `vec`, and converts it to a geographic coordinate */ -VecGeo* OLib_Vec3fToVecGeo(VecGeo* dest, Vec3f* vec) { +VecGeo OLib_Vec3fToVecGeo(Vec3f* vec) { VecSph sph; - OLib_Vec3fToVecSph(&sph, vec); + sph = OLib_Vec3fToVecSph(vec); sph.pitch = 0x3FFF - sph.pitch; - *dest = sph; - - return dest; + return sph; } /** * Takes the differences of positions `a` and `b`, and converts them to spherical coordinates */ -VecSph* OLib_Vec3fDiffToVecSph(VecSph* dest, Vec3f* a, Vec3f* b) { +VecSph OLib_Vec3fDiffToVecSph(Vec3f* a, Vec3f* b) { Vec3f diff; diff.x = b->x - a->x; diff.y = b->y - a->y; diff.z = b->z - a->z; - return OLib_Vec3fToVecSph(dest, &diff); + return OLib_Vec3fToVecSph(&diff); } /** * Takes the difference of positions `a` and `b`, and converts them to geographic coordinates */ -VecGeo* OLib_Vec3fDiffToVecGeo(VecGeo* dest, Vec3f* a, Vec3f* b) { +VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b) { Vec3f diff; diff.x = b->x - a->x; diff.y = b->y - a->y; diff.z = b->z - a->z; - return OLib_Vec3fToVecGeo(dest, &diff); + return OLib_Vec3fToVecGeo(&diff); } /** * Gets the pitch/yaw of the vector formed from `b`-`a`, result is in radians */ -Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b) { +Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b) { Vec3f anglesRad; anglesRad.x = Math_FAtan2F(b->z - a->z, b->y - a->y); anglesRad.y = Math_FAtan2F(b->x - a->x, b->z - a->z); anglesRad.z = 0; - *dest = anglesRad; - - return dest; + return anglesRad; } /** * Gets the pitch/yaw of the vector formed from `b`-`a`, result is in degrees */ -Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b) { +Vec3f OLib_Vec3fDiffDegF(Vec3f* a, Vec3f* b) { Vec3f anglesRad; Vec3f anglesDegrees; - OLib_Vec3fDiffRad(&anglesRad, a, b); + anglesRad = OLib_Vec3fDiffRad(a, b); anglesDegrees.x = RAD_TO_DEG(anglesRad.x); anglesDegrees.y = RAD_TO_DEG(anglesRad.y); anglesDegrees.z = 0.0f; - *dest = anglesDegrees; - - return dest; + return anglesDegrees; } /** * Gets the pitch/yaw of the vector formed from `b`-`a`, result is in binary degrees */ -Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) { +Vec3s OLib_Vec3fDiffBinAng(Vec3f* a, Vec3f* b) { Vec3f anglesRad; Vec3s anglesBinAng; - OLib_Vec3fDiffRad(&anglesRad, a, b); + anglesRad = OLib_Vec3fDiffRad(a, b); anglesBinAng.x = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.x)); anglesBinAng.y = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.y)); anglesBinAng.z = 0.0f; - *dest = anglesBinAng; - - return dest; + return anglesBinAng; } diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 3a6586ecc8..1ba0c01ff5 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -9,19 +9,15 @@ static s32 sPrevFrameCs1100 = -4096; #include "z_onepointdemo_data.inc.c" -Vec3f* OnePointCutscene_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) { +Vec3f OnePointCutscene_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo) { Vec3f sum; - Vec3f b; - - OLib_VecGeoToVec3f(&b, geo); + Vec3f b = OLib_VecGeoToVec3f(geo); sum.x = a->x + b.x; sum.y = a->y + b.y; sum.z = a->z + b.z; - *dest = sum; - - return dest; + return sum; } s16 OnePointCutscene_Vec3fYaw(Vec3f* vec1, Vec3f* vec2) { @@ -98,7 +94,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_80120964[0].atTargetInit = play->view.at; D_80120964[0].eyeTargetInit = play->view.eye; D_80120964[0].fovTargetInit = play->view.fovy; - OLib_Vec3fDiffToVecGeo(&spD0, &mainCam->at, &mainCam->eye); + spD0 = OLib_Vec3fDiffToVecGeo(&mainCam->at, &mainCam->eye); D_80120964[1].eyeTargetInit.y = CAM_BINANG_TO_DEG(spD0.yaw); D_80120964[1].timerInit = timer - 1; @@ -112,9 +108,9 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_801209B4[0].atTargetInit = D_801209B4[1].atTargetInit = play->view.at; D_801209B4[0].eyeTargetInit = play->view.eye; D_801209B4[0].fovTargetInit = D_801209B4[2].fovTargetInit = play->view.fovy; - OLib_Vec3fDiffToVecGeo(&spD0, &actor->focus.pos, &mainCam->at); + spD0 = OLib_Vec3fDiffToVecGeo(&actor->focus.pos, &mainCam->at); spD0.r = mainCam->dist; - OnePointCutscene_AddVecGeoToVec3f(&D_801209B4[1].eyeTargetInit, &D_801209B4[1].atTargetInit, &spD0); + D_801209B4[1].eyeTargetInit = OnePointCutscene_AddVecGeoToVec3f(&D_801209B4[1].atTargetInit, &spD0); D_801209B4[1].atTargetInit.y += 20.0f; csInfo->keyFrames = D_801209B4; @@ -310,14 +306,14 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 4500: - Actor_GetFocus(&spA0, actor); + spA0 = Actor_GetFocus(actor); spC0 = spA0.pos; spC0.y = OnePointCutscene_RaycastDown(&play->colCtx, &spC0) + 40.0f; spD0.r = 150.0f; spD0.yaw = spA0.rot.y; spD0.pitch = 0x3E8; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); @@ -329,7 +325,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 2210: - OLib_Vec3fDiffToVecGeo(&spD0, &player->actor.world.pos, &actor->world.pos); + spD0 = OLib_Vec3fDiffToVecGeo(&player->actor.world.pos, &actor->world.pos); D_801213B4[0].eyeTargetInit.y = D_801213B4[1].eyeTargetInit.y = D_801213B4[2].eyeTargetInit.y = D_801213B4[2].atTargetInit.y = CAM_BINANG_TO_DEG(spD0.yaw); if (Rand_ZeroOne() < 0.0f) { @@ -454,7 +450,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act case 3100: VEC_SET(spB4, 0.0f, -280.0f, -1400.0f); - Actor_GetFocus(&spA0, actor); + spA0 = Actor_GetFocus(actor); spC0 = spA0.pos; Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_PIVOT_VERTICAL); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); @@ -556,14 +552,14 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3170: - Actor_GetWorld(&spA0, actor); + spA0 = Actor_GetWorld(actor); spC0 = spA0.pos; spD0.pitch = -0x5DC; spC0.y += 50.0f; spD0.r = 250.0f; - Actor_GetWorld(&spA0, &player->actor); + spA0 = Actor_GetWorld(&player->actor); spD0.yaw = OnePointCutscene_Vec3fYaw(&spC0, &spA0.pos) - 0x7D0; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); Play_CopyCamera(play, CAM_ID_MAIN, subCamId); @@ -573,12 +569,12 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3160: - Actor_GetWorld(&spA0, actor); + spA0 = Actor_GetWorld(actor); spC0 = spA0.pos; spD0.pitch = 0; spD0.yaw = spA0.rot.y; spD0.r = 150.0f; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; @@ -587,13 +583,13 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3180: - Actor_GetWorldPosShapeRot(&spA0, actor); + spA0 = Actor_GetWorldPosShapeRot(actor); spC0 = spA0.pos; spC0.y += 120.0f; spD0.r = 300.0f; spD0.yaw = spA0.rot.y; spD0.pitch = -0xAF0; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; @@ -619,15 +615,15 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act subCam->roll = 0x1E; subCam->fov = 75.0f; Player_SetCsAction(play, &player->actor, PLAYER_CSACTION_8); - Actor_GetWorldPosShapeRot(&spA0, actor); - Actor_GetFocus(&sp8C, &player->actor); + spA0 = Actor_GetWorldPosShapeRot(actor); + sp8C = Actor_GetFocus(&player->actor); spC0.x = sp8C.pos.x; spC0.y = sp8C.pos.y + 70.0f; spC0.z = sp8C.pos.z; - OLib_Vec3fDiffToVecGeo(&spD0, &spA0.pos, &sp8C.pos); + spD0 = OLib_Vec3fDiffToVecGeo(&spA0.pos, &sp8C.pos); spD0.pitch = 0x5DC; spD0.r = 120.0f; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); Play_SetCameraAtEye(play, CAM_ID_MAIN, &spC0, &spB4); i = Quake_Request(subCam, QUAKE_TYPE_3); @@ -637,13 +633,13 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 6010: - Actor_GetWorld(&spA0, actor); + spA0 = Actor_GetWorld(actor); spC0 = spA0.pos; spD0.pitch = 0; spC0.y += 70.0f; spD0.yaw = spA0.rot.y + 0x7FFF; spD0.r = 300.0f; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; @@ -652,14 +648,14 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3220: - Actor_GetFocus(&spA0, actor); + spA0 = Actor_GetFocus(actor); spC0 = spA0.pos; Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_PIVOT_VERTICAL); - Actor_GetWorld(&spA0, &player->actor); - OLib_Vec3fDiffToVecGeo(&spD0, &spC0, &spA0.pos); + spA0 = Actor_GetWorld(&player->actor); + spD0 = OLib_Vec3fDiffToVecGeo(&spC0, &spA0.pos); spD0.yaw += 0x3E8; spD0.r = 400.0f; - OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); + spB4 = OnePointCutscene_AddVecGeoToVec3f(&spC0, &spD0); spB4.y = spA0.pos.y + 60.0f; Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; @@ -681,7 +677,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act case 6001: Play_RequestCameraSetting(play, subCamId, CAM_SET_CS_3); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); - Actor_GetWorld(&spA0, actor); + spA0 = Actor_GetWorld(actor); if (spA0.pos.z > -750.0f) { OnePointCutscene_SetCsCamPoints(subCam, D_801208E8, D_801208E4, D_801206A0, D_80120820); } else { @@ -732,7 +728,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_80121F1C[0].atTargetInit = play->view.at; D_80121F1C[0].eyeTargetInit = play->view.eye; D_80121F1C[0].fovTargetInit = play->view.fovy; - Actor_GetFocus(&spA0, actor); + spA0 = Actor_GetFocus(actor); player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = spA0.rot.y; csInfo->keyFrames = D_80121F1C; @@ -1002,8 +998,8 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 8700: - Actor_GetFocus(&spA0, actor); - Actor_GetFocus(&sp8C, &player->actor); + spA0 = Actor_GetFocus(actor); + sp8C = Actor_GetFocus(&player->actor); D_80122E44[timer & 1][0].atTargetInit.y = ((spA0.pos.y - sp8C.pos.y) / 10.0f) + 90.0f; D_80122E44[timer & 1][5].atTargetInit = mainCam->at; @@ -1052,13 +1048,13 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act if (player->stateFlags1 & PLAYER_STATE1_27) { D_801231B4[2].atTargetInit.z = 0.0f; } - Actor_GetWorldPosShapeRot(&spA0, &player->actor); - OLib_Vec3fDiffToVecGeo(&spD0, &spA0.pos, &mainCam->at); + spA0 = Actor_GetWorldPosShapeRot(&player->actor); + spD0 = OLib_Vec3fDiffToVecGeo(&spA0.pos, &mainCam->at); spD0.yaw -= spA0.rot.y; - OLib_VecGeoToVec3f(&D_801231B4[3].atTargetInit, &spD0); - OLib_Vec3fDiffToVecGeo(&spD0, &spA0.pos, &mainCam->eye); + D_801231B4[3].atTargetInit = OLib_VecGeoToVec3f(&spD0); + spD0 = OLib_Vec3fDiffToVecGeo(&spA0.pos, &mainCam->eye); spD0.yaw -= spA0.rot.y; - OLib_VecGeoToVec3f(&D_801231B4[3].eyeTargetInit, &spD0); + D_801231B4[3].eyeTargetInit = OLib_VecGeoToVec3f(&spD0); D_801231B4[3].fovTargetInit = mainCam->fov; D_801231B4[3].timerInit = timer - 50; diff --git a/src/code/z_play.c b/src/code/z_play.c index 101be010db..a90f0ab6e2 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1200,7 +1200,7 @@ void Play_Draw(PlayState* this) { (GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) { Vec3f quakeOffset; - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this)); + quakeOffset = Camera_GetQuakeOffset(GET_ACTIVE_CAM(this)); Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x, this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z); } diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 4ac8f06e98..38b97c4d71 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -22,18 +22,15 @@ QuakeRequest sQuakeRequests[4]; s16 sQuakeUnused = 1; s16 sQuakeRequestCount = 0; -Vec3f* Quake_AddVecGeoToVec3f(Vec3f* dst, Vec3f* a, VecGeo* geo) { - Vec3f vec; - Vec3f b; +Vec3f Quake_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo) { + Vec3f sum; + Vec3f b = OLib_VecGeoToVec3f(geo); - OLib_VecGeoToVec3f(&b, geo); - vec.x = a->x + b.x; - vec.y = a->y + b.y; - vec.z = a->z + b.z; + sum.x = a->x + b.x; + sum.y = a->y + b.y; + sum.z = a->z + b.z; - *dst = vec; - - return dst; + return sum; } void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { @@ -47,7 +44,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { offset.x = 0; offset.y = 0; offset.z = 0; - OLib_Vec3fDiffToVecGeo(&eyeToAtGeo, eye, at); + eyeToAtGeo = OLib_Vec3fDiffToVecGeo(eye, at); // y shake geo.r = req->y * y; @@ -55,7 +52,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { geo.pitch = eyeToAtGeo.pitch + req->orientation.x + 0x4000; geo.yaw = eyeToAtGeo.yaw + req->orientation.y; // apply y shake - Quake_AddVecGeoToVec3f(&offset, &offset, &geo); + offset = Quake_AddVecGeoToVec3f(&offset, &geo); // x shake geo.r = req->x * x; @@ -63,7 +60,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { geo.pitch = eyeToAtGeo.pitch + req->orientation.x; geo.yaw = eyeToAtGeo.yaw + req->orientation.y + 0x4000; // apply x shake - Quake_AddVecGeoToVec3f(&offset, &offset, &geo); + offset = Quake_AddVecGeoToVec3f(&offset, &geo); } else { offset.x = 0; offset.y = req->y * y; @@ -71,7 +68,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { geo.r = req->x * x; geo.pitch = req->orientation.x; geo.yaw = req->orientation.y; - Quake_AddVecGeoToVec3f(&offset, &offset, &geo); + offset = Quake_AddVecGeoToVec3f(&offset, &geo); } shake->atOffset = shake->eyeOffset = offset; diff --git a/src/code/z_room.c b/src/code/z_room.c index 25850aa196..e0a79f1e93 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -389,7 +389,7 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { Vec3f quakeOffset; gfx = POLY_OPA_DISP; - Camera_GetQuakeOffset(&quakeOffset, activeCam); + quakeOffset = Camera_GetQuakeOffset(activeCam); Room_DrawBackground2D(&gfx, roomShape->source, roomShape->tlut, roomShape->width, roomShape->height, roomShape->fmt, roomShape->siz, roomShape->tlutMode, roomShape->tlutCount, (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, @@ -487,7 +487,7 @@ void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) { Vec3f quakeOffset; gfx = POLY_OPA_DISP; - Camera_GetQuakeOffset(&quakeOffset, activeCam); + quakeOffset = Camera_GetQuakeOffset(activeCam); Room_DrawBackground2D(&gfx, bgEntry->source, bgEntry->tlut, bgEntry->width, bgEntry->height, bgEntry->fmt, bgEntry->siz, bgEntry->tlutMode, bgEntry->tlutCount, (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 9baad8188e..79cc56ac50 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -734,19 +734,15 @@ void DemoKankyo_Vec3fCopy(Vec3f* src, Vec3f* dst) { dst->z = src->z; } -Vec3f* DemoKankyo_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) { +Vec3f DemoKankyo_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo) { Vec3f sum; - Vec3f b; - - OLib_VecGeoToVec3f(&b, geo); + Vec3f b = OLib_VecGeoToVec3f(geo); sum.x = a->x + b.x; sum.y = a->y + b.y; sum.z = a->z + b.z; - *dest = sum; - - return dest; + return sum; } void DemoKankyo_Vec3fAddPosRot(PosRot* posRot, Vec3f* vec, Vec3f* dst) { @@ -754,9 +750,9 @@ void DemoKankyo_Vec3fAddPosRot(PosRot* posRot, Vec3f* vec, Vec3f* dst) { Vec3f vecCopy; DemoKankyo_Vec3fCopy(vec, &vecCopy); - OLib_Vec3fToVecGeo(&geo, &vecCopy); + geo = OLib_Vec3fToVecGeo(&vecCopy); geo.yaw += posRot->rot.y; - DemoKankyo_AddVecGeoToVec3f(dst, &posRot->pos, &geo); + *dst = DemoKankyo_AddVecGeoToVec3f(&posRot->pos, &geo); } void DemoKankyo_DrawWarpSparkles(Actor* thisx, PlayState* play) { @@ -817,7 +813,7 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, PlayState* play) { this->unk_150[i].unk_22++; } } - Actor_GetWorld(&posRot, &player->actor); + posRot = Actor_GetWorld(&player->actor); DemoKankyo_Vec3fAddPosRot(&posRot, &camPos, &D_8098CF98); break; case 2: @@ -941,7 +937,7 @@ void DemoKankyo_DrawSparkles(Actor* thisx, PlayState* play) { &this->unk_150[i].unk_20, &this->unk_150[i].unk_1C) != 0) { this->unk_150[i].unk_22++; } - Actor_GetWorld(&posRot, &this->actor); + posRot = Actor_GetWorld(&this->actor); DemoKankyo_Vec3fAddPosRot(&posRot, &camPos, &D_8098CFB8); break; case 2: diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index 09d8474499..32087b23d3 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -121,7 +121,7 @@ void EnButte_DrawTransformationEffect(EnButte* this, PlayState* play) { alpha = Math_SinS(sTransformationEffectAlpha) * 250; alpha = CLAMP(alpha, 0, 255); - Camera_GetCamDir(&camDir, GET_ACTIVE_CAM(play)); + camDir = Camera_GetCamDir(GET_ACTIVE_CAM(play)); Matrix_RotateY(BINANG_TO_RAD(camDir.y), MTXMODE_NEW); Matrix_RotateX(BINANG_TO_RAD(camDir.x), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD(camDir.z), MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index ca3b77352d..94f7a78c15 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -75,7 +75,7 @@ void OceffWipe_Draw(Actor* thisx, PlayState* play) { Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + quakeOffset = Camera_GetQuakeOffset(GET_ACTIVE_CAM(play)); OPEN_DISPS(play->state.gfxCtx, "../z_oceff_wipe.c", 346); diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index a575a6676b..708549e168 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -69,7 +69,7 @@ void OceffWipe2_Draw(Actor* thisx, PlayState* play) { Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + quakeOffset = Camera_GetQuakeOffset(GET_ACTIVE_CAM(play)); if (this->timer < 32) { z = Math_SinS(this->timer << 9) * 1330; } else { diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index 77c9e1d335..950bbdb6ff 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -70,7 +70,7 @@ void OceffWipe3_Draw(Actor* thisx, PlayState* play) { Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + quakeOffset = Camera_GetQuakeOffset(GET_ACTIVE_CAM(play)); if (this->counter < 32) { z = Math_SinS(this->counter << 9) * 1330; } else { diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index 19574b6149..e2d44343f0 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -68,7 +68,7 @@ void OceffWipe4_Draw(Actor* thisx, PlayState* play) { Vec3f quakeOffset; eye = GET_ACTIVE_CAM(play)->eye; - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + quakeOffset = Camera_GetQuakeOffset(GET_ACTIVE_CAM(play)); if (this->timer < 16) { z = Math_SinS(this->timer * 1024) * 1330.0f; } else {