OpenMoHAA 0.82.0
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 dtCrowd;
33class dtTileCache;
34struct dtTileCacheAlloc;
35struct dtTileCacheCompressor;
36struct dtTileCacheMeshProcess;
38struct rcPolyMesh;
39struct rcPolyMeshDetail;
41
46class NavigationMap
47{
48public:
49 NavigationMap();
50 ~NavigationMap();
51
57 void LoadWorldMap(const char *mapname);
58
64 void CleanUp(qboolean samemap);
65
69 void ClearNavigation();
70
76 bool IsValid() const;
77
83 dtNavMesh *GetNavMesh() const;
84
90 dtNavMeshQuery *GetNavMeshQuery() const;
91
97 const navMap_t& GetNavigationData() const;
98
103 void Update();
104
105private:
106 void GatherOffMeshPoints(Container<offMeshNavigationPoint>& points, const rcPolyMesh *polyMesh);
107 void GeneratePolyMesh(
108 RecastBuildContext& buildContext,
109 float *vertsBuffer,
110 int numVertices,
111 int *indexesBuffer,
112 int numIndexes,
113 rcPolyMesh *& outPolyMesh,
114 rcPolyMeshDetail *& outPolyMeshDetail
115 );
116
117 void InitializeNavMesh(RecastBuildContext& buildContext, const navMap_t& navMap);
118 void BuildDetourData(
119 RecastBuildContext& buildContext,
120 rcPolyMesh *polyMesh,
121 rcPolyMeshDetail *polyMeshDetail,
122 int index,
124 );
125
126 void BuildRecastMesh(
127 RecastBuildContext& buildContext,
128 const navModel_t& model,
129 const Vector& origin,
130 const Vector& angles,
131 rcPolyMesh *& outPolyMesh,
132 rcPolyMeshDetail *& outPolyMeshDetail
133 );
134 void ProcessBSPForNavigation(const char *mapname, navMap_t& outNavigationMap);
135
136 void BuildWorldMesh(RecastBuildContext& buildContext, const navMap_t& navigationMap);
137 void BuildMeshesForEntities(RecastBuildContext& buildContext, const navMap_t& navigationMap);
138
139private:
140 dtNavMesh *navMeshDt;
141 dtNavMeshQuery *navMeshQuery;
142 NavigationBSP navigationData;
143
144public:
145 float *offMeshConVerts;
146 float *offMeshConRad;
147 unsigned short *offMeshConFlags;
148 unsigned char *offMeshConAreas;
149 unsigned char *offMeshConDir;
150 unsigned int *offMeshConUserID;
151 int offMeshConCount;
152 str currentMap;
153 bool validNavigation;
154};
155
156extern NavigationMap navigationMap;
157
158void G_Navigation_Frame();
Definition container.h:85
Navigation generated by a BSP file.
Definition navigation_bsp.h:352
Full navigation map with meshes and tiles.
Definition navigation_recast_load.h:47
void LoadWorldMap(const char *mapname)
Generate the navigation system from the specified BSP map file.
Definition navigation_recast_load.cpp:637
void Update()
Update the navigation map.
Definition navigation_recast_load.cpp:533
dtNavMesh * GetNavMesh() const
Get the navigation mesh.
Definition navigation_recast_load.cpp:503
void CleanUp(qboolean samemap)
Do some cleanups.
Definition navigation_recast_load.cpp:712
dtNavMeshQuery * GetNavMeshQuery() const
Get navigation query object.
Definition navigation_recast_load.cpp:513
bool IsValid() const
Whether or not the navigation system is valid.
Definition navigation_recast_load.cpp:559
void ClearNavigation()
Clear and free memory allocated for the navigation system.
Definition navigation_recast_load.cpp:542
const navMap_t & GetNavigationData() const
Return the navigation data loaded from the BSP.
Definition navigation_recast_load.cpp:523
Recast build context.
Definition navigation_recast_load.cpp:52
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