1
0
mirror of https://github.com/blawar/ooot.git synced 2024-06-30 16:29:55 +00:00
* FIZZLE_CAM:
changes for camera on a second stick(xbox controller tested) with a timer for allowing the default behaviour to persist after not using the right stick

* updates to improve the FIZZLE cam control with added support for the swimming,ladder,jump,epona cameras

* removing FIZZLE_CAM define

* fix comments

* testing camera timers
This commit is contained in:
frizzle101101 2022-04-07 21:23:19 -04:00 committed by Blake Warner
parent 29a9879c8d
commit c2dbf9e3a8
2 changed files with 36 additions and 24 deletions

View File

@ -209,7 +209,7 @@ struct Normal1Anim {
/* 0x20 */ f32 unk_20; /* 0x20 */ f32 unk_20;
/* 0x24 */ s16 slopePitchAdj; /* 0x24 */ s16 slopePitchAdj;
/* 0x26 */ s16 swingYawTarget; /* 0x26 */ s16 swingYawTarget;
/* 0x28 */ s16 unk_28; /* 0x28 */ s16 distTimer;
/* 0x2A */ s16 startSwingTimer; /* 0x2A */ s16 startSwingTimer;
}; // size = 0x2C }; // size = 0x2C
@ -281,7 +281,7 @@ struct Parallel1Anim {
/* 0x12 */ s16 yawTarget; /* 0x12 */ s16 yawTarget;
/* 0x14 */ s16 pitchTarget; /* 0x14 */ s16 pitchTarget;
/* 0x16 */ s16 unk_16; /* 0x16 */ s16 unk_16;
/* 0x18 */ s16 animTimer; /* 0x18 */ Timer animTimer;
}; // size = 0x1A }; // size = 0x1A
struct Parallel1 { struct Parallel1 {
@ -324,7 +324,7 @@ struct Jump2Anim {
/* 0x6 */ s16 initYawDiff; // unused, set but not read. /* 0x6 */ s16 initYawDiff; // unused, set but not read.
/* 0x8 */ s16 yawAdj; /* 0x8 */ s16 yawAdj;
/* 0xA */ s16 onFloor; // unused, set but not read /* 0xA */ s16 onFloor; // unused, set but not read
/* 0xC */ s16 animTimer; /* 0xC */ Timer animTimer;
}; // size = 0x10 }; // size = 0x10
struct Jump2 { struct Jump2 {
@ -643,9 +643,9 @@ struct Unique3Params {
struct DoorParams { struct DoorParams {
/* 0x0 */ struct Actor* doorActor; /* 0x0 */ struct Actor* doorActor;
/* 0x4 */ s16 camDataIdx; /* 0x4 */ s16 camDataIdx;
/* 0x6 */ s16 timer1; /* 0x6 */ Timer timer1;
/* 0x8 */ s16 timer2; /* 0x8 */ Timer timer2;
/* 0xA */ s16 timer3; /* 0xA */ Timer timer3;
}; // size = 0xC }; // size = 0xC
struct Unique3 { struct Unique3 {
@ -915,13 +915,13 @@ struct Camera {
/* 0x15A */ s16 roll; /* 0x15A */ s16 roll;
/* 0x15C */ s16 paramFlags; /* 0x15C */ s16 paramFlags;
/* 0x15E */ s16 animState; /* 0x15E */ s16 animState;
/* 0x160 */ s16 timer; /* 0x160 */ Timer timer;
/* 0x162 */ s16 parentCamIdx; /* 0x162 */ s16 parentCamIdx;
/* 0x164 */ s16 thisIdx; /* 0x164 */ s16 thisIdx;
/* 0x166 */ s16 prevCamDataIdx; /* 0x166 */ s16 prevCamDataIdx;
/* 0x168 */ s16 csId; /* 0x168 */ s16 csId;
/* 0x16A */ s16 unk_16A; /* 0x16A */ s16 unk_16A;
/* 0x16C */ s16 startControlTimer; /* 0x16C */ Timer startControlTimer;
}; // size = 0x16C }; // size = 0x16C
/** /**

View File

@ -1559,7 +1559,7 @@ s32 Camera_Normal1(Camera* camera) {
case 0x19: case 0x19:
anim->swing.atEyePoly = NULL; anim->swing.atEyePoly = NULL;
anim->slopePitchAdj = 0; anim->slopePitchAdj = 0;
anim->unk_28 = 0xA; anim->distTimer = 0xA;
anim->swing.unk_16 = anim->swing.unk_14 = anim->swing.unk_18 = 0; anim->swing.unk_16 = anim->swing.unk_14 = anim->swing.unk_18 = 0;
anim->swing.swingUpdateRate = norm1->unk_0C; anim->swing.swingUpdateRate = norm1->unk_0C;
anim->yOffset = camera->playerPosRot.pos.y; anim->yOffset = camera->playerPosRot.pos.y;
@ -1582,8 +1582,8 @@ s32 Camera_Normal1(Camera* camera) {
camera->animState = 1; camera->animState = 1;
sUpdateCameraDirection = 1; sUpdateCameraDirection = 1;
if (anim->unk_28 != 0) { if (anim->distTimer != 0) {
anim->unk_28--; anim->distTimer--;
} }
if(oot::config().camera().useClassicCamera()) if(oot::config().camera().useClassicCamera())
@ -1674,7 +1674,7 @@ s32 Camera_Normal1(Camera* camera) {
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, at, eyeNext); OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, at, eyeNext);
camera->dist = eyeAdjustment.r = camera->dist = eyeAdjustment.r =
Camera_ClampDist(camera, eyeAdjustment.r, norm1->distMin, norm1->distMax, anim->unk_28); Camera_ClampDist(camera, eyeAdjustment.r, norm1->distMin, norm1->distMax, anim->distTimer);
if(oot::config().camera().useClassicCamera()) if(oot::config().camera().useClassicCamera())
{ {
@ -2123,14 +2123,17 @@ s32 Camera_Normal3(Camera* camera) {
return 1; return 1;
} }
//noop
s32 Camera_Normal4(Camera* camera) { s32 Camera_Normal4(Camera* camera) {
return Camera_Noop(camera); return Camera_Noop(camera);
} }
//noop
s32 Camera_Normal0(Camera* camera) { s32 Camera_Normal0(Camera* camera) {
return Camera_Noop(camera); return Camera_Noop(camera);
} }
//z toggle camera
s32 Camera_Parallel1(Camera* camera) { s32 Camera_Parallel1(Camera* camera) {
Vec3f* eye = &camera->eye; Vec3f* eye = &camera->eye;
Vec3f* at = &camera->at; Vec3f* at = &camera->at;
@ -2194,7 +2197,8 @@ s32 Camera_Parallel1(Camera* camera) {
camera->animState++; camera->animState++;
} }
if (anim->animTimer != 0) { if(anim->animTimer.toS16() != 0)
{
if (para1->interfaceFlags & 2) { if (para1->interfaceFlags & 2) {
// Rotate para1->yawTarget degrees from behind the player. // Rotate para1->yawTarget degrees from behind the player.
anim->yawTarget = BINANG_ROT180(playerPosRot->rot.y) + para1->yawTarget; anim->yawTarget = BINANG_ROT180(playerPosRot->rot.y) + para1->yawTarget;
@ -2255,9 +2259,10 @@ s32 Camera_Parallel1(Camera* camera) {
func_800458D4(camera, &atToEyeNextDir, para1->unk_18, &anim->yTarget, para1->interfaceFlags & 1); func_800458D4(camera, &atToEyeNextDir, para1->unk_18, &anim->yTarget, para1->interfaceFlags & 1);
} }
if (anim->animTimer != 0) { if(anim->animTimer.toS16() != 0)
{
camera->unk_14C |= 0x20; camera->unk_14C |= 0x20;
tangle = (((anim->animTimer + 1) * anim->animTimer) >> 1); tangle = (((anim->animTimer.whole() + 1) * anim->animTimer.whole()) >> 1);
spA8.yaw = atToEyeDir.yaw + ((BINANG_SUB(anim->yawTarget, atToEyeDir.yaw) / tangle) * anim->animTimer); spA8.yaw = atToEyeDir.yaw + ((BINANG_SUB(anim->yawTarget, atToEyeDir.yaw) / tangle) * anim->animTimer);
spA8.pitch = atToEyeDir.pitch; spA8.pitch = atToEyeDir.pitch;
spA8.r = atToEyeDir.r; spA8.r = atToEyeDir.r;
@ -2312,10 +2317,12 @@ s32 Camera_Parallel1(Camera* camera) {
return 0; return 0;
} }
//noop
s32 Camera_Parallel2(Camera* camera) { s32 Camera_Parallel2(Camera* camera) {
return Camera_Noop(camera); return Camera_Noop(camera);
} }
s32 Camera_Parallel3(Camera* camera) { s32 Camera_Parallel3(Camera* camera) {
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
s16 val = NEXTSETTING; s16 val = NEXTSETTING;
@ -2332,10 +2339,12 @@ s32 Camera_Parallel3(Camera* camera) {
return 0; return 0;
} }
//noop
s32 Camera_Parallel4(Camera* camera) { s32 Camera_Parallel4(Camera* camera) {
return Camera_Noop(camera); return Camera_Noop(camera);
} }
//noop
s32 Camera_Parallel0(Camera* camera) { s32 Camera_Parallel0(Camera* camera) {
return Camera_Noop(camera); return Camera_Noop(camera);
} }
@ -2641,7 +2650,7 @@ s32 Camera_Jump2(Camera* camera) {
} }
yawDiff = BINANG_SUB(BINANG_ROT180(playerPosRot->rot.y), adjAtToEyeDir.yaw); yawDiff = BINANG_SUB(BINANG_ROT180(playerPosRot->rot.y), adjAtToEyeDir.yaw);
if(anim->animTimer != 0) if(anim->animTimer.toS16() != 0)
{ {
anim->yawTarget = BINANG_ROT180(playerPosRot->rot.y); anim->yawTarget = BINANG_ROT180(playerPosRot->rot.y);
anim->animTimer--; anim->animTimer--;
@ -2815,7 +2824,7 @@ s32 Camera_Jump3(Camera* camera)
anim->swing.swingUpdateRateTimer = 0; anim->swing.swingUpdateRateTimer = 0;
break; break;
default: default:
if(anim->animTimer != 0) if(anim->animTimer >= 0.0f)
{ {
anim->animTimer--; anim->animTimer--;
} }
@ -3032,7 +3041,7 @@ s32 Camera_Battle1(Camera* camera) {
anim->unk_10 = Camera_LERPCeilF(PCT(OREG(12)) * 0.5f, anim->unk_10, PCT(OREG(25)), 0.1f); anim->unk_10 = Camera_LERPCeilF(PCT(OREG(12)) * 0.5f, anim->unk_10, PCT(OREG(25)), 0.1f);
camera->xzOffsetUpdateRate = Camera_LERPCeilF(0.2f, camera->xzOffsetUpdateRate, PCT(OREG(25)), 0.1f); camera->xzOffsetUpdateRate = Camera_LERPCeilF(0.2f, camera->xzOffsetUpdateRate, PCT(OREG(25)), 0.1f);
camera->yOffsetUpdateRate = Camera_LERPCeilF(0.2f, camera->yOffsetUpdateRate, PCT(OREG(25)), 0.1f); camera->yOffsetUpdateRate = Camera_LERPCeilF(0.2f, camera->yOffsetUpdateRate, PCT(OREG(25)), 0.1f);
if (anim->chargeTimer >= -19) { if (anim->chargeTimer >= -19.0f) {
anim->chargeTimer--; anim->chargeTimer--;
} else { } else {
distance = 250.0f; distance = 250.0f;
@ -3535,6 +3544,7 @@ s32 Camera_KeepOn1(Camera* camera) {
return 1; return 1;
} }
//noop
s32 Camera_KeepOn2(Camera* camera) { s32 Camera_KeepOn2(Camera* camera) {
return Camera_Noop(camera); return Camera_Noop(camera);
} }
@ -3681,14 +3691,14 @@ s32 Camera_KeepOn3(Camera* camera) {
} }
osSyncPrintf("camera: talk: BG&collision check %d time(s)\n", i); osSyncPrintf("camera: talk: BG&collision check %d time(s)\n", i);
camera->unk_14C &= ~0xC; camera->unk_14C &= ~0xC;
pad = ((anim->animTimer + 1) * anim->animTimer) >> 1; pad = ((anim->animTimer.whole() + 1) * anim->animTimer.whole()) >> 1;
anim->eyeToAtTarget.y = (f32)BINANG_SUB(atToEyeAdj.yaw, atToEyeNextDir.yaw) / pad; anim->eyeToAtTarget.y = (f32)BINANG_SUB(atToEyeAdj.yaw, atToEyeNextDir.yaw) / pad;
anim->eyeToAtTarget.z = (f32)BINANG_SUB(atToEyeAdj.pitch, atToEyeNextDir.pitch) / pad; anim->eyeToAtTarget.z = (f32)BINANG_SUB(atToEyeAdj.pitch, atToEyeNextDir.pitch) / pad;
anim->eyeToAtTarget.x = (atToEyeAdj.r - atToEyeNextDir.r) / pad; anim->eyeToAtTarget.x = (atToEyeAdj.r - atToEyeNextDir.r) / pad;
return 1; return 1;
} }
if (anim->animTimer != 0) { if (anim->animTimer != 0.0f) {
at->x += (anim->atTarget.x - at->x) / anim->animTimer; at->x += (anim->atTarget.x - at->x) / anim->animTimer;
at->y += (anim->atTarget.y - at->y) / anim->animTimer; at->y += (anim->atTarget.y - at->y) / anim->animTimer;
at->z += (anim->atTarget.z - at->z) / anim->animTimer; at->z += (anim->atTarget.z - at->z) / anim->animTimer;
@ -3727,6 +3737,7 @@ s32 Camera_KeepOn3(Camera* camera) {
return 1; return 1;
} }
//when picking up a new item
s32 Camera_KeepOn4(Camera* camera) { s32 Camera_KeepOn4(Camera* camera) {
static Vec3f D_8015BD50; static Vec3f D_8015BD50;
static Vec3f D_8015BD60; static Vec3f D_8015BD60;
@ -3995,7 +4006,7 @@ s32 Camera_KeepOn4(Camera* camera) {
camera->unk_14C |= (0x400 | 0x10); camera->unk_14C |= (0x400 | 0x10);
camera->unk_14C |= (0x4 | 0x2); camera->unk_14C |= (0x4 | 0x2);
camera->unk_14C &= ~8; camera->unk_14C &= ~8;
if (camera->timer > 0) { if (camera->timer > 0.0f) {
camera->timer--; camera->timer--;
} }
} else { } else {
@ -5202,7 +5213,7 @@ s32 Camera_Unique6(Camera* camera) {
camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye); camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye);
} }
if (uniq6->interfaceFlags & 1 && camera->timer > 0) { if (uniq6->interfaceFlags & 1 && camera->timer > 0.0f) {
camera->timer--; camera->timer--;
} }
@ -5735,7 +5746,7 @@ s32 Camera_Unique9(Camera* camera) {
anim->playerPos.z = playerPosRot.pos.z; anim->playerPos.z = playerPosRot.pos.z;
} }
if (anim->unk_38 == 0 && camera->timer > 0) { if (anim->unk_38 == 0 && camera->timer > 0.0f) {
camera->timer--; camera->timer--;
} }
@ -7836,7 +7847,8 @@ void Camera_Finish(Camera* camera) {
Camera* mainCam = camera->globalCtx->cameraPtrs[MAIN_CAM]; Camera* mainCam = camera->globalCtx->cameraPtrs[MAIN_CAM];
Player* player = GET_PLAYER(camera->globalCtx); Player* player = GET_PLAYER(camera->globalCtx);
if (camera->timer == 0) { if(camera->timer == 0.0f)
{
Gameplay_ChangeCameraStatus(camera->globalCtx, camera->parentCamIdx, CAM_STAT_ACTIVE); Gameplay_ChangeCameraStatus(camera->globalCtx, camera->parentCamIdx, CAM_STAT_ACTIVE);
if ((camera->parentCamIdx == MAIN_CAM) && (camera->csId != 0)) { if ((camera->parentCamIdx == MAIN_CAM) && (camera->csId != 0)) {