gwnavruntime/visualdebug/messages/lodmaxblob.h Source File

lodmaxblob.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 
8 #pragma once
9 
18 
19 
20 namespace Kaim
21 {
22 
23 
29 {
30  KY_ROOT_BLOB_CLASS(Runtime, LodMaxBlob, 0)
31 
32 public:
33  LodMaxBlob() : m_visualDebugId(KyUInt32MAXVAL) {}
34 
35  KyUInt32 m_visualDebugId; // the id of the visualdebug element.
36  Vec3f m_shapePosition; // the 3D position of the shape.
37 };
38 
39 inline void SwapEndianness(Kaim::Endianness::Target e, LodMaxBlob& self)
40 {
41  SwapEndianness(e, self.m_visualDebugId);
42  SwapEndianness(e, self.m_shapePosition);
43 }
44 
45 
46 class LodMaxBlobBuilder : public BaseBlobBuilder<LodMaxBlob>
47 {
48 public:
49  LodMaxBlobBuilder(KyUInt32 visualDebugId, const Vec3f& shapePosition)
50  : m_visualDebugId(visualDebugId), m_shapePosition(shapePosition) {}
51 
52  virtual void DoBuild()
53  {
54  BLOB_SET(m_blob->m_visualDebugId, m_visualDebugId);
55  BLOB_SET(m_blob->m_shapePosition, m_shapePosition);
56  }
57 private:
58  KyUInt32 m_visualDebugId;
59  Vec3f m_shapePosition;
60 };
61 
62 
63 class LodMaxHintDisplayListBuilder
64 {
65 public:
66  static void DisplayLodMaxHint(DisplayList* displayList, const LodMaxBlob* lodMaxBlob)
67  {
68  if (lodMaxBlob == nullptr)
69  return;
70 
71  KyFloat32 radius = 0.3f;
72  KyFloat32 radius_div_3 = radius / 3.0f;
73 
74  ShapeColor shapeColor(Color::Yellow, Color::Fade(Color::Yellow, 0.8f));
75 
76  // Horizontal box
77 
78  Vec3f horizontalBoxMin = lodMaxBlob->m_shapePosition;
79  horizontalBoxMin.x -= radius;
80  horizontalBoxMin.y -= radius_div_3;
81  horizontalBoxMin.z -= radius_div_3;
82 
83  Vec3f horizontalBoxMax = lodMaxBlob->m_shapePosition;
84  horizontalBoxMax.x += radius;
85  horizontalBoxMax.y += radius_div_3;
86  horizontalBoxMax.z += radius_div_3;
87 
88  displayList->PushBox(Box3f(horizontalBoxMin, horizontalBoxMax), shapeColor);
89 
90 
91  // Vertical box
92 
93  Vec3f verticalBoxMin = lodMaxBlob->m_shapePosition;
94  verticalBoxMin.x -= radius_div_3;
95  verticalBoxMin.y -= radius_div_3;
96  verticalBoxMin.z -= radius;
97 
98  Vec3f verticalBoxMax = lodMaxBlob->m_shapePosition;
99  verticalBoxMax.x += radius_div_3;
100  verticalBoxMax.y += radius_div_3;
101  verticalBoxMax.z += radius;
102 
103  displayList->PushBox(Box3f(verticalBoxMin, verticalBoxMax), shapeColor);
104  }
105 };
106 
107 }
108 
#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
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
Send this blob to display a shape saying that the visual element with id m_visualDebugId is at LOD ma...
Definition: lodmaxblob.h:28
LodMaxBlob * 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 KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16