OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
navigation_recast_load.h
1/*
2===========================================================================
3Copyright (C) 2025 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// navigation -- Modern navigation system using Recast and Detour
24
25#pragma once
26
27#include "g_local.h"
28#include "navigation_bsp.h"
29
30class dtNavMesh;
31class dtNavMeshQuery;
32class dtQueryFilter;
33class dtCrowd;
34class dtTileCache;
35struct dtTileCacheAlloc;
36struct dtTileCacheCompressor;
37struct dtTileCacheMeshProcess;
39struct rcPolyMesh;
40struct rcPolyMeshDetail;
43
48class NavigationMap
49{
50public:
51 NavigationMap();
52 ~NavigationMap();
53
59 void LoadWorldMap(const char *mapname);
60
66 void CleanUp(qboolean samemap);
67
71 void ClearNavigation();
72
78 bool IsValid() const;
79
85 dtNavMesh *GetNavMesh() const;
86
92 dtNavMeshQuery *GetNavMeshQuery() const;
93
99 const dtQueryFilter *GetQueryFilter() const;
100
106 const navMap_t& GetNavigationData() const;
107
112 void Update();
113
114private:
115 void GatherOffMeshPoints(Container<offMeshNavigationPoint>& points, const rcPolyMesh *polyMesh);
116 void GeneratePolyMesh(
117 RecastBuildContext& buildContext,
118 float *vertsBuffer,
119 int numVertices,
120 int *indexesBuffer,
121 int numIndexes,
122 rcPolyMesh *& outPolyMesh,
123 rcPolyMeshDetail *& outPolyMeshDetail
124 );
125
126 void InitializeExtensions();
127 void ClearExtensions();
128
129 void InitializeNavMesh(RecastBuildContext& buildContext, const navMap_t& navMap);
130 void InitializeFilter();
131
132 void BuildDetourData(
133 RecastBuildContext& buildContext,
134 rcPolyMesh *polyMesh,
135 rcPolyMeshDetail *polyMeshDetail,
136 int index,
138 );
139
140 void BuildRecastMesh(
141 RecastBuildContext& buildContext,
142 const navModel_t& model,
143 const Vector& origin,
144 const Vector& angles,
145 rcPolyMesh *& outPolyMesh,
146 rcPolyMeshDetail *& outPolyMeshDetail
147 );
148 void ProcessBSPForNavigation(const char *mapname, navMap_t& outNavigationMap);
149
150 void BuildWorldMesh(RecastBuildContext& buildContext, const navMap_t& navigationMap);
151 void BuildMeshesForEntities(RecastBuildContext& buildContext, const navMap_t& navigationMap);
152
153private:
154 dtNavMesh *navMeshDt;
155 dtNavMeshQuery *navMeshQuery;
156 dtQueryFilter *queryFilter;
157 NavigationBSP navigationData;
158
159public:
160 float *offMeshConVerts;
161 float *offMeshConRad;
162 unsigned short *offMeshConFlags;
163 unsigned char *offMeshConAreas;
164 unsigned char *offMeshConDir;
165 unsigned int *offMeshConUserID;
166 int offMeshConCount;
167
169
170 str currentMap;
171 bool validNavigation;
172};
173
174extern NavigationMap navigationMap;
175
176void G_Navigation_Frame();
Definition container.h:85
Definition navigation_recast_load_ext.h:74
Navigation generated by a BSP file.
Definition navigation_bsp.h:353
Full navigation map with meshes and tiles.
Definition navigation_recast_load.h:49
void LoadWorldMap(const char *mapname)
Generate the navigation system from the specified BSP map file.
Definition navigation_recast_load.cpp:713
const dtQueryFilter * GetQueryFilter() const
Get the query used when querying the navmesh.
Definition navigation_recast_load.cpp:581
void Update()
Update the navigation map.
Definition navigation_recast_load.cpp:601
dtNavMesh * GetNavMesh() const
Get the navigation mesh.
Definition navigation_recast_load.cpp:561
void CleanUp(qboolean samemap)
Do some cleanups.
Definition navigation_recast_load.cpp:797
dtNavMeshQuery * GetNavMeshQuery() const
Get navigation query object.
Definition navigation_recast_load.cpp:571
bool IsValid() const
Whether or not the navigation system is valid.
Definition navigation_recast_load.cpp:635
void ClearNavigation()
Clear and free memory allocated for the navigation system.
Definition navigation_recast_load.cpp:608
const navMap_t & GetNavigationData() const
Return the navigation data loaded from the BSP.
Definition navigation_recast_load.cpp:591
Recast build context.
Definition navigation_recast_load.cpp:53
Definition vector.h:61
Definition str.h:77
Navigation map. Contains indices and vertices renderer from LOD terrain, brushes and patches.
Definition navigation_bsp.h:98
Navigation model containing faces.
Definition navigation_bsp.h:84
An offmesh point that the navigation system will use to find path.
Definition navigation_recast_load_ext.h:40