Gui: Fix camera behavior when rotation center is far from object

Also fixes a regression in turntable navigation speed
This commit is contained in:
Bas Ruigrok
2024-11-03 10:32:23 +01:00
committed by Yorik van Havre
parent d7c49329a2
commit 579e1c5bbd
2 changed files with 6 additions and 2 deletions

View File

@@ -219,6 +219,7 @@ void NavigationStyle::initialize()
this->spinsamplecounter = 0;
this->spinincrement = SbRotation::identity();
this->rotationCenterFound = false;
this->rotationCenterIsScenePointAtCursor = false;
// FIXME: use a smaller sphere than the default one to have a larger
// area close to the borders that gives us "z-axis rotation"?
@@ -868,8 +869,8 @@ void NavigationStyle::spin(const SbVec2f & pointerpos)
float sensitivity = getSensitivity();
// Adjust the spin projector sphere to the screen position of the rotation center
if (rotationCenterFound) {
// Adjust the spin projector sphere to the screen position of the rotation center when the mouse intersects an object
if (getOrbitStyle() == Trackball && rotationCenterMode & RotationCenterMode::ScenePointAtCursor && rotationCenterFound && rotationCenterIsScenePointAtCursor) {
const auto pointOnScreen = viewer->getPointOnViewport(rotationCenter);
const auto sphereCenter = 2 * normalizePixelPos(pointOnScreen) - SbVec2f {1, 1};
@@ -1040,6 +1041,7 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev)
{
this->globalPos.setValue(QCursor::pos().x(), QCursor::pos().y());
this->localPos = ev->getPosition();
rotationCenterIsScenePointAtCursor = false;
// mode is WindowCenter
if (!this->rotationCenterMode) {
@@ -1058,6 +1060,7 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev)
SoPickedPoint * picked = rpaction.getPickedPoint();
if (picked) {
setRotationCenter(picked->getPoint());
rotationCenterIsScenePointAtCursor = true;
return;
}
}