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

Method updateView

Source/Render/Camera.cpp:84–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void CameraBasic::updateView() {
85 if (_transformDirty) {
86 _transformDirty = false;
87 bx::Vec3 dest = bx::sub(_target, _position);
88 float distance = bx::length(dest);
89 if (distance == 0.0f) {
90 bx::mtxIdentity(_view.m);
91 } else {
92 float rotateX = std::asin(dest.y / distance);
93 float rotateY = 0.0f;
94 if (dest.x != 0.0f) {
95 rotateY = -std::atan(dest.z / dest.x);
96 }
97 Matrix transform;
98 bx::mtxRotateZYX(transform.m, rotateX, rotateY, -bx::toRad(_rotation));
99 bx::Vec3 up = bx::mul(bx::Vec3{0, 1.0f, 0}, transform.m);
100 _up = Vec3::from(bx::normalize(up));
101 bx::mtxLookAt(_view.m, _position, _target, _up);
102 }
103 Updated();
104 }
105}
106
107const Matrix& CameraBasic::getView() {
108 updateView();

Callers

nothing calls this directly

Calls 11

asinClass · 0.85
mtxRotateZYXFunction · 0.85
toRadFunction · 0.85
mtxLookAtFunction · 0.85
mtxRotateZFunction · 0.85
getStandardDistanceMethod · 0.80
subClass · 0.50
lengthFunction · 0.50
atanFunction · 0.50
mulClass · 0.50
normalizeFunction · 0.50

Tested by

no test coverage detected