OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
navigation_recast_obstacle.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#pragma once
24
25#include "../qcommon/q_shared.h"
26#include "../qcommon/vector.h"
27#include "g_public.h"
28
29static constexpr unsigned int NAVOBS_FLAG_ACTIVE = (1 << 0);
30
35struct NavigationObstacleEntities {
36public:
37 NavigationObstacleEntities();
38
39 const Vector& GetMin(unsigned int entnum) const;
40 const Vector& GetMax(unsigned int entnum) const;
41 int GetContents(unsigned int entnum) const;
42 void SetContents(unsigned int entnum, int contents);
43 solid_t GetSolidType(unsigned int entnum) const;
44 void SetSolidType(unsigned int entnum, solid_t type);
45 void SetBounds(unsigned int entnum, const Vector& min, const Vector& max);
46 bool IsActive(unsigned int entnum) const;
47 void Add(unsigned int entnum);
48 void Set(unsigned int entnum, const Vector& position);
49 void Remove(unsigned int entnum);
50
51public:
52 int contents[MAX_GENTITIES];
53 Vector bounds[2][MAX_GENTITIES];
54 byte flag[MAX_GENTITIES];
55 solid_t solid[MAX_GENTITIES];
56};
57
63struct NavigationObstacleTiles {
64public:
65 NavigationObstacleTiles();
66 ~NavigationObstacleTiles();
67
68 void Init();
69 void Clear();
70
71public:
72 unsigned int *tilesRef;
73 unsigned int **polysRef;
74 unsigned int numTiles;
75};
76
81class NavigationObstacleMap
82{
83public:
84 NavigationObstacleMap();
85 ~NavigationObstacleMap();
86
87 void Clear();
88 void Init();
89 void Update();
90
91private:
92 bool IsValidEntity(gentity_t *ent) const;
93 bool IsSpecialEntity(gentity_t *ent) const;
94 bool HasChanged(gentity_t *ent) const;
95
96 void EntityAdded(gentity_t *ent);
97 void EntityRemoved(gentity_t *ent);
98 void EntityChanged(gentity_t *ent);
99
100 void EngagePolysAt(gentity_t *ent, const Vector& min, const Vector& max);
101 void ReleasePolysAt(gentity_t *ent, const Vector& min, const Vector& max);
102
103private:
104 // This instance is quite big so only allocate it when used
107};
108
109extern NavigationObstacleMap navigationObstacleMap;
Manages obstacle on the map.
Definition navigation_recast_obstacle.h:82
Definition vector.h:61
Store a list of entities and their last bounds.
Definition navigation_recast_obstacle.h:35
Store a list of tiles only containing a number of references, used to keep track of the number of ent...
Definition navigation_recast_obstacle.h:63