From 52f3b08a6f9f14799bb37b761e8fb73059e118ba Mon Sep 17 00:00:00 2001 From: aglab2 Date: Sat, 28 Aug 2021 21:41:43 +0800 Subject: [PATCH] Puppycam: use softer clamp for Y movement --- src/game/puppycam2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index 6172efc2..065fb74f 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -27,6 +27,15 @@ #ifdef PUPPYCAM +static inline float smooth(float x) { + x = CLAMP(x, 0, 1); + return x * x * (3.f - 2.f * x); +} + +static inline float softClamp(float x, float a, float b) { + return smooth((2.f / 3.f) * (x - a) / (b - a) + (1.f / 6.f)) * (b - a) + a; +} + #define DECELERATION 0.66f #define DEADZONE 20 #define SCRIPT_MEMORY_POOL 0x1000 @@ -1164,8 +1173,8 @@ void puppycam_projection_behaviours(void) if (!(gMarioState->action & ACT_FLAG_SWIMMING)) { - gPuppyCam.floorY[0] = CLAMP(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -300, 300); - gPuppyCam.floorY[1] = CLAMP(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -300, 350); + gPuppyCam.floorY[0] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 300); + gPuppyCam.floorY[1] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 350); gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,0,0.2f); } else