gwnavgeneration/input/trianglesplitter.h Source File

trianglesplitter.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 namespace Kaim
18 {
19 class GeneratorSystem;
20 
21 class Triangle3fi
22 {
23  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
24 public:
25  Triangle3fi() {}
26 
27  Triangle3fi(const Vec3f& A, const Vec3f& B, const Vec3f& C, KyFloat32 rasterPrecision)
28  {
29  m_tri3f.A = A;
30  m_tri3f.B = B;
31  m_tri3f.C = C;
32  ComputeIntegerCoords(rasterPrecision);
33  }
34 
35  Triangle3fi& operator=(const Triangle3fi& other)
36  {
37  m_tri3f = other.m_tri3f;
38  m_tri3i = other.m_tri3i;
39  return *this;
40  }
41 
42  Vec3f Af() const { return m_tri3f.A; }
43  Vec3f Bf() const { return m_tri3f.B; }
44  Vec3f Cf() const { return m_tri3f.C; }
45 
46  Vec3i Ai() const { return m_tri3i.A; }
47  Vec3i Bi() const { return m_tri3i.B; }
48  Vec3i Ci() const { return m_tri3i.C; }
49 
50  void ComputeIntegerCoords(KyFloat32 rasterPrecision)
51  {
52  IntCoordSystem::NavigationToInt_Pos(m_tri3f.A, m_tri3i.A, rasterPrecision);
53  IntCoordSystem::NavigationToInt_Pos(m_tri3f.B, m_tri3i.B, rasterPrecision);
54  IntCoordSystem::NavigationToInt_Pos(m_tri3f.C, m_tri3i.C, rasterPrecision);
55  }
56 
57  void Setf(const Vec3f& A, const Vec3f& B, const Vec3f& C)
58  {
59  m_tri3f.A = A;
60  m_tri3f.B = B;
61  m_tri3f.C = C;
62  }
63 
64  Triangle3f m_tri3f;
65  Triangle3i m_tri3i;
66 };
67 
68 
69 // This class essentially split a triangle into multiple sub triangles using the "IsTriangleTooBig" criteria from the coordSystem.
70 // Children will have the same winding (CW or CCW) as their parent.
71 // If the input triangles already satisfies the criteria, children list will be empty
72 class TriangleSplitter
73 {
74  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
75  KY_CLASS_WITHOUT_COPY(TriangleSplitter)
76 
77 public:
78  TriangleSplitter(const GeneratorSystem* sys, KyArray<Triangle3fi>* stack, KyArray<Triangle3fi>* output)
79  : m_sys(sys), m_stack(stack), m_output(output)
80  {
81  }
82 
83  void Split(const Triangle3fi& big);
84 
85  const GeneratorSystem* m_sys;
86  KyArray<Triangle3fi>* m_stack;
87  KyArray<Triangle3fi>* m_output;
88 };
89 
90 
91 }
92 
93 
94 
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#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
float KyFloat32
float
Definition: types.h:32