forked from lazytiger/unityai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnav_mesh_path.go
More file actions
97 lines (77 loc) · 2.16 KB
/
nav_mesh_path.go
File metadata and controls
97 lines (77 loc) · 2.16 KB
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
package unityai
type NavMeshPath struct {
m_timeStamp uint32
m_status NavMeshPathStatus
m_polygons []NavMeshPolyRef
m_sourcePosition Vector3f
m_targetPosition Vector3f
m_Size int32
}
type NavMeshPathStatus int32
const (
kPathComplete NavMeshPathStatus = 0
kPathPartial NavMeshPathStatus = 1
kPathInvalid NavMeshPathStatus = 2
)
func (this *NavMeshPath) GetSourcePosition() Vector3f {
return this.m_sourcePosition
}
func (this *NavMeshPath) SetSourcePosition(sourcePosition Vector3f) {
this.m_sourcePosition = sourcePosition
}
func (this *NavMeshPath) GetTargetPosition() Vector3f {
return this.m_targetPosition
}
func (this *NavMeshPath) SetTargetPosition(targetPosition Vector3f) {
this.m_targetPosition = targetPosition
}
func (this *NavMeshPath) GetPolygonCount() int32 {
return this.m_Size
}
func (this *NavMeshPath) GetPolygonCapacity() int32 {
return int32(len(this.m_polygons))
}
func (this *NavMeshPath) SetPolygonCount(polygonCount int32) {
if this.GetPolygonCapacity() < polygonCount {
this.ReservePolygons(polygonCount)
}
this.m_Size = polygonCount
}
func (this *NavMeshPath) GetPolygonPath() []NavMeshPolyRef {
return this.m_polygons
}
func (this *NavMeshPath) GetPolygonData() []NavMeshPolyRef {
return this.m_polygons[:this.m_Size]
}
func (this *NavMeshPath) GetStatus() NavMeshPathStatus {
return this.m_status
}
func (this *NavMeshPath) IsComplete() bool {
return this.m_status == kPathComplete
}
func (this *NavMeshPath) IsPartial() bool {
return this.m_status == kPathPartial
}
func (this *NavMeshPath) IsInvalid() bool {
return this.m_status == kPathInvalid
}
func (this *NavMeshPath) SetStatus(status NavMeshPathStatus) {
this.m_status = status
}
func (this *NavMeshPath) SetTimeStamp(timeStamp uint32) {
this.m_timeStamp = timeStamp
}
func NewNavMeshPath() *NavMeshPath {
var path NavMeshPath
path.m_status = kPathInvalid
return &path
}
func (this *NavMeshPath) ReservePolygons(size int32) {
kSizeInc := int32(32)
capNum := ((size + kSizeInc - 1) / kSizeInc) * kSizeInc
if cap(this.m_polygons) < int(capNum) {
d := make([]NavMeshPolyRef, capNum, capNum)
copy(d, this.m_polygons)
this.m_polygons = d
}
}