gwnavruntime/pathfollower/avoidancecomputer.h Source File

avoidancecomputer.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 // primary contact: LAPA - secondary contact: NOBODY
8 #ifndef Navigation_AvoidanceComputer_H
9 #define Navigation_AvoidanceComputer_H
10 
18 
19 
20 namespace Kaim
21 {
22 
23 class SpatializedCylinder;
24 class SpatializedPoint;
25 class AvoidanceComputer;
26 class Bot;
27 
28 
32 {
33 public:
34  // ---------------------------------- Public Member Functions ----------------------------------
35 
37  : m_bot(KY_NULL)
38  , m_avoidanceComputer(KY_NULL)
39  {}
40 
41  bool ShouldCollectSpatializedPoint(SpatializedPoint* spatializedPoint);
42 
43  // ---------------------------------- Public Data Members ----------------------------------
44 
45  Bot* m_bot;
46  AvoidanceComputer* m_avoidanceComputer;
47 };
48 
49 
54 {
55  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_PathFollowing)
57 
58 public:
59  // ---------------------------------- Public Member Functions ----------------------------------
60 
62 
63  void SetAvoidanceSolver(Ptr<IAvoidanceSolver> avoidanceSolver) { m_avoidanceSolver = avoidanceSolver; }
64  void SetAvoidanceFilter(Ptr<IAvoidanceFilter> avoidanceFilter) { m_avoidanceFilter = avoidanceFilter; }
65 
66  virtual AvoidanceResult Compute(Bot& bot, KyFloat32 simulationTimeInSeconds, KyFloat32 desiredSpeed, const Vec2f& movingDirection, Vec2f& avoidanceVelocity, Vec2f& outputFrontDirection, bool& collide);
67 
68 protected:
69  friend class AvoidanceComputerCollectorFilter;
70 
71  void CollectSpatializedPoints(Bot& bot);
72  void SetupAvoidanceWorkspace(const Bot& bot, KyFloat32 desiredSpeed, const Vec2f& desiredMovingDirection);
73  void FillAvoidanceWorkspace(const Bot& bot);
74 
75  AvoidanceResult SolveAvoidanceWorkspace(Bot& bot, KyFloat32 simulationTimeInSeconds, KyFloat32 desiredSpeed, const Vec2f& movingDirection, Vec2f& outputAvoidanceVelocity, Vec2f& outputFrontDirection, bool& collide);
76 
77  void UpdateForcePassage(Bot& bot, KyFloat32 simulationTimeInSeconds, const Vec2f& desiredVelocity,
78  AvoidanceSolverConfig& solverConfig, AvoidanceResult& solverResult, Vec2f& avoidanceVelocity, bool collide);
79 
80  bool DoesCollectionQueryNeedToBeUpdated(const Bot& bot);
81  const SpatializedCylinder* GetSpatializedCylinderFromSpatializedPoint(SpatializedPoint* spatializedPoint);
82  AvoidanceWorkspaceAddColliderResult AddColliderToVOWorkspace(const Bot& bot, const AvoidanceConfig& avoidanceConfig, AvoidanceWorkspace& avoidanceWorkspace, const SpatializedCylinder& colliderCylinder, const KyFloat32 databaseRadiusPrecision);
83 
84  void SetupSolverConfig(AvoidanceSolverConfig&, const Bot&);
85 
86  AvoidanceResult ComputeAvoidanceVelocity( Bot& bot, KyFloat32 simulationTimeInSeconds, KyFloat32 desiredSpeed, const Vec2f& desiredMovingDirection, Vec2f& avoidanceVelocity, Vec2f& outputFrontDirection, bool& collide);
87 
88 public: // internal
89  // Used specifically by the ShortcutTrajectory in order to skip, cf. World::SetNumberOfFramesForShortcutTrajectoryPeriodicUpdate()
90  virtual bool IsComputationRequiredThisFrame(Bot* bot, KyFloat32 simulationTimeInSeconds);
91 
92 protected:
93  Ptr<IAvoidanceSolver> m_avoidanceSolver; // If let to KY_NULL, AvoidanceComputer will instantiate a AvoidanceSolver with the world default TraverseLogic
94  SpatializedPointCollectorInAABBQuery<AvoidanceComputerCollectorFilter> m_collectQuery; // Put this in a Ptr<> if you want to push it in a queryQueue
95  Ptr<IAvoidanceFilter> m_avoidanceFilter;
96 };
97 
98 
99 } // namespace Kaim
100 
101 #endif // Navigation_AvoidanceComputer_H
This class is the world element that represent an active character in Gameware Navigation.
Definition: bot.h:150
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
AvoidanceResult
Enumerates the possible results of a call to IAvoidanceComputer::Compute().
Definition: iavoidancecomputer.h:20
This class compute collision-free trajectories.
Definition: avoidancecomputer.h:63
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
This interface class defines the way avoidance is computed.
Definition: iavoidancecomputer.h:38
Class used to filter potential colliders in AvoidanceComputer at SpatializedPoint collection step...
Definition: avoidancecomputer.h:31
Internal class used for point spatialization in NavData.
Definition: spatializedpoint.h:171
Interface class for Avoidance solvers.
Definition: iavoidancesolver.h:100
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43