| 81 | } |
| 82 | |
| 83 | void PlatformCamera::updateView() { |
| 84 | if (SharedView.getSize() != _viewSize) { |
| 85 | auto pos = _camPos; |
| 86 | setPosition(Vec2::zero); |
| 87 | _viewSize = SharedView.getSize(); |
| 88 | reset(); |
| 89 | setPosition(pos); |
| 90 | _transformDirty = true; |
| 91 | } |
| 92 | if (_followTarget) { |
| 93 | Vec2 targetPos = _followTarget->convertToWorldSpace(Vec2::zero) + _offset; |
| 94 | Vec2 pos = Vec2{_position.x, _position.y}; |
| 95 | Vec2 delta = targetPos - pos; |
| 96 | setPosition(pos + delta * _ratio); |
| 97 | _transformDirty = true; |
| 98 | } |
| 99 | float z = -SharedView.getStandardDistance() / _zoom; |
| 100 | if (_position.z != z) { |
| 101 | _position.z = z; |
| 102 | _transformDirty = true; |
| 103 | } |
| 104 | if (_transformDirty) { |
| 105 | _transformDirty = false; |
| 106 | Matrix rotateZ; |
| 107 | bx::mtxRotateZ(rotateZ.m, -bx::toRad(_rotation)); |
| 108 | _up = Vec3::from(bx::mul(bx::Vec3{0, 1.0f, 0}, rotateZ.m)); |
| 109 | _up = Vec3::from(bx::normalize(_up)); |
| 110 | bx::mtxLookAt(_view.m, _position, _target, _up); |
| 111 | Updated(); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | bool PlatformCamera::init() { |
| 116 | if (!Camera::init()) return false; |
nothing calls this directly
no test coverage detected