| 82 | } |
| 83 | |
| 84 | void 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 | |
| 107 | const Matrix& CameraBasic::getView() { |
| 108 | updateView(); |
nothing calls this directly
no test coverage detected