| 148 | } |
| 149 | |
| 150 | void InteractiveCameraHandler::fromCamera(const sibr::InputCamera & cam, bool interpolate, bool updateResolution) { |
| 151 | _isSetup = true; |
| 152 | |
| 153 | sibr::InputCamera idealCam(cam); |
| 154 | if (updateResolution) { |
| 155 | // Viewport might have not been set, in this case defer the full camera update |
| 156 | // until after the viewport has been updated, ie in onUpdate(). |
| 157 | if (_viewport.isEmpty()) { |
| 158 | _triggerCameraUpdate = true; |
| 159 | } |
| 160 | else { |
| 161 | const float w = _viewport.finalWidth(); |
| 162 | const float h = _viewport.finalHeight(); |
| 163 | idealCam.size(uint(w), uint(h)); |
| 164 | idealCam.aspect(w / h); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | _orbit.fromCamera(idealCam, _raycaster); |
| 169 | _fpsCamera.fromCamera(idealCam); |
| 170 | |
| 171 | |
| 172 | if (_raycaster != nullptr) { |
| 173 | sibr::RayHit hit = _raycaster->intersect(sibr::Ray(idealCam.position(), idealCam.dir())); |
| 174 | // If hit at the proxy surface, save the distance between the camera and the mesh, to use as a trackball radius. |
| 175 | if (hit.hitSomething()) { |
| 176 | _radius = hit.dist(); |
| 177 | } |
| 178 | } |
| 179 | _trackball.fromCamera(idealCam, _viewport, _radius); |
| 180 | |
| 181 | _currentCamera = idealCam; |
| 182 | _cameraFovDeg = _currentCamera.fovy() * 180.0f / float(M_PI); |
| 183 | |
| 184 | if (!interpolate) { |
| 185 | _previousCamera = _currentCamera; |
| 186 | } |
| 187 | |
| 188 | _clippingPlanes[0] = _currentCamera.znear(); |
| 189 | _clippingPlanes[1] = _currentCamera.zfar(); |
| 190 | } |
| 191 | |
| 192 | void InteractiveCameraHandler::fromTransform(const Transform3f & transform, bool interpolate, bool updateResolution) |
| 193 | { |
nothing calls this directly
no test coverage detected