Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/rvo2/rvo2_3d/Agent3d.h
9903 views
1
/*
2
* Agent.h
3
* RVO2-3D Library
4
*
5
* Copyright 2008 University of North Carolina at Chapel Hill
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
10
*
11
* http://www.apache.org/licenses/LICENSE-2.0
12
*
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
18
*
19
* Please send all bug reports to <[email protected]>.
20
*
21
* The authors may be contacted via:
22
*
23
* Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, Dinesh Manocha
24
* Dept. of Computer Science
25
* 201 S. Columbia St.
26
* Frederick P. Brooks, Jr. Computer Science Bldg.
27
* Chapel Hill, N.C. 27599-3175
28
* United States of America
29
*
30
* <http://gamma.cs.unc.edu/RVO2/>
31
*/
32
33
/**
34
* \file Agent.h
35
* \brief Contains the Agent class.
36
*/
37
#ifndef RVO3D_AGENT_H_
38
#define RVO3D_AGENT_H_
39
40
#include <cstddef>
41
#include <cstdint>
42
#include <utility>
43
#include <vector>
44
45
#include "RVOSimulator3d.h"
46
#include "Vector3.h"
47
48
namespace RVO3D {
49
/**
50
* \brief Defines an agent in the simulation.
51
*/
52
class Agent3D {
53
public:
54
/**
55
* \brief Constructs an agent instance.
56
* \param sim The simulator instance.
57
*/
58
explicit Agent3D();
59
60
/**
61
* \brief Computes the neighbors of this agent.
62
*/
63
void computeNeighbors(RVOSimulator3D *sim_);
64
65
/**
66
* \brief Computes the new velocity of this agent.
67
*/
68
void computeNewVelocity(RVOSimulator3D *sim_);
69
70
/**
71
* \brief Inserts an agent neighbor into the set of neighbors of this agent.
72
* \param agent A pointer to the agent to be inserted.
73
* \param rangeSq The squared range around this agent.
74
*/
75
void insertAgentNeighbor(const Agent3D *agent, float &rangeSq);
76
77
/**
78
* \brief Updates the three-dimensional position and three-dimensional velocity of this agent.
79
*/
80
void update(RVOSimulator3D *sim_);
81
82
Vector3 newVelocity_;
83
Vector3 position_;
84
Vector3 prefVelocity_;
85
Vector3 velocity_;
86
RVOSimulator3D *sim_;
87
size_t id_;
88
size_t maxNeighbors_;
89
float maxSpeed_;
90
float neighborDist_;
91
float radius_;
92
float timeHorizon_;
93
float timeHorizonObst_;
94
std::vector<std::pair<float, const Agent3D *> > agentNeighbors_;
95
std::vector<Plane> orcaPlanes_;
96
float height_ = 1.0;
97
uint32_t avoidance_layers_ = 1;
98
uint32_t avoidance_mask_ = 1;
99
float avoidance_priority_ = 1.0;
100
101
friend class KdTree3D;
102
friend class RVOSimulator3D;
103
};
104
}
105
106
#endif /* RVO3D_AGENT_H_ */
107
108