mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027793: Visualization - object drifts at zoom within Graphic3d_TMF_TriedronPers applied
Graphic3d_TransformPers now takes Graphic3d_Camera definition as argument for methods applying transformation. Graphic3d_TransformPers::Apply() now computes Graphic3d_TMF_TriedronPers transformation in the following way: - The object is moved onto Z focus distance. - The object is expected to be defined in pixels. - The Z coordinate on anchor point is used as offset from the view corner in pixels. - It is now possible to define not only corners of the view, but also middle of the side. - Graphic3d_TMF_TriedronPers now works with perspective projection. OpenGl_LayerList::ChangeLayer() - fixed removing of the element in old ZLayer. OpenGl_Layer::BoundingBox() now takes into account bounding box of Graphic3d_TMF_TriedronPers presentations for Z-fit operation.
This commit is contained in:
@@ -35,6 +35,7 @@ SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
|
||||
//=======================================================================
|
||||
void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
myCamera = theCamera;
|
||||
myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
|
||||
myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix());
|
||||
myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
|
||||
@@ -51,6 +52,7 @@ void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
|
||||
const Standard_Integer theIsOrthographic,
|
||||
const Graphic3d_WorldViewProjState& theWVPState)
|
||||
{
|
||||
myCamera.Nullify();
|
||||
myBuilder->SetWorldViewMatrix (theWorldView);
|
||||
myBuilder->SetProjectionMatrix (theProjection);
|
||||
myBuilder->SetWorldViewProjState (theWVPState);
|
||||
|
@@ -48,6 +48,9 @@ public:
|
||||
|
||||
virtual ~SelectMgr_BaseFrustum() {}
|
||||
|
||||
//! Return camera definition.
|
||||
const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
|
||||
|
||||
//! Passes camera projection and orientation matrices to builder
|
||||
Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
|
||||
|
||||
@@ -173,6 +176,7 @@ protected:
|
||||
Standard_Boolean myIsOrthographic; //!< Defines if current camera is orthographic
|
||||
|
||||
Handle(SelectMgr_FrustumBuilder) myBuilder; //!< A tool implementing methods for volume build
|
||||
Handle(Graphic3d_Camera) myCamera; //!< camera definition
|
||||
};
|
||||
|
||||
#endif // _SelectMgr_BaseFrustum_HeaderFile
|
||||
|
@@ -117,7 +117,8 @@ Standard_Boolean SelectMgr_SelectableObjectTrsfPersSet::Remove (const Handle(Sel
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const NCollection_Handle<BVH_Tree<Standard_Real, 3> >&
|
||||
SelectMgr_SelectableObjectTrsfPersSet::BVH (const Graphic3d_Mat4d& theProjectionMatrix,
|
||||
SelectMgr_SelectableObjectTrsfPersSet::BVH (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMatrix,
|
||||
const Graphic3d_Mat4d& theWorldViewMatrix,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight,
|
||||
@@ -141,7 +142,7 @@ const NCollection_Handle<BVH_Tree<Standard_Real, 3> >&
|
||||
anObject->BoundingBox (aBoundingBox);
|
||||
if (!aBoundingBox.IsVoid())
|
||||
{
|
||||
anObject->TransformPersistence().Apply (theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, aBoundingBox);
|
||||
anObject->TransformPersistence().Apply (theCamera, theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, aBoundingBox);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,8 @@ public:
|
||||
}
|
||||
|
||||
//! Returns BVH tree for the given world view projection (builds it if necessary).
|
||||
Standard_EXPORT const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& BVH (const Graphic3d_Mat4d& theProjectionMatrix,
|
||||
Standard_EXPORT const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& BVH (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMatrix,
|
||||
const Graphic3d_Mat4d& theWorldViewMatrix,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight,
|
||||
|
@@ -53,6 +53,9 @@ public:
|
||||
|
||||
Standard_EXPORT void SetActiveSelectionType (const SelectionType& theType);
|
||||
|
||||
//! Returns current camera definition.
|
||||
const Handle(Graphic3d_Camera)& Camera() const { return mySelectingVolumes[Frustum]->Camera(); }
|
||||
|
||||
//! Updates camera projection and orientation matrices in all selecting volumes
|
||||
Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera) theCamera);
|
||||
|
||||
|
@@ -333,7 +333,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
|
||||
|
||||
gp_GTrsf aTPers;
|
||||
Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (aProjection, aWorldView, aViewportWidth, aViewportHeight);
|
||||
Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (mySelectingVolumeMgr.Camera(), aProjection, aWorldView, aViewportWidth, aViewportHeight);
|
||||
aTPers.SetValue (1, 1, aMat.GetValue (0, 0));
|
||||
aTPers.SetValue (1, 2, aMat.GetValue (0, 1));
|
||||
aTPers.SetValue (1, 3, aMat.GetValue (0, 2));
|
||||
@@ -449,7 +449,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
Standard_Integer aViewportWidth;
|
||||
Standard_Integer aViewportHeight;
|
||||
mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
|
||||
aBVHTree = mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
|
||||
aBVHTree = mySelectableObjectsTrsfPers.BVH (mySelectingVolumeMgr.Camera(), aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -888,7 +888,7 @@ void SelectMgr_ViewerSelector::RebuildObjectsTree (const Standard_Boolean theIsF
|
||||
mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
|
||||
|
||||
mySelectableObjects.BVH();
|
||||
mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
|
||||
mySelectableObjectsTrsfPers.BVH (mySelectingVolumeMgr.Camera(), aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user