summaryrefslogtreecommitdiff
path: root/Runtime/NavMesh/NavMeshManager.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/NavMesh/NavMeshManager.h
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/NavMesh/NavMeshManager.h')
-rw-r--r--Runtime/NavMesh/NavMeshManager.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/Runtime/NavMesh/NavMeshManager.h b/Runtime/NavMesh/NavMeshManager.h
new file mode 100644
index 0000000..e761ef7
--- /dev/null
+++ b/Runtime/NavMesh/NavMeshManager.h
@@ -0,0 +1,96 @@
+#pragma once
+
+#include "Runtime/BaseClasses/GameManager.h"
+
+class CrowdProfiler;
+class HeightMeshQuery;
+class NavMeshAgent;
+class NavMeshCarving;
+class NavMeshObstacle;
+class OffMeshLink;
+class dtCrowd;
+class dtNavMesh;
+class dtNavMeshQuery;
+struct dtCrowdAgentDebugInfo;
+struct dtMeshHeader;
+
+
+class NavMeshManager
+{
+public:
+
+ NavMeshManager ();
+ ~NavMeshManager ();
+
+ // NavMeshModule Interface
+ virtual void Update ();
+
+ void Initialize (const dtNavMesh* navMesh, const HeightMeshQuery* heightMeshQuery);
+ void CleanupMeshDependencies (const dtNavMesh* mesh);
+ void CleanupMeshDependencies ();
+
+ inline dtCrowd* GetCrowdSystem ();
+ inline NavMeshCarving* GetCarvingSystem ();
+ const dtNavMeshQuery* GetInternalNavMeshQuery () const;
+ const dtNavMesh* GetInternalNavMesh () const;
+
+ void RegisterAgent (NavMeshAgent& agent, int& handle);
+ void UnregisterAgent (int& handle);
+
+ void RegisterObstacle (NavMeshObstacle& obstacle, int& handle);
+ void UnregisterObstacle (int& handle);
+
+ void RegisterOffMeshLink (OffMeshLink& link, int& handle);
+ void UnregisterOffMeshLink (int& handle);
+
+ void UpdateAllNavMeshAgentCosts (int layerIndex, float layerCost);
+
+#if UNITY_EDITOR
+ inline dtCrowdAgentDebugInfo* GetInternalDebugInfo ();
+#endif
+
+private:
+ const dtMeshHeader* GetNavMeshHeader (const dtNavMesh* navmesh);
+ bool InitializeCrowdSystem (const dtNavMesh* navmesh, const HeightMeshQuery* heightMeshQuery, const dtMeshHeader* header);
+ void InitializeObstacleSamplingQuality ();
+ void InitializeCarvingSystem ();
+
+ void NotifyNavMeshChanged ();
+ void NotifyNavMeshCleanup ();
+ void UpdateCrowdSystem (float deltaTime);
+ void UpdateCarving ();
+ void UpdateDynamicLinks ();
+ void InvalidateDynamicLinks ();
+
+ dynamic_array<NavMeshAgent*> m_Agents;
+ dynamic_array<NavMeshObstacle*> m_Obstacles;
+ dynamic_array<OffMeshLink*> m_Links;
+
+ NavMeshCarving* m_CarvingSystem;
+
+ dtCrowd* m_CrowdSystem;
+ dtCrowdAgentDebugInfo* m_CrowdAgentDebugInfo;
+ CrowdProfiler* m_Profiler;
+ static const int kInitialAgentCount;
+};
+
+inline dtCrowd* NavMeshManager::GetCrowdSystem ()
+{
+ return m_CrowdSystem;
+}
+
+inline NavMeshCarving* NavMeshManager::GetCarvingSystem ()
+{
+ return m_CarvingSystem;
+}
+
+#if UNITY_EDITOR
+inline dtCrowdAgentDebugInfo* NavMeshManager::GetInternalDebugInfo ()
+{
+ return m_CrowdAgentDebugInfo;
+}
+#endif // UNITY_EDITOR
+
+NavMeshManager& GetNavMeshManager ();
+void InitializeNavMeshManager ();
+void CleanupNavMeshManager ();