aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/BoundingIntervalHierarchy.h
diff options
context:
space:
mode:
authorSubv2112 <s.v.h21@hotmail.com>2012-02-03 16:03:52 -0500
committerSubv <s.v.h21@hotmail.com>2012-02-09 13:58:22 -0500
commit93d199f04382fe3c7f6f08f59fd2ad058568679a (patch)
treeb698029a6cf0649bed6689cd0aa4414d8ad1aa42 /src/server/collision/BoundingIntervalHierarchy.h
parent229d4119e887fa6079a6e0b093860e11b5facb63 (diff)
Core/Collision: Ported dynamic line of sight patch by Silverice from MaNGOS and
added lots of improvements Please re-extract vmaps
Diffstat (limited to 'src/server/collision/BoundingIntervalHierarchy.h')
-rwxr-xr-xsrc/server/collision/BoundingIntervalHierarchy.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/server/collision/BoundingIntervalHierarchy.h b/src/server/collision/BoundingIntervalHierarchy.h
index b0c35237a9d..ea70fc3e322 100755
--- a/src/server/collision/BoundingIntervalHierarchy.h
+++ b/src/server/collision/BoundingIntervalHierarchy.h
@@ -81,13 +81,25 @@ struct AABound
class BIH
{
+ private:
+ void init_empty()
+ {
+ tree.clear();
+ objects.clear();
+ // create space for the first node
+ tree.push_back(3 << 30); // dummy leaf
+ tree.insert(tree.end(), 2, 0);
+ }
public:
- BIH() {};
- template< class T, class BoundsFunc >
- void build(const std::vector<T> &primitives, BoundsFunc &getBounds, uint32 leafSize = 3, bool printStats=false)
+ BIH() { init_empty(); }
+ template< class BoundsFunc, class PrimArray >
+ void build(const PrimArray &primitives, BoundsFunc &getBounds, uint32 leafSize = 3, bool printStats=false)
{
- if (primitives.empty())
+ if (primitives.size() == 0)
+ {
+ init_empty();
return;
+ }
buildData dat;
dat.maxPrims = leafSize;
@@ -397,4 +409,4 @@ class BIH
void subdivide(int left, int right, std::vector<uint32> &tempTree, buildData &dat, AABound &gridBox, AABound &nodeBox, int nodeIndex, int depth, BuildStats &stats);
};
-#endif // _BIH_H
+#endif // _BIH_H \ No newline at end of file