gwnavruntime/collision/indexedmeshblob.h Source File

indexedmeshblob.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 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 
8 #ifndef Navigation_IndexedMeshBlob_H
9 #define Navigation_IndexedMeshBlob_H
10 
16 
17 namespace Kaim
18 {
19 
20 class IndexedMeshBlob
21 {
22  KY_ROOT_BLOB_CLASS(CollisionData, IndexedMeshBlob, 0)
23  KY_CLASS_WITHOUT_COPY(IndexedMeshBlob)
24 public:
25  IndexedMeshBlob() {}
26 
27  KyUInt32 GetIndexStride() const { return 3*sizeof(KyUInt32); }
28  KyUInt32 GetVertexStride() const { return sizeof(Vec3f); }
29  const UByte * GetIndexBase() const { return (const UByte*)m_indices.GetValues(); }
30  const UByte * GetVertexBase() const { return (const UByte*)m_vertices.GetValues(); }
31 
32  KyUInt32 GetTriangleCount() const { return m_indices.GetCount() / 3; }
33 
34  BlobArray<Vec3f> m_vertices;
35  BlobArray<KyUInt32> m_indices;
36 };
37 
38 inline void SwapEndianness(Kaim::Endianness::Target e, IndexedMeshBlob& self)
39 {
40  SwapEndianness(e, self.m_vertices);
41  SwapEndianness(e, self.m_indices);
42 }
43 
44 class IndexedMeshBlobBuilder : public BaseBlobBuilder<IndexedMeshBlob>
45 {
46 public:
47  enum IndexedState
48  {
49  NotIndexed = 0,
50  Indexed = 1,
51  };
52 
53  IndexedMeshBlobBuilder() : m_indexedState(NotIndexed) {}
54 
55  void Clear();
56 
57  bool IsEmpty() { return m_indices.GetCount() == 0; }
58  void AddTriangle(const Vec3f& a, const Vec3f& b, const Vec3f& c);
59 
60  virtual void DoBuild();
61 
62 private:
63  void MakeIndexed();
64 
65  KyArrayPOD<KyUInt32> m_indices;
66  KyArray<Vec3f> m_vertices;
67  IndexedState m_indexedState;
68 };
69 
70 class IndexedMeshArrayBlob
71 {
72  KY_ROOT_BLOB_CLASS(CollisionData, IndexedMeshArrayBlob, 0)
73  KY_CLASS_WITHOUT_COPY(IndexedMeshArrayBlob)
74 
75 public:
76  IndexedMeshArrayBlob() {}
77  //
78  //KyFloat32 m_scaling[4];
79  BlobArray<IndexedMeshBlob> m_meshParts;
80 };
81 
82 inline void SwapEndianness(Kaim::Endianness::Target e, IndexedMeshArrayBlob& self)
83 {
84  SwapEndianness(e, self.m_meshParts);
85 }
86 
87 }
88 
89 #endif // Navigation_IndexedMeshBlob_H
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36