gwnavruntime/collision/heightfieldblob.h Source File

heightfieldblob.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 
14 
15 namespace Kaim
16 {
17 
18 class HeightFieldBlob
19 {
20  KY_ROOT_BLOB_CLASS(CollisionData, HeightFieldBlob, 0)
21  KY_CLASS_WITHOUT_COPY(HeightFieldBlob)
22 
23 public:
24  HeightFieldBlob() {}
25 
26  Vec3f m_origin;
27  BlobArray<KyFloat32> m_altitudes;
28  KyFloat32 m_tileSize;
29  KyUInt32 m_xAltitudeCount;
30  KyUInt32 m_yAltitudeCount;
31 };
32 
33 inline void SwapEndianness(Endianness::Target e, HeightFieldBlob& self)
34 {
35  SwapEndianness(e, self.m_origin);
36  SwapEndianness(e, self.m_altitudes);
37  SwapEndianness(e, self.m_tileSize);
38  SwapEndianness(e, self.m_xAltitudeCount);
39  SwapEndianness(e, self.m_yAltitudeCount);
40 }
41 
42 class HeightFieldBlobBuilder : public BaseBlobBuilder<HeightFieldBlob>
43 {
44 public:
45  HeightFieldBlobBuilder(const Vec3f& origin, KyFloat32 tileSize, KyUInt32 xCount, KyUInt32 yCount)
46  : m_origin(origin), m_tileSize(tileSize), m_xAltitudeCount(xCount), m_yAltitudeCount(yCount)
47  {
48  }
49 
50  void DoBuild()
51  {
52  BLOB_SET(m_blob->m_origin, m_origin);
53  BLOB_ARRAY(m_blob->m_altitudes, m_xAltitudeCount * m_yAltitudeCount);
54  BLOB_SET(m_blob->m_tileSize, m_tileSize);
55  BLOB_SET(m_blob->m_xAltitudeCount, m_xAltitudeCount);
56  BLOB_SET(m_blob->m_yAltitudeCount, m_yAltitudeCount);
57  }
58 
59  Vec3f m_origin;
60  KyFloat32 m_tileSize;
61  KyUInt32 m_xAltitudeCount;
62  KyUInt32 m_yAltitudeCount;
63 };
64 }
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:130
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
HeightFieldBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:113
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define BLOB_ARRAY(blobArray, count)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:139
float KyFloat32
float
Definition: types.h:32