papermario/src/cam_mode_no_interp.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
3.9 KiB
C
Raw Normal View History

Splat refactor (#257) * all non-world rodata migrated * data disasm * kinda working * updated yaml * bloop * linker header * configure 2.0 * bin * mass rename to remove code_ * pause rename * battle partner stuff * whew * more renames * more renames * more renaming * it builds! * updates * remove main prefix * one more thing * crc, yay0 * .data, .rodata, .bss * img * dead_atan2 * it buildsgit add -A * split battle/partner/6FAD10 * rm &s on sleepy_sheep syms * sha1sum ninja rule description * OK but commented out PaperMarioMapFS and PaperMarioNpcSprites * uncomment * fix mapfs * match func_8003CFB4 * . * clean up and name npc_iter_no_op * npc.c * enable cc warnings * name npc_find_near * use singular options.asset_path * smores * cc_dsl only when needed * kinda fix configure for splat refactor2 * ok! * new msg format * remove old msg format docs * slight bug fixes, splat adjustment * git subrepo pull (merge) --force tools/splat subrepo: subdir: "tools/splat" merged: "cfc140bb76" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "cfc140bb76" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * git subrepo pull (merge) --force tools/splat subrepo: subdir: "tools/splat" merged: "85349befcd" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "85349befcd" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * Update symbol addrs * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "a44631e194" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "a44631e194" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" Co-authored-by: Alex Bates <hi@imalex.xyz>
2021-04-13 09:47:52 +02:00
#include "common.h"
2024-09-23 20:42:15 +02:00
// implements CAM_UPDATE_NO_INTERP
// this camera uses a set of control parameters to calculate its lookAt_obj and lookAt_eye positions,
// which are only updated if skipRecalc = FALSE
// the ultimate target is given by lookAt_obj_target, with an offset given by targetPos (?!)
// in practice, this is used for CAM_BATTLE and CAM_TATTLE, with skipRecalc almost always set to FALSE
//
// control parameters:
// dist -- length of the camera boom arm
// pitch -- rising angle of the boom arm, up toward the y-axis
// yaw -- yaw angle for the boom arm in the xz-plane
// offsetY -- offset of the base of the boom arm above the target point
// fovScale -- adjusts vertical fov, with 100 being normal (=25). scales as 1/x so larger values mean smaller vfov.
// skipRecalc -- do not calculate lookAt_obj and lookAt_eye from params
void update_camera_no_interp(Camera* camera) {
2023-01-24 00:46:51 +01:00
f32 sinBoom;
f32 cosBoom;
f32 deltaX;
f32 deltaY;
f32 deltaZ;
f32 deltaX2;
f32 deltaY2;
f32 deltaZ2;
f32 boomYaw;
2023-01-24 00:46:51 +01:00
f32 new_var;
f32 planarDist;
2024-09-23 20:42:15 +02:00
if (camera->needsInit || camera->needsReinit) {
camera->needsInit = FALSE;
2024-09-23 20:42:15 +02:00
camera->needsReinit = FALSE;
camera->params.basic.skipRecalc = FALSE;
camera->params.basic.dist = 100;
camera->params.basic.fovScale = 100;
camera->params.basic.pitch = 0;
camera->params.basic.yaw = 0;
camera->params.basic.offsetY = 0;
camera->targetPos.x = 0.0f;
camera->targetPos.y = 0.0f;
camera->targetPos.z = 0.0f;
camera->lookAt_obj.x = camera->lookAt_obj_target.x;
camera->lookAt_obj.y = camera->lookAt_obj_target.y;
camera->lookAt_obj.z = camera->lookAt_obj_target.z;
}
2024-09-23 20:42:15 +02:00
if (!camera->params.basic.skipRecalc) {
2023-01-24 00:46:51 +01:00
camera->lookAt_obj.x = camera->lookAt_obj_target.x + camera->targetPos.x;
2024-09-23 20:42:15 +02:00
camera->lookAt_obj.y = camera->lookAt_obj_target.y + camera->targetPos.y + camera->params.basic.offsetY / 256.0;
2023-01-24 00:46:51 +01:00
camera->lookAt_obj.z = camera->lookAt_obj_target.z + camera->targetPos.z;
2024-09-23 20:42:15 +02:00
camera->curBoomYaw = camera->params.basic.yaw;
camera->curBoomPitch = camera->params.basic.pitch;
camera->curBoomLength = camera->params.basic.dist;
camera->vfov = (10000 / camera->params.basic.fovScale) / 4;
boomYaw = DEG_TO_RAD(camera->curBoomPitch);
2023-01-24 00:46:51 +01:00
sinBoom = sin_rad(boomYaw);
cosBoom = cos_rad(boomYaw);
deltaX = 0.0f;
deltaY = 0.0f;
deltaZ = camera->curBoomLength;
deltaX2 = 0.0f;
deltaY2 = 0.0f;
2023-01-24 00:46:51 +01:00
boomYaw = deltaX = -deltaY2;
deltaZ2 = camera->curBoomLength;
2023-01-24 00:46:51 +01:00
new_var = boomYaw;
deltaX = deltaX2;
deltaY = cosBoom * deltaY2 + deltaZ2 * sinBoom;
deltaZ = sinBoom * new_var + deltaZ2 * cosBoom;
2024-09-23 20:42:15 +02:00
boomYaw = DEG_TO_RAD(camera->curBoomYaw);
2023-01-24 00:46:51 +01:00
sinBoom = sin_rad(boomYaw);
cosBoom = cos_rad(boomYaw);
deltaZ2 = cosBoom * deltaX - deltaZ * sinBoom;
deltaX2 = cosBoom * deltaX - deltaZ * sinBoom;
deltaY2 = deltaY;
deltaZ2 = sinBoom * deltaX + deltaZ * cosBoom;
camera->lookAt_eye.x = camera->lookAt_obj.x + deltaX2;
camera->lookAt_eye.y = camera->lookAt_obj.y + deltaY2;
camera->lookAt_eye.z = camera->lookAt_obj.z + deltaZ2;
}
2024-09-23 20:42:15 +02:00
camera->curYaw = atan2(camera->lookAt_eye.x, camera->lookAt_eye.z, camera->lookAt_obj.x, camera->lookAt_obj.z);
2023-01-24 00:46:51 +01:00
deltaX = camera->lookAt_obj.x - camera->lookAt_eye.x;
deltaY = camera->lookAt_obj.y - camera->lookAt_eye.y;
deltaZ = camera->lookAt_obj.z - camera->lookAt_eye.z;
2024-09-23 20:42:15 +02:00
camera->lookAt_yaw = -atan2(0.0f, 0.0f, deltaX, deltaZ);
planarDist = sqrtf(SQ(deltaX) + SQ(deltaZ));
2024-09-23 20:42:15 +02:00
camera->lookAt_pitch = atan2(0.0f, 0.0f, deltaY, -planarDist);
gBattleStatus.camLookatObjPos.x = camera->lookAt_obj.x;
gBattleStatus.camLookatObjPos.y = camera->lookAt_obj.y;
gBattleStatus.camLookatObjPos.z = camera->lookAt_obj.z;
}