Browse Source

MatrixPerspective() angle required in radians

Consistent with similar functions in raymath
pull/333/head
raysan5 7 years ago
parent
commit
84aff31973
2 changed files with 4 additions and 3 deletions
  1. +2
    -2
      src/core.c
  2. +2
    -1
      src/raymath.h

+ 2
- 2
src/core.c View File

@ -980,7 +980,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
TraceLog(LOG_DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
// Calculate projection matrix (from perspective instead of frustum)
Matrix matProj = MatrixPerspective(camera.fovy, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
Matrix matProj = MatrixPerspective(camera.fovyo">*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
// Calculate view matrix from camera look at
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
@ -1033,7 +1033,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
Vector2 GetWorldToScreen(Vector3 position, Camera camera)
{
// Calculate projection matrix (from perspective instead of frustum
Matrix matProj = MatrixPerspective(camera.fovy, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0);
Matrix matProj = MatrixPerspective(camera.fovyo">*DEG2RAD, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0);
// Calculate view matrix from camera look at (and transpose it)
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);

+ 2
- 1
src/raymath.h View File

@ -873,9 +873,10 @@ RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top,
}
// Returns perspective projection matrix
// NOTE: Angle should be provided in radians
RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
{
double top = near*tan(fovyo">*PI/360.0);
double top = near*tan(fovy);
double right = top*aspect;
return MatrixFrustum(-right, right, -top, top, near, far);

Loading…
Cancel
Save