1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 12:54:51 +00:00
oot/src/code/code_800BB0A0.c

73 lines
2.5 KiB
C
Raw Normal View History

#include "global.h"
// The code in this file is very similar to a spline system used in Super Mario 64 for cutscene camera movement
void func_800BB0A0(f32 u, Vec3f* pos, f32* roll, f32* viewAngle, f32* point0, f32* point1, f32* point2, f32* point3) {
f32 coeff[4];
u = CLAMP_MAX(u, 1.0f);
coeff[0] = (1.0f - u) * (1.0f - u) * (1.0f - u) / 6.0f;
coeff[1] = u * u * u / 2.0f - u * u + 2.0f / 3.0f;
coeff[2] = -u * u * u / 2.0f + u * u / 2.0f + u / 2.0f + 1.0f / 6.0f;
coeff[3] = u * u * u / 6.0f;
pos->x = (coeff[0] * point0[0]) + (coeff[1] * point1[0]) + (coeff[2] * point2[0]) + (coeff[3] * point3[0]);
pos->y = (coeff[0] * point0[1]) + (coeff[1] * point1[1]) + (coeff[2] * point2[1]) + (coeff[3] * point3[1]);
pos->z = (coeff[0] * point0[2]) + (coeff[1] * point1[2]) + (coeff[2] * point2[2]) + (coeff[3] * point3[2]);
*roll = (coeff[0] * point0[3]) + (coeff[1] * point1[3]) + (coeff[2] * point2[3]) + (coeff[3] * point3[3]);
*viewAngle = (coeff[0] * point0[4]) + (coeff[1] * point1[4]) + (coeff[2] * point2[4]) + (coeff[3] * point3[4]);
}
s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s16* keyFrame, f32* curFrame) {
s32 ret = false;
f32 pointData[4][5];
s32 i;
f32 progress = *curFrame;
s32 key = *keyFrame;
f32 speed1 = 0.0f;
f32 speed2 = 0.0f;
f32 advance;
if (key < 0) {
progress = 0.0f;
}
z_demo documentation (#1327) * commit old stuff * progress * progress * progress * progress * more progress, renaming cues next * small changes * enum values added for all actions * hardcoded values removed when possible * commands renamed * first pass of action -> cue * fix some matches * some more cleanup * scriptPtr * forgot one * remove cue rot union * more changes * some more stuff * more stuff * fix matching issues * some more things * progress, starting to rename destinations * small changes * name some destinations * more names * need to switch branch * progress * first pass of destination names * usages fixed * use destination enum * fix csdis * format * command descriptions * revert accidental zap changes * forgot some things * use a single macro for CutsceneCameraPoint (idk why i didnt think of this sooner) * typo * review1 * clarify ruby/sapphire comment * remove endframe for commands that dont use it * some more review * most review, but not all * scriptPtr -> script, and another small change * ocarina action * remove +1 from light settings command, change comment * actionIndex -> cueIdTemp (i guess) * _SetCueX -> _SetXFromCue * format * tweak fade out seq arg names * use spline terminology * more dragorn and engineer review * misc start/end frame note * cleanup StartPosRotFromCue vs PosRotFromCue * cleanup spline terminology * sPrevCamId -> sReturnToCamId * comment on debug cs data address * Cutscene_Init -> Cutscene_InitContext * single point types are not a list * remove todo comment * some more review * rumble struct names * some review * more review * missed one * reword pointer comment * even more review * match transition terminology with z_play * change condition and format * frame count * command specific structs with alignment * anon review * remove unneeded arg from time macro * yeet `CsCmdGeneric` * remove unused from single point types * typo * compromise attempt -- name endFrame everywhere * fixes * fix again * copied the wrong note * cutscene data note * review, format * compat defines * idk whats going on man Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
2022-12-24 18:55:17 +00:00
if ((point[key].continueFlag == CS_CAM_STOP) || (point[key + 1].continueFlag == CS_CAM_STOP) ||
(point[key + 2].continueFlag == CS_CAM_STOP)) {
return true;
}
for (i = 0; i < 4; i++) {
pointData[i][0] = point[key + i].pos.x;
pointData[i][1] = point[key + i].pos.y;
pointData[i][2] = point[key + i].pos.z;
pointData[i][3] = point[key + i].cameraRoll;
pointData[i][4] = point[key + i].viewAngle;
}
func_800BB0A0(progress, pos, roll, fov, pointData[0], pointData[1], pointData[2], pointData[3]);
if (point[*keyFrame + 1].nextPointFrame != 0) {
speed1 = 1.0f / point[*keyFrame + 1].nextPointFrame;
}
if (point[*keyFrame + 2].nextPointFrame != 0) {
speed2 = 1.0f / point[*keyFrame + 2].nextPointFrame;
}
advance = (*curFrame * (speed2 - speed1)) + speed1;
if (advance < 0.0f) {
advance = 0;
}
*curFrame += advance;
if (*curFrame >= 1) {
if (point[++*keyFrame + 3].continueFlag == CS_CAM_STOP) {
*keyFrame = 0;
ret = true;
}
*curFrame -= 1;
}
return ret;
}