This commit is contained in:
TheLuda 2008-10-15 18:24:39 +02:00
parent 800ee76535
commit 9116f0286b
29 changed files with 253 additions and 254 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
compile
FILES
INSTALL INSTALL
*.pyc *.pyc

View file

@ -279,11 +279,11 @@ public:
/** Compares centers */ /** Compares centers */
class CenterComparator { class CenterComparator {
public: public:
Vector3::Axis sortAxis; Vector3::Axis sortAxis;
CenterComparator(Vector3::Axis a) : sortAxis(a) {} CenterComparator(Vector3::Axis a) : sortAxis(a) {}
inline int operator()(_AABSPTree::Handle<T>* A, const _AABSPTree::Handle<T>* B) const { inline int operator()(_AABSPTree::Handle<T>* A, const _AABSPTree::Handle<T>* B) const {
float a = A->center[sortAxis]; float a = A->center[sortAxis];
float b = B->center[sortAxis]; float b = B->center[sortAxis];
@ -294,18 +294,18 @@ public:
} else { } else {
return 0; return 0;
} }
} }
}; };
/** Compares bounds for strict >, <, or overlap*/ /** Compares bounds for strict >, <, or overlap*/
class BoundsComparator { class BoundsComparator {
public: public:
Vector3::Axis sortAxis; Vector3::Axis sortAxis;
BoundsComparator(Vector3::Axis a) : sortAxis(a) {} BoundsComparator(Vector3::Axis a) : sortAxis(a) {}
inline int operator()(_AABSPTree::Handle<T>* A, const _AABSPTree::Handle<T>* B) const { inline int operator()(_AABSPTree::Handle<T>* A, const _AABSPTree::Handle<T>* B) const {
const AABox& a = A->bounds; const AABox& a = A->bounds;
const AABox& b = B->bounds; const AABox& b = B->bounds;
@ -316,33 +316,33 @@ public:
} else { } else {
return 0; return 0;
} }
} }
}; };
/** Compares bounds to the sort location */ /** Compares bounds to the sort location */
class Comparator { class Comparator {
public: public:
Vector3::Axis sortAxis; Vector3::Axis sortAxis;
float sortLocation; float sortLocation;
Comparator(Vector3::Axis a, float l) : sortAxis(a), sortLocation(l) {} Comparator(Vector3::Axis a, float l) : sortAxis(a), sortLocation(l) {}
inline int operator()(_AABSPTree::Handle<T>* /*ignore*/, const _AABSPTree::Handle<T>* handle) const { inline int operator()(_AABSPTree::Handle<T>* /*ignore*/, const _AABSPTree::Handle<T>* handle) const {
const AABox& box = handle->bounds; const AABox& box = handle->bounds;
debugAssert(ignore == NULL); debugAssert(ignore == NULL);
if (box.high()[sortAxis] < sortLocation) { if (box.high()[sortAxis] < sortLocation) {
// Box is strictly below the sort location // Box is strictly below the sort location
return -1; return -1;
} else if (box.low()[sortAxis] > sortLocation) { } else if (box.low()[sortAxis] > sortLocation) {
// Box is strictly above the sort location // Box is strictly above the sort location
return 1; return 1;
} else { } else {
// Box overlaps the sort location // Box overlaps the sort location
return 0; return 0;
} }
} }
}; };
// Using System::malloc with this class provided no speed improvement. // Using System::malloc with this class provided no speed improvement.
@ -450,42 +450,42 @@ public:
} }
} }
void verifyNode(const Vector3& lo, const Vector3& hi) { void verifyNode(const Vector3& lo, const Vector3& hi) {
// debugPrintf("Verifying: split %d @ %f [%f, %f, %f], [%f, %f, %f]\n", // debugPrintf("Verifying: split %d @ %f [%f, %f, %f], [%f, %f, %f]\n",
// splitAxis, splitLocation, lo.x, lo.y, lo.z, hi.x, hi.y, hi.z); // splitAxis, splitLocation, lo.x, lo.y, lo.z, hi.x, hi.y, hi.z);
debugAssert(lo == splitBounds.low()); debugAssert(lo == splitBounds.low());
debugAssert(hi == splitBounds.high()); debugAssert(hi == splitBounds.high());
for (int i = 0; i < valueArray.length(); ++i) { for (int i = 0; i < valueArray.length(); ++i) {
const AABox& b = valueArray[i]->bounds; const AABox& b = valueArray[i]->bounds;
debugAssert(b == boundsArray[i]); debugAssert(b == boundsArray[i]);
for(int axis = 0; axis < 3; ++axis) { for(int axis = 0; axis < 3; ++axis) {
debugAssert(b.low()[axis] <= b.high()[axis]); debugAssert(b.low()[axis] <= b.high()[axis]);
debugAssert(b.low()[axis] >= lo[axis]); debugAssert(b.low()[axis] >= lo[axis]);
debugAssert(b.high()[axis] <= hi[axis]); debugAssert(b.high()[axis] <= hi[axis]);
} }
} }
if (child[0] || child[1]) { if (child[0] || child[1]) {
debugAssert(lo[splitAxis] < splitLocation); debugAssert(lo[splitAxis] < splitLocation);
debugAssert(hi[splitAxis] > splitLocation); debugAssert(hi[splitAxis] > splitLocation);
} }
Vector3 newLo = lo; Vector3 newLo = lo;
newLo[splitAxis] = splitLocation; newLo[splitAxis] = splitLocation;
Vector3 newHi = hi; Vector3 newHi = hi;
newHi[splitAxis] = splitLocation; newHi[splitAxis] = splitLocation;
if (child[0] != NULL) { if (child[0] != NULL) {
child[0]->verifyNode(lo, newHi); child[0]->verifyNode(lo, newHi);
} }
if (child[1] != NULL) { if (child[1] != NULL) {
child[1]->verifyNode(newLo, hi); child[1]->verifyNode(newLo, hi);
} }
} }
#if 0 #if 0
/** /**
@ -735,26 +735,26 @@ public:
int numMeanSplits, int numMeanSplits,
Array<_AABSPTree::Handle<T> * >& temp) { Array<_AABSPTree::Handle<T> * >& temp) {
Node* node = NULL; Node* node = NULL;
if (source.size() <= valuesPerNode) { if (source.size() <= valuesPerNode) {
// Make a new leaf node // Make a new leaf node
node = new Node(source); node = new Node(source);
// Set the pointers in the memberTable // Set the pointers in the memberTable
for (int i = 0; i < source.size(); ++i) { for (int i = 0; i < source.size(); ++i) {
memberTable.set(Member(source[i]), node); memberTable.set(Member(source[i]), node);
} }
source.clear(); source.clear();
} else { } else {
// Make a new internal node // Make a new internal node
node = new Node(); node = new Node();
const AABox bounds = computeBounds(source, 0, source.size() - 1); const AABox bounds = computeBounds(source, 0, source.size() - 1);
const Vector3 extent = bounds.high() - bounds.low(); const Vector3 extent = bounds.high() - bounds.low();
Vector3::Axis splitAxis = extent.primaryAxis(); Vector3::Axis splitAxis = extent.primaryAxis();
float splitLocation; float splitLocation;
@ -846,20 +846,20 @@ public:
for (int i = 0; i < node->valueArray.size(); ++i) { for (int i = 0; i < node->valueArray.size(); ++i) {
_AABSPTree::Handle<T> * v = node->valueArray[i]; _AABSPTree::Handle<T> * v = node->valueArray[i];
node->boundsArray[i] = v->bounds; node->boundsArray[i] = v->bounds;
memberTable.set(Member(v), node); memberTable.set(Member(v), node);
} }
if (lt.size() > 0) { if (lt.size() > 0) {
node->child[0] = makeNode(lt, valuesPerNode, numMeanSplits - 1, temp); node->child[0] = makeNode(lt, valuesPerNode, numMeanSplits - 1, temp);
} }
if (gt.size() > 0) { if (gt.size() > 0) {
node->child[1] = makeNode(gt, valuesPerNode, numMeanSplits - 1, temp); node->child[1] = makeNode(gt, valuesPerNode, numMeanSplits - 1, temp);
} }
} }
return node; return node;
} }
/** /**
@ -1317,51 +1317,51 @@ public:
BoxIntersectionIterator& operator++() { BoxIntersectionIterator& operator++() {
++nextValueArrayIndex; ++nextValueArrayIndex;
bool foundIntersection = false; bool foundIntersection = false;
while (! isEnd && ! foundIntersection) { while (! isEnd && ! foundIntersection) {
// Search for the next node if we've exhausted this one // Search for the next node if we've exhausted this one
while ((! isEnd) && (nextValueArrayIndex >= node->valueArray.length())) { while ((! isEnd) && (nextValueArrayIndex >= node->valueArray.length())) {
// If we entered this loop, then the iterator has exhausted the elements at // If we entered this loop, then the iterator has exhausted the elements at
// node (possibly because it just switched to a child node with no members). // node (possibly because it just switched to a child node with no members).
// This loop continues until it finds a node with members or reaches // This loop continues until it finds a node with members or reaches
// the end of the whole intersection search. // the end of the whole intersection search.
// If the right child overlaps the box, push it onto the stack for // If the right child overlaps the box, push it onto the stack for
// processing. // processing.
if ((node->child[1] != NULL) && if ((node->child[1] != NULL) &&
(box.high()[node->splitAxis] > node->splitLocation)) { (box.high()[node->splitAxis] > node->splitLocation)) {
stack.push(node->child[1]); stack.push(node->child[1]);
} }
// If the left child overlaps the box, push it onto the stack for // If the left child overlaps the box, push it onto the stack for
// processing. // processing.
if ((node->child[0] != NULL) && if ((node->child[0] != NULL) &&
(box.low()[node->splitAxis] < node->splitLocation)) { (box.low()[node->splitAxis] < node->splitLocation)) {
stack.push(node->child[0]); stack.push(node->child[0]);
} }
if (stack.length() > 0) { if (stack.length() > 0) {
// Go on to the next node (which may be either one of the ones we // Go on to the next node (which may be either one of the ones we
// just pushed, or one from farther back the tree). // just pushed, or one from farther back the tree).
node = stack.pop(); node = stack.pop();
nextValueArrayIndex = 0; nextValueArrayIndex = 0;
} else { } else {
// That was the last node; we're done iterating // That was the last node; we're done iterating
isEnd = true; isEnd = true;
} }
} }
// Search for the next intersection at this node until we run out of children // Search for the next intersection at this node until we run out of children
while (! isEnd && ! foundIntersection && (nextValueArrayIndex < node->valueArray.length())) { while (! isEnd && ! foundIntersection && (nextValueArrayIndex < node->valueArray.length())) {
if (box.intersects(node->boundsArray[nextValueArrayIndex])) { if (box.intersects(node->boundsArray[nextValueArrayIndex])) {
foundIntersection = true; foundIntersection = true;
} else { } else {
++nextValueArrayIndex; ++nextValueArrayIndex;
// If we exhaust this node, we'll loop around the master loop // If we exhaust this node, we'll loop around the master loop
// to find a new node. // to find a new node.
} }
} }
} }
return *this; return *this;
@ -1615,6 +1615,3 @@ public:
} }
#endif #endif

View file

@ -27,30 +27,30 @@ AM_CPPFLAGS = $(MANGOS_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(sr
noinst_LIBRARIES = libmangosvmaps.a noinst_LIBRARIES = libmangosvmaps.a
libmangosvmaps_a_SOURCES = \ libmangosvmaps_a_SOURCES = \
AABSPTree.h \ AABSPTree.h \
BaseModel.cpp \ BaseModel.cpp \
BaseModel.h \ BaseModel.h \
CoordModelMapping.cpp \ CoordModelMapping.cpp \
CoordModelMapping.h \ CoordModelMapping.h \
DebugCmdLogger.cpp \ DebugCmdLogger.cpp \
DebugCmdLogger.h \ DebugCmdLogger.h \
IVMapManager.h \ IVMapManager.h \
ManagedModelContainer.cpp \ ManagedModelContainer.cpp \
ManagedModelContainer.h \ ManagedModelContainer.h \
ModelContainer.cpp \ ModelContainer.cpp \
ModelContainer.h \ ModelContainer.h \
NodeValueAccess.h \ NodeValueAccess.h \
ShortBox.h \ ShortBox.h \
ShortVector.h \ ShortVector.h \
SubModel.cpp \ SubModel.cpp \
SubModel.h \ SubModel.h \
TileAssembler.cpp \ TileAssembler.cpp \
TileAssembler.h \ TileAssembler.h \
TreeNode.cpp \ TreeNode.cpp \
TreeNode.h \ TreeNode.h \
VMapDefinitions.h \ VMapDefinitions.h \
VMapFactory.cpp \ VMapFactory.cpp \
VMapFactory.h \ VMapFactory.h \
VMapManager.cpp \ VMapManager.cpp \
VMapManager.h \ VMapManager.h \
VMapTools.h VMapTools.h

View file

@ -66,7 +66,7 @@ namespace VMAP
nSubModels += pNode.valueArray.size(); nSubModels += pNode.valueArray.size();
for(int i=0;i<pNode.valueArray.size(); i++) for(int i=0;i<pNode.valueArray.size(); i++)
{ {
G3D::_AABSPTree::Handle<SubModel*>* h= pNode.valueArray[i]; G3D::_AABSPTree::Handle<SubModel*>* h= pNode.valueArray[i];
SubModel *m = h->value; SubModel *m = h->value;
// add the internal nodes as well // add the internal nodes as well
nNodes += m->getNNodes(); nNodes += m->getNNodes();