mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-20 03:49:31 -06:00
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:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user