gwnavruntime/pathfollower/avoidancecomputer.h Source File

avoidancecomputer.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
16 
17 
18 namespace Kaim
19 {
20 
21 class SpatializedCylinder;
22 class SpatializedPoint;
23 class AvoidanceComputer;
24 class Bot;
25 
26 
30 {
31 public:
32  // ------------------------------ Functions -----------------------------
33 
35  : m_bot(nullptr)
36  , m_avoidanceComputer(nullptr)
37  {}
38 
39  bool ShouldCollectSpatializedPoint(SpatializedPoint* spatializedPoint);
40 
41  // ---------------------------------- Public Data Members ----------------------------------
42 
43  Bot* m_bot;
44  AvoidanceComputer* m_avoidanceComputer;
45 };
46 
47 
52 {
53  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_PathFollowing)
55 
56 public:
57  // ------------------------------ Functions -----------------------------
58 
60 
61  void SetAvoidanceSolver(Ptr<IAvoidanceSolver> avoidanceSolver) { m_avoidanceSolver = avoidanceSolver; }
62  void SetAvoidanceFilter(Ptr<IAvoidanceFilter> avoidanceFilter) { m_avoidanceFilter = avoidanceFilter; }
63 
64  virtual AvoidanceResult Compute(Bot& bot, KyFloat32 simulationTimeInSeconds, KyFloat32 desiredSpeed, const Vec2f& movingDirection, Vec2f& avoidanceVelocity, Vec2f& outputFrontDirection, bool& collide);
65 
66 protected:
68 
69  void CollectSpatializedPoints(Bot& bot);
70  void SetupAvoidanceWorkspace(const Bot& bot, KyFloat32 desiredSpeed, const Vec2f& desiredMovingDirection);
71  void FillAvoidanceWorkspace(const Bot& bot);
72 
73  AvoidanceResult SolveAvoidanceWorkspace(Bot& bot, KyFloat32 simulationTimeInSeconds, KyFloat32 desiredSpeed, const Vec2f& movingDirection, Vec2f& outputAvoidanceVelocity, Vec2f& outputFrontDirection, bool& collide);
74 
75  void UpdateForcePassage(Bot& bot, KyFloat32 simulationTimeInSeconds, const Vec2f& desiredVelocity,
76  AvoidanceSolverConfig& solverConfig, AvoidanceResult& solverResult, Vec2f& avoidanceVelocity, bool collide);
77 
78  bool DoesCollectionQueryNeedToBeUpdated(const Bot& bot);
79  const SpatializedCylinder* GetSpatializedCylinderFromSpatializedPoint(SpatializedPoint* spatializedPoint);
80  AvoidanceWorkspaceAddColliderResult AddColliderToVOWorkspace(const Bot& bot, const AvoidanceConfig& avoidanceConfig, AvoidanceWorkspace& avoidanceWorkspace, const SpatializedCylinder& colliderCylinder, const KyFloat32 databaseRadiusPrecision);
81 
82  void SetupSolverConfig(AvoidanceSolverConfig&, const Bot&);
83 
84  AvoidanceResult ComputeAvoidanceVelocity( Bot& bot, KyFloat32 simulationTimeInSeconds, KyFloat32 desiredSpeed, const Vec2f& desiredMovingDirection, Vec2f& avoidanceVelocity, Vec2f& outputFrontDirection, bool& collide);
85 
86 public: // internal
87  // Used specifically by the ShortcutTrajectory in order to skip, cf. World::SetNumberOfFramesForShortcutTrajectoryPeriodicUpdate()
88  virtual bool IsComputationRequiredThisFrame(Bot* bot, KyFloat32 timeToNextUpdate);
89 
90 protected:
91  Ptr<IAvoidanceSolver> m_avoidanceSolver; // If let to nullptr, AvoidanceComputer will instantiate a AvoidanceSolver with the world default TraverseLogic
92  SpatializedPointCollectorInAABBQuery<AvoidanceComputerCollectorFilter> m_collectQuery; // Put this in a Ptr<> if you want to push it in a queryQueue
93  Ptr<IAvoidanceFilter> m_avoidanceFilter;
94 };
95 
96 
97 } // namespace Kaim
98 
AvoidanceWorkspace aggregates at once:
Definition: avoidanceworkspace.h:34
This class is the world element that represent an active character in Autodesk Navigation.
Definition: bot.h:128
Set of parameters used to configure AvoidanceComputer.
Definition: avoidanceconfig.h:106
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
The SpatializedPointCollectorInAABBQuery class retrieves all SpatializedPoints within an Axis-Aligned...
Definition: spatializedpointcollectorinaabbquery.h:53
AvoidanceResult
Enumerates the possible results of a call to IAvoidanceComputer::Compute().
Definition: iavoidancecomputer.h:18
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
This class compute collision-free trajectories.
Definition: avoidancecomputer.h:51
2d vector using KyFloat32.
Definition: vec2f.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
This interface class defines the way avoidance is computed.
Definition: iavoidancecomputer.h:34
Internal representation of world elements, using a vertical cylinder shape.
Definition: spatializedcylinder.h:44
Class used to filter potential colliders in AvoidanceComputer at SpatializedPoint collection step...
Definition: avoidancecomputer.h:29
SpatializedPoint is used to the NavTriangle of "object": Bot, CylinderObstacle, BoxObstacle and Point...
Definition: spatializedpoint.h:146
float KyFloat32
float
Definition: types.h:32
AvoidanceWorkspaceAddColliderResult
AvoidanceWorkspaceAddColliderResult.
Definition: avoidanceworkspace.h:22