diff --git a/server/gameserver/navmeshhelper.cc b/server/gameserver/navmeshhelper.cc index 9b1c8fa..b2f03e3 100644 --- a/server/gameserver/navmeshhelper.cc +++ b/server/gameserver/navmeshhelper.cc @@ -107,3 +107,41 @@ void NavMeshHelper::OutputObjFile(MapInstance* map_instance) fclose(fp); } } + +static bool checkOverlapRect(const float amin[2], const float amax[2], + const float bmin[2], const float bmax[2]) +{ + bool overlap = true; + overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap; + overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap; + return overlap; +} + +int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm, + float bmin[2], float bmax[2], + int* ids, const int maxIds) +{ + // Traverse tree + int i = 0; + int n = 0; + while (i < cm->nnodes) { + const rcChunkyTriMeshNode* node = &cm->nodes[i]; + const bool overlap = checkOverlapRect(bmin, bmax, node->bmin, node->bmax); + const bool isLeafNode = node->i >= 0; + + if (isLeafNode && overlap) { + if (n < maxIds) { + ids[n] = i; + n++; + } + } + + if (overlap || isLeafNode) + i++; + else { + const int escapeIndex = -node->i; + i += escapeIndex; + } + } + return n; +} diff --git a/server/gameserver/navmeshhelper.h b/server/gameserver/navmeshhelper.h index 5c78b33..6900102 100644 --- a/server/gameserver/navmeshhelper.h +++ b/server/gameserver/navmeshhelper.h @@ -74,43 +74,9 @@ struct ConvexVolume rcAreaModification areaMod; }; -inline bool checkOverlapRect(const float amin[2], const float amax[2], - const float bmin[2], const float bmax[2]) -{ - bool overlap = true; - overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap; - overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap; - return overlap; -} - -inline int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm, +int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm, float bmin[2], float bmax[2], - int* ids, const int maxIds) -{ - // Traverse tree - int i = 0; - int n = 0; - while (i < cm->nnodes) { - const rcChunkyTriMeshNode* node = &cm->nodes[i]; - const bool overlap = checkOverlapRect(bmin, bmax, node->bmin, node->bmax); - const bool isLeafNode = node->i >= 0; - - if (isLeafNode && overlap) { - if (n < maxIds) { - ids[n] = i; - n++; - } - } - - if (overlap || isLeafNode) - i++; - else { - const int escapeIndex = -node->i; - i += escapeIndex; - } - } - return n; -} + int* ids, const int maxIds); struct RasterizationContext {