From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/NavMesh/NavMeshCarving.h | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Runtime/NavMesh/NavMeshCarving.h (limited to 'Runtime/NavMesh/NavMeshCarving.h') diff --git a/Runtime/NavMesh/NavMeshCarving.h b/Runtime/NavMesh/NavMeshCarving.h new file mode 100644 index 0000000..0cec244 --- /dev/null +++ b/Runtime/NavMesh/NavMeshCarving.h @@ -0,0 +1,45 @@ +#pragma once + +#include "Runtime/Utilities/dynamic_array.h" +#include "Runtime/NavMesh/NavMeshTypes.h" +#include "Runtime/Geometry/AABB.h" + +class NavMeshObstacle; +class NavMesh; + +class NavMeshCarving +{ + enum TileCarveStatus + { + kIgnore = 0, + kRestore = 1, + kCarve = 2 + }; + + struct ObstacleCarveInfo + { + NavMeshCarveData carveData; + MinMaxAABB carveBounds; + NavMeshObstacle* obstacle; + }; + +public: + NavMeshCarving (); + ~NavMeshCarving (); + + + void AddObstacle (NavMeshObstacle& obstacle, int& handle); + void RemoveObstacle (int& handle); + bool Carve (); + +private: + + void UpdateCarveData (dynamic_array& newCarveData); + bool UpdateTiles (NavMesh* navmesh, const dynamic_array& newCarveData); + + TileCarveStatus CollectCarveDataAndStatus (dynamic_array& transforms, dynamic_array& sizes, dynamic_array& aabbs, const dynamic_array& newCarveData, const MinMaxAABB& tileBounds) const; + void CollectOverlappingCarveData (dynamic_array& transforms, dynamic_array& sizes, dynamic_array& aabbs, const MinMaxAABB& bounds) const; + + dynamic_array m_ObstacleInfo; + dynamic_array m_OldCarveBounds; +}; -- cgit v1.1-26-g67d0