MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / mtxLookAt

Function mtxLookAt

Source/3rdParty/bx/src/math.cpp:28–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26 }
27
28 void mtxLookAt(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up, Handedness::Enum _handedness)
29 {
30 const Vec3 view = normalize(
31 Handedness::Right == _handedness
32 ? sub(_eye, _at)
33 : sub(_at, _eye)
34 );
35
36 Vec3 right = bx::InitNone;
37 Vec3 up = bx::InitNone;
38
39 const Vec3 uxv = cross(_up, view);
40
41 if (0.0f == dot(uxv, uxv) )
42 {
43 right = { Handedness::Left == _handedness ? -1.0f : 1.0f, 0.0f, 0.0f };
44 }
45 else
46 {
47 right = normalize(uxv);
48 }
49
50 up = cross(view, right);
51
52 _result[ 0] = right.x;
53 _result[ 1] = up.x;
54 _result[ 2] = view.x;
55 _result[ 3] = 0.0f;
56
57 _result[ 4] = right.y;
58 _result[ 5] = up.y;
59 _result[ 6] = view.y;
60 _result[ 7] = 0.0f;
61
62 _result[ 8] = right.z;
63 _result[ 9] = up.z;
64 _result[10] = view.z;
65 _result[11] = 0.0f;
66
67 _result[12] = -dot(right, _eye);
68 _result[13] = -dot(up, _eye);
69 _result[14] = -dot(view, _eye);
70 _result[15] = 1.0f;
71 }
72
73 static void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _homogeneousNdc, Handedness::Enum _handedness)
74 {

Callers 3

updateViewMethod · 0.85
Camera.cppFile · 0.85
updateViewMethod · 0.85

Calls 4

normalizeFunction · 0.50
subFunction · 0.50
crossClass · 0.50
dotFunction · 0.50

Tested by

no test coverage detected