summaryrefslogtreecommitdiffhomepage
path: root/src/rlgl.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2017-07-22 11:02:40 +0200
committerraysan5 <[email protected]>2017-07-22 11:02:40 +0200
commitcbb134946c73c3857d1f3185c25a5398fad3fa5d (patch)
tree7a7cf4b9ef590e32dc7d54506a87cd1c3c63b576 /src/rlgl.c
parentc756227e11ec3a16b6c3ce09826e5c8162cfd031 (diff)
downloadraylib-cbb134946c73c3857d1f3185c25a5398fad3fa5d.tar.gz
raylib-cbb134946c73c3857d1f3185c25a5398fad3fa5d.zip
Corrected GetMouseRay() and rlUnproject()
Now it works great with reviewed maths
Diffstat (limited to 'src/rlgl.c')
-rw-r--r--src/rlgl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rlgl.c b/src/rlgl.c
index ac4ad20d..244badc9 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -1306,15 +1306,15 @@ Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view)
{
Vector3 result = { 0.0f, 0.0f, 0.0f };
- // Calculate unproject matrix (multiply projection matrix and view matrix) and invert it
- Matrix matProjView = MatrixMultiply(proj, view);
- MatrixInvert(&matProjView);
+ // Calculate unproject matrix (multiply view patrix by projection matrix) and invert it
+ Matrix matViewProj = MatrixMultiply(view, proj);
+ MatrixInvert(&matViewProj);
// Create quaternion from source point
Quaternion quat = { source.x, source.y, source.z, 1.0f };
// Multiply quat point by unproject matrix
- QuaternionTransform(&quat, matProjView);
+ QuaternionTransform(&quat, matViewProj);
// Normalized world points in vectors
result.x = quat.x/quat.w;