diff --git a/src/Graphic3d/Graphic3d_Structure.hxx b/src/Graphic3d/Graphic3d_Structure.hxx index f3d869180e..6e0b80eac3 100644 --- a/src/Graphic3d/Graphic3d_Structure.hxx +++ b/src/Graphic3d/Graphic3d_Structure.hxx @@ -124,8 +124,7 @@ public: Standard_EXPORT void Remove(); //! Computes axis-aligned bounding box of a structure. - //! Category: Methods to modify the class definition - Standard_EXPORT void CalculateBoundBox(); + Standard_EXPORT virtual void CalculateBoundBox(); //! If is Standard_True then is infinite and //! the MinMaxValues method method return : diff --git a/src/OpenGl/OpenGl_StructureShadow.cxx b/src/OpenGl/OpenGl_StructureShadow.cxx index f53fe405cd..3d272abb34 100644 --- a/src/OpenGl/OpenGl_StructureShadow.cxx +++ b/src/OpenGl/OpenGl_StructureShadow.cxx @@ -33,6 +33,7 @@ OpenGl_StructureShadow::OpenGl_StructureShadow (const Handle(Graphic3d_Structure ContainsFacet = myParent->ContainsFacet; IsInfinite = myParent->IsInfinite; Transformation = myParent->Transformation; + myBndBox = myParent->BoundingBox(); UpdateTransformation(); myInstancedStructure = const_cast (myParent->InstancedStructure()); diff --git a/src/Prs3d/Prs3d_PresentationShadow.cxx b/src/Prs3d/Prs3d_PresentationShadow.cxx index 246d85e346..37e4fa24bf 100644 --- a/src/Prs3d/Prs3d_PresentationShadow.cxx +++ b/src/Prs3d/Prs3d_PresentationShadow.cxx @@ -30,3 +30,12 @@ Prs3d_PresentationShadow::Prs3d_PresentationShadow (const Handle(Graphic3d_Struc { // } + +//======================================================================= +//function : CalculateBoundBox +//purpose : +//======================================================================= +void Prs3d_PresentationShadow::CalculateBoundBox() +{ + // +} diff --git a/src/Prs3d/Prs3d_PresentationShadow.hxx b/src/Prs3d/Prs3d_PresentationShadow.hxx index 819b02aad3..26037deaf7 100644 --- a/src/Prs3d/Prs3d_PresentationShadow.hxx +++ b/src/Prs3d/Prs3d_PresentationShadow.hxx @@ -34,6 +34,9 @@ public: //! Returns view affinity of the parent presentation Standard_EXPORT inline const Handle(Graphic3d_ViewAffinity)& ParentAffinity() const { return myParentAffinity; } + //! Do nothing - axis-aligned bounding box should be initialized from parent structure. + Standard_EXPORT virtual void CalculateBoundBox() Standard_OVERRIDE; + private: DEFINE_STANDARD_RTTIEXT(Prs3d_PresentationShadow,Prs3d_Presentation) diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index 33e0690dd5..f2c04933fa 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -2190,21 +2190,31 @@ void V3d_View::Gravity (Standard_Real& theX, { const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key(); if (!aStruct->IsVisible() - || (hasSelection && !aStruct->IsHighlighted()) - || aStruct->IsEmpty()) + || aStruct->IsInfinite() + || (hasSelection && !aStruct->IsHighlighted())) { continue; } - Bnd_Box aBox = aStruct->MinMaxValues(); - if (aBox.IsVoid() || aStruct->IsInfinite()) + const Graphic3d_BndBox4f& aBox = aStruct->CStructure()->BoundingBox(); + if (!aBox.IsValid()) + { + continue; + } + + // skip transformation-persistent objects + if (aStruct->TransformPersistence().Flags != Graphic3d_TMF_None) { continue; } // use camera projection to find gravity point - aBox.Get (Xmin, Ymin, Zmin, - Xmax, Ymax, Zmax); + Xmin = (Standard_Real )aBox.CornerMin().x(); + Ymin = (Standard_Real )aBox.CornerMin().y(); + Zmin = (Standard_Real )aBox.CornerMin().z(); + Xmax = (Standard_Real )aBox.CornerMax().x(); + Ymax = (Standard_Real )aBox.CornerMax().y(); + Zmax = (Standard_Real )aBox.CornerMax().z(); gp_Pnt aPnts[THE_NB_BOUND_POINTS] = { gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax), @@ -2228,21 +2238,10 @@ void V3d_View::Gravity (Standard_Real& theX, if (aNbPoints == 0) { - for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures); - aStructIter.More(); aStructIter.Next()) + // fallback - just use bounding box of entire scene + Bnd_Box aBox = myView->MinMaxValues (Standard_True); + if (!aBox.IsVoid()) { - const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key(); - if (aStruct->IsEmpty()) - { - continue; - } - - Bnd_Box aBox = aStruct->MinMaxValues(); - if (aBox.IsVoid() || aStruct->IsInfinite()) - { - continue; - } - aBox.Get (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); gp_Pnt aPnts[THE_NB_BOUND_POINTS] =