Update camera scaling based on anchor pos even if path is playing

Previously this was only done hwen the Orbitalnavigator controlled the camera
This commit is contained in:
Emma Broman
2021-07-14 10:54:30 +02:00
parent be9df994c8
commit 2905fef7d9
3 changed files with 13 additions and 2 deletions

View File

@@ -61,6 +61,7 @@ public:
void updateStatesFromInput(const InputState& inputState, double deltaTime);
void updateCameraStateFromStates(double deltaTime);
void updateCameraScalingFromAnchor(double deltaTime);
void resetVelocities();
Camera* camera() const;

View File

@@ -180,6 +180,8 @@ void NavigationHandler::updateCamera(double deltaTime) {
_orbitalNavigator.updateStatesFromInput(_inputState, deltaTime);
_orbitalNavigator.updateCameraStateFromStates(deltaTime);
}
_orbitalNavigator.updateCameraScalingFromAnchor(deltaTime);
}
// If session recording (playback mode) was started in the midst of a camera path,

View File

@@ -686,16 +686,24 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) {
// Update the camera state
_camera->setPositionVec3(pose.position);
_camera->setRotation(composeCameraRotation(camRot));
}
void OrbitalNavigator::updateCameraScalingFromAnchor(double deltaTime) {
if (_useAdaptiveStereoscopicDepth) {
const glm::dvec3 anchorPos = _anchorNode->worldPosition();
const glm::dvec3 cameraPos = _camera->positionVec3();
SurfacePositionHandle posHandle =
calculateSurfacePositionHandle(*_anchorNode, cameraPos);
double targetCameraToSurfaceDistance = glm::length(
cameraToSurfaceVector(pose.position, anchorPos, posHandle)
cameraToSurfaceVector(cameraPos, anchorPos, posHandle)
);
if (_aimNode) {
targetCameraToSurfaceDistance = std::min(
targetCameraToSurfaceDistance,
glm::distance(pose.position, _aimNode->worldPosition())
glm::distance(cameraPos, _aimNode->worldPosition())
);
}