mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-02 17:46:22 +03:00
0032390: Visualization, SelectMgr_FrustumBuilder - use camera instead of duplicated methods
Fix incorrect value of axis intersection with segment inside of SelectMgr_AxisIntersector::raySegmentDistance(). Move camera definition to base intersector (it is not possible to set it for axis intersector, is is not applicable). Add method Graphic3d_Camera::SetIdentityOrientation() to set camera parameters to make current orientation matrix identity one. Remove all matrices from selection intersectors and frustum builder and use camera instead of them. Fix missed axis tests in vselect grid.
This commit is contained in:
parent
4db6d89bc6
commit
51d4a4f9d0
@ -200,6 +200,16 @@ void Graphic3d_Camera::Copy (const Handle(Graphic3d_Camera)& theOther)
|
||||
CopyOrientationData (theOther);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetIdentityOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Camera::SetIdentityOrientation()
|
||||
{
|
||||
SetEyeAndCenter (gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(0.0, 0.0, -1.0));
|
||||
SetUp (gp_Dir(0.0, 1.0, 0.0));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : MoveEyeTo
|
||||
// purpose :
|
||||
|
@ -489,6 +489,9 @@ public:
|
||||
//! @param theTile tile definition
|
||||
Standard_EXPORT void SetTile (const Graphic3d_CameraTile& theTile);
|
||||
|
||||
//! Sets camera parameters to make current orientation matrix identity one.
|
||||
Standard_EXPORT void SetIdentityOrientation();
|
||||
|
||||
//! @name Basic camera operations
|
||||
public:
|
||||
|
||||
|
@ -55,6 +55,14 @@ void SelectMgr_AxisIntersector::Build()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetCamera
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_AxisIntersector::SetCamera (const Handle(Graphic3d_Camera)&)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ScaleAndTransform
|
||||
// purpose :
|
||||
@ -156,7 +164,7 @@ Standard_Boolean SelectMgr_AxisIntersector::raySegmentDistance (const gp_Pnt& th
|
||||
return false;
|
||||
}
|
||||
|
||||
const Standard_Real aParam = anUWNormVec.Dot (anUVNormVec) / anUVNormVecMod;
|
||||
const Standard_Real aParam = anUWNormVec.Dot (anUVNormVec) / anUVNormVec.SquareModulus();
|
||||
if (aParam < 0.0)
|
||||
{
|
||||
// Intersection is out of axis start point
|
||||
|
@ -37,6 +37,10 @@ public:
|
||||
//! NOTE: it should be called after Init() method
|
||||
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
|
||||
|
||||
//! Saves camera definition.
|
||||
//! Do nothing for axis intersector (not applicable to this volume).
|
||||
Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
|
||||
|
||||
//! Returns FALSE (not applicable to this volume).
|
||||
virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; }
|
||||
|
||||
|
@ -26,70 +26,23 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector)
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
|
||||
: myPixelTolerance (2),
|
||||
myIsOrthographic (Standard_True)
|
||||
: myPixelTolerance (2)
|
||||
{
|
||||
myBuilder = new SelectMgr_FrustumBuilder();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetCamera
|
||||
// purpose : Passes camera projection and orientation matrices to builder
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
myCamera = theCamera;
|
||||
myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
|
||||
myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix(), theCamera->IsZeroToOneDepth());
|
||||
myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
|
||||
myIsOrthographic = theCamera->IsOrthographic();
|
||||
myBuilder->InvalidateViewport();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetCamera
|
||||
// purpose : Passes camera projection and orientation matrices to builder
|
||||
//=======================================================================
|
||||
void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
|
||||
const Graphic3d_Mat4d& theWorldView,
|
||||
const Standard_Boolean theIsOrthographic,
|
||||
const Graphic3d_WorldViewProjState& theWVPState)
|
||||
{
|
||||
myCamera.Nullify();
|
||||
myBuilder->SetWorldViewMatrix (theWorldView);
|
||||
myBuilder->SetProjectionMatrix (theProjection, false);
|
||||
myBuilder->SetWorldViewProjState (theWVPState);
|
||||
myIsOrthographic = theIsOrthographic;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ProjectionMatrix
|
||||
// purpose : Returns current camera projection transformation common for
|
||||
// all selecting volumes
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_BaseFrustum::ProjectionMatrix() const
|
||||
{
|
||||
return myBuilder->ProjectionMatrix();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewMatrix
|
||||
// purpose : Returns current camera world view transformation common for
|
||||
// all selecting volumes
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_BaseFrustum::WorldViewMatrix() const
|
||||
{
|
||||
return myBuilder->WorldViewMatrix();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewProjState
|
||||
// purpose : Returns current camera world view projection transformation
|
||||
// state
|
||||
//=======================================================================
|
||||
const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const
|
||||
{
|
||||
return myBuilder->WorldViewProjState();
|
||||
SelectMgr_BaseIntersector::SetCamera (theCamera);
|
||||
if (!myBuilder.IsNull())
|
||||
{
|
||||
myBuilder->SetCamera (theCamera);
|
||||
myBuilder->InvalidateViewport();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -140,6 +93,10 @@ void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)&
|
||||
{
|
||||
myBuilder.Nullify();
|
||||
myBuilder = theBuilder;
|
||||
if (!myBuilder.IsNull())
|
||||
{
|
||||
myCamera = myBuilder->Camera();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -152,7 +109,5 @@ void SelectMgr_BaseFrustum::DumpJson (Standard_OStream& theOStream, Standard_Int
|
||||
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_BaseIntersector)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)
|
||||
}
|
||||
|
@ -37,27 +37,9 @@ public:
|
||||
//! Nullifies the builder created in the constructor and copies the pointer given
|
||||
Standard_EXPORT void SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder);
|
||||
|
||||
//! Return camera definition.
|
||||
virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
|
||||
|
||||
//! Passes camera projection and orientation matrices to builder
|
||||
//! Saves camera definition and passes it to builder
|
||||
Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
|
||||
|
||||
//! Passes camera projection and orientation matrices to builder
|
||||
Standard_EXPORT virtual void SetCamera (const Graphic3d_Mat4d& theProjection,
|
||||
const Graphic3d_Mat4d& theWorldView,
|
||||
const Standard_Boolean theIsOrthographic,
|
||||
const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState()) Standard_OVERRIDE;
|
||||
|
||||
//! @return current camera projection transformation common for all selecting volumes
|
||||
Standard_EXPORT virtual const Graphic3d_Mat4d& ProjectionMatrix() const Standard_OVERRIDE;
|
||||
|
||||
//! @return current camera world view transformation common for all selecting volumes
|
||||
Standard_EXPORT virtual const Graphic3d_Mat4d& WorldViewMatrix() const Standard_OVERRIDE;
|
||||
|
||||
//! @return current camera world view projection transformation state
|
||||
Standard_EXPORT virtual const Graphic3d_WorldViewProjState& WorldViewProjState() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void SetPixelTolerance (const Standard_Integer theTol) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void SetWindowSize (const Standard_Integer theWidth,
|
||||
@ -78,11 +60,9 @@ public:
|
||||
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector)
|
||||
|
||||
protected:
|
||||
Standard_Integer myPixelTolerance; //!< Pixel tolerance
|
||||
Standard_Boolean myIsOrthographic; //!< Defines if current camera is orthographic
|
||||
Standard_Integer myPixelTolerance; //!< Pixel tolerance
|
||||
|
||||
Handle(SelectMgr_FrustumBuilder) myBuilder; //!< A tool implementing methods for volume build
|
||||
Handle(Graphic3d_Camera) myCamera; //!< camera definition
|
||||
};
|
||||
|
||||
#endif // _SelectMgr_BaseFrustum_HeaderFile
|
||||
|
@ -36,63 +36,13 @@ SelectMgr_BaseIntersector::~SelectMgr_BaseIntersector()
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Camera
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const Handle(Graphic3d_Camera)& SelectMgr_BaseIntersector::Camera() const
|
||||
{
|
||||
static const Handle(Graphic3d_Camera) anEmptyCamera;
|
||||
return anEmptyCamera;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetCamera
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_BaseIntersector::SetCamera (const Handle(Graphic3d_Camera)&)
|
||||
void SelectMgr_BaseIntersector::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetCamera
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_BaseIntersector::SetCamera (const Graphic3d_Mat4d&,
|
||||
const Graphic3d_Mat4d&,
|
||||
const Standard_Boolean,
|
||||
const Graphic3d_WorldViewProjState&)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ProjectionMatrix
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_BaseIntersector::ProjectionMatrix() const
|
||||
{
|
||||
static const Graphic3d_Mat4d anEmptyMatrix;
|
||||
return anEmptyMatrix;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewMatrix
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_BaseIntersector::WorldViewMatrix() const
|
||||
{
|
||||
static const Graphic3d_Mat4d anEmptyMatrix;
|
||||
return anEmptyMatrix;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewProjState
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const Graphic3d_WorldViewProjState& SelectMgr_BaseIntersector::WorldViewProjState() const
|
||||
{
|
||||
static const Graphic3d_WorldViewProjState anEmptyState;
|
||||
return anEmptyState;
|
||||
myCamera = theCamera;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -199,4 +149,5 @@ void SelectMgr_BaseIntersector::DumpJson (Standard_OStream& theOStream, Standard
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySelectionType)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)
|
||||
}
|
||||
|
@ -73,33 +73,12 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//! Returns camera definition.
|
||||
//! This method returns empty camera for the base class.
|
||||
Standard_EXPORT virtual const Handle(Graphic3d_Camera)& Camera() const;
|
||||
//! Return camera definition.
|
||||
const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
|
||||
|
||||
//! Sets camera projection and orientation matrices.
|
||||
//! This method does nothing for the base class.
|
||||
//! Saves camera definition.
|
||||
Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
|
||||
|
||||
//! Sets camera projection and orientation matrices.
|
||||
//! This method does nothing for the base class.
|
||||
Standard_EXPORT virtual void SetCamera (const Graphic3d_Mat4d& theProjection,
|
||||
const Graphic3d_Mat4d& theWorldView,
|
||||
const Standard_Boolean theIsOrthographic,
|
||||
const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState());
|
||||
|
||||
//! Returns current camera projection transformation.
|
||||
//! This method returns empty matrix for the base class.
|
||||
Standard_EXPORT virtual const Graphic3d_Mat4d& ProjectionMatrix() const;
|
||||
|
||||
//! Returns current camera world view transformation.
|
||||
//! This method returns empty matrix for the base class.
|
||||
Standard_EXPORT virtual const Graphic3d_Mat4d& WorldViewMatrix() const;
|
||||
|
||||
//! Returns current camera world view projection transformation state.
|
||||
//! This method returns empty matrix for the base class.
|
||||
Standard_EXPORT virtual const Graphic3d_WorldViewProjState& WorldViewProjState() const;
|
||||
|
||||
//! Returns current window size.
|
||||
//! This method doesn't set any output values for the base class.
|
||||
Standard_EXPORT virtual void WindowSize (Standard_Integer& theWidth,
|
||||
@ -209,7 +188,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
SelectMgr_SelectionType mySelectionType;
|
||||
Handle(Graphic3d_Camera) myCamera; //!< camera definition (if builder isn't NULL it is the same as its camera)
|
||||
SelectMgr_SelectionType mySelectionType; //!< type of selection
|
||||
};
|
||||
|
||||
#endif // _SelectMgr_BaseIntersector_HeaderFile
|
||||
|
@ -146,7 +146,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasBoxOverlap (const SelectMgr_Vec3& theM
|
||||
}
|
||||
}
|
||||
|
||||
const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1;
|
||||
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
|
||||
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor)
|
||||
{
|
||||
@ -182,7 +182,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasBoxOverlap (const SelectMgr_Vec3& theM
|
||||
// of vector with 1.0 at the position aDim and myEdgeDirs[aVolDir]
|
||||
const Standard_Integer aNext = (aDim + 1) % 3;
|
||||
const Standard_Integer aNextNext = (aDim + 2) % 3;
|
||||
for (Standard_Integer aVolDir = 0, aDirectionsNb = myIsOrthographic ? 4 : 6; aVolDir < aDirectionsNb; ++aVolDir)
|
||||
for (Standard_Integer aVolDir = 0, aDirectionsNb = Camera()->IsOrthographic() ? 4 : 6; aVolDir < aDirectionsNb; ++aVolDir)
|
||||
{
|
||||
gp_XYZ aDirection (DBL_MAX, DBL_MAX, DBL_MAX);
|
||||
aDirection.ChangeData()[aDim] = 0;
|
||||
@ -206,7 +206,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasBoxOverlap (const SelectMgr_Vec3& theM
|
||||
template <int N>
|
||||
Standard_Boolean SelectMgr_Frustum<N>::hasPointOverlap (const gp_Pnt& thePnt) const
|
||||
{
|
||||
const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1;
|
||||
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
|
||||
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor)
|
||||
{
|
||||
@ -234,7 +234,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasSegmentOverlap (const gp_Pnt& theStart
|
||||
if (aDir.Modulus() < Precision::Confusion())
|
||||
return Standard_True;
|
||||
|
||||
const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1;
|
||||
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor)
|
||||
{
|
||||
Standard_Real aMinSegm = RealLast(), aMaxSegm = RealFirst();
|
||||
@ -273,7 +273,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasSegmentOverlap (const gp_Pnt& theStart
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Integer aDirectionsNb = myIsOrthographic ? 4 : 6;
|
||||
Standard_Integer aDirectionsNb = Camera()->IsOrthographic() ? 4 : 6;
|
||||
for (Standard_Integer aEdgeDirIdx = 0; aEdgeDirIdx < aDirectionsNb; ++aEdgeDirIdx)
|
||||
{
|
||||
Standard_Real aMinSegm = DBL_MAX, aMaxSegm = -DBL_MAX;
|
||||
@ -338,7 +338,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasPolygonOverlap (const TColgp_Array1OfP
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1;
|
||||
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor)
|
||||
{
|
||||
Standard_Real aMaxF = RealFirst();
|
||||
@ -361,7 +361,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasPolygonOverlap (const TColgp_Array1OfP
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer aDirectionsNb = myIsOrthographic ? 4 : 6;
|
||||
Standard_Integer aDirectionsNb = Camera()->IsOrthographic() ? 4 : 6;
|
||||
for (Standard_Integer aPntsIter = 0, aLastIdx = anEndIdx - aStartIdx, aLen = theArrayOfPnts.Length(); aPntsIter <= aLastIdx; ++aPntsIter)
|
||||
{
|
||||
const gp_XYZ aSegmDir = theArrayOfPnts.Value ((aPntsIter + 1) % aLen + aStartIdx).XYZ()
|
||||
@ -413,7 +413,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasTriangleOverlap (const gp_Pnt& thePnt1
|
||||
thePnt3.XYZ() - thePnt2.XYZ(),
|
||||
thePnt1.XYZ() - thePnt3.XYZ() };
|
||||
|
||||
const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1;
|
||||
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor)
|
||||
{
|
||||
const gp_XYZ& aPlane = myPlanes[aPlaneIdx].XYZ();
|
||||
@ -446,7 +446,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasTriangleOverlap (const gp_Pnt& thePnt1
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Integer aDirectionsNb = myIsOrthographic ? 4 : 6;
|
||||
Standard_Integer aDirectionsNb = myCamera->IsOrthographic() ? 4 : 6;
|
||||
for (Standard_Integer aTriangleEdgeIdx = 0; aTriangleEdgeIdx < 3; ++aTriangleEdgeIdx)
|
||||
{
|
||||
for (Standard_Integer aVolDir = 0; aVolDir < aDirectionsNb; ++aVolDir)
|
||||
@ -472,7 +472,7 @@ void SelectMgr_Frustum<N>::DumpJson (Standard_OStream& theOStream, Standard_Inte
|
||||
{
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||
|
||||
const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1;
|
||||
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor)
|
||||
{
|
||||
const gp_Vec& aPlane = myPlanes[aPlaneIdx];
|
||||
@ -489,7 +489,6 @@ void SelectMgr_Frustum<N>::DumpJson (Standard_OStream& theOStream, Standard_Inte
|
||||
}
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)
|
||||
|
||||
|
@ -26,71 +26,20 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder,Standard_Transient)
|
||||
// purpose : Creates new frustum builder with empty matrices
|
||||
//=======================================================================
|
||||
SelectMgr_FrustumBuilder::SelectMgr_FrustumBuilder()
|
||||
: myWorldView(),
|
||||
myProjection(),
|
||||
myWorldViewProjState(),
|
||||
myWidth (INT_MAX),
|
||||
: myWidth (INT_MAX),
|
||||
myHeight (INT_MAX),
|
||||
myIsViewportSet (Standard_False),
|
||||
myIsZeroToOneDepth (Standard_False)
|
||||
myIsViewportSet (Standard_False)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetWorldViewMatrix
|
||||
// purpose : Stores current world view transformation matrix
|
||||
// function : SetCamera
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_FrustumBuilder::SetWorldViewMatrix (const Graphic3d_Mat4d& theWorldView)
|
||||
void SelectMgr_FrustumBuilder::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
myWorldView = theWorldView;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewMatrix
|
||||
// purpose : Returns current world view transformation matrix
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_FrustumBuilder::WorldViewMatrix() const
|
||||
{
|
||||
return myWorldView;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetProjectionMatrix
|
||||
// purpose : Stores current projection matrix
|
||||
//=======================================================================
|
||||
void SelectMgr_FrustumBuilder::SetProjectionMatrix (const Graphic3d_Mat4d& theProjection,
|
||||
const Standard_Boolean theIsZeroToOneDepth)
|
||||
{
|
||||
myProjection = theProjection;
|
||||
myIsZeroToOneDepth = theIsZeroToOneDepth;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ProjectionMatrix
|
||||
// purpose : Returns current projection matrix
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_FrustumBuilder::ProjectionMatrix() const
|
||||
{
|
||||
return myProjection;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetWorldViewProjState
|
||||
// purpose : Stores current world view projection matrix state
|
||||
//=======================================================================
|
||||
void SelectMgr_FrustumBuilder::SetWorldViewProjState (const Graphic3d_WorldViewProjState& theState)
|
||||
{
|
||||
myWorldViewProjState = theState;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewProjState
|
||||
// purpose : Returns current world view projection matrix state
|
||||
//=======================================================================
|
||||
const Graphic3d_WorldViewProjState& SelectMgr_FrustumBuilder::WorldViewProjState() const
|
||||
{
|
||||
return myWorldViewProjState;
|
||||
myCamera = theCamera;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -153,52 +102,6 @@ Standard_Real SelectMgr_FrustumBuilder::SignedPlanePntDist (const SelectMgr_Vec3
|
||||
return anA * thePnt.x() + aB * thePnt.y() + aC * thePnt.z();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : safePointCast
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
static NCollection_Vec4<Standard_Real> safePointCast (const gp_Pnt& thePnt)
|
||||
{
|
||||
Standard_Real aLim = 1e15f;
|
||||
|
||||
// have to deal with values greater then max float
|
||||
gp_Pnt aSafePoint = thePnt;
|
||||
const Standard_Real aBigFloat = aLim * 0.1f;
|
||||
if (Abs (aSafePoint.X()) > aLim)
|
||||
aSafePoint.SetX (aSafePoint.X() >= 0 ? aBigFloat : -aBigFloat);
|
||||
if (Abs (aSafePoint.Y()) > aLim)
|
||||
aSafePoint.SetY (aSafePoint.Y() >= 0 ? aBigFloat : -aBigFloat);
|
||||
if (Abs (aSafePoint.Z()) > aLim)
|
||||
aSafePoint.SetZ (aSafePoint.Z() >= 0 ? aBigFloat : -aBigFloat);
|
||||
|
||||
// convert point
|
||||
NCollection_Vec4<Standard_Real> aPnt (aSafePoint.X(), aSafePoint.Y(), aSafePoint.Z(), 1.0);
|
||||
|
||||
return aPnt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : unProject
|
||||
// purpose : Unprojects point from NDC coords to 3d world space
|
||||
//=======================================================================
|
||||
gp_Pnt SelectMgr_FrustumBuilder::unProject (const gp_Pnt& thePnt) const
|
||||
{
|
||||
// inversed matrices could be cached
|
||||
Graphic3d_Mat4d aInvView, aInvProj;
|
||||
if (!myWorldView.Inverted (aInvView) || !myProjection.Inverted (aInvProj))
|
||||
{
|
||||
return gp_Pnt (0.0, 0.0, 0.0); // this case should never happen
|
||||
}
|
||||
|
||||
// use compatible type of point
|
||||
NCollection_Vec4<Standard_Real> aPnt = safePointCast (thePnt);
|
||||
aPnt = aInvProj * aPnt; // convert to view coordinate space
|
||||
aPnt = aInvView * aPnt; // convert to world coordinate space
|
||||
|
||||
const Standard_Real aInvW = 1.0 / Standard_Real (aPnt.w());
|
||||
return gp_Pnt (aPnt.x() * aInvW, aPnt.y() * aInvW, aPnt.z() * aInvW);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ProjectPntOnViewPlane
|
||||
// purpose : Projects 2d screen point onto view frustum plane:
|
||||
@ -209,13 +112,17 @@ gp_Pnt SelectMgr_FrustumBuilder::ProjectPntOnViewPlane (const Standard_Real& the
|
||||
const Standard_Real& theY,
|
||||
const Standard_Real& theZ) const
|
||||
{
|
||||
if (myCamera.IsNull())
|
||||
{
|
||||
return gp_Pnt();
|
||||
}
|
||||
// map coords to NDC
|
||||
gp_Pnt anXYZ;
|
||||
if (!myIsViewportSet)
|
||||
{
|
||||
anXYZ.SetCoord (2.0 * theX / myWidth - 1.0,
|
||||
(myHeight - 1 - theY) / myHeight * 2.0 - 1.0,
|
||||
myIsZeroToOneDepth ? theZ : (2.0 * theZ - 1.0));
|
||||
myCamera->IsZeroToOneDepth() ? theZ : (2.0 * theZ - 1.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -223,5 +130,5 @@ gp_Pnt SelectMgr_FrustumBuilder::ProjectPntOnViewPlane (const Standard_Real& the
|
||||
2.0 * (theY - myHeight * myViewport.y()) / (myHeight * (myViewport.w() - myViewport.y())) - 1.0,
|
||||
theZ);
|
||||
}
|
||||
return unProject (anXYZ);
|
||||
return myCamera->UnProject (anXYZ);
|
||||
}
|
||||
|
@ -32,24 +32,11 @@ public:
|
||||
//! Creates new frustum builder with empty matrices
|
||||
Standard_EXPORT SelectMgr_FrustumBuilder();
|
||||
|
||||
//! Stores current world view transformation matrix
|
||||
Standard_EXPORT void SetWorldViewMatrix (const Graphic3d_Mat4d& theWorldViewMatrix);
|
||||
//! Returns current camera
|
||||
const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
|
||||
|
||||
//! @return current world view transformation matrix
|
||||
Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const;
|
||||
|
||||
//! Stores current projection matrix
|
||||
Standard_EXPORT void SetProjectionMatrix (const Graphic3d_Mat4d& theProjection,
|
||||
const Standard_Boolean theIsZeroToOneDepth);
|
||||
|
||||
//! @return current projection matrix
|
||||
Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const;
|
||||
|
||||
//! Stores current world view projection matrix state for the orientation and projection matrices
|
||||
Standard_EXPORT void SetWorldViewProjState (const Graphic3d_WorldViewProjState& theState);
|
||||
|
||||
//! @return current world view projection state
|
||||
Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const;
|
||||
//! Stores current camera
|
||||
Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
|
||||
|
||||
//! Stores current window width and height
|
||||
Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth,
|
||||
@ -82,19 +69,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
//! Unprojects point from NDC coords to 3d world space
|
||||
gp_Pnt unProject (const gp_Pnt& thePnt) const;
|
||||
|
||||
private:
|
||||
|
||||
Graphic3d_Mat4d myWorldView;
|
||||
Graphic3d_Mat4d myProjection;
|
||||
Graphic3d_WorldViewProjState myWorldViewProjState;
|
||||
Handle(Graphic3d_Camera) myCamera;
|
||||
Standard_Integer myWidth;
|
||||
Standard_Integer myHeight;
|
||||
NCollection_Vec4<Standard_Real> myViewport;
|
||||
Standard_Boolean myIsViewportSet;
|
||||
Standard_Boolean myIsZeroToOneDepth;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(SelectMgr_FrustumBuilder, Standard_Transient)
|
||||
|
@ -225,7 +225,7 @@ namespace
|
||||
// =======================================================================
|
||||
void SelectMgr_RectangularFrustum::cacheVertexProjections (SelectMgr_RectangularFrustum* theFrustum) const
|
||||
{
|
||||
if (theFrustum->myIsOrthographic)
|
||||
if (theFrustum->Camera()->IsOrthographic())
|
||||
{
|
||||
// project vertices onto frustum normals
|
||||
// Since orthographic view volume's faces are always a pairwise translation of
|
||||
@ -377,7 +377,7 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_RectangularFrustum::ScaleAndTransfor
|
||||
return aRes;
|
||||
}
|
||||
|
||||
aRes->myIsOrthographic = myIsOrthographic;
|
||||
aRes->SetCamera (myCamera);
|
||||
const SelectMgr_RectangularFrustum* aRef = this;
|
||||
|
||||
if (isToScale)
|
||||
@ -436,6 +436,8 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_RectangularFrustum::ScaleAndTransfor
|
||||
aRes->myScale = Sqrt (aRefScale / aRes->myFarPickedPnt.SquareDistance (aRes->myNearPickedPnt));
|
||||
}
|
||||
|
||||
aRes->SetBuilder (theBuilder);
|
||||
|
||||
// compute frustum normals
|
||||
computeNormals (aRes->myEdgeDirs, aRes->myPlanes);
|
||||
|
||||
@ -443,7 +445,6 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_RectangularFrustum::ScaleAndTransfor
|
||||
|
||||
aRes->mySelectionType = mySelectionType;
|
||||
aRes->mySelRectangle = mySelRectangle;
|
||||
aRes->SetBuilder (theBuilder);
|
||||
return aRes;
|
||||
}
|
||||
|
||||
@ -787,7 +788,7 @@ void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>
|
||||
SelectMgr_Vec4 anEquation;
|
||||
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 6; ++aPlaneIdx)
|
||||
{
|
||||
const gp_Vec& aPlaneNorm = myIsOrthographic && aPlaneIdx % 2 == 1 ?
|
||||
const gp_Vec& aPlaneNorm = Camera()->IsOrthographic() && aPlaneIdx % 2 == 1 ?
|
||||
myPlanes[aPlaneIdx - 1].Reversed() : myPlanes[aPlaneIdx];
|
||||
anEquation.x() = aPlaneNorm.X();
|
||||
anEquation.y() = aPlaneNorm.Y();
|
||||
|
@ -105,66 +105,6 @@ void SelectMgr_SelectingVolumeManager::SetCamera (const Handle(Graphic3d_Camera)
|
||||
myActiveSelectingVolume->SetCamera (theCamera);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetCamera
|
||||
// purpose : Updates camera projection and orientation matrices in all
|
||||
// selecting volumes
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectingVolumeManager::SetCamera (const Graphic3d_Mat4d& theProjection,
|
||||
const Graphic3d_Mat4d& theWorldView,
|
||||
const Standard_Boolean theIsOrthographic,
|
||||
const Graphic3d_WorldViewProjState& theWVPState)
|
||||
{
|
||||
Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
|
||||
"SelectMgr_SelectingVolumeManager::SetCamera() should be called after initialization of selection volume ");
|
||||
myActiveSelectingVolume->SetCamera (theProjection, theWorldView, theIsOrthographic, theWVPState);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ProjectionMatrix
|
||||
// purpose : Returns current projection transformation common for all
|
||||
// selecting volumes
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_SelectingVolumeManager::ProjectionMatrix() const
|
||||
{
|
||||
if (myActiveSelectingVolume.IsNull())
|
||||
{
|
||||
static const Graphic3d_Mat4d anEmptyMatrix;
|
||||
return anEmptyMatrix;
|
||||
}
|
||||
return myActiveSelectingVolume->ProjectionMatrix();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewMatrix
|
||||
// purpose : Returns current world view transformation common for all
|
||||
// selecting volumes
|
||||
//=======================================================================
|
||||
const Graphic3d_Mat4d& SelectMgr_SelectingVolumeManager::WorldViewMatrix() const
|
||||
{
|
||||
if (myActiveSelectingVolume.IsNull())
|
||||
{
|
||||
static const Graphic3d_Mat4d anEmptyMatrix;
|
||||
return anEmptyMatrix;
|
||||
}
|
||||
return myActiveSelectingVolume->WorldViewMatrix();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WorldViewProjState
|
||||
// purpose : Returns current camera world view projection transformation
|
||||
// state common for all selecting volumes
|
||||
//=======================================================================
|
||||
const Graphic3d_WorldViewProjState& SelectMgr_SelectingVolumeManager::WorldViewProjState() const
|
||||
{
|
||||
if (myActiveSelectingVolume.IsNull())
|
||||
{
|
||||
static const Graphic3d_WorldViewProjState anEmptyState;
|
||||
return anEmptyState;
|
||||
}
|
||||
return myActiveSelectingVolume->WorldViewProjState();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : WindowSize
|
||||
// purpose :
|
||||
|
@ -91,25 +91,6 @@ public:
|
||||
//! else exception will be thrown
|
||||
Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera) theCamera);
|
||||
|
||||
//! Updates camera projection and orientation matrices in all selecting volumes
|
||||
//! Note: this method should be called after selection volume building
|
||||
//! else exception will be thrown
|
||||
Standard_EXPORT void SetCamera (const Graphic3d_Mat4d& theProjection,
|
||||
const Graphic3d_Mat4d& theWorldView,
|
||||
const Standard_Boolean theIsOrthographic,
|
||||
const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState());
|
||||
|
||||
//! @return current projection transformation common for all selecting volumes
|
||||
Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const;
|
||||
|
||||
//! @return current world view transformation common for all selecting volumes
|
||||
Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const;
|
||||
|
||||
Standard_EXPORT void WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
|
||||
|
||||
//! @return current camera world view projection transformation state common for all selecting volumes
|
||||
Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const;
|
||||
|
||||
//! Updates viewport in all selecting volumes
|
||||
//! Note: this method should be called after selection volume building
|
||||
//! else exception will be thrown
|
||||
@ -123,6 +104,9 @@ public:
|
||||
//! else exception will be thrown
|
||||
Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
|
||||
|
||||
//! Returns window size
|
||||
Standard_EXPORT void WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
|
||||
|
||||
//! Updates window size in all selecting volumes
|
||||
//! Note: this method should be called after selection volume building
|
||||
//! else exception will be thrown
|
||||
|
@ -157,6 +157,7 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform
|
||||
const Handle(SelectMgr_FrustumBuilder)&) const
|
||||
{
|
||||
Handle(SelectMgr_TriangularFrustum) aRes = new SelectMgr_TriangularFrustum();
|
||||
aRes->SetCamera (myCamera);
|
||||
|
||||
for (Standard_Integer anIt = 0; anIt < 6; anIt++)
|
||||
{
|
||||
@ -165,8 +166,6 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustum::ScaleAndTransform
|
||||
aRes->myVertices[anIt] = aPoint;
|
||||
}
|
||||
|
||||
aRes->myIsOrthographic = myIsOrthographic;
|
||||
|
||||
// V0_Near - V0_Far
|
||||
aRes->myEdgeDirs[0] = aRes->myVertices[0].XYZ() - aRes->myVertices[3].XYZ();
|
||||
// V1_Near - V1_Far
|
||||
|
@ -162,6 +162,7 @@ Handle(SelectMgr_BaseIntersector) SelectMgr_TriangularFrustumSet::ScaleAndTransf
|
||||
"Error! SelectMgr_TriangularFrustumSet::ScaleAndTransform() should be called after selection frustum initialization");
|
||||
|
||||
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()->ScaleAndTransform (theScale, theTrsf, theBuilder)));
|
||||
|
@ -602,14 +602,16 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
Standard_Integer aWidth = 0;
|
||||
Standard_Integer aHeight = 0;
|
||||
mySelectingVolumeMgr.WindowSize (aWidth, aHeight);
|
||||
mySelectableObjects.UpdateBVH (mySelectingVolumeMgr.Camera(),
|
||||
mySelectingVolumeMgr.ProjectionMatrix(),
|
||||
mySelectingVolumeMgr.WorldViewMatrix(),
|
||||
mySelectingVolumeMgr.WorldViewProjState(),
|
||||
aWidth, aHeight);
|
||||
|
||||
const Handle(Graphic3d_Camera)& aCamera = mySelectingVolumeMgr.Camera();
|
||||
Graphic3d_Mat4d aProjectionMat, aWorldViewMat;
|
||||
Graphic3d_WorldViewProjState aViewState;
|
||||
if (!aCamera.IsNull())
|
||||
{
|
||||
aProjectionMat = aCamera->ProjectionMatrix();
|
||||
aWorldViewMat = aCamera->OrientationMatrix();
|
||||
aViewState = aCamera->WorldViewProjState();
|
||||
|
||||
myCameraEye = aCamera->Eye().XYZ();
|
||||
myCameraDir = aCamera->Direction().XYZ();
|
||||
myCameraScale = aCamera->IsOrthographic()
|
||||
@ -618,6 +620,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
const double aPixelSize = Max (1.0 / aWidth, 1.0 / aHeight);
|
||||
myCameraScale *= aPixelSize;
|
||||
}
|
||||
mySelectableObjects.UpdateBVH (aCamera, aProjectionMat, aWorldViewMat, aViewState, aWidth, aHeight);
|
||||
|
||||
for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt)
|
||||
{
|
||||
@ -632,7 +635,6 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
continue;
|
||||
}
|
||||
|
||||
gp_GTrsf aTFrustum;
|
||||
SelectMgr_SelectingVolumeManager aMgr;
|
||||
|
||||
// for 2D space selection transform selecting volumes to perform overlap testing
|
||||
@ -640,23 +642,28 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
// needed there at all
|
||||
if (aBVHSubset == SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent)
|
||||
{
|
||||
const Graphic3d_Mat4d& aMat = mySelectingVolumeMgr.WorldViewMatrix();
|
||||
aTFrustum.SetValue (1, 1, aMat.GetValue (0, 0));
|
||||
aTFrustum.SetValue (1, 2, aMat.GetValue (0, 1));
|
||||
aTFrustum.SetValue (1, 3, aMat.GetValue (0, 2));
|
||||
aTFrustum.SetValue (2, 1, aMat.GetValue (1, 0));
|
||||
aTFrustum.SetValue (2, 2, aMat.GetValue (1, 1));
|
||||
aTFrustum.SetValue (2, 3, aMat.GetValue (1, 2));
|
||||
aTFrustum.SetValue (3, 1, aMat.GetValue (2, 0));
|
||||
aTFrustum.SetValue (3, 2, aMat.GetValue (2, 1));
|
||||
aTFrustum.SetValue (3, 3, aMat.GetValue (2, 2));
|
||||
aTFrustum.SetTranslationPart (gp_XYZ (aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3)));
|
||||
gp_GTrsf aTFrustum;
|
||||
aTFrustum.SetValue (1, 1, aWorldViewMat.GetValue (0, 0));
|
||||
aTFrustum.SetValue (1, 2, aWorldViewMat.GetValue (0, 1));
|
||||
aTFrustum.SetValue (1, 3, aWorldViewMat.GetValue (0, 2));
|
||||
aTFrustum.SetValue (2, 1, aWorldViewMat.GetValue (1, 0));
|
||||
aTFrustum.SetValue (2, 2, aWorldViewMat.GetValue (1, 1));
|
||||
aTFrustum.SetValue (2, 3, aWorldViewMat.GetValue (1, 2));
|
||||
aTFrustum.SetValue (3, 1, aWorldViewMat.GetValue (2, 0));
|
||||
aTFrustum.SetValue (3, 2, aWorldViewMat.GetValue (2, 1));
|
||||
aTFrustum.SetValue (3, 3, aWorldViewMat.GetValue (2, 2));
|
||||
aTFrustum.SetTranslationPart (gp_XYZ (aWorldViewMat.GetValue (0, 3),
|
||||
aWorldViewMat.GetValue (1, 3),
|
||||
aWorldViewMat.GetValue (2, 3)));
|
||||
|
||||
// define corresponding frustum builder parameters
|
||||
Handle(SelectMgr_FrustumBuilder) aBuilder = new SelectMgr_FrustumBuilder();
|
||||
aBuilder->SetProjectionMatrix (mySelectingVolumeMgr.ProjectionMatrix(),
|
||||
aCamera->IsZeroToOneDepth());
|
||||
aBuilder->SetWorldViewMatrix (SelectMgr_ViewerSelector_THE_IDENTITY_MAT);
|
||||
Handle(Graphic3d_Camera) aNewCamera = new Graphic3d_Camera();
|
||||
aNewCamera->CopyMappingData (aCamera);
|
||||
aNewCamera->SetIdentityOrientation();
|
||||
aWorldViewMat = aNewCamera->OrientationMatrix(); // should be identity matrix
|
||||
aProjectionMat = aNewCamera->ProjectionMatrix(); // should be the same to aProjectionMat
|
||||
aBuilder->SetCamera (aNewCamera);
|
||||
aBuilder->SetWindowSize (aWidth, aHeight);
|
||||
aMgr = mySelectingVolumeMgr.ScaleAndTransform (1, aTFrustum, aBuilder);
|
||||
}
|
||||
@ -665,11 +672,6 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
aMgr = mySelectingVolumeMgr;
|
||||
}
|
||||
|
||||
const Graphic3d_Mat4d& aProjectionMat = mySelectingVolumeMgr.ProjectionMatrix();
|
||||
const Graphic3d_Mat4d& aWorldViewMat = aBVHSubset != SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent
|
||||
? mySelectingVolumeMgr.WorldViewMatrix()
|
||||
: SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
|
||||
|
||||
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& aBVHTree = mySelectableObjects.BVH (aBVHSubset);
|
||||
|
||||
Standard_Integer aNode = 0;
|
||||
@ -1002,11 +1004,14 @@ void SelectMgr_ViewerSelector::RebuildObjectsTree (const Standard_Boolean theIsF
|
||||
Standard_Integer aWidth;
|
||||
Standard_Integer aHeight;
|
||||
mySelectingVolumeMgr.WindowSize (aWidth, aHeight);
|
||||
mySelectableObjects.UpdateBVH (mySelectingVolumeMgr.Camera(),
|
||||
mySelectingVolumeMgr.ProjectionMatrix(),
|
||||
mySelectingVolumeMgr.WorldViewMatrix(),
|
||||
mySelectingVolumeMgr.WorldViewProjState(),
|
||||
aWidth, aHeight);
|
||||
const Handle(Graphic3d_Camera)& aCamera = mySelectingVolumeMgr.Camera();
|
||||
const Graphic3d_Mat4d& aProjMat = !aCamera.IsNull() ? aCamera->ProjectionMatrix()
|
||||
: SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
|
||||
const Graphic3d_Mat4d& anOrientMat = !aCamera.IsNull() ? aCamera->OrientationMatrix()
|
||||
: SelectMgr_ViewerSelector_THE_IDENTITY_MAT;
|
||||
Graphic3d_WorldViewProjState aViewState = !aCamera.IsNull() ? aCamera->WorldViewProjState()
|
||||
: Graphic3d_WorldViewProjState();
|
||||
mySelectableObjects.UpdateBVH (aCamera, aProjMat, anOrientMat, aViewState, aWidth, aHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,16 +20,16 @@ vaxo
|
||||
vfit
|
||||
if { [vselaxis -4 0 6 0 0 -1 -display sel_a0] != "There are no any intersections with this axis." } { puts "Error: there should be no any intersections" }
|
||||
|
||||
set pointlist1 [vselaxis 0 0 6 0 0 -1 -display sel_a2 -onlytop 0]
|
||||
set pointlist1 [vselaxis 0 0 6 0 0 -1 -display sel_a1 -onlytop 0]
|
||||
regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)\s([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)\s([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${pointlist1} full p1 p2 p3
|
||||
checkpoint "point1" $p1 {0 0 5} 0.001
|
||||
checkpoint "point2" $p2 {0 0 4} 0.001
|
||||
checkpoint "point3" $p3 {0 0 2} 0.001
|
||||
|
||||
set pointlist2 [vselaxis 1 0 6 0 0 -1 -display sel_a1 -onlytop 0 -shownormal]
|
||||
set pointlist2 [vselaxis 1 0 6 0 0 -1 -display sel_a2 -onlytop 0 -shownormal]
|
||||
regexp {([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)\s([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)\s([-0-9.+eE]+ [-0-9.+eE]+ [-0-9.+eE]+)} ${pointlist2} full p1 p2 p3
|
||||
checkpoint "point1" $p1 {1 0 4} 0.0001
|
||||
checkpoint "point2" $p2 {1 0 2} 0.0001
|
||||
checkpoint "point3" $p3 {1 0 1.7410396881859338} 0.0001
|
||||
checkpoint "point3" $p3 {1 0 1.7320508075688776} 0.0001
|
||||
|
||||
vdump ${imagedir}/${casename}.png
|
||||
|
@ -12,3 +12,4 @@
|
||||
012 wire
|
||||
013 wire_solid
|
||||
014 sphere
|
||||
015 axis
|
||||
|
Loading…
x
Reference in New Issue
Block a user