#include <OpenGl_BVHClipPrimitiveSet.hxx>
#include <BVH_BinnedBuilder.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
// =======================================================================
// function : OpenGl_BVHClipPrimitiveSet
{
Graphic3d_BndBox4f aBndBox = myStructs.FindKey (theIdx + 1)->BoundingBox();
- return (aBndBox.CornerMin()[theAxis] +
- aBndBox.CornerMax()[theAxis]) * 0.5f;
+ // to prevent float overflow
+ const Standard_Real aMin = Standard_Real (aBndBox.CornerMin()[theAxis]);
+ const Standard_Real aMax = Standard_Real (aBndBox.CornerMax()[theAxis]);
+ const Standard_Real aCenter = (aMin + aMax) * 0.5;
+
+ if (aCenter <= Standard_Real (-ShortRealLast()))
+ return -ShortRealLast();
+ if (aCenter >= Standard_Real (ShortRealLast()))
+ return ShortRealLast();
+
+ return Standard_ShortReal (aCenter);
}
// =======================================================================
myStructs.Swap (theIdx1 + 1, theIdx2 + 1);
}
-// =======================================================================
-// function : Assign
-// purpose :
-// =======================================================================
-void OpenGl_BVHClipPrimitiveSet::Assign (const OpenGl_ArrayOfStructure& theStructs)
-{
- myStructs.Clear();
-
- for (Standard_Integer aPriorityIdx = 0, aNbPriorities = theStructs.Length(); aPriorityIdx < aNbPriorities; ++aPriorityIdx)
- {
- for (OpenGl_SequenceOfStructure::Iterator aStructIter (theStructs (aPriorityIdx)); aStructIter.More(); aStructIter.Next())
- {
- const OpenGl_Structure* aStruct = aStructIter.Value();
-
- if (!aStruct->IsAlwaysRendered())
- {
- myStructs.Add (aStruct);
- }
- }
- }
-
- MarkDirty();
-}
-
// =======================================================================
// function : Add
// purpose :
// =======================================================================
-void OpenGl_BVHClipPrimitiveSet::Add (const OpenGl_Structure* theStruct)
+Standard_Boolean OpenGl_BVHClipPrimitiveSet::Add (const OpenGl_Structure* theStruct)
{
const Standard_Integer aSize = myStructs.Size();
if (myStructs.Add (theStruct) > aSize) // new structure?
{
MarkDirty();
+
+ return Standard_True;
}
+
+ return Standard_False;
}
// =======================================================================
// function : Remove
// purpose :
// =======================================================================
-void OpenGl_BVHClipPrimitiveSet::Remove (const OpenGl_Structure* theStruct)
+Standard_Boolean OpenGl_BVHClipPrimitiveSet::Remove (const OpenGl_Structure* theStruct)
{
const Standard_Integer anIndex = myStructs.FindIndex (theStruct);
myStructs.Swap (Size(), anIndex);
myStructs.RemoveLast();
MarkDirty();
+
+ return Standard_True;
}
+
+ return Standard_False;
}
// =======================================================================