Gui: Perspective camera set focal distance to rotation center depth to fix zooming at new rotation center
This commit is contained in:
committed by
Chris Hennes
parent
60cb0d9d8b
commit
21d0e8af5f
@@ -1026,6 +1026,20 @@ void NavigationStyle::setRotationCenter(const SbVec3f& cnt)
|
||||
{
|
||||
this->rotationCenter = cnt;
|
||||
this->rotationCenterFound = true;
|
||||
|
||||
const auto camera = getCamera();
|
||||
if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
|
||||
SbVec3f direction;
|
||||
camera->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
|
||||
|
||||
// Calculate distance from camera to rotation center
|
||||
const auto rotationCenterDistance = rotationCenter - camera->position.getValue();
|
||||
const auto rotationCenterDepth = rotationCenterDistance.dot(direction);
|
||||
|
||||
// Set focal distance to match rotation center depth so we can zoom at the new rotation
|
||||
// center with a perspective camera
|
||||
camera->focalDistance.setValue(rotationCenterDepth);
|
||||
}
|
||||
}
|
||||
|
||||
SbVec3f NavigationStyle::getFocalPoint() const
|
||||
|
||||
Reference in New Issue
Block a user