From a2cf878190569f2d37c90ff475594d90205eafb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agnis=20Aldi=C5=86=C5=A1=20=22NeZv=C4=93rs?= Date: Mon, 23 Jun 2025 13:43:38 +0300 Subject: [PATCH] cleanup variable shadowing --- examples/core/core_3d_fps_controller.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/core/core_3d_fps_controller.c b/examples/core/core_3d_fps_controller.c index d4936388b..3a21ac2dd 100644 --- a/examples/core/core_3d_fps_controller.c +++ b/examples/core/core_3d_fps_controller.c @@ -74,7 +74,7 @@ void UpdateDrawFrame(void); // Update and Draw one frame void DrawLevel(); -void UpdateCameraAngle(Camera* camera, Vector2* rot, float headTimer, float walkLerp, Vector2 lean); +void UpdateCameraAngle(); void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed, bool crouchHold); @@ -167,7 +167,7 @@ void UpdateDrawFrame(void) lean.x = Lerp(lean.x, sideway * 0.02f, 10.f * delta); lean.y = Lerp(lean.y, forward * 0.015f, 10.f * delta); - UpdateCameraAngle(&camera, &lookRotation, headTimer, walkLerp, lean); + UpdateCameraAngle(); // Draw //---------------------------------------------------------------------------------- @@ -272,46 +272,46 @@ void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed } } -void UpdateCameraAngle(Camera* camera, Vector2* rot, float headTimer, float walkLerp, Vector2 lean) +void UpdateCameraAngle() { const Vector3 up = (Vector3){ 0.f, 1.f, 0.f }; const Vector3 targetOffset = (Vector3){ 0.f, 0.f, -1.f }; /* Left & Right */ - Vector3 yaw = Vector3RotateByAxisAngle(targetOffset, up, rot->x); + Vector3 yaw = Vector3RotateByAxisAngle(targetOffset, up, lookRotation.x); // Clamp view up float maxAngleUp = Vector3Angle(up, yaw); maxAngleUp -= 0.001f; // avoid numerical errors - if ( -(rot->y) > maxAngleUp) { rot->y = -maxAngleUp; } + if ( -(lookRotation.y) > maxAngleUp) { lookRotation.y = -maxAngleUp; } // Clamp view down float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw); maxAngleDown *= -1.0f; // downwards angle is negative maxAngleDown += 0.001f; // avoid numerical errors - if ( -(rot->y) < maxAngleDown) { rot->y = -maxAngleDown; } + if ( -(lookRotation.y) < maxAngleDown) { lookRotation.y = -maxAngleDown; } /* Up & Down */ Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up)); // Rotate view vector around right axis - Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, -rot->y - lean.y); + Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, -lookRotation.y - lean.y); // Head animation // Rotate up direction around forward axis float _sin = sin(headTimer * PI); float _cos = cos(headTimer * PI); const float stepRotation = 0.01f; - camera->up = Vector3RotateByAxisAngle(up, pitch, _sin * stepRotation + lean.x); + camera.up = Vector3RotateByAxisAngle(up, pitch, _sin * stepRotation + lean.x); /* BOB */ const float bobSide = 0.1f; const float bobUp = 0.15f; Vector3 bobbing = Vector3Scale(right, _sin * bobSide); bobbing.y = fabsf(_cos * bobUp); - camera->position = Vector3Add(camera->position, Vector3Scale(bobbing, walkLerp)); + camera.position = Vector3Add(camera.position, Vector3Scale(bobbing, walkLerp)); - camera->target = Vector3Add(camera->position, pitch); + camera.target = Vector3Add(camera.position, pitch); }