gwnavruntime/queries/utils/baseinsideposfromoutsideposquery.h Source File

baseinsideposfromoutsideposquery.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 
13 
14 namespace Kaim
15 {
16 
17 class BaseNearestBorderHalfEdgeFromPosQuery;
18 
21 {
24 
26 
29 };
30 
31 enum InsidePosFromOutsidePosQueryMode
32 {
33  INSIDEPOSFROMOUTSIDE_FROM_NEAREST_HALFEDGE,
34  INSIDEPOSFROMOUTSIDE_FROM_RAYCAST
35 };
36 
39 {
40 public:
41  static QueryType GetStaticType() { return TypeInsidePosFromOutsidePos; }
42  virtual QueryType GetType() const { return TypeInsidePosFromOutsidePos; }
43  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
44  virtual void InitFromQueryBlob(World* world, void* blob);
45  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
46  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
47 
48  // ---------------------------------- Main API Functions ----------------------------------
49 
50  InsidePosFromOutsidePosQueryResult GetResult() const { return m_result; }
51  InsidePosFromOutsidePosQueryMode GetQueryMode() const { return m_queryMode; }
52  const Vec3f& GetInputPos() const { return m_inputPos3f; }
53  const Vec3f& GetInsidePos() const { return m_insidePos3f; }
54  const Vec2f& GetCastDirection() const { return m_castDirection; }
55  const NavTrianglePtr& GetInsidePosTrianglePtr() const { return m_insidePosTrianglePtr; }
56  KyFloat32 GetHorizontalTolerance() const { return m_horizontalTolerance; }
57  KyFloat32 GetDistFromObstacle() const { return m_distFromObstacle; }
58  const WorldIntegerPos& GetInputIntegerPos() const { return m_inputIntegerPos; }
59  const WorldIntegerPos& GetInsideIntegerPos() const { return m_insideIntegerPos; }
60  const PositionSpatializationRange& GetPositionSpatializationRange() const { return m_positionSpatializationRange; }
61 
62  BaseInsidePosFromOutsidePosQuery();
63  ~BaseInsidePosFromOutsidePosQuery() {}
64 
65  void BindToDatabase(Database* database);
66  void Initialize(const Vec3f& inputPos);
67  void Initialize(const Vec3f& inputPos, const Vec2f& direction);
68 
69  void SetHorizontalTolerance(KyFloat32 horizontalTolerance) { m_horizontalTolerance = fabsf(horizontalTolerance); }
70  void SetResult(InsidePosFromOutsidePosQueryResult result) { m_result = result; }
71  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange) { m_positionSpatializationRange = positionSpatializationRange; }
72  void SetDistFromObstacle(KyFloat32 distFromObstacle) { m_distFromObstacle = fabsf(distFromObstacle); }
73  void SetInputIntegerPos(const WorldIntegerPos& inputIntegerPos) { m_inputIntegerPos = inputIntegerPos; }
74 
75  KyResult ComputeInsidePosFromBordersAndPos(WorkingMemory* workingMemory, const NavHalfEdgeRawPtr& prevBorderHalfEdgeRawPtr, const NavHalfEdgeRawPtr& borderHalfEdgeRawPtr,
76  const NavHalfEdgeRawPtr& nextBorderHalfEdgeRawPtr, const Vec3f& posOnBorderEdge, Vec3f& startToEndNormalInside2d);
77 
78 protected:
79  WorldIntegerPos m_inputIntegerPos;
80  WorldIntegerPos m_insideIntegerPos;
81 
83 
86 
91 
92  InsidePosFromOutsidePosQueryMode m_queryMode;
93  Vec2f m_castDirection;
94 
96 
98 
100 };
101 
102 }
103 
Base class for InsidePosFromOutsidePosQuery.
Definition: baseinsideposfromoutsideposquery.h:38
InsidePosFromOutsidePosQueryResult
Enumerates the possible results of an InsidePosFromOutsidePosQuery.
Definition: baseinsideposfromoutsideposquery.h:20
Indicates that the query was completed successfully, and a valid position on the NavMesh was found wi...
Definition: baseinsideposfromoutsideposquery.h:28
virtual QueryType GetType() const
Get query type.
Definition: baseinsideposfromoutsideposquery.h:42
Indicates the query has not yet been initialized.
Definition: baseinsideposfromoutsideposquery.h:22
Vertical range (above, below) that represents the altitude tolerance for a position to be inside the ...
Definition: positionspatializationrange.h:17
Base class for all the queries that do not need to be time-sliced.
Definition: iquery.h:245
PositionSpatializationRange m_positionSpatializationRange
The Z extent from m_inputPos3f of the axis-aligned bounding box within which the search is performed...
Definition: baseinsideposfromoutsideposquery.h:85
KyFloat32 m_distFromObstacle
Specifies a preferred distance between the final chosen point and the border of the NavMesh...
Definition: baseinsideposfromoutsideposquery.h:90
Indicates that insufficient working memory caused the query to stop.
Definition: baseinsideposfromoutsideposquery.h:25
This class is a runtime container for Autodesk Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:52
QueryType
Enumerates all the type of query.
Definition: iquery.h:25
2d vector using KyFloat32.
Definition: vec2f.h:18
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
NavTrianglePtr m_insidePosTrianglePtr
Updated during processing to store the NavMesh triangle that contains m_insidePos3f.
Definition: baseinsideposfromoutsideposquery.h:97
Indicates that the query has not yet been initialized.
Definition: iquery.h:295
Vec3f m_insidePos3f
Updated during processing to store the valid point found inside the NavMesh, if any.
Definition: baseinsideposfromoutsideposquery.h:95
Indicates the query has not yet been launched.
Definition: baseinsideposfromoutsideposquery.h:23
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
InsidePosFromOutsidePosQueryResult m_result
Updated during processing to indicate the result of the query.
Definition: baseinsideposfromoutsideposquery.h:99
Indicates that the query has not yet been launched.
Definition: iquery.h:296
KyFloat32 m_horizontalTolerance
The horizontal half-width (along both the X and Y axes) of the axis-aligned bounding box within which...
Definition: baseinsideposfromoutsideposquery.h:84
Indicates that a valid position was not found within the query's bounding box.
Definition: baseinsideposfromoutsideposquery.h:27
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
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
Vec3f m_inputPos3f
The starting position for the query.
Definition: baseinsideposfromoutsideposquery.h:82