File: navigation_path.h

package info (click to toggle)
openmohaa 0.82.1%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 34,192 kB
  • sloc: cpp: 315,720; ansic: 275,789; sh: 312; xml: 246; asm: 141; makefile: 7
file content (164 lines) | stat: -rw-r--r-- 4,695 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
===========================================================================
Copyright (C) 2025 the OpenMoHAA team

This file is part of OpenMoHAA source code.

OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

#pragma once

#include "../qcommon/vector.h"
#include "../qcommon/container.h"
#include "../qcommon/lightclass.h"

struct PathNav {
    Vector origin;
    vec2_t dir;
    float  dist;
};

struct PathSearchParameter {
    Vector  leashHome;
    float   leashDist;
    int     fallHeight;
    Entity *entity;
};

class IPather : public LightClass
{
public:
    virtual ~IPather() = default;

    /**
     * @brief Create a new Pather object based on supported navigation features.
     * 
     * @return IPather*
     */
    static IPather *CreatePather();

    /**
     * @brief Find and set the path from start to end
     * 
     * @param start Start of the path.
     * @param end End of the path
     * @param parameters
     */
    virtual void FindPath(const Vector& start, const Vector& end, const PathSearchParameter& parameters) = 0;

    /**
     * @brief Find and set the path from start to end with the specified goal radius
     * 
     * @param start Start of the path
     * @param end End of the path
     * @param radius The radius at which to stop the path
     * @param parameters
     */
    virtual void
    FindPathNear(const Vector& start, const Vector& end, float radius, const PathSearchParameter& parameters) = 0;

    /**
     * @brief Find and set the path away from the specified origin
     * 
     * @param start Start of the path
     * @param avoid Location to avoid
     * @param preferredDir Preferred direction to use to escape from the location to avoid
     * @param radius Minimum safe distance to avoid
     * @param parameters
     */
    virtual void FindPathAway(
        const Vector&              start,
        const Vector&              avoid,
        const Vector&              preferredDir,
        float                      radius,
        const PathSearchParameter& parameters
    ) = 0;

    /**
     * @brief Returns true if the path exists, false otherwise.
     * 
     * @param start Start of the path.
     * @param end End of the path
     * @param parameters
     * @return true if the path exists
     */
    virtual bool TestPath(const Vector& start, const Vector& end, const PathSearchParameter& parameters) = 0;

    /**
     * @brief Update path movement
     * 
     * @param origin The origin to set
     */
    virtual void UpdatePos(const Vector& origin) = 0;

    /**
     * @brief Clear the path
     * 
     */
    virtual void Clear() = 0;

    /**
     * @brief Return the node at the specified index (0 = first node, and nodecount - 1 = last node).
     * 
     * @param index
     * @return A copy of the path information. 
     */
    virtual PathNav GetNode(unsigned int index = 0) const = 0;

    /**
     * @brief Return the number of nodes.
     * 
     * @return The number of nodes. If 0, then there is no path.
     */
    virtual int GetNodeCount() const = 0;

    /**
     * @brief Return the current move delta
     * 
     * @return Vector with the current move delta.
     */
    virtual Vector GetCurrentDelta() const = 0;

    /**
     * @brief Return the directional vector towards the path
     * 
     * @return Vector with the current directional vector.
     */
    virtual Vector GetCurrentDirection() const = 0;

    /**
     * @brief Return the final destination
     * 
     * @return Vector the destination.
     */
    virtual Vector GetDestination() const = 0;

    /**
     * @brief Return true if the origin is at the end of the goal
     * 
     * @param origin The current origin to test
     */
    virtual bool HasReachedGoal(const Vector& origin) const = 0;

    /**
     * @brief Return true if the path is currently being calculated.
     * 
     * @return true 
     * @return false 
     */
    virtual bool IsQuerying() const = 0;
};