mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-05-18 17:06:14 +08:00
0027919: Visualization - support multiple transformation persistence groups within single presentation
Added transform persistence property to Graphic3d_Group and Select3D_SensitiveEntity. SelectMgr_ViewerSelector, Graphic3d_Layer and OpenGl_Structure have been updated to process per-group transform persistence within picking, ZFit and rendering. Added zoomable state to Prs3d_ArrowAspect supported by PrsDim_Dimension. Added gp_GTrsf::SetMat4(), opposite to gp_GTrsf::GetMat4().
This commit is contained in:
@@ -114,8 +114,7 @@ namespace
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMat,
|
||||
const Graphic3d_Mat4d& theWorldViewMat,
|
||||
const Standard_Integer theWidth,
|
||||
const Standard_Integer theHeight)
|
||||
const Graphic3d_Vec2i& theWinSize)
|
||||
: myObjects (theObjects)
|
||||
{
|
||||
myBoundings.ReSize (myObjects.Size());
|
||||
@@ -125,15 +124,51 @@ namespace
|
||||
|
||||
Bnd_Box aBoundingBox;
|
||||
anObject->BoundingBox (aBoundingBox);
|
||||
if (aBoundingBox.IsVoid()
|
||||
|| anObject->TransformPersistence().IsNull())
|
||||
if (!aBoundingBox.IsVoid()
|
||||
&& !anObject->TransformPersistence().IsNull())
|
||||
{
|
||||
anObject->TransformPersistence()->Apply (theCamera,
|
||||
theProjectionMat, theWorldViewMat,
|
||||
theWinSize.x(), theWinSize.y(),
|
||||
aBoundingBox);
|
||||
}
|
||||
|
||||
// processing presentations with own transform persistence
|
||||
for (PrsMgr_Presentations::Iterator aPrsIter (anObject->Presentations()); aPrsIter.More(); aPrsIter.Next())
|
||||
{
|
||||
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value();
|
||||
if (!aPrs3d->CStructure()->HasGroupTransformPersistence())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
const Handle(Graphic3d_Group)& aGroup = aGroupIter.Value();
|
||||
const Graphic3d_BndBox4f& aBndBox = aGroup->BoundingBox();
|
||||
if (aGroup->TransformPersistence().IsNull()
|
||||
|| !aBndBox.IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Bnd_Box aGroupBox;
|
||||
aGroupBox.Update (aBndBox.CornerMin().x(), aBndBox.CornerMin().y(), aBndBox.CornerMin().z(),
|
||||
aBndBox.CornerMax().x(), aBndBox.CornerMax().y(), aBndBox.CornerMax().z());
|
||||
aGroup->TransformPersistence()->Apply (theCamera,
|
||||
theProjectionMat, theWorldViewMat,
|
||||
theWinSize.x(), theWinSize.y(),
|
||||
aGroupBox);
|
||||
aBoundingBox.Add (aGroupBox);
|
||||
}
|
||||
}
|
||||
|
||||
if (aBoundingBox.IsVoid())
|
||||
{
|
||||
myBoundings.Add (new Select3D_HBndBox3d());
|
||||
}
|
||||
else
|
||||
{
|
||||
anObject->TransformPersistence()->Apply (theCamera, theProjectionMat, theWorldViewMat, theWidth, theHeight, aBoundingBox);
|
||||
|
||||
const gp_Pnt aMin = aBoundingBox.CornerMin();
|
||||
const gp_Pnt aMax = aBoundingBox.CornerMax();
|
||||
myBoundings.Add (new Select3D_HBndBox3d (Select3D_Vec3 (aMin.X(), aMin.Y(), aMin.Z()),
|
||||
@@ -205,8 +240,6 @@ namespace
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
SelectMgr_SelectableObjectSet::SelectMgr_SelectableObjectSet()
|
||||
: myLastWidth (0),
|
||||
myLastHeight (0)
|
||||
{
|
||||
myBVH[BVHSubset_2dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
myBVH[BVHSubset_3dPersistent] = new BVH_Tree<Standard_Real, 3>();
|
||||
@@ -311,12 +344,8 @@ void SelectMgr_SelectableObjectSet::ChangeSubset (const Handle(SelectMgr_Selecta
|
||||
// Function: UpdateBVH
|
||||
// Purpose :
|
||||
//=============================================================================
|
||||
void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMat,
|
||||
const Graphic3d_Mat4d& theWorldViewMat,
|
||||
const Graphic3d_WorldViewProjState& theViewState,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight)
|
||||
void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& theCam,
|
||||
const Graphic3d_Vec2i& theWinSize)
|
||||
{
|
||||
// -----------------------------------------
|
||||
// check and update 3D BVH tree if necessary
|
||||
@@ -333,20 +362,24 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
|
||||
myIsDirty[BVHSubset_3d] = Standard_False;
|
||||
}
|
||||
|
||||
if (!theCamera.IsNull())
|
||||
if (!theCam.IsNull())
|
||||
{
|
||||
const Standard_Boolean isWindowSizeChanged =
|
||||
(myLastHeight != theViewportHeight) || (myLastWidth != theViewportWidth);
|
||||
const Standard_Boolean isWinSizeChanged = myLastWinSize != theWinSize;
|
||||
const Graphic3d_Mat4d& aProjMat = theCam->ProjectionMatrix();
|
||||
const Graphic3d_Mat4d& aWorldViewMat = theCam->OrientationMatrix();
|
||||
const Graphic3d_WorldViewProjState& aViewState = theCam->WorldViewProjState();
|
||||
|
||||
// -----------------------------------------------------
|
||||
// check and update 3D persistence BVH tree if necessary
|
||||
// -----------------------------------------------------
|
||||
if (!IsEmpty (BVHSubset_3dPersistent) &&
|
||||
(myIsDirty[BVHSubset_3dPersistent] || myLastViewState.IsChanged (theViewState) || isWindowSizeChanged))
|
||||
if (!IsEmpty (BVHSubset_3dPersistent)
|
||||
&& (myIsDirty[BVHSubset_3dPersistent]
|
||||
|| myLastViewState.IsChanged (aViewState)
|
||||
|| isWinSizeChanged))
|
||||
{
|
||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
||||
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_3dPersistent],
|
||||
theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
|
||||
theCam, aProjMat, aWorldViewMat, theWinSize);
|
||||
|
||||
// update corresponding BVH tree data structure
|
||||
myBuilder[BVHSubset_3dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_3dPersistent].get(), anAdaptor.Box());
|
||||
@@ -355,12 +388,14 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
|
||||
// -----------------------------------------------------
|
||||
// check and update 2D persistence BVH tree if necessary
|
||||
// -----------------------------------------------------
|
||||
if (!IsEmpty (BVHSubset_2dPersistent) &&
|
||||
(myIsDirty[BVHSubset_2dPersistent] || myLastViewState.IsProjectionChanged (theViewState) || isWindowSizeChanged))
|
||||
if (!IsEmpty (BVHSubset_2dPersistent)
|
||||
&& (myIsDirty[BVHSubset_2dPersistent]
|
||||
|| myLastViewState.IsProjectionChanged (aViewState)
|
||||
|| isWinSizeChanged))
|
||||
{
|
||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
||||
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_2dPersistent],
|
||||
theCamera, theProjectionMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theViewportWidth, theViewportHeight);
|
||||
theCam, aProjMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theWinSize);
|
||||
|
||||
// update corresponding BVH tree data structure
|
||||
myBuilder[BVHSubset_2dPersistent]->Build (&anAdaptor, myBVH[BVHSubset_2dPersistent].get(), anAdaptor.Box());
|
||||
@@ -371,12 +406,11 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
|
||||
myIsDirty[BVHSubset_2dPersistent] = Standard_False;
|
||||
|
||||
// keep last view state
|
||||
myLastViewState = theViewState;
|
||||
myLastViewState = aViewState;
|
||||
}
|
||||
|
||||
// keep last window state
|
||||
myLastWidth = theViewportWidth;
|
||||
myLastHeight = theViewportHeight;
|
||||
myLastWinSize = theWinSize;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@@ -412,6 +446,6 @@ void SelectMgr_SelectableObjectSet::DumpJson (Standard_OStream& theOStream, Stan
|
||||
TCollection_AsciiString separator;
|
||||
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, separator)
|
||||
}
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastWidth)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastHeight)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastWinSize.x())
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastWinSize.y())
|
||||
}
|
||||
|
||||
@@ -134,12 +134,8 @@ public:
|
||||
|
||||
//! Updates outdated BVH trees and remembers the last state of the
|
||||
//! camera view-projection matrices and viewport (window) dimensions.
|
||||
Standard_EXPORT void UpdateBVH (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMat,
|
||||
const Graphic3d_Mat4d& theWorldViewMat,
|
||||
const Graphic3d_WorldViewProjState& theViewState,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight);
|
||||
Standard_EXPORT void UpdateBVH (const Handle(Graphic3d_Camera)& theCam,
|
||||
const Graphic3d_Vec2i& theWinSize);
|
||||
|
||||
//! Marks every BVH subset for update.
|
||||
Standard_EXPORT void MarkDirty();
|
||||
@@ -190,6 +186,15 @@ private:
|
||||
{
|
||||
if (theObject->TransformPersistence().IsNull())
|
||||
{
|
||||
const PrsMgr_Presentations& aPresentations = theObject->Presentations();
|
||||
for (PrsMgr_Presentations::Iterator aPrsIter (aPresentations); aPrsIter.More(); aPrsIter.Next())
|
||||
{
|
||||
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
|
||||
if (aPrs3d->CStructure()->HasGroupTransformPersistence())
|
||||
{
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_3dPersistent;
|
||||
}
|
||||
}
|
||||
return SelectMgr_SelectableObjectSet::BVHSubset_3d;
|
||||
}
|
||||
else if (theObject->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
|
||||
@@ -221,9 +226,8 @@ private:
|
||||
opencascade::handle<BVH_Tree<Standard_Real, 3> > myBVH[BVHSubsetNb]; //!< BVH tree computed for each subset
|
||||
Handle(Select3D_BVHBuilder3d) myBuilder[BVHSubsetNb]; //!< Builder allocated for each subset
|
||||
Standard_Boolean myIsDirty[BVHSubsetNb]; //!< Dirty flag for each subset
|
||||
Graphic3d_WorldViewProjState myLastViewState; //!< Last view-projection state used for construction of BVH
|
||||
Standard_Integer myLastWidth; //!< Last viewport's (window's) width used for construction of BVH
|
||||
Standard_Integer myLastHeight; //!< Last viewport's (window's) height used for construction of BVH
|
||||
Graphic3d_WorldViewProjState myLastViewState; //!< Last view-projection state used for construction of BVH
|
||||
Graphic3d_Vec2i myLastWinSize; //!< Last viewport's (window's) width used for construction of BVH
|
||||
friend class Iterator;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <SelectMgr_SensitiveEntitySet.hxx>
|
||||
|
||||
#include <Graphic3d_TransformPers.hxx>
|
||||
#include <Select3D_SensitiveEntity.hxx>
|
||||
#include <SelectMgr_SensitiveEntity.hxx>
|
||||
|
||||
@@ -47,6 +48,10 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_SensitiveEntit
|
||||
{
|
||||
addOwner (theEntity->BaseSensitive()->OwnerId());
|
||||
}
|
||||
if (!theEntity->BaseSensitive()->TransformPersistence().IsNull())
|
||||
{
|
||||
myHasEntityWithPersistence = Standard_True;
|
||||
}
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
@@ -59,16 +64,21 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& th
|
||||
{
|
||||
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
|
||||
{
|
||||
if (!aSelEntIter.Value()->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity)))
|
||||
const Handle(SelectMgr_SensitiveEntity)& aSensEnt = aSelEntIter.Value();
|
||||
if (!aSensEnt->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity)))
|
||||
{
|
||||
aSelEntIter.Value()->ResetSelectionActiveStatus();
|
||||
aSensEnt->ResetSelectionActiveStatus();
|
||||
continue;
|
||||
}
|
||||
|
||||
const Standard_Integer anExtent = mySensitives.Extent();
|
||||
if (mySensitives.Add (aSelEntIter.Value()) > anExtent)
|
||||
if (mySensitives.Add (aSensEnt) > anExtent)
|
||||
{
|
||||
addOwner (aSelEntIter.Value()->BaseSensitive()->OwnerId());
|
||||
addOwner (aSensEnt->BaseSensitive()->OwnerId());
|
||||
}
|
||||
if (!aSensEnt->BaseSensitive()->TransformPersistence().IsNull())
|
||||
{
|
||||
myHasEntityWithPersistence = Standard_True;
|
||||
}
|
||||
}
|
||||
MarkDirty();
|
||||
@@ -107,7 +117,13 @@ void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& th
|
||||
//=======================================================================
|
||||
Select3D_BndBox3d SelectMgr_SensitiveEntitySet::Box (const Standard_Integer theIndex) const
|
||||
{
|
||||
return GetSensitiveById (theIndex)->BaseSensitive()->BoundingBox();
|
||||
const Handle(Select3D_SensitiveEntity)& aSensitive = GetSensitiveById (theIndex)->BaseSensitive();
|
||||
if (!aSensitive->TransformPersistence().IsNull())
|
||||
{
|
||||
return Select3D_BndBox3d();
|
||||
}
|
||||
|
||||
return aSensitive->BoundingBox();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
typedef NCollection_IndexedMap<Handle(SelectMgr_SensitiveEntity)> SelectMgr_IndexedMapOfHSensitive;
|
||||
typedef NCollection_DataMap<Handle(SelectMgr_EntityOwner), Standard_Integer> SelectMgr_MapOfOwners;
|
||||
|
||||
//! This class is used to store all calculated sensitive entites of one selectable
|
||||
//! object. It provides an interface for building BVH tree which is used to speed-up
|
||||
//! This class is used to store all calculated sensitive entities of one selectable object.
|
||||
//! It provides an interface for building BVH tree which is used to speed-up
|
||||
//! the performance of searching for overlap among sensitives of one selectable object
|
||||
class SelectMgr_SensitiveEntitySet : public BVH_PrimitiveSet3d
|
||||
{
|
||||
@@ -79,6 +79,9 @@ public:
|
||||
//! Returns map of owners.
|
||||
const SelectMgr_MapOfOwners& Owners() const { return myOwnersMap; }
|
||||
|
||||
//! Returns map of entities.
|
||||
Standard_Boolean HasEntityWithPersistence() const { return myHasEntityWithPersistence; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Adds entity owner to the map of owners (or increases its counter if it is already there).
|
||||
@@ -89,8 +92,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH
|
||||
SelectMgr_MapOfOwners myOwnersMap; //!< Map of entity owners and its corresponding number of sensitives
|
||||
SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH
|
||||
SelectMgr_MapOfOwners myOwnersMap; //!< Map of entity owners and its corresponding number of sensitives
|
||||
Standard_Boolean myHasEntityWithPersistence; //!< flag if some of sensitive entity has own transform persistence
|
||||
};
|
||||
|
||||
#endif // _SelectMgr_SensitiveEntitySet_HeaderFile
|
||||
|
||||
@@ -356,8 +356,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMat,
|
||||
const Graphic3d_Mat4d& theWorldViewMat,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight)
|
||||
const Graphic3d_Vec2i& theWinSize)
|
||||
{
|
||||
Handle(SelectMgr_SensitiveEntitySet)& anEntitySet = myMapOfObjectSensitives.ChangeFind (theObject);
|
||||
if (anEntitySet->Size() == 0)
|
||||
@@ -365,6 +364,8 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
return;
|
||||
}
|
||||
|
||||
const bool hasEntityTrsfPers = anEntitySet->HasEntityWithPersistence()
|
||||
&& !theCamera.IsNull();
|
||||
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& aSensitivesTree = anEntitySet->BVH();
|
||||
gp_GTrsf aInversedTrsf;
|
||||
if (theObject->HasTransformation() || !theObject->TransformPersistence().IsNull())
|
||||
@@ -379,20 +380,12 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Graphic3d_Mat4d aMat = theObject->TransformPersistence()->Compute (theCamera,
|
||||
theProjectionMat, theWorldViewMat,
|
||||
theWinSize.x(), theWinSize.y());
|
||||
gp_GTrsf aTPers;
|
||||
Graphic3d_Mat4d aMat = theObject->TransformPersistence()->Compute (theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
|
||||
|
||||
aTPers.SetValue (1, 1, aMat.GetValue (0, 0));
|
||||
aTPers.SetValue (1, 2, aMat.GetValue (0, 1));
|
||||
aTPers.SetValue (1, 3, aMat.GetValue (0, 2));
|
||||
aTPers.SetValue (2, 1, aMat.GetValue (1, 0));
|
||||
aTPers.SetValue (2, 2, aMat.GetValue (1, 1));
|
||||
aTPers.SetValue (2, 3, aMat.GetValue (1, 2));
|
||||
aTPers.SetValue (3, 1, aMat.GetValue (2, 0));
|
||||
aTPers.SetValue (3, 2, aMat.GetValue (2, 1));
|
||||
aTPers.SetValue (3, 3, aMat.GetValue (2, 2));
|
||||
aTPers.SetTranslationPart (gp_XYZ (aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3)));
|
||||
|
||||
aTPers.SetMat4 (aMat);
|
||||
aInversedTrsf = (aTPers * gp_GTrsf (theObject->Transformation())).Inverted();
|
||||
}
|
||||
}
|
||||
@@ -400,7 +393,8 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
SelectMgr_SelectingVolumeManager aMgr = aInversedTrsf.Form() != gp_Identity
|
||||
? theMgr.ScaleAndTransform (1, aInversedTrsf, NULL)
|
||||
: theMgr;
|
||||
if (!aMgr.OverlapsBox (aSensitivesTree->MinPoint (0),
|
||||
if (!hasEntityTrsfPers
|
||||
&& !aMgr.OverlapsBox (aSensitivesTree->MinPoint (0),
|
||||
aSensitivesTree->MaxPoint (0)))
|
||||
{
|
||||
return;
|
||||
@@ -482,12 +476,14 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
{
|
||||
const Standard_Integer aLeftChildIdx = aSensitivesTree->Child<0> (aNode);
|
||||
const Standard_Integer aRightChildIdx = aSensitivesTree->Child<1> (aNode);
|
||||
const Standard_Boolean isLeftChildIn = aMgr.OverlapsBox (aSensitivesTree->MinPoint (aLeftChildIdx),
|
||||
aSensitivesTree->MaxPoint (aLeftChildIdx));
|
||||
const Standard_Boolean isRightChildIn = aMgr.OverlapsBox (aSensitivesTree->MinPoint (aRightChildIdx),
|
||||
const Standard_Boolean isLeftChildIn = hasEntityTrsfPers
|
||||
|| aMgr.OverlapsBox (aSensitivesTree->MinPoint (aLeftChildIdx),
|
||||
aSensitivesTree->MaxPoint (aLeftChildIdx));
|
||||
const Standard_Boolean isRightChildIn = hasEntityTrsfPers
|
||||
|| aMgr.OverlapsBox (aSensitivesTree->MinPoint (aRightChildIdx),
|
||||
aSensitivesTree->MaxPoint (aRightChildIdx));
|
||||
if (isLeftChildIn
|
||||
&& isRightChildIn)
|
||||
&& isRightChildIn)
|
||||
{
|
||||
aNode = aLeftChildIdx;
|
||||
++aHead;
|
||||
@@ -544,17 +540,35 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
||||
}
|
||||
if (!aClipped)
|
||||
{
|
||||
Standard_Integer aStartIdx = aSensitivesTree->BegPrimitive (aNode);
|
||||
Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode);
|
||||
const Standard_Integer aStartIdx = aSensitivesTree->BegPrimitive (aNode);
|
||||
const Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode);
|
||||
for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
|
||||
{
|
||||
const Handle(SelectMgr_SensitiveEntity)& aSensitive = anEntitySet->GetSensitiveById (anIdx);
|
||||
if (aSensitive->IsActiveForSelection())
|
||||
if (!aSensitive->IsActiveForSelection())
|
||||
{
|
||||
const Handle(Select3D_SensitiveEntity)& anEnt = aSensitive->BaseSensitive();
|
||||
computeFrustum (anEnt, theMgr, aMgr, aInversedTrsf, aScaledTrnsfFrustums, aTmpMgr);
|
||||
checkOverlap (anEnt, aInversedTrsf, aTmpMgr);
|
||||
continue;
|
||||
}
|
||||
|
||||
const Handle(Select3D_SensitiveEntity)& anEnt = aSensitive->BaseSensitive();
|
||||
|
||||
gp_GTrsf aInvSensTrsf = aInversedTrsf;
|
||||
if (!anEnt->TransformPersistence().IsNull())
|
||||
{
|
||||
if (theCamera.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const Graphic3d_Mat4d aMat = anEnt->TransformPersistence()->Compute (theCamera,
|
||||
theProjectionMat, theWorldViewMat,
|
||||
theWinSize.x(), theWinSize.y());
|
||||
gp_GTrsf aTPers;
|
||||
aTPers.SetMat4 (aMat);
|
||||
aInvSensTrsf = (aTPers * gp_GTrsf(theObject->Transformation())).Inverted();
|
||||
}
|
||||
|
||||
computeFrustum (anEnt, theMgr, aMgr, aInvSensTrsf, aScaledTrnsfFrustums, aTmpMgr);
|
||||
checkOverlap (anEnt, aInvSensTrsf, aTmpMgr);
|
||||
}
|
||||
}
|
||||
if (aHead < 0)
|
||||
@@ -599,9 +613,8 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
|
||||
mystored.Clear();
|
||||
|
||||
Standard_Integer aWidth = 0;
|
||||
Standard_Integer aHeight = 0;
|
||||
mySelectingVolumeMgr.WindowSize (aWidth, aHeight);
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
mySelectingVolumeMgr.WindowSize (aWinSize.x(), aWinSize.y());
|
||||
|
||||
const Handle(Graphic3d_Camera)& aCamera = mySelectingVolumeMgr.Camera();
|
||||
Graphic3d_Mat4d aProjectionMat, aWorldViewMat;
|
||||
@@ -617,10 +630,10 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
myCameraScale = aCamera->IsOrthographic()
|
||||
? aCamera->Scale()
|
||||
: 2.0 * Tan (aCamera->FOVy() * M_PI / 360.0);
|
||||
const double aPixelSize = Max (1.0 / aWidth, 1.0 / aHeight);
|
||||
const double aPixelSize = Max (1.0 / aWinSize.x(), 1.0 / aWinSize.y());
|
||||
myCameraScale *= aPixelSize;
|
||||
}
|
||||
mySelectableObjects.UpdateBVH (aCamera, aProjectionMat, aWorldViewMat, aViewState, aWidth, aHeight);
|
||||
mySelectableObjects.UpdateBVH (aCamera, aWinSize);
|
||||
|
||||
for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt)
|
||||
{
|
||||
@@ -664,7 +677,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
aWorldViewMat = aNewCamera->OrientationMatrix(); // should be identity matrix
|
||||
aProjectionMat = aNewCamera->ProjectionMatrix(); // should be the same to aProjectionMat
|
||||
aBuilder->SetCamera (aNewCamera);
|
||||
aBuilder->SetWindowSize (aWidth, aHeight);
|
||||
aBuilder->SetWindowSize (aWinSize.x(), aWinSize.y());
|
||||
aMgr = mySelectingVolumeMgr.ScaleAndTransform (1, aTFrustum, aBuilder);
|
||||
}
|
||||
else
|
||||
@@ -724,7 +737,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
|
||||
const Handle(SelectMgr_SelectableObject)& aSelectableObject =
|
||||
mySelectableObjects.GetObjectById (aBVHSubset, anIdx);
|
||||
|
||||
traverseObject (aSelectableObject, aMgr, aCamera, aProjectionMat, aWorldViewMat, aWidth, aHeight);
|
||||
traverseObject (aSelectableObject, aMgr, aCamera, aProjectionMat, aWorldViewMat, aWinSize);
|
||||
}
|
||||
if (aHead < 0)
|
||||
{
|
||||
@@ -998,20 +1011,9 @@ void SelectMgr_ViewerSelector::RebuildObjectsTree (const Standard_Boolean theIsF
|
||||
|
||||
if (theIsForce)
|
||||
{
|
||||
Standard_Integer aViewportWidth, aViewportHeight;
|
||||
mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight);
|
||||
|
||||
Standard_Integer aWidth;
|
||||
Standard_Integer aHeight;
|
||||
mySelectingVolumeMgr.WindowSize (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);
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
mySelectingVolumeMgr.WindowSize (aWinSize.x(), aWinSize.y());
|
||||
mySelectableObjects.UpdateBVH (mySelectingVolumeMgr.Camera(), aWinSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,8 +281,7 @@ protected:
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Graphic3d_Mat4d& theProjectionMat,
|
||||
const Graphic3d_Mat4d& theWorldViewMat,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight);
|
||||
const Graphic3d_Vec2i& theWinSize);
|
||||
|
||||
//! Internal function that checks if a particular sensitive
|
||||
//! entity theEntity overlaps current selecting volume precisely
|
||||
|
||||
Reference in New Issue
Block a user