Gui: Improve orthographic camera rotation stability
This commit is contained in:
committed by
Kacper Donat
parent
b8c08a7ec8
commit
ff516f0a2b
@@ -700,6 +700,19 @@ void NavigationStyle::reorientCamera(SoCamera* camera, const SbRotation& rotatio
|
||||
// Reposition camera so the rotation center stays in the same place
|
||||
camera->position = rotationCenter + newRotationCenterDistance;
|
||||
|
||||
if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())) {
|
||||
// Adjust the camera position to keep the focal point in the same place while making sure
|
||||
// the focal distance stays small. This increases rotation stability for small and large
|
||||
// scenes
|
||||
|
||||
SbVec3f direction;
|
||||
camera->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
|
||||
|
||||
constexpr float orthographicFocalDistance = 1;
|
||||
camera->position = getFocalPoint() - orthographicFocalDistance * direction;
|
||||
camera->focalDistance = orthographicFocalDistance;
|
||||
}
|
||||
|
||||
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
|
||||
// Fix issue with near clipping in orthogonal view
|
||||
if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())) {
|
||||
|
||||
Reference in New Issue
Block a user