integration/gwnavruntimeglue/bulletcollisioninterface/bulletdebugdraw.h Source File

bulletdebugdraw.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 
9 #include "btBulletCollisionCommon.h"
12 
13 inline Kaim::Vec3f btVectorToVec3f(const btVector3& btVec) { return Kaim::Vec3f(btVec[0], btVec[1], btVec[2]); }
14 
15 inline btVector3 Vec3fTobtVector(const Kaim::Vec3f& vec3f) { return btVector3(vec3f[0], vec3f[1], vec3f[2]); }
16 
17 Kaim::Color btColorToNavColor(const btVector3& btColor) { return Kaim::Color((KyUInt8)btColor[0], (KyUInt8)btColor[1], (KyUInt8)btColor[2]); }
18 
19 class CollisionInterfaceDebugDraw : public btIDebugDraw
20 {
21 public:
22  CollisionInterfaceDebugDraw() : m_displayList(nullptr), m_debugMode(0) {}
23 
24  virtual ~CollisionInterfaceDebugDraw() {}
25 
26  virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
27  {
28  m_displayList->PushLine(btVectorToVec3f(from), btVectorToVec3f(to), btColorToNavColor(color));
29  }
30 
31  virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& fromColor, const btVector3& /*toColor*/) { drawLine(from, to, fromColor); }
32 
33  virtual void drawTriangle(const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& color, btScalar /*alpha*/)
34  {
35  m_displayList->PushTriangle(btVectorToVec3f(a), btVectorToVec3f(b), btVectorToVec3f(c), Kaim::ShapeColor::FillOnly(btColorToNavColor(color)));
36  }
37 
38  virtual void drawTriangle(const btVector3& v0, const btVector3& v1, const btVector3& v2, const btVector3& /*n0*/, const btVector3& /*n1*/, const btVector3& /*n2*/,
39  const btVector3& color, btScalar alpha)
40  {
41  drawTriangle(v0, v1, v2, color, alpha);
42  }
43 
44  virtual void drawContactPoint(const btVector3& /*PointOnB*/, const btVector3& /*normalOnB*/, btScalar /*distance*/, int /*lifeTime*/, const btVector3& /*color*/) {}
45 
46  virtual void reportErrorWarning(const char* /*warningString*/) {}
47 
48  virtual void draw3dText(const btVector3& location, const char* textString)
49  {
50  const Kaim::Vec3f loc = btVectorToVec3f(location);
51  m_displayList->PushText(loc, Kaim::Color::Salmon, textString);
52  }
53 
54  virtual void setDebugMode(int debugMode) { m_debugMode = debugMode; }
55 
56  virtual int getDebugMode() const { return btIDebugDraw::DBG_DrawWireframe; }
57 
58  void BeginFrame(Kaim::DisplayList* displayList) { m_displayList = displayList; }
59 
60  void EndFrame() { m_displayList = nullptr; }
61 
62 private:
63  Kaim::DisplayList* m_displayList;
64  int m_debugMode;
65 };
DisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:128
RGBA color.
Definition: color.h:16
std::uint8_t KyUInt8
uint8_t
Definition: types.h:27
3d vector using 32bits floating points.
Definition: vec3f.h:16