aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/BoundingIntervalHierarchy.h
diff options
context:
space:
mode:
authorMalcrom <malcromdev@gmail.com>2012-02-09 16:43:00 -0330
committerMalcrom <malcromdev@gmail.com>2012-02-09 16:43:00 -0330
commitb20c0a1770872caec0f9e8069241e23df005ba60 (patch)
treea4752d89d7bb49c133f12fd1ce66db2f9766fe2f /src/server/collision/BoundingIntervalHierarchy.h
parent197b72ccb66083460dee8b542ede83c69259e096 (diff)
parent800cf737500048a0950dcde312b35be08e1ed006 (diff)
Merge branch 'master' of git://github.com/TrinityCore/TrinityCore
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