gwnavruntime/pathfollower/circlearcspline.h Source File

circlearcspline.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 
11 
12 
13 namespace Kaim
14 {
15 
16 
17 enum SplineCutMode
18 {
19  CutSplineAtArcStart,
20  CutSplineAtArcEnd,
21  CutSplineAtArcInnerPosition
22 };
23 
28 {
29 public:
30  CircleArcSpline() {}
31 
32  void Clear();
33  bool IsEmpty() const;
34  KyUInt32 GetSectionCount() const;
35 
37  const CircleArcSplineSection& GetSection(KyUInt32 index) const;
38 
40  const Vec3f& GetStartPosition() const;
41 
43  const Vec3f& GetEndPosition() const;
44 
47 
50 
52  Vec2f ComputeStartTangent() const;
53 
55  Vec2f ComputeEndTangent() const;
56 
57 
58  void Display(const CircleArcSplineSectionDisplayConfig& displayConfig, DisplayList& displayList_arc, DisplayList& displayList_extremities,
59  DisplayList& displayList_sectionIdx, DisplayList& displayList_radius) const;
60 
61 
62 public: // internal
63 
64  // Cuts tail and head to keep just the spline portion between provided positions.
65  KyResult KeepSplineBetween(
66  const Vec3f& newStartPosition, KyUInt32 newStartArcIndex, SplineCutMode startCutMode, KyUInt32 newStartSectionIdx,
67  const Vec3f& newEndPosition, KyUInt32 newEndArcIndex, SplineCutMode endCutMode, KyUInt32 newEndSectionIdx);
68 
69  void Append(const KyArray<CircleArcSplineSection>& sections);
70  void Reset(const KyArray<CircleArcSplineSection>& sections);
71  void PushBack(const CircleArcSplineSection& sections);
72 
73  const KyArray<CircleArcSplineSection>& GetSectionArray() const { return m_sections; }
74 
75 private:
76  KyResult CutTailAt(const Vec3f& position, KyUInt32 arcIndex, SplineCutMode cutMode, KyUInt32 sectionIdx);
77  KyResult CutHeadAt(const Vec3f& position, KyUInt32 arcIndex, SplineCutMode cutMode, KyUInt32 sectionIdx);
78 
79 public: // internal
81 };
82 
83 KY_INLINE void CircleArcSpline::Clear() { m_sections.Clear(); };
84 KY_INLINE void CircleArcSpline::Reset(const KyArray<CircleArcSplineSection>& sections) { m_sections = sections; }
85 
86 KY_INLINE bool CircleArcSpline::IsEmpty() const { return m_sections.IsEmpty(); }
87 KY_INLINE KyUInt32 CircleArcSpline::GetSectionCount() const { return m_sections.GetCount(); }
88 KY_INLINE const CircleArcSplineSection& CircleArcSpline::GetSection(KyUInt32 index) const { KY_ASSERT(IsEmpty() == false); return m_sections[index]; }
89 KY_INLINE const Vec3f& CircleArcSpline::GetStartPosition() const { KY_ASSERT(IsEmpty() == false); return m_sections[0].GetStartPosition(); }
90 KY_INLINE const Vec3f& CircleArcSpline::GetEndPosition() const { KY_ASSERT(IsEmpty() == false); return m_sections[GetLastSectionIndex()].GetEndPosition(); }
91 KY_INLINE KyUInt32 CircleArcSpline::GetLastSectionIndex() const { KY_ASSERT(IsEmpty() == false); return (m_sections.GetCount() - 1); }
92 KY_INLINE const CircleArcSplineSection& CircleArcSpline::GetLastSection() const { KY_ASSERT(IsEmpty() == false); return m_sections[GetLastSectionIndex()]; }
93 KY_INLINE Vec2f CircleArcSpline::ComputeStartTangent() const { KY_ASSERT(IsEmpty() == false); return m_sections[0].ComputeTangent(GetStartPosition()); }
94 KY_INLINE Vec2f CircleArcSpline::ComputeEndTangent() const { KY_ASSERT(IsEmpty() == false); return m_sections[GetLastSectionIndex()].ComputeTangent(GetEndPosition()); }
95 
96 }
97 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
const CircleArcSplineSection & GetSection(KyUInt32 index) const
Definition: circlearcspline.h:88
Vec2f ComputeEndTangent() const
Definition: circlearcspline.h:94
Vec2f ComputeStartTangent() const
Definition: circlearcspline.h:93
KyUInt32 GetLastSectionIndex() const
Definition: circlearcspline.h:91
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
const Vec3f & GetEndPosition() const
Definition: circlearcspline.h:90
The class representing a spline compounded of oriented circle arcs and straight line segments...
Definition: circlearcspline.h:27
2d vector using KyFloat32.
Definition: vec2f.h:18
DisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:128
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
const Vec3f & GetStartPosition() const
Definition: circlearcspline.h:89
Class representing either an oriented circle arc or a straight line segment, to be aggregated into a ...
Definition: circlearcsplinesection.h:23
const CircleArcSplineSection & GetLastSection() const
Definition: circlearcspline.h:92
3d vector using 32bits floating points.
Definition: vec3f.h:16