diff --git a/vcg/space/index/aabb_binary_tree/aabb_binary_tree.h b/vcg/space/index/aabb_binary_tree/aabb_binary_tree.h index 0b549125..e6e8a75d 100644 --- a/vcg/space/index/aabb_binary_tree/aabb_binary_tree.h +++ b/vcg/space/index/aabb_binary_tree/aabb_binary_tree.h @@ -25,6 +25,10 @@ History $Log: not supported by cvs2svn $ +Revision 1.4 2005/09/28 21:23:03 m_di_benedetto +Added Import() to box and barycenter functors +to handle tree and objects with different ScalarType. + Revision 1.3 2005/09/28 20:10:41 m_di_benedetto First Commit. @@ -38,6 +42,7 @@ First Commit. #include #include #include +#include #include #include #include @@ -67,25 +72,9 @@ public: template inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd) { - class GetBoxFunctor { - public: - void operator () (const ObjType & obj, Box3 & box) { - Box3 tb; - obj.GetBBox(tb); - box.Import(tb); - } - }; - - class GetBarycenterFunctor { - public: - void operator () (const ObjType & obj, CoordType & bar) { - bar.Import(obj.Barycenter()); - } - }; - GetPointerFunctor getPtr; - GetBoxFunctor getBox; - GetBarycenterFunctor getBarycenter; + GetBox3Functor getBox; + GetBarycenter3Functor getBarycenter; const unsigned int divs = 100; const unsigned int size = (unsigned int)(std::distance(_oBegin, _oEnd)); const unsigned int maxObjectsPerLeaf = (size < divs) ? (size) : ((unsigned int)((float)(std::distance(_oBegin, _oEnd)) / (float)divs)); @@ -96,8 +85,8 @@ public: } template - inline bool Set(const OBJITERATOR & oBegin, const OBJITERATOR & oEnd, OBJITERATORPTRFUNCT & objPtr, OBJBOXFUNCT & objBox, OBJBARYCENTERFUNCT & objBarycenter, const unsigned int maxElemsPerLeaf = 1, const ScalarType & leafBoxMaxVolume = ((ScalarType)0), const bool useVariance = true) { - return (this->tree.Set(oBegin, oEnd, objPtr, objBox, objBarycenter, maxElemsPerLeaf, leafBoxMaxVolume, useVariance)); + inline bool Set(const OBJITERATOR & _oBegin, const OBJITERATOR & _oEnd, OBJITERATORPTRFUNCT & _objPtr, OBJBOXFUNCT & _objBox, OBJBARYCENTERFUNCT & _objBarycenter, const unsigned int _maxElemsPerLeaf = 1, const ScalarType & _leafBoxMaxVolume = ((ScalarType)0), const bool _useVariance = true) { + return (this->tree.Set(_oBegin, _oEnd, _objPtr, _objBox, _objBarycenter, _maxElemsPerLeaf, _leafBoxMaxVolume, _useVariance)); } template @@ -122,6 +111,14 @@ public: return (AABBBinaryTreeRay::Ray(this->tree, _rayIntersector, _ray, _maxDist, _t)); } + inline void InitializeFrustumCull(void) { + (void)(AABBBinaryTreeFrustumCull::Initialize(this->tree)); + } + + inline void FrustumCull(const Plane3 _frustumPlanes[6], const unsigned int _minNodeObjectsCount) { + (void)(AABBBinaryTreeFrustumCull::FrustumCull(this->tree, _frustumPlanes, _minNodeObjectsCount)); + } + protected: TreeType tree;