gwnavruntime/visualsystem/displayshapeutils.h Source File

displayshapeutils.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 namespace Kaim
13 {
14 
15 class Box3f;
16 class Transform;
17 class OrientedBox2d;
18 
19 
20 KyFloat32 ComputeFrontUpRight( const Vec3f& P, const Vec3f& Q, KyFloat32 radius, Vec3f& front, Vec3f& up, Vec3f& right);
21 
22 KyFloat32 ComputeFrontRight2d5(const Vec3f& P, const Vec3f& Q, KyFloat32 radius, Vec3f& front, Vec3f& right);
23 
24 
25 // H----------G FRONT VIEW | BACK VIEW | BOTTOM VIEW | TOP VIEW | RIGHT VIEW | LEFT VIEW
26 // /| /| E---F | G---H | A---B | H---G | F---G | H---E
27 // / | / | | P | | | Q | | | | | | | | | | | | |
28 // E----------F | A---B | C---D | D---C | E---F | B---C | D---A
29 // | | | | A, B, F, E | C, D, H, G | D, C, B, A | E, F, G, H | B, C, G, F | D, A, E, H
30 // | D-------|--C
31 // | / | /
32 // |/ |/
33 // A----------B
34 class VisualBoxVertices
35 {
36  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_VisualSystem)
37 
38 public:
39  void InitFromCenter(const Vec3f& center, KyFloat32 radius);
40  void InitFromBox(const Box3f& box);
41  void InitFromSegment(const Vec3f& P, const Vec3f& Q, KyFloat32 radius);
42  void InitShearedBoxFromSegment(const Vec3f& P, const Vec3f& Q, KyFloat32 height, KyFloat32 radius);
43  void InitFromTransformExtent(const Transform& transform, const Box3f& radius);
44  void InitFromOrientedBox2d(const OrientedBox2d& orientedBox2d);
45 public:
46  Vec3f A, B, C, D, E, F, G, H;
47 };
48 
49 // Compute segment PQ along arc (dir1, dir2, winding). Segments are generated counter-clockwise
50 // usage:
51 // CircleArcTesselator tesselator(...);
52 // while(tesselator.Next()) { read tesselator.P and tesselator.Q }
53 class CircleArcTesselator
54 {
55 public:
56  enum { MinCount = 10, MaxCount = 1024 };
57 
58  static KyUInt32 ComputeCountFromAngle(KyFloat32 radius, KyFloat32 precision, KyFloat32 total_angle = KY_2_PI);
59  static KyUInt32 ComputeCountFromDirSpan(KyFloat32 radius, KyFloat32 precision, const Vec2f& dir1, const Vec2f& dir2, Winding::Enum winding);
60  static KyUInt32 ComputeCountFromPosSpan(KyFloat32 radius, KyFloat32 precision, const Vec3f& center, const Vec3f& pos1, const Vec3f& pos2, Winding::Enum winding);
61 
62  CircleArcTesselator(const Vec3f& center, KyFloat32 radius, KyUInt32 segmentCount, const Vec2f& dir1 = Vec2f::UnitX(), const Vec2f& dir2 = Vec2f::UnitX(),
63  Winding::Enum winding = Winding::CCW);
64 
65  bool Next();
66  void Reset();
67 
68 public:
69  Vec3f P;
70  Vec3f Q;
71 
72 private:
73  Vec3f m_center;
74  KyFloat32 m_radius;
75  Vec2f m_start_ray;
76 
77  KyInt32 m_count;
78  KyFloat32 m_cos; // cos(angle_step) where angle_step > 0
79  KyFloat32 m_sin; // sin(angle_step) where angle_step > 0
80 
81  KyInt32 m_index;
82  Vec2f m_ray;
83 };
84 
85 
86 }
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
static Vec2f UnitX()
Returns {1.0f, 0.0f}.
Definition: vec2f.h:97
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
static const KyFloat32 KY_2_PI
Stores the value of 2*pi.
Definition: fastmath.h:143
float KyFloat32
float
Definition: types.h:32