BsDebugDraw.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "CmModule.h"
  4. #include "CmColor.h"
  5. #include "CmAABox.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Methods you can use for debugging. Quite inefficient way of rendering though,
  10. * so use them sparingly.
  11. *
  12. * TODO - NOT THREAD SAFE
  13. */
  14. class BS_EXPORT DebugDraw : public CM::Module<DebugDraw>
  15. {
  16. enum class DebugDrawType
  17. {
  18. Line, Triangle
  19. };
  20. struct DebugDrawCommand
  21. {
  22. DebugDrawType type;
  23. float timeEnds;
  24. CM::UINT32* indices;
  25. CM::UINT8* vertices;
  26. CM::UINT32 numElements;
  27. };
  28. public:
  29. DebugDraw();
  30. void draw2DLine(const CM::Vector2&a, const CM::Vector2& b, const CM::Color& color = CM::Color::Green, float timeout = 0.0f);
  31. //void drawAABB(const AxisAlignedBox& aab, const Color& color = Color::Green, float timeout = 0.0f);
  32. //void drawSphere(const Vector3& center, float radius, const Color& color = Color::Green, float timeout = 0.0f);
  33. void render(const Camera* camera, CM::CoreAccessor& coreAccessor);
  34. private:
  35. CM::HMesh mTriangleMesh;
  36. CM::HMesh mLineMesh;
  37. CM::HMaterial mTriangleMaterial;
  38. CM::HMaterial mLineMaterial;
  39. CM::Vector<DebugDrawCommand>::type mCommands;
  40. static const int VertexSize = 16;
  41. void updateMeshes();
  42. };
  43. }