mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0033551: Visualization - Add new transform persistence mode to force orthographic projection on object.
The new transform persistence mode, with flag `Graphic3d_TMF_OrthoPers`, can be combined (bitwise OR operation) with the other persistence modes (2D, Trihedron or Zoom/Rotate Persistence) to make objects be rendered with orthographic projection when it is on a view with perspective projection. If the view already uses orthographic projection, there will be no difference. This feature was implemented to fix ViewCube being distorted when view with perspective projection changes size.
This commit is contained in:
@@ -93,6 +93,24 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_AxisIntersector::ScaleAndTransform (
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CopyWithBuilder
|
||||
// purpose : Returns a copy of the frustum using the given frustum builder configuration.
|
||||
// Returned frustum should be re-constructed before being used.
|
||||
//=======================================================================
|
||||
Handle(SelectMgr_BaseIntersector) SelectMgr_AxisIntersector::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
|
||||
{
|
||||
(void )theBuilder;
|
||||
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
|
||||
"Error! SelectMgr_AxisIntersector::CopyWithBuilder() should be called after selection axis initialization");
|
||||
|
||||
Handle(SelectMgr_AxisIntersector) aRes = new SelectMgr_AxisIntersector();
|
||||
aRes->myAxis = myAxis;
|
||||
aRes->mySelectionType = mySelectionType;
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : hasIntersection
|
||||
// purpose :
|
||||
|
@@ -52,6 +52,11 @@ public:
|
||||
const gp_GTrsf& theTrsf,
|
||||
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns a copy of the intersector transformed using the builder configuration given.
|
||||
//! Builder is an argument that represents corresponding settings for re-constructing transformed frustum from scratch.
|
||||
//! In this class, builder is not used and theBuilder parameter is ignored.
|
||||
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Intersection test between defined axis and given axis-aligned box
|
||||
|
@@ -71,6 +71,11 @@ public:
|
||||
const gp_GTrsf& theTrsf,
|
||||
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0;
|
||||
|
||||
//! @param theBuilder [in] argument that represents corresponding settings for re-constructing transformed frustum from scratch;
|
||||
//! should NOT be NULL.
|
||||
//! @return a copy of the frustum with the input builder assigned
|
||||
virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Return camera definition.
|
||||
|
@@ -449,6 +449,28 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_RectangularFrustum::ScaleAndTransfor
|
||||
return aRes;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : CopyWithBuilder
|
||||
// purpose : Returns a copy of the frustum using the given frustum builder configuration.
|
||||
// Returned frustum should be re-constructed before being used.
|
||||
// =======================================================================
|
||||
Handle(SelectMgr_BaseIntersector) SelectMgr_RectangularFrustum::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
|
||||
{
|
||||
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point || mySelectionType == SelectMgr_SelectionType_Box,
|
||||
"Error! SelectMgr_RectangularFrustum::CopyWithBuilder() should be called after selection frustum initialization");
|
||||
|
||||
Standard_ASSERT_RAISE (!theBuilder.IsNull(),
|
||||
"Error! SelectMgr_RectangularFrustum::CopyWithBuilder() should be called with valid builder");
|
||||
|
||||
Handle(SelectMgr_RectangularFrustum) aRes = new SelectMgr_RectangularFrustum();
|
||||
aRes->mySelectionType = mySelectionType;
|
||||
aRes->mySelRectangle = mySelRectangle;
|
||||
aRes->myPixelTolerance = myPixelTolerance;
|
||||
aRes->SetBuilder (theBuilder);
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsScalable
|
||||
// purpose :
|
||||
|
@@ -99,6 +99,13 @@ public:
|
||||
const gp_GTrsf& theTrsf,
|
||||
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns a copy of the frustum using the given frustum builder configuration.
|
||||
//! Returned frustum should be re-constructed before being used.
|
||||
//! @param theBuilder [in] argument that represents corresponding settings for re-constructing transformed frustum from scratch;
|
||||
//! should NOT be NULL.
|
||||
//! @return a copy of the frustum with the input builder assigned
|
||||
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
// SAT Tests for different objects
|
||||
|
||||
//! SAT intersection test between defined volume and given axis-aligned box
|
||||
|
@@ -241,17 +241,23 @@ namespace
|
||||
//=============================================================================
|
||||
SelectMgr_SelectableObjectSet::SelectMgr_SelectableObjectSet()
|
||||
{
|
||||
myBVH[BVHSubset_2dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_3dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_3d] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_ortho2dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_ortho3dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_2dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_3dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_3d] = new BVH_Tree<Standard_Real, 3>();
|
||||
|
||||
myBuilder[BVHSubset_2dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
|
||||
myBuilder[BVHSubset_3dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
|
||||
myBuilder[BVHSubset_3d] = new BVH_BinnedBuilder<Standard_Real, 3, 4> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth, Standard_True);
|
||||
myBuilder[BVHSubset_ortho2dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
|
||||
myBuilder[BVHSubset_ortho3dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
|
||||
myBuilder[BVHSubset_2dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
|
||||
myBuilder[BVHSubset_3dPersistent] = new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth);
|
||||
myBuilder[BVHSubset_3d] = new BVH_BinnedBuilder<Standard_Real, 3, 4> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth, Standard_True);
|
||||
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_3dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_3d] = Standard_False;
|
||||
myIsDirty[BVHSubset_ortho2dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_ortho3dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_3dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_3d] = Standard_False;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@@ -262,10 +268,9 @@ Standard_Boolean SelectMgr_SelectableObjectSet::Append (const Handle(SelectMgr_S
|
||||
{
|
||||
// get an appropriate BVH subset to insert the object into it
|
||||
const Standard_Integer aSubsetIdx = appropriateSubset (theObject);
|
||||
|
||||
|
||||
// check that the object is excluded from other subsets
|
||||
if (myObjects[(aSubsetIdx + 1) % BVHSubsetNb].Contains (theObject)
|
||||
|| myObjects[(aSubsetIdx + 2) % BVHSubsetNb].Contains (theObject))
|
||||
if (currentSubset (theObject) != -1)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -401,9 +406,51 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
|
||||
myBuilder[BVHSubset_2dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_2dPersistent].get(), anAdaptor.Box());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// check and update 3D orthographic persistence BVH tree if necessary
|
||||
// -------------------------------------------------------------------
|
||||
if (!IsEmpty (BVHSubset_ortho3dPersistent)
|
||||
&& (myIsDirty[BVHSubset_ortho3dPersistent]
|
||||
|| myLastViewState.IsChanged (aViewState)
|
||||
|| isWinSizeChanged))
|
||||
{
|
||||
Handle(Graphic3d_Camera) aNewOrthoCam = new Graphic3d_Camera (*theCam); // If OrthoPers, copy camera and set to orthographic projection
|
||||
aNewOrthoCam->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
|
||||
|
||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
||||
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_ortho3dPersistent],
|
||||
aNewOrthoCam, aNewOrthoCam->ProjectionMatrix(),
|
||||
aNewOrthoCam->OrientationMatrix(), theWinSize);
|
||||
|
||||
// update corresponding BVH tree data structure
|
||||
myBuilder[BVHSubset_ortho3dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_ortho3dPersistent].get(), anAdaptor.Box());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// check and update 2D orthographic persistence BVH tree if necessary
|
||||
// -------------------------------------------------------------------
|
||||
if (!IsEmpty (BVHSubset_ortho2dPersistent)
|
||||
&& (myIsDirty[BVHSubset_ortho2dPersistent]
|
||||
|| myLastViewState.IsProjectionChanged (aViewState)
|
||||
|| isWinSizeChanged))
|
||||
{
|
||||
Handle(Graphic3d_Camera) aNewOrthoCam = new Graphic3d_Camera (*theCam); // If OrthoPers, copy camera and set to orthographic projection
|
||||
aNewOrthoCam->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
|
||||
|
||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
||||
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_ortho2dPersistent],
|
||||
aNewOrthoCam, aNewOrthoCam->ProjectionMatrix(),
|
||||
SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theWinSize);
|
||||
|
||||
// update corresponding BVH tree data structure
|
||||
myBuilder[BVHSubset_ortho2dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_ortho2dPersistent].get(), anAdaptor.Box());
|
||||
}
|
||||
|
||||
// release dirty state for every subset
|
||||
myIsDirty[BVHSubset_3dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_3dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_ortho3dPersistent] = Standard_False;
|
||||
myIsDirty[BVHSubset_ortho2dPersistent] = Standard_False;
|
||||
|
||||
// keep last view state
|
||||
myLastViewState = aViewState;
|
||||
@@ -419,9 +466,11 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
|
||||
//=============================================================================
|
||||
void SelectMgr_SelectableObjectSet::MarkDirty()
|
||||
{
|
||||
myIsDirty[BVHSubset_3d] = Standard_True;
|
||||
myIsDirty[BVHSubset_3dPersistent] = Standard_True;
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_True;
|
||||
myIsDirty[BVHSubset_3d] = Standard_True;
|
||||
myIsDirty[BVHSubset_3dPersistent] = Standard_True;
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_True;
|
||||
myIsDirty[BVHSubset_ortho3dPersistent] = Standard_True;
|
||||
myIsDirty[BVHSubset_ortho2dPersistent] = Standard_True;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : DumpJson
|
||||
|
@@ -42,11 +42,22 @@ public:
|
||||
//! needs to be updated only when camera's projection changes. Bounding volumes for this object subclass
|
||||
//! is represented directly in eye space coordinates.
|
||||
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
|
||||
//! - BVHSubset_ortho3dPersistent refers to the subset of 3D persistent selectable objects (rotate, pan, zoom persistence)
|
||||
//! that contains `Graphic3d_TMF_OrthoPers` persistence mode.
|
||||
//! Associated BVH tree needs to be updated when either the camera's projection and position change.
|
||||
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
|
||||
//! - BVHSubset_ortho2dPersistent refers to the subset of 2D persistent selectable objects
|
||||
//! that contains `Graphic3d_TMF_OrthoPers` persistence mode. Associated BVH tree
|
||||
//! needs to be updated only when camera's projection changes. Bounding volumes for this object subclass
|
||||
//! is represented directly in eye space coordinates.
|
||||
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
|
||||
enum BVHSubset
|
||||
{
|
||||
BVHSubset_3d,
|
||||
BVHSubset_3dPersistent,
|
||||
BVHSubset_2dPersistent,
|
||||
BVHSubset_ortho3dPersistent,
|
||||
BVHSubset_ortho2dPersistent,
|
||||
BVHSubsetNb
|
||||
};
|
||||
|
||||
@@ -140,7 +151,9 @@ public:
|
||||
{
|
||||
return myObjects[BVHSubset_3d].Contains (theObject)
|
||||
|| myObjects[BVHSubset_3dPersistent].Contains (theObject)
|
||||
|| myObjects[BVHSubset_2dPersistent].Contains (theObject);
|
||||
|| myObjects[BVHSubset_2dPersistent].Contains (theObject)
|
||||
|| myObjects[BVHSubset_ortho3dPersistent].Contains (theObject)
|
||||
|| myObjects[BVHSubset_ortho2dPersistent].Contains (theObject);
|
||||
}
|
||||
|
||||
//! Returns true if the object set does not contain any selectable objects.
|
||||
@@ -148,7 +161,9 @@ public:
|
||||
{
|
||||
return myObjects[BVHSubset_3d].IsEmpty()
|
||||
&& myObjects[BVHSubset_3dPersistent].IsEmpty()
|
||||
&& myObjects[BVHSubset_2dPersistent].IsEmpty();
|
||||
&& myObjects[BVHSubset_2dPersistent].IsEmpty()
|
||||
&& myObjects[BVHSubset_ortho3dPersistent].IsEmpty()
|
||||
&& myObjects[BVHSubset_ortho2dPersistent].IsEmpty();
|
||||
}
|
||||
|
||||
//! Returns true if the specified object subset is empty.
|
||||
@@ -192,10 +207,18 @@ private:
|
||||
}
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_3d;
|
||||
}
|
||||
else if (theObject->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
|
||||
else if ((theObject->TransformPersistence()->Mode() & Graphic3d_TMF_2d) != 0)
|
||||
{
|
||||
if (theObject->TransformPersistence()->IsOrthoPers())
|
||||
{
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_ortho2dPersistent;
|
||||
}
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent;
|
||||
}
|
||||
else if (theObject->TransformPersistence()->IsOrthoPers())
|
||||
{
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_ortho3dPersistent;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_3dPersistent;
|
||||
|
@@ -67,6 +67,28 @@ SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTrans
|
||||
return aMgr;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CopyWithBuilder
|
||||
// purpose : Returns a copy of the selecting volume manager and its active frustum re-constructed using the passed builder.
|
||||
// Builder is an argument that represents corresponding settings for re-constructing transformed
|
||||
// frustum from scratch.
|
||||
//=======================================================================
|
||||
SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
|
||||
{
|
||||
SelectMgr_SelectingVolumeManager aMgr;
|
||||
aMgr.myToAllowOverlap = myToAllowOverlap;
|
||||
aMgr.myViewClipPlanes = myViewClipPlanes;
|
||||
aMgr.myObjectClipPlanes = myObjectClipPlanes;
|
||||
aMgr.myViewClipRange = myViewClipRange;
|
||||
if (!myActiveSelectingVolume.IsNull())
|
||||
{
|
||||
aMgr.myActiveSelectingVolume = myActiveSelectingVolume->CopyWithBuilder (theBuilder);
|
||||
aMgr.BuildSelectingVolume();
|
||||
}
|
||||
|
||||
return aMgr;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetActiveSelectionType
|
||||
// purpose :
|
||||
|
@@ -81,6 +81,11 @@ public:
|
||||
const gp_GTrsf& theTrsf,
|
||||
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const;
|
||||
|
||||
//! Returns a copy of the selecting volume manager and its active frustum re-constructed using the passed builder.
|
||||
//! Builder is an argument that represents corresponding settings for re-constructing transformed
|
||||
//! frustum from scratch.
|
||||
Standard_EXPORT virtual SelectMgr_SelectingVolumeManager CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns current camera definition.
|
||||
|
@@ -189,6 +189,20 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CopyWithBuilder
|
||||
// purpose : Returns a copy of the frustum using the given frustum builder configuration.
|
||||
// Returned frustum should be re-constructed before being used.
|
||||
//=======================================================================
|
||||
Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
|
||||
{
|
||||
Handle(SelectMgr_TriangularFrustum) aRes = new SelectMgr_TriangularFrustum();
|
||||
aRes->mySelTriangle = mySelTriangle;
|
||||
aRes->SetBuilder (theBuilder);
|
||||
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : OverlapsBox
|
||||
// purpose : SAT intersection test between defined volume and
|
||||
|
@@ -55,6 +55,13 @@ public:
|
||||
const gp_GTrsf& theTrsf,
|
||||
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns a copy of the frustum using the given frustum builder configuration.
|
||||
//! Returned frustum should be re-constructed before being used.
|
||||
//! @param theBuilder [in] argument that represents corresponding settings for re-constructing transformed frustum from scratch;
|
||||
//! should NOT be NULL.
|
||||
//! @return a copy of the frustum with the input builder assigned
|
||||
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
public: //! @name SAT Tests for different objects
|
||||
|
||||
//! SAT intersection test between defined volume and given axis-aligned box
|
||||
|
@@ -186,6 +186,32 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustumSet::ScaleAndTransf
|
||||
return aRes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CopyWithBuilder
|
||||
// purpose : Returns a copy of the frustum using the given frustum builder configuration.
|
||||
// Returned frustum should be re-constructed before being used.
|
||||
//=======================================================================
|
||||
Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustumSet::CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
|
||||
{
|
||||
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Polyline,
|
||||
"Error! SelectMgr_TriangularFrustumSet::CopyWithBuilder() should be called after selection frustum initialization");
|
||||
|
||||
Standard_ASSERT_RAISE (!theBuilder.IsNull(),
|
||||
"Error! SelectMgr_TriangularFrustumSet::CopyWithBuilder() should be called with valid builder");
|
||||
|
||||
Handle(SelectMgr_TriangularFrustumSet) aRes = new SelectMgr_TriangularFrustumSet();
|
||||
aRes->SetCamera (myCamera);
|
||||
for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next())
|
||||
{
|
||||
aRes->myFrustums.Append (Handle(SelectMgr_TriangularFrustum)::DownCast (anIter.Value()->CopyWithBuilder (theBuilder)));
|
||||
}
|
||||
aRes->mySelectionType = mySelectionType;
|
||||
aRes->mySelPolyline = mySelPolyline;
|
||||
aRes->myToAllowOverlap = myToAllowOverlap;
|
||||
aRes->SetBuilder (theBuilder);
|
||||
return aRes;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OverlapsBox
|
||||
// purpose :
|
||||
|
@@ -62,6 +62,13 @@ public:
|
||||
const gp_GTrsf& theTrsf,
|
||||
const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns a copy of the frustum using the given frustum builder configuration.
|
||||
//! Returned frustum should be re-constructed before being used.
|
||||
//! @param theBuilder [in] argument that represents corresponding settings for re-constructing transformed frustum from scratch;
|
||||
//! should NOT be NULL.
|
||||
//! @return a copy of the frustum with the input builder assigned
|
||||
Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt,
|
||||
|
@@ -138,12 +138,12 @@ void SelectMgr_ViewerSelector::updatePoint3d (SelectMgr_SortCriterion& theCriter
|
||||
case SelectMgr_TypeOfDepthTolerance_UniformPixels:
|
||||
case SelectMgr_TypeOfDepthTolerance_SensitivityFactor:
|
||||
{
|
||||
if (mySelectingVolumeMgr.Camera().IsNull())
|
||||
if (theMgr.Camera().IsNull())
|
||||
{
|
||||
// fallback for an arbitrary projection matrix
|
||||
theCriterion.Tolerance = aSensFactor / 33.0;
|
||||
}
|
||||
else if (mySelectingVolumeMgr.Camera()->IsOrthographic())
|
||||
else if (theMgr.Camera()->IsOrthographic())
|
||||
{
|
||||
theCriterion.Tolerance = myCameraScale * aSensFactor;
|
||||
}
|
||||
@@ -634,6 +634,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives (const Standard_Integer theVie
|
||||
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
mySelectingVolumeMgr.WindowSize (aWinSize.x(), aWinSize.y());
|
||||
const double aPixelSize = Max (1.0 / aWinSize.x(), 1.0 / aWinSize.y());
|
||||
|
||||
const Handle(Graphic3d_Camera)& aCamera = mySelectingVolumeMgr.Camera();
|
||||
Graphic3d_Mat4d aProjectionMat, aWorldViewMat;
|
||||
@@ -646,11 +647,6 @@ void SelectMgr_ViewerSelector::TraverseSensitives (const Standard_Integer theVie
|
||||
|
||||
myCameraEye = aCamera->Eye().XYZ();
|
||||
myCameraDir = aCamera->Direction().XYZ();
|
||||
myCameraScale = aCamera->IsOrthographic()
|
||||
? aCamera->Scale()
|
||||
: 2.0 * Tan (aCamera->FOVy() * M_PI / 360.0);
|
||||
const double aPixelSize = Max (1.0 / aWinSize.x(), 1.0 / aWinSize.y());
|
||||
myCameraScale *= aPixelSize;
|
||||
}
|
||||
mySelectableObjects.UpdateBVH (aCamera, aWinSize);
|
||||
|
||||
@@ -672,7 +668,8 @@ void SelectMgr_ViewerSelector::TraverseSensitives (const Standard_Integer theVie
|
||||
// for 2D space selection transform selecting volumes to perform overlap testing
|
||||
// directly in camera's eye space omitting the camera position, which is not
|
||||
// needed there at all
|
||||
if (aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent)
|
||||
if (aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent
|
||||
|| aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_ortho2dPersistent)
|
||||
{
|
||||
gp_GTrsf aTFrustum;
|
||||
aTFrustum.SetValue (1, 1, aWorldViewMat.GetValue (0, 0));
|
||||
@@ -688,22 +685,43 @@ void SelectMgr_ViewerSelector::TraverseSensitives (const Standard_Integer theVie
|
||||
aWorldViewMat.GetValue (1, 3),
|
||||
aWorldViewMat.GetValue (2, 3)));
|
||||
|
||||
// define corresponding frustum builder parameters
|
||||
// define corresponding frustum builder parameters for 2d persistence.
|
||||
Handle(SelectMgr_FrustumBuilder) aBuilder = new SelectMgr_FrustumBuilder();
|
||||
Handle(Graphic3d_Camera) aNewCamera = new Graphic3d_Camera();
|
||||
aNewCamera->CopyMappingData (aCamera);
|
||||
aNewCamera->SetIdentityOrientation();
|
||||
if (aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_ortho2dPersistent)
|
||||
{
|
||||
aNewCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
|
||||
}
|
||||
aWorldViewMat = aNewCamera->OrientationMatrix(); // should be identity matrix
|
||||
aProjectionMat = aNewCamera->ProjectionMatrix(); // should be the same to aProjectionMat
|
||||
aBuilder->SetCamera (aNewCamera);
|
||||
aBuilder->SetWindowSize (aWinSize.x(), aWinSize.y());
|
||||
aMgr = mySelectingVolumeMgr.ScaleAndTransform (1, aTFrustum, aBuilder);
|
||||
}
|
||||
else if (aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_ortho3dPersistent)
|
||||
{
|
||||
// define corresponding frustum builder parameters for 3d orthographic persistence.
|
||||
Handle(SelectMgr_FrustumBuilder) aBuilder = new SelectMgr_FrustumBuilder();
|
||||
Handle(Graphic3d_Camera) aNewCamera = new Graphic3d_Camera (*aCamera);
|
||||
aNewCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
|
||||
aWorldViewMat = aNewCamera->OrientationMatrix(); // should be the same to aWorldViewMat
|
||||
aProjectionMat = aNewCamera->ProjectionMatrix(); // should be orthographic projection
|
||||
aBuilder->SetCamera (aNewCamera);
|
||||
aBuilder->SetWindowSize (aWinSize.x(), aWinSize.y());
|
||||
aMgr = mySelectingVolumeMgr.CopyWithBuilder (aBuilder);
|
||||
}
|
||||
else
|
||||
{
|
||||
aMgr = mySelectingVolumeMgr;
|
||||
}
|
||||
|
||||
myCameraScale = aMgr.Camera()->IsOrthographic()
|
||||
? aMgr.Camera()->Scale()
|
||||
: 2.0 * Tan (aMgr.Camera()->FOVy() * M_PI / 360.0);
|
||||
myCameraScale *= aPixelSize;
|
||||
|
||||
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& aBVHTree = mySelectableObjects.BVH (aBVHSubset);
|
||||
|
||||
Standard_Integer aNode = 0;
|
||||
|
@@ -328,7 +328,7 @@ protected:
|
||||
//! @param theObject [in] the selectable object for traversal.
|
||||
//! @param theMgr [in] the (un)transformed copy of the selecting volume manager representing active selection frustum.
|
||||
//! @param theCamera, theProjectionMat, theWorldViewMat [in] the source camera and matrices for theMgr given.
|
||||
//! @param theViewportWidth, theViewportHeight [in] viewport (window) dimensions for evaluating
|
||||
//! @param theWinSize [in] viewport (window) dimensions for evaluating
|
||||
//! object's transformation persistence.
|
||||
Standard_EXPORT void traverseObject (const Handle(SelectMgr_SelectableObject)& theObject,
|
||||
const SelectMgr_SelectingVolumeManager& theMgr,
|
||||
|
Reference in New Issue
Block a user