summaryrefslogtreecommitdiffhomepage
path: root/src/raymath.h
diff options
context:
space:
mode:
authorRandom <[email protected]>2020-11-29 01:08:22 -0800
committerGitHub <[email protected]>2020-11-29 10:08:22 +0100
commit0322fc28d4c2c794adfb9b95a3d968a590109bb0 (patch)
tree00dfbcf5c2861214c2ad0be35a3a912e59a42b18 /src/raymath.h
parented0fda2b406c14e445ebe61c7b75ed05fbe820ab (diff)
downloadraylib-0322fc28d4c2c794adfb9b95a3d968a590109bb0.tar.gz
raylib-0322fc28d4c2c794adfb9b95a3d968a590109bb0.zip
optimized MatrixLookAt (#1442)
Diffstat (limited to 'src/raymath.h')
-rw-r--r--src/raymath.h21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/raymath.h b/src/raymath.h
index 086eba12..7f05ea4e 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -1074,27 +1074,24 @@ RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
Vector3 x = Vector3CrossProduct(up, z);
x = Vector3Normalize(x);
Vector3 y = Vector3CrossProduct(z, x);
- y = Vector3Normalize(y);
result.m0 = x.x;
- result.m1 = x.y;
- result.m2 = x.z;
+ result.m1 = y.x;
+ result.m2 = z.x;
result.m3 = 0.0f;
- result.m4 = y.x;
+ result.m4 = x.y;
result.m5 = y.y;
- result.m6 = y.z;
+ result.m6 = z.y;
result.m7 = 0.0f;
- result.m8 = z.x;
- result.m9 = z.y;
+ result.m8 = x.z;
+ result.m9 = y.z;
result.m10 = z.z;
result.m11 = 0.0f;
- result.m12 = eye.x;
- result.m13 = eye.y;
- result.m14 = eye.z;
+ result.m12 = -Vector3DotProduct(x, eye);
+ result.m13 = -Vector3DotProduct(y, eye);
+ result.m14 = -Vector3DotProduct(z, eye);
result.m15 = 1.0f;
- result = MatrixInvert(result);
-
return result;
}