Skip to content

Commit 0133a4e

Browse files
authored
Make CameraMove up and right work with Z up cameras like the other functions do. (#5458)
1 parent c124f25 commit 0133a4e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/rcamera.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,13 @@ void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane)
252252

253253
if (moveInWorldPlane)
254254
{
255-
// Project vector onto world plane
256-
forward.y = 0;
255+
// Project vector onto world plane (the plane defined by the up vector)
256+
if (fabsf(camera->up.z) > 0)
257+
forward.z = 0;
258+
else if (fabsf(camera->up.x) > 0)
259+
forward.x = 0;
260+
else
261+
forward.y = 0;
257262
forward = Vector3Normalize(forward);
258263
}
259264

@@ -285,8 +290,14 @@ void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane)
285290

286291
if (moveInWorldPlane)
287292
{
288-
// Project vector onto world plane
289-
right.y = 0;
293+
// Project vector onto world plane (the plane defined by the up vector)
294+
if (fabsf(camera->up.z) > 0)
295+
right.z = 0;
296+
else if (fabsf(camera->up.x) > 0)
297+
right.x = 0;
298+
else
299+
right.y = 0;
300+
290301
right = Vector3Normalize(right);
291302
}
292303

0 commit comments

Comments
 (0)