Agent3d.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 <geom@cs.unc.edu>.
  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. * \file Agent.h
  34. * \brief Contains the Agent class.
  35. */
  36. #ifndef RVO3D_AGENT_H_
  37. #define RVO3D_AGENT_H_
  38. #include <cstddef>
  39. #include <cstdint>
  40. #include <utility>
  41. #include <vector>
  42. #include "RVOSimulator3d.h"
  43. #include "Vector3.h"
  44. namespace RVO3D {
  45. /**
  46. * \brief Defines an agent in the simulation.
  47. */
  48. class Agent3D {
  49. public:
  50. /**
  51. * \brief Constructs an agent instance.
  52. * \param sim The simulator instance.
  53. */
  54. explicit Agent3D();
  55. /**
  56. * \brief Computes the neighbors of this agent.
  57. */
  58. void computeNeighbors(RVOSimulator3D *sim_);
  59. /**
  60. * \brief Computes the new velocity of this agent.
  61. */
  62. void computeNewVelocity(RVOSimulator3D *sim_);
  63. /**
  64. * \brief Inserts an agent neighbor into the set of neighbors of this agent.
  65. * \param agent A pointer to the agent to be inserted.
  66. * \param rangeSq The squared range around this agent.
  67. */
  68. void insertAgentNeighbor(const Agent3D *agent, float &rangeSq);
  69. /**
  70. * \brief Updates the three-dimensional position and three-dimensional velocity of this agent.
  71. */
  72. void update(RVOSimulator3D *sim_);
  73. Vector3 newVelocity_;
  74. Vector3 position_;
  75. Vector3 prefVelocity_;
  76. Vector3 velocity_;
  77. RVOSimulator3D *sim_;
  78. size_t id_;
  79. size_t maxNeighbors_;
  80. float maxSpeed_;
  81. float neighborDist_;
  82. float radius_;
  83. float timeHorizon_;
  84. float timeHorizonObst_;
  85. std::vector<std::pair<float, const Agent3D *> > agentNeighbors_;
  86. std::vector<Plane> orcaPlanes_;
  87. float height_ = 1.0;
  88. uint32_t avoidance_layers_ = 1;
  89. uint32_t avoidance_mask_ = 1;
  90. float avoidance_priority_ = 1.0;
  91. friend class KdTree3D;
  92. friend class RVOSimulator3D;
  93. };
  94. }
  95. #endif /* RVO3D_AGENT_H_ */