summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorchriscamacho <[email protected]>2019-12-29 12:47:01 +0000
committerRay <[email protected]>2019-12-29 13:47:01 +0100
commitcedd5efe4c899e5f99be3abd00f358c2ac75b01b (patch)
tree6a75d8a4efb43970702c9c8434a43b4a584c19bb /src
parentf8bd56b07f6407dd56aba105f9e51bc0234c6512 (diff)
downloadraylib-cedd5efe4c899e5f99be3abd00f358c2ac75b01b.tar.gz
raylib-cedd5efe4c899e5f99be3abd00f358c2ac75b01b.zip
fixed free camera pitch (#1040)
Diffstat (limited to 'src')
-rw-r--r--src/camera.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/camera.h b/src/camera.h
index ac4139ba..ae389c93 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -167,8 +167,8 @@ void SetCameraMoveControls(int frontKey, int backKey,
// FIRST_PERSON
//#define CAMERA_FIRST_PERSON_MOUSE_SENSITIVITY 0.003f
#define CAMERA_FIRST_PERSON_FOCUS_DISTANCE 25.0f
-#define CAMERA_FIRST_PERSON_MIN_CLAMP 85.0f
-#define CAMERA_FIRST_PERSON_MAX_CLAMP -85.0f
+#define CAMERA_FIRST_PERSON_MIN_CLAMP 89.0f
+#define CAMERA_FIRST_PERSON_MAX_CLAMP -89.0f
#define CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 5.0f
#define CAMERA_FIRST_PERSON_STEP_DIVIDER 30.0f
@@ -429,9 +429,15 @@ void UpdateCamera(Camera *camera)
else if (cameraAngle.y < CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD;
// Camera is always looking at player
- camera->target.x = camera->position.x - sinf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
- camera->target.y = camera->position.y + sinf(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
- camera->target.z = camera->position.z - cosf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ //camera->target.x = camera->position.x - sinf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ //camera->target.y = camera->position.y + sinf(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ //camera->target.z = camera->position.z - cosf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ Matrix t = MatrixTranslate(0,0,(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER));
+ Matrix r = MatrixRotateXYZ((Vector3){PI*2-cameraAngle.y,PI*2-cameraAngle.x,0});
+ r = MatrixMultiply(t,r);
+ camera->target.x = camera->position.x - r.m12;
+ camera->target.y = camera->position.y - r.m13;
+ camera->target.z = camera->position.z - r.m14;
if (isMoving) swingCounter++;