Recast Navigation
Navigation-mesh Toolset for Games
Loading...
Searching...
No Matches
Tool_NavMeshTester.h
Go to the documentation of this file.
1//
2// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3//
4// This software is provided 'as-is', without any express or implied
5// warranty. In no event will the authors be held liable for any damages
6// arising from the use of this software.
7// Permission is granted to anyone to use this software for any purpose,
8// including commercial applications, and to alter it and redistribute it
9// freely, subject to the following restrictions:
10// 1. The origin of this software must not be misrepresented; you must not
11// claim that you wrote the original software. If you use this software
12// in a product, an acknowledgment in the product documentation would be
13// appreciated but is not required.
14// 2. Altered source versions must be plainly marked as such, and must not be
15// misrepresented as being the original software.
16// 3. This notice may not be removed or altered from any source distribution.
17//
18
19#pragma once
20
21#include "DetourNavMesh.h"
22#include "DetourNavMeshQuery.h"
23#include "Sample.h"
24
26{
27 static constexpr int MAX_POLYS = 256;
28 static constexpr int MAX_SMOOTH = 2048;
29 static constexpr int MAX_RAND_POINTS = 64;
30
31 Sample* sample = nullptr;
32
33 dtQueryFilter filter;
34 dtStatus pathFindStatus = DT_FAILURE;
35
36 enum class ToolMode : uint8_t
37 {
38 PATHFIND_FOLLOW,
39 PATHFIND_STRAIGHT,
40 PATHFIND_SLICED,
41 RAYCAST,
42 DISTANCE_TO_WALL,
43 FIND_POLYS_IN_CIRCLE,
44 FIND_POLYS_IN_SHAPE,
45 FIND_LOCAL_NEIGHBORHOOD
46 };
47 ToolMode toolMode = ToolMode::PATHFIND_FOLLOW;
48
49 int straightPathOptions = 0;
50
51 dtPolyRef startRef = 0;
52 dtPolyRef endRef = 0;
53 dtPolyRef polys[MAX_POLYS];
54 dtPolyRef parent[MAX_POLYS];
55 int npolys = 0;
56 float straightPath[MAX_POLYS * 3];
57 unsigned char straightPathFlags[MAX_POLYS];
58 dtPolyRef straightPathPolys[MAX_POLYS];
59 int nstraightPath = 0;
60 float polyPickExt[3] = {2, 4, 2};
61
62 float smoothPath[MAX_SMOOTH * 3];
63 int nsmoothPath = 0;
64 float queryPoly[4 * 3];
65
66 float randPoints[MAX_RAND_POINTS * 3];
67 int nrandPoints = 0;
68 bool randPointsInCircle = false;
69
70 bool sposSet = false;
71 float spos[3];
72 bool eposSet = false;
73 float epos[3];
74
75 float hitPos[3];
76 float hitNormal[3];
77 bool hitResult = false;
78 float distanceToWall = 0;
79 float neighborhoodRadius = 2.5f;
80 float randomRadius = 5.0f;
81
82 int pathIterNum = 0;
83 dtPolyRef pathIterPolys[MAX_POLYS];
84 int pathIterPolyCount = 0;
85 float prevIterPos[3];
86 float iterPos[3];
87 float steerPos[3];
88 float targetPos[3];
89
90 static constexpr int MAX_STEER_POINTS = 10;
91 float steerPoints[MAX_STEER_POINTS * 3];
92 int steerPointCount = 0;
93
94public:
96
98 void init(Sample* newSample) override;
99 void reset() override;
100 void drawMenuUI() override;
101 void onClick(const float* s, const float* p, bool shift) override;
102 void onToggle() override;
103 void singleStep() override;
104 void update(const float dt) override;
105 void render() override;
106 void drawOverlayUI() override;
107
108 void recalc();
109 void drawAgent(const float* pos, float r, float h, float c, const unsigned int col) const;
110};
unsigned int dtStatus
Definition DetourStatus.h:22
static const unsigned int DT_FAILURE
Definition DetourStatus.h:25
SampleToolType
Tool types.
Definition Sample.h:33
Definition Tool_NavMeshTester.h:26
void onClick(const float *s, const float *p, bool shift) override
Definition Tool_NavMeshTester.cpp:422
void update(const float dt) override
Definition Tool_NavMeshTester.cpp:602
void drawMenuUI() override
Definition Tool_NavMeshTester.cpp:222
void init(Sample *newSample) override
Definition Tool_NavMeshTester.cpp:202
void onToggle() override
Definition Tool_NavMeshTester.cpp:439
void reset() override
Definition Tool_NavMeshTester.cpp:642
SampleToolType type() override
Definition Tool_NavMeshTester.h:97
void render() override
Definition Tool_NavMeshTester.cpp:1064
void drawAgent(const float *pos, float r, float h, float c, const unsigned int col) const
Definition Tool_NavMeshTester.cpp:1483
void drawOverlayUI() override
Definition Tool_NavMeshTester.cpp:1467
void recalc()
Definition Tool_NavMeshTester.cpp:654
NavMeshTesterTool()
Definition Tool_NavMeshTester.cpp:196
void singleStep() override
Definition Tool_NavMeshTester.cpp:437
Definition Sample.h:116
Defines polygon filtering and traversal costs for navigation mesh query operations.
Definition DetourNavMeshQuery.h:36
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition DetourNavMesh.h:48
Definition Sample.h:85