gwnavruntime/queries/utils/baseraycastquery.h Source File

baseraycastquery.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 
15 
16 namespace Kaim
17 {
18 
19 class NavHalfEdgeRawPtr;
20 class RawNavTagSubSegment;
21 template <class T> class WorkingMemArray;
22 
25 {
28 
36 
40 };
41 
44 {
45 public:
46  static QueryType GetStaticType() { return TypeRayCast; }
47  virtual QueryType GetType() const { return TypeRayCast; }
48  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
49  virtual void InitFromQueryBlob(World* world, void* blob);
50  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
51  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
52 
53 
54  // ---------------------------------- Main API Functions ----------------------------------
55 
56  RayCastQueryResult GetResult() const;
57  const Vec3f& GetStartPos() const;
58  const Vec3f& GetCollisionPos() const;
59  const Vec3f& GetArrivalPos() const;
60  const Vec2f& GetMaxMove2D() const;
61  const NavTrianglePtr& GetStartTrianglePtr() const;
62  const NavTrianglePtr& GetArrivalTrianglePtr() const;
63  const NavHalfEdgePtr& GetCollisionNavHalfEdgePtr() const;
64  DynamicOutputMode GetDynamicOutputMode() const;
65  QueryDynamicOutput* GetQueryDynamicOutput() const;
66  const WorldIntegerPos& GetStartIntegerPos() const;
67  const WorldIntegerPos& GetArrivalIntegerPos() const;
68 
69  const PositionSpatializationRange& GetPositionSpatializationRange() const;
70 
71  static CoordPos64 ResolveCollisionPointWhenPointsAreAligned(const CoordPos64& edgeStartPos, const CoordPos64& edgeEndPos, const CoordPos64& startCoordPos64, const CoordPos64& destCoordPos64);
72 public: // internal
73  BaseRayCastQuery();
74  virtual ~BaseRayCastQuery() {}
75 
76  void BindToDatabase(Database* database);
77  void Initialize(const Vec3f& startPos, const Vec2f& maxMove2D);
78 
79  void SetStartTrianglePtr(const NavTrianglePtr& startTrianglePtr);
80  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange);
81  void SetDynamicOutputMode(DynamicOutputMode dynamicOutputMode);
82  void SetQueryDynamicOutput(QueryDynamicOutput* queryDynamicOutput);
83  void SetStartIntegerPos(const WorldIntegerPos& startIntegerPos);
84  void SetResult(RayCastQueryResult result);
85 
86 protected:
87  void RayCast_NoHit(const NavHalfEdgeRawPtr& lastHalfEdgeRawPtr, const WorldIntegerPos& destIntegerPos, const Vec3f& destPos3f,
88  CompositeSubSegment& subSegment, ScopedDynamicOutput& scopedDynamicOutput);
89 
90  KyResult ComputeCollisionPosition(const NavHalfEdgeRawPtr& halfEdgeIdRawPtrHit, const CoordPos64& startCoordPos64, const CoordPos64& destCoordPos64,
91  CoordPos64& collisionCoordPos64, Vec3f& edgeStartPos3f, Vec3f& edgeEndPos3f, Vec3f& edgeThirdPos3f);
92 protected:
93  WorldIntegerPos m_startIntegerPos;
94  WorldIntegerPos m_arrivalIntegerPos;
95 
98 
104 
110 
113 
116 
120 
123 
125 
127 
134  Ptr<QueryDynamicOutput> m_queryDynamicOutput;
135 };
136 
137 }
138 
140 
141 
142 
143 
Indicates that the query has not yet been initialized.
Definition: baseraycastquery.h:26
Ptr< QueryDynamicOutput > m_queryDynamicOutput
A ref-counted Ptr to a QueryDynamicOutput instance, used to store the data encountered during the que...
Definition: baseraycastquery.h:134
Indicates that a NavMesh triangle has been found for the starting point, but its NavTag is not consid...
Definition: baseraycastquery.h:30
Vec3f m_arrivalPos3f
Updated during processing to indicate the final position of the ray at the end of the cast...
Definition: baseraycastquery.h:103
Vertical range (above, below) that represents the altitude tolerance for a position to be inside the ...
Definition: positionspatializationrange.h:17
Indicates that an unknown error occurred during the query processing.
Definition: baseraycastquery.h:35
Vec3f m_startPos3f
The starting point of the line segment to be tested.
Definition: baseraycastquery.h:96
PositionSpatializationRange m_positionSpatializationRange
The altitude range around the position to use when determining m_startTrianglePtr from the m_startPos...
Definition: baseraycastquery.h:115
Base class for all the queries that do not need to be time-sliced.
Definition: iquery.h:245
NavTrianglePtr m_startTrianglePtr
The NavMesh triangle that corresponds to m_startPos3f. You can set it as an input or retrieve it as a...
Definition: baseraycastquery.h:112
virtual QueryType GetType() const
Get query type.
Definition: baseraycastquery.h:47
Indicates that the query was not performed, because the value of BaseRayCastQuery::m_maxDist is large...
Definition: baseraycastquery.h:34
Indicates that insufficient memory was available to store crossed triangles or sub-sections, and the query failed as a result.
Definition: baseraycastquery.h:33
Vec2f m_maxMove2D
A vector that represents the direction and the maximum distance the ray will travel.
Definition: baseraycastquery.h:109
This class is a runtime container for Autodesk Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:52
NavHalfEdgePtr m_collisionHalfEdgePtr
If a collision has been detected, this is updated to indicate the triangle edge that the ray collided...
Definition: baseraycastquery.h:122
DynamicOutputMode
Enumerates possible ways of storing collected data by a query in a QueryDynamicOutput object...
Definition: querydynamicoutput.h:21
Indicates that the ray was able to travel its maximum distance without collision. ...
Definition: baseraycastquery.h:37
RayCastQueryResult
Enumerates the possible results of a RayCastQuery.
Definition: baseraycastquery.h:24
QueryType
Enumerates all the type of query.
Definition: iquery.h:25
Indicates that a collision point was found, but moving back from that point resulted in an arrival po...
Definition: baseraycastquery.h:32
2d vector using KyFloat32.
Definition: vec2f.h:18
NavTrianglePtr m_arrivalTrianglePtr
Updated during processing to indicate the NavMesh triangle that corresponds to m_arrivalPos3f.
Definition: baseraycastquery.h:119
Vec2LL CoordPos64
A type that represents the position of a point within the 2D integer grid.
Definition: navmeshtypes.h:16
Navigation return code class.
Definition: types.h:108
Base class for RayCastQuery.
Definition: baseraycastquery.h:43
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: baseraycastquery.h:29
Indicates that the query has not yet been initialized.
Definition: iquery.h:295
Indicates that a collision point was found and that a final arrival position was calculated successfu...
Definition: baseraycastquery.h:38
Indicates that the query has not yet been launched.
Definition: baseraycastquery.h:27
DynamicOutputMode m_dynamicOutputMode
Specifies the type of data stored in m_queryDynamicOutput.
Definition: baseraycastquery.h:126
Vec3f m_collisionPos3f
Updated to indicate the position at which the ray collided with the NavMesh border or NavTag...
Definition: baseraycastquery.h:97
Each instance of this class uniquely identifies a single NavHalfEdge in a NavFloor.
Definition: navhalfedgeptr.h:16
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
Indicates that the query has not yet been launched.
Definition: iquery.h:296
void Initialize()
Should be called by the derived class prior to perform the query or to push it in a QueryQueue...
Definition: iquery.h:220
weird name kept for backward compatibility
Definition: baseraycastquery.h:39
3d vector using 32bits floating points.
Definition: vec3f.h:16
RayCastQueryResult m_result
Updated during processing to indicate the result of the query.
Definition: baseraycastquery.h:124
Indicates that the starting point is very close to a NavMesh border, such that moving back the collis...
Definition: baseraycastquery.h:31