Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Graph
CGraphQuery.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2024 Skylicht Technology CO., LTD
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "RenderMesh/CRenderMeshData.h"
28
#include "ObstacleAvoidance/CObstacleAvoidance.h"
29
#include "WalkingMap/CWalkingTileMap.h"
30
31
namespace
Skylicht
32
{
33
namespace
Graph
34
{
35
class
COctreeNode
36
{
37
public
:
38
core::aabbox3df
Box;
39
core::aabbox3df
OctreeBox;
40
41
int
Level;
42
43
COctreeNode* Parent;
44
COctreeNode* Childs[8];
45
46
core::array<core::triangle3df>
Triangles;
47
CObstacleAvoidance
Obstacle;
48
49
COctreeNode();
50
51
virtual
~COctreeNode();
52
};
53
54
struct
SDistanceTile
55
{
56
float
Distance;
57
STile
* Tile;
58
};
59
60
class
CDistancePriorityQueue
61
{
62
protected
:
63
core::array<SDistanceTile>
m_queue;
64
65
public
:
66
CDistancePriorityQueue();
67
68
virtual
~CDistancePriorityQueue();
69
70
void
push(
const
SDistanceTile
& d);
71
72
void
pop();
73
74
inline
bool
empty()
75
{
76
return
m_queue.empty();
77
}
78
79
const
SDistanceTile
& top();
80
};
81
82
class
CGraphQuery
83
{
84
protected
:
85
COctreeNode
* m_root;
86
87
u32
m_minimalPolysPerNode;
88
89
public
:
90
CGraphQuery();
91
92
virtual
~CGraphQuery();
93
94
void
release();
95
96
void
buildIndexNavMesh(
CMesh
* navMesh,
CObstacleAvoidance
* obstacle);
97
98
inline
COctreeNode
* getRootNode()
99
{
100
return
m_root;
101
}
102
103
bool
getCollisionPoint(
104
const
core::line3d<f32>
& ray,
105
f32
& outBestDistanceSquared,
106
core::vector3df
& outIntersection,
107
core::triangle3df
& outTriangle);
108
109
void
getTriangles(
const
core::aabbox3df
& box,
core::array<core::triangle3df*>
& result);
110
111
void
getObstacles(
const
core::aabbox3df
& box,
CObstacleAvoidance
& obstacle);
112
113
bool
findPath(
CWalkingTileMap
* map,
STile
* from,
STile
* to,
core::array<STile*>
& result);
114
115
protected
:
116
117
void
constructOctree(
COctreeNode
* node);
118
119
void
getTrianglesFromOctree(
120
core::array<core::triangle3df*>
& listTriangle,
121
COctreeNode
* node,
122
const
core::vector3df
& midLine,
123
const
core::vector3df
& lineVect,
124
float
halfLength);
125
126
void
getTrianglesFromOctree(
127
core::array<core::triangle3df*>
& listTriangle,
128
COctreeNode
* node,
129
const
core::aabbox3df
& box);
130
131
void
getObstacleFromOctree(
132
CObstacleAvoidance
& obstacle,
133
COctreeNode
* node,
134
const
core::aabbox3df
& box);
135
};
136
}
137
}
Skylicht::CMesh
Definition
CMesh.h:75
Skylicht::Graph::CObstacleAvoidance
Definition
CObstacleAvoidance.h:38
Skylicht::Graph::COctreeNode
Definition
CGraphQuery.h:36
Skylicht::Graph::CWalkingTileMap
Definition
CWalkingTileMap.h:106
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition
irrArray.h:23
irr::core::line3d
3D line between two points with intersection methods.
Definition
line3d.h:19
Skylicht::Graph
Component that manages the navigation lifecycle, including NavMesh generation and pathfinding.
Definition
CGraphComponent.h:41
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition
vector3d.h:445
irr::core::triangle3df
triangle3d< f32 > triangle3df
Typedef for a f32 3d triangle.
Definition
triangle3d.h:335
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition
aabbox3d.h:351
irr::f32
float f32
32 bit floating point variable.
Definition
irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition
irrTypes.h:58
Skylicht::Graph::SDistanceTile
Definition
CGraphQuery.h:55
Skylicht::Graph::STile
Definition
CWalkingTileMap.h:36
Generated by
1.17.0