mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-05 05:39:18 -05:00
Update rcamera.h
This commit is contained in:
@ -192,6 +192,8 @@ RLAPI Matrix GetCameraProjectionMatrix(Camera *camera, float aspect);
|
|||||||
// IsKeyPressed()
|
// IsKeyPressed()
|
||||||
// GetFrameTime()
|
// GetFrameTime()
|
||||||
|
|
||||||
|
#include <math.h> // Required for: fabsf()
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -253,12 +255,10 @@ void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane)
|
|||||||
if (moveInWorldPlane)
|
if (moveInWorldPlane)
|
||||||
{
|
{
|
||||||
// Project vector onto world plane (the plane defined by the up vector)
|
// Project vector onto world plane (the plane defined by the up vector)
|
||||||
if (fabsf(camera->up.z) > 0)
|
if (fabsf(camera->up.z) > 0) forward.z = 0;
|
||||||
forward.z = 0;
|
else if (fabsf(camera->up.x) > 0) forward.x = 0;
|
||||||
else if (fabsf(camera->up.x) > 0)
|
else forward.y = 0;
|
||||||
forward.x = 0;
|
|
||||||
else
|
|
||||||
forward.y = 0;
|
|
||||||
forward = Vector3Normalize(forward);
|
forward = Vector3Normalize(forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,12 +291,9 @@ void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane)
|
|||||||
if (moveInWorldPlane)
|
if (moveInWorldPlane)
|
||||||
{
|
{
|
||||||
// Project vector onto world plane (the plane defined by the up vector)
|
// Project vector onto world plane (the plane defined by the up vector)
|
||||||
if (fabsf(camera->up.z) > 0)
|
if (fabsf(camera->up.z) > 0) right.z = 0;
|
||||||
right.z = 0;
|
else if (fabsf(camera->up.x) > 0) right.x = 0;
|
||||||
else if (fabsf(camera->up.x) > 0)
|
else right.y = 0;
|
||||||
right.x = 0;
|
|
||||||
else
|
|
||||||
right.y = 0;
|
|
||||||
|
|
||||||
right = Vector3Normalize(right);
|
right = Vector3Normalize(right);
|
||||||
}
|
}
|
||||||
@ -356,7 +353,7 @@ void CameraYaw(Camera *camera, float angle, bool rotateAroundTarget)
|
|||||||
// - lockView prevents camera overrotation (aka "somersaults")
|
// - lockView prevents camera overrotation (aka "somersaults")
|
||||||
// - rotateAroundTarget defines if rotation is around target or around its position
|
// - rotateAroundTarget defines if rotation is around target or around its position
|
||||||
// - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
|
// - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
|
||||||
// NOTE: angle must be provided in radians
|
// NOTE: [angle] must be provided in radians
|
||||||
void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
|
void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
|
||||||
{
|
{
|
||||||
// Up direction
|
// Up direction
|
||||||
@ -393,7 +390,7 @@ void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTa
|
|||||||
// Move position relative to target
|
// Move position relative to target
|
||||||
camera->position = Vector3Subtract(camera->target, targetPosition);
|
camera->position = Vector3Subtract(camera->target, targetPosition);
|
||||||
}
|
}
|
||||||
else // rotate around camera.position
|
else // Rotate around camera.position
|
||||||
{
|
{
|
||||||
// Move target relative to position
|
// Move target relative to position
|
||||||
camera->target = Vector3Add(camera->position, targetPosition);
|
camera->target = Vector3Add(camera->position, targetPosition);
|
||||||
|
|||||||
Reference in New Issue
Block a user