Skip to content

Commit eb4ad50

Browse files
authored
make sure that our up vector really is up in an axis before picking a world plane (#5459)
1 parent 95f72b1 commit eb4ad50

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/rcamera.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane)
255255
if (moveInWorldPlane)
256256
{
257257
// Project vector onto world plane (the plane defined by the up vector)
258-
if (fabsf(camera->up.z) > 0) forward.z = 0;
259-
else if (fabsf(camera->up.x) > 0) forward.x = 0;
258+
if (fabsf(camera->up.z) > 0.7071f) forward.z = 0;
259+
else if (fabsf(camera->up.x) > 0.7071f) forward.x = 0;
260260
else forward.y = 0;
261261

262262
forward = Vector3Normalize(forward);
@@ -291,8 +291,8 @@ void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane)
291291
if (moveInWorldPlane)
292292
{
293293
// Project vector onto world plane (the plane defined by the up vector)
294-
if (fabsf(camera->up.z) > 0) right.z = 0;
295-
else if (fabsf(camera->up.x) > 0) right.x = 0;
294+
if (fabsf(camera->up.z) > 0.7071f) right.z = 0;
295+
else if (fabsf(camera->up.x) > 0.7071f) right.x = 0;
296296
else right.y = 0;
297297

298298
right = Vector3Normalize(right);

0 commit comments

Comments
 (0)