Gui: Use Coin 4.0.3 fix for orthographic camera clipping

This commit is contained in:
Bas Ruigrok
2024-09-07 11:09:48 +02:00
committed by Yorik van Havre
parent fdb0b46857
commit 6f0c3d2fea
4 changed files with 30 additions and 1 deletions

View File

@@ -58,7 +58,10 @@ FixedTimeAnimation::FixedTimeAnimation(NavigationStyle* navigation, const SbRota
void FixedTimeAnimation::initialize()
{
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
navigation->findBoundingSphere();
#endif
prevAngle = 0;
prevTranslation = SbVec3f(0, 0, 0);
@@ -135,7 +138,10 @@ SpinningAnimation::SpinningAnimation(NavigationStyle* navigation, const SbVec3f&
void SpinningAnimation::initialize()
{
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
navigation->findBoundingSphere();
#endif
prevAngle = 0;
navigation->setViewing(true);

View File

@@ -516,12 +516,14 @@ void NavigationStyle::viewAll()
}
}
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
void NavigationStyle::findBoundingSphere() {
// Find a bounding sphere for the scene
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
action.apply(viewer->getSceneGraph());
boundingSphere.circumscribe(action.getBoundingBox());
}
#endif
/** Rotate the camera by the given amount, then reposition it so we're still pointing at the same
* focal point
@@ -554,8 +556,9 @@ void NavigationStyle::reorientCamera(SoCamera* camera, const SbRotation& rotatio
// Reposition camera so the rotation center stays in the same place
camera->position = rotationCenter + newRotationCenterDistance;
#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())) {
if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())) {
// The center of the bounding sphere in camera coordinate system
SbVec3f center;
@@ -572,6 +575,7 @@ void NavigationStyle::reorientCamera(SoCamera* camera, const SbRotation& rotatio
camera->farDistance = 2 * boundingSphere.getRadius();
camera->focalDistance = camera->focalDistance.getValue() - repositionDistance;
}
#endif
}
void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane & panplane,
@@ -782,7 +786,10 @@ void NavigationStyle::doZoom(SoCamera* camera, float logfactor, const SbVec2f& p
// Rotation mode is WindowCenter
if (!rotationCenterMode) {
viewer->changeRotationCenterPosition(getFocalPoint());
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
findBoundingSphere();
#endif
}
}
}
@@ -1405,7 +1412,11 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
// first starting a drag operation.
animator->stop();
viewer->showRotationCenter(true);
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
findBoundingSphere();
#endif
this->spinprojector->project(this->lastmouseposition);
this->interactiveCountInc();
this->clearLog();

View File

@@ -152,7 +152,11 @@ public:
SoCamera* getCamera() const;
void setCameraOrientation(const SbRotation& orientation, SbBool moveToCenter = false);
void translateCamera(const SbVec3f& translation);
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
void findBoundingSphere();
#endif
void reorientCamera(SoCamera* camera, const SbRotation& rotation);
void reorientCamera(SoCamera* camera, const SbRotation& rotation, const SbVec3f& rotationCenter);
@@ -284,7 +288,9 @@ private:
float sensitivity;
SbBool resetcursorpos;
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
SbSphere boundingSphere;
#endif
};
/** Sub-classes of this class appear in the preference dialog where users can

View File

@@ -1073,7 +1073,11 @@ void View3DInventorViewer::setEditingViewProvider(Gui::ViewProvider* vp, int Mod
{
this->editViewProvider = vp;
this->editViewProvider->setEditViewer(this, ModNum);
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
this->navigation->findBoundingSphere();
#endif
addEventCallback(SoEvent::getClassTypeId(), Gui::ViewProvider::eventCallback,this->editViewProvider);
}
@@ -1536,7 +1540,9 @@ void View3DInventorViewer::setSceneGraph(SoNode* root)
}
}
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
navigation->findBoundingSphere();
#endif
}
void View3DInventorViewer::savePicture(int width, int height, int sample, const QColor& bg, QImage& img) const