#include <BVH_Types.hxx>
+#include <limits>
+
//! Defines axis aligned bounding box (AABB) based on BVH vectors.
//! \tparam T Numeric data type
//! \tparam N Vector dimension
BVH_VecNt& CornerMax();
//! Returns surface area of bounding box.
+ //! If the box is degenerated into line, returns the perimeter instead.
T Area() const;
//! Returns diagonal of bounding box.
{
static T Area (const typename BVH_Box<T, 2>::BVH_VecNt& theSize)
{
- return theSize.x() * theSize.y();
+ const T anArea = theSize.x() * theSize.y();
+
+ if (anArea < std::numeric_limits<T>::epsilon())
+ {
+ return theSize.x() + theSize.y();
+ }
+
+ return anArea;
}
};
{
static T Area (const typename BVH_Box<T, 3>::BVH_VecNt& theSize)
{
- return ( theSize.x() * theSize.y() +
- theSize.x() * theSize.z() +
- theSize.z() * theSize.y() ) * static_cast<T> (2.0);
+ const T anArea = ( theSize.x() * theSize.y() +
+ theSize.x() * theSize.z() +
+ theSize.z() * theSize.y() ) * static_cast<T> (2.0);
+
+ if (anArea < std::numeric_limits<T>::epsilon())
+ {
+ return theSize.x() +
+ theSize.y() +
+ theSize.z();
+ }
+
+ return anArea;
}
};
{
static T Area (const typename BVH_Box<T, 4>::BVH_VecNt& theSize)
{
- return ( theSize.x() * theSize.y() +
- theSize.x() * theSize.z() +
- theSize.z() * theSize.y() ) * static_cast<T> (2.0);
+ const T anArea = ( theSize.x() * theSize.y() +
+ theSize.x() * theSize.z() +
+ theSize.z() * theSize.y() ) * static_cast<T> (2.0);
+
+ if (anArea < std::numeric_limits<T>::epsilon())
+ {
+ return theSize.x() +
+ theSize.y() +
+ theSize.z();
+ }
+
+ return anArea;
}
};
--- /dev/null
+puts "========"
+puts "OCC25679"
+puts "========"
+puts ""
+############################################################################
+# Visualization, TKOpenGl - View frustum culling clips wrong objects
+############################################################################
+
+pload VISUALIZATION MODELING
+
+set LINES_IN_ROW 50
+
+set aNoCulling $imagedir/${casename}_without.png
+set aWithCulling $imagedir/${casename}_with.png
+set aDiff $imagedir/${casename}_diff.png
+
+vinit
+
+for {set i 0} {$i < $LINES_IN_ROW} {incr i} {
+ for {set j 0} {$j < $LINES_IN_ROW} {incr j} {
+ set aLineName "line"
+ append aLineName [expr $i * $LINES_IN_ROW + $j]
+ vline $aLineName 0 0 0 1 0 0
+ vsetlocation $aLineName [expr $i * 3] [expr $j * 3] 0
+ }
+}
+
+vfit
+
+vfrustumculling 1
+vdump $aWithCulling
+vfrustumculling 0
+vdump $aNoCulling
+
+set aDiffRes [diffimage $aWithCulling $aNoCulling 0.1 0 0 $aDiff]
+if {$aDiffRes != 0} {
+ puts "ERROR : Test failed: there is a difference between images rendered with and without frustum culling"
+}