blob: 49bdd0223e9f18d8948ac3e13723c0500161bf50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#include "UnityPrefix.h"
#include "NavMeshSettings.h"
#include "NavMeshManager.h"
#include "Runtime/Serialize/TransferFunctions/SerializeTransfer.h"
#include "Runtime/BaseClasses/ManagerContext.h"
#include "Runtime/BaseClasses/IsPlaying.h"
#include "OffMeshLink.h"
#include "NavMeshLayers.h"
#include "NavMesh.h"
#include "HeightmapData.h"
#include "DetourNavMesh.h"
void NavMeshSettings::InitializeClass ()
{
InitializeNavMeshManager ();
}
void NavMeshSettings::CleanupClass ()
{
CleanupNavMeshManager ();
}
NavMeshSettings::NavMeshSettings (MemLabelId& label, ObjectCreationMode mode)
: Super (label, mode)
{
}
NavMeshSettings::~NavMeshSettings ()
{
GetNavMeshManager ().CleanupMeshDependencies ();
}
void NavMeshSettings::Reset ()
{
Super::Reset ();
#if UNITY_EDITOR
m_BuildSettings = NavMeshBuildSettings ();
#endif
}
void NavMeshSettings::AwakeFromLoad (AwakeFromLoadMode mode)
{
Super::AwakeFromLoad (mode);
// Initialize NavMesh
const dtNavMesh* internalNavMesh = NULL;
const HeightMeshQuery* heightMeshQuery = NULL;
if (m_NavMesh)
{
// Calling m_NavMesh->Create () here to ensure state of navmesh is restored.
// Were are already copying the data so memory usage is not affected.
m_NavMesh->Create ();
internalNavMesh = m_NavMesh->GetInternalNavMesh ();
heightMeshQuery = m_NavMesh->GetHeightMeshQuery ();
}
else
{
GetNavMeshManager ().CleanupMeshDependencies ();
}
GetNavMeshManager ().Initialize (internalNavMesh, heightMeshQuery);
}
template<class T>
void NavMeshSettings::Transfer (T& transfer)
{
Super::Transfer (transfer);
TRANSFER_EDITOR_ONLY (m_BuildSettings);
TRANSFER (m_NavMesh);
}
bool NavMeshSettings::SetOffMeshPolyInstanceID (dtPolyRef ref, int instanceID)
{
if (dtNavMesh* navmesh = GetInternalNavMesh ())
return navmesh->setOffMeshPolyInstanceID (ref, instanceID) == DT_SUCCESS;
return false;
}
void NavMeshSettings::SetOffMeshPolyCostOverride (dtPolyRef ref, float costOverride)
{
if (dtNavMesh* navmesh = GetInternalNavMesh ())
navmesh->setOffMeshPolyCostOverride (ref, costOverride);
}
void NavMeshSettings::SetOffMeshPolyAccess (dtPolyRef ref, bool access)
{
if (dtNavMesh* navmesh = GetInternalNavMesh ())
navmesh->setOffMeshPolyAccess (ref, access);
}
dtNavMesh* NavMeshSettings::GetInternalNavMesh ()
{
NavMesh* navmesh = GetNavMesh ();
if (navmesh == NULL)
return NULL;
return navmesh->GetInternalNavMesh ();
}
IMPLEMENT_OBJECT_SERIALIZE (NavMeshSettings)
IMPLEMENT_CLASS_HAS_INIT (NavMeshSettings)
GET_MANAGER (NavMeshSettings)
|