From 3a5ae8d071c314219c834aa4dfa58e3d4904d9aa Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 17 Aug 2020 20:45:21 +0800 Subject: [PATCH] 1 --- server/gameserver/navmeshbuilder.cc | 2 + server/gameserver/navmeshhelper.cc | 38 ------------------- server/gameserver/navmeshhelper.h | 58 ++--------------------------- 3 files changed, 6 insertions(+), 92 deletions(-) diff --git a/server/gameserver/navmeshbuilder.cc b/server/gameserver/navmeshbuilder.cc index 7572ef3..a8bde38 100644 --- a/server/gameserver/navmeshbuilder.cc +++ b/server/gameserver/navmeshbuilder.cc @@ -10,6 +10,8 @@ #include "navmeshhelper.h" +#include "framework/cpp/inputgemo.h" + void NavMeshBuilder::Init() { diff --git a/server/gameserver/navmeshhelper.cc b/server/gameserver/navmeshhelper.cc index b2f03e3..9b1c8fa 100644 --- a/server/gameserver/navmeshhelper.cc +++ b/server/gameserver/navmeshhelper.cc @@ -107,41 +107,3 @@ 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 6dd6a4b..92d6807 100644 --- a/server/gameserver/navmeshhelper.h +++ b/server/gameserver/navmeshhelper.h @@ -37,47 +37,6 @@ struct TileCacheData int dataSize; }; -struct rcChunkyTriMeshNode -{ - float bmin[2]; - float bmax[2]; - int i; - int n; -}; - -struct rcChunkyTriMesh -{ - inline rcChunkyTriMesh() : nodes(0), nnodes(0), tris(0), ntris(0), maxTrisPerChunk(0) {}; - inline ~rcChunkyTriMesh() { delete [] nodes; delete [] tris; } - - rcChunkyTriMeshNode* nodes; - int nnodes; - int* tris; - int ntris; - int maxTrisPerChunk; - -private: - // Explicitly disabled copy constructor and copy assignment operator. - #if 0 - rcChunkyTriMesh(const rcChunkyTriMesh&); - rcChunkyTriMesh& operator=(const rcChunkyTriMesh&); - #endif -}; - -static const int MAX_CONVEXVOL_PTS = 12; -struct ConvexVolume -{ - ConvexVolume(): areaMod(RC_AREA_FLAGS_MASK) {} - float verts[MAX_CONVEXVOL_PTS*3]; - float hmin, hmax; - int nverts; - rcAreaModification areaMod; -}; - -int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm, - float bmin[2], float bmax[2], - int* ids, const int maxIds); - struct RasterizationContext { RasterizationContext() : @@ -219,19 +178,10 @@ class NavMeshHelper static void OutputObjFile(MapInstance* map_instance); }; -class InputGeom +namespace f8 { - public: - const float* GetMeshBoundsMin() const { return nullptr; } - const float* GetMeshBoundsMax() const { return nullptr; } - const float* GetVerts() const { return nullptr; } - int GetVertCount() const { return 0; } - const rcChunkyTriMesh* GetChunkyMesh() { return nullptr; } - #if 0 - const ConvexVolume* GetConvexVolumes() { return nullptr; } - int GetConvexVolumeCount() { return 0; } - #endif -}; + class InputGeom; +} struct BuilderParams { @@ -285,7 +235,7 @@ struct BuilderParams int tile_height = 0; MapInstance* map_instance = nullptr; - InputGeom* gemo = nullptr; + f8::InputGeom* gemo = nullptr; dtNavMesh* navmesh = nullptr; rcContext* ctx = nullptr; dtTileCache* tile_cache = nullptr;