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

Method updateView

Source/Platformer/PlatformCamera.cpp:83–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void 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
115bool PlatformCamera::init() {
116 if (!Camera::init()) return false;

Callers

nothing calls this directly

Calls 10

setPositionFunction · 0.85
mtxRotateZFunction · 0.85
toRadFunction · 0.85
mtxLookAtFunction · 0.85
convertToWorldSpaceMethod · 0.80
getStandardDistanceMethod · 0.80
resetFunction · 0.50
mulClass · 0.50
normalizeFunction · 0.50
getSizeMethod · 0.45

Tested by

no test coverage detected