Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
NavMeshConfig.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_NAV_MESH_CONFIG_H_
34#define DVD_NAV_MESH_CONFIG_H_
35
36#include "NavMeshDefines.h"
37
38/*http://www.ogre3d.org/forums/viewtopic.php?f=11&t=69781&sid=2439989b4c0208780a353e4c90f9864b
39 */
40
41namespace Divide {
42namespace AI {
43
45 public:
47 {
48 eval();
49 }
50
51 /*****************
52 * Rasterization
53 *****************/
54 void setCellSize(const F32 cellSize) {
55 this->_cellSize = cellSize;
56 eval();
57 }
58
59 void setCellHeight(const F32 cellHeight) {
60 this->_cellHeight = cellHeight;
61 eval();
62 }
63
64 void setTileSize(const I32 tileSize) noexcept {
65 this->_tileSize = tileSize;
66 }
67
68 /*****************
69 * Agent
70 *****************/
71 void setAgentHeight(const F32 agentHeight) {
72 this->_agentHeight = agentHeight;
73 eval();
74 }
75
76 void setAgentRadius(const F32 agentRadius) {
77 this->_agentRadius = agentRadius;
78 eval();
79 }
80
81 void setAgentMaxClimb(const F32 agentMaxClimb) {
82 this->_agentMaxClimb = agentMaxClimb;
83 eval();
84 }
85
86 void setAgentMaxSlope(const F32 agentMaxSlope) noexcept {
87 this->_agentMaxSlope = agentMaxSlope;
88 }
89
90 /*****************
91 * Region
92 *****************/
93 void setRegionMinSize(const I32 regionMinSize) {
94 this->_regionMinSize = regionMinSize;
95 eval();
96 }
97
98 void setRegionMergeSize(const I32 regionMergeSize) {
99 this->_regionMergeSize = regionMergeSize;
100 eval();
101 }
102
103 /*****************
104 * Polygonization
105 *****************/
106 void setEdgeMaxLen(const I32 edgeMaxLength) {
107 this->_edgeMaxLen = edgeMaxLength;
108 eval();
109 }
110
111 void setEdgeMaxError(const F32 edgeMaxError) noexcept {
112 this->_edgeMaxError = edgeMaxError;
113 }
114
115 void setVertsPerPoly(const I32 vertsPerPoly) noexcept {
116 this->_vertsPerPoly = vertsPerPoly;
117 }
118
119 /*****************
120 * Detail mesh
121 *****************/
122 void setDetailSampleDist(const F32 detailSampleDist) {
123 this->_detailSampleDist = detailSampleDist;
124 eval();
125 }
126
127 void setDetailSampleMaxError(const F32 detailSampleMaxError) {
128 this->_detailSampleMaxError = detailSampleMaxError;
129 eval();
130 }
131
132 void setKeepInterResults(const bool keepInterResults) noexcept {
133 this->_keepInterResults = keepInterResults;
134 }
135
136 /*********************************************************************
137 * Override derived parameters (params set in the eval function)
138 *********************************************************************/
139
140 void base_setWalkableHeight(const I32 walkableHeight) noexcept {
141 this->_walkableHeight = walkableHeight;
142 }
143
144 void base_setWalkableClimb(const I32 walkableClimb) noexcept {
145 this->_walkableClimb = walkableClimb;
146 }
147
148 void base_setWalkableRadius(const I32 walkableRadius) noexcept {
149 this->_walkableRadius = walkableRadius;
150 }
151
152 void base_setMaxEdgeLen(const I32 maxEdgeLen) noexcept {
153 this->_maxEdgeLen = maxEdgeLen;
154 }
155
156 void base_setMinRegionArea(const I32 minRegionArea) noexcept {
157 this->_minRegionArea = minRegionArea;
158 }
159
160 void base_setMergeRegionArea(const I32 mergeRegionArea) noexcept {
161 this->_mergeRegionArea = mergeRegionArea;
162 }
163
164 void base_setDetailSampleDist(const F32 detailSampleDist) noexcept {
165 this->_base_detailSampleDist = detailSampleDist;
166 }
167
168 void base_setDetailSampleMaxError(const F32 detailSampleMaxError) noexcept {
169 this->_base_detailSampleMaxError = detailSampleMaxError;
170 }
171
172 [[nodiscard]] F32 getCellSize() const noexcept { return _cellSize; }
173 [[nodiscard]] F32 getCellHeight() const noexcept { return _cellHeight; }
174 [[nodiscard]] I32 getTileSize() const noexcept { return _tileSize; }
175 [[nodiscard]] F32 getAgentMaxSlope() const noexcept { return _agentMaxSlope; }
176 [[nodiscard]] F32 getAgentHeight() const noexcept { return _agentHeight; }
177 [[nodiscard]] F32 getAgentMaxClimb() const noexcept { return _agentMaxClimb; }
178 [[nodiscard]] F32 getAgentRadius() const noexcept { return _agentRadius; }
179 [[nodiscard]] I32 getEdgeMaxLen() const noexcept { return _edgeMaxLen; }
180 [[nodiscard]] F32 getEdgeMaxError() const noexcept { return _edgeMaxError; }
181 [[nodiscard]] I32 getRegionMinSize() const noexcept { return _regionMinSize; }
182 [[nodiscard]] I32 getRegionMergeSize() const noexcept { return _regionMergeSize; }
183 [[nodiscard]] I32 getVertsPerPoly() const noexcept { return _vertsPerPoly; }
184 [[nodiscard]] F32 getDetailSampleDist() const noexcept { return _detailSampleDist; }
185 [[nodiscard]] F32 getDetailSampleMaxError() const noexcept { return _detailSampleMaxError; }
186 [[nodiscard]] bool getKeepInterResults() const noexcept { return _keepInterResults; }
187
188 [[nodiscard]] I32 base_getWalkableHeight() const noexcept { return _walkableHeight; }
189 [[nodiscard]] I32 base_getWalkableClimb() const noexcept { return _walkableClimb; }
190 [[nodiscard]] I32 base_getWalkableRadius() const noexcept { return _walkableRadius; }
191 [[nodiscard]] I32 base_getMaxEdgeLen() const noexcept { return _maxEdgeLen; }
192 [[nodiscard]] I32 base_getMinRegionArea() const noexcept { return _minRegionArea; }
193 [[nodiscard]] I32 base_getMergeRegionArea() const noexcept { return _mergeRegionArea; }
194 [[nodiscard]] I32 base_getDetailSampleDist() const noexcept { return to_I32(_base_detailSampleDist); }
195 [[nodiscard]] I32 base_getDetailSampleMaxError() const noexcept { return to_I32(_base_detailSampleMaxError); }
196
197 private:
203 void eval() {
208 _minRegionArea = to_I32(rcSqr(_regionMinSize)); // Note: area = size*size
209 _mergeRegionArea = to_I32(rcSqr(_regionMergeSize)); // Note: area = size*size
212 }
213
216
231
252
261
271
281
298
307
321
331
339
351 I32 _vertsPerPoly = DT_VERTS_PER_POLYGON;
352
365
379
384 bool _keepInterResults = false;
385
400
413
432
446
460
474
493
507};
508
509} // namespace AI
510} // namespace Divide
511
512#endif //DVD_NAV_MESH_CONFIG_H_
void base_setMinRegionArea(const I32 minRegionArea) noexcept
void setDetailSampleMaxError(const F32 detailSampleMaxError)
void setAgentRadius(const F32 agentRadius)
Definition: NavMeshConfig.h:76
void base_setMergeRegionArea(const I32 mergeRegionArea) noexcept
I32 base_getMaxEdgeLen() const noexcept
I32 base_getWalkableHeight() const noexcept
I32 base_getWalkableClimb() const noexcept
I32 base_getDetailSampleDist() const noexcept
F32 getAgentMaxClimb() const noexcept
I32 base_getWalkableRadius() const noexcept
F32 getEdgeMaxError() const noexcept
I32 base_getMergeRegionArea() const noexcept
F32 getAgentRadius() const noexcept
F32 getCellSize() const noexcept
void setAgentMaxSlope(const F32 agentMaxSlope) noexcept
Definition: NavMeshConfig.h:86
void setTileSize(const I32 tileSize) noexcept
Definition: NavMeshConfig.h:64
I32 getRegionMinSize() const noexcept
void setEdgeMaxError(const F32 edgeMaxError) noexcept
void setCellSize(const F32 cellSize)
Definition: NavMeshConfig.h:54
I32 base_getDetailSampleMaxError() const noexcept
void setAgentMaxClimb(const F32 agentMaxClimb)
Definition: NavMeshConfig.h:81
void base_setWalkableRadius(const I32 walkableRadius) noexcept
F32 getDetailSampleMaxError() const noexcept
I32 getTileSize() const noexcept
void base_setDetailSampleDist(const F32 detailSampleDist) noexcept
F32 getCellHeight() const noexcept
void base_setMaxEdgeLen(const I32 maxEdgeLen) noexcept
void setDetailSampleDist(const F32 detailSampleDist)
void setKeepInterResults(const bool keepInterResults) noexcept
void base_setWalkableHeight(const I32 walkableHeight) noexcept
void setEdgeMaxLen(const I32 edgeMaxLength)
void setVertsPerPoly(const I32 vertsPerPoly) noexcept
F32 getDetailSampleDist() const noexcept
bool getKeepInterResults() const noexcept
I32 base_getMinRegionArea() const noexcept
F32 getAgentMaxSlope() const noexcept
I32 getRegionMergeSize() const noexcept
void setAgentHeight(const F32 agentHeight)
Definition: NavMeshConfig.h:71
void base_setWalkableClimb(const I32 walkableClimb) noexcept
I32 getVertsPerPoly() const noexcept
F32 getAgentHeight() const noexcept
I32 getEdgeMaxLen() const noexcept
void setRegionMergeSize(const I32 regionMergeSize)
Definition: NavMeshConfig.h:98
void setRegionMinSize(const I32 regionMinSize)
Definition: NavMeshConfig.h:93
void setCellHeight(const F32 cellHeight)
Definition: NavMeshConfig.h:59
void base_setDetailSampleMaxError(const F32 detailSampleMaxError) noexcept
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int32_t I32
constexpr I32 to_I32(const T value)