Leviathan  0.8.0.0
Leviathan game engine
PhysicsDebugDrawer.cpp
Go to the documentation of this file.
1 // ------------------------------------ //
2 #include "PhysicsDebugDrawer.h"
3 
4 #include "Common/Types.h"
5 
6 #include "bsfEngine/Debug/BsDebugDraw.h"
7 
8 using namespace Leviathan;
9 // ------------------------------------ //
11  Target(drawtarget), World(cameraworld)
12 {}
13 // ------------------------------------ //
15  const btVector3& from, const btVector3& to, const btVector3& color)
16 {
17  bs::DebugDraw::instance().setColor(Float4(color, 1.f));
18  bs::DebugDraw::instance().drawLine(Float3(from), Float3(to));
19 }
20 
22  const btVector3& p, btScalar radius, const btVector3& color)
23 {
24  bs::DebugDraw::instance().setColor(Float4(color, 1.f));
25  bs::DebugDraw::instance().drawWireSphere(Float3(p), radius);
26 }
27 
28 void PhysicsDebugDrawer::drawContactPoint(const btVector3& pointOnB,
29  const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color)
30 {
31  const auto to = pointOnB + normalOnB * distance;
32 
33  drawLine(pointOnB, to, color);
34 
35  // According to one source lifeTime should be drawn as a string near pointOnB
36 }
37 
38 void PhysicsDebugDrawer::reportErrorWarning(const char* warningString)
39 {
40  LOG_WARNING("[PHYSICS DEBUG] " + std::string(warningString));
41 }
42 // ------------------------------------ //
44 {
45  bs::DebugDraw::instance().clear();
46 }
void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color) override
void reportErrorWarning(const char *warningString) override
PhysicsDebugDrawer(Window &drawtarget, GameWorld &cameraworld)
void drawSphere(const btVector3 &p, btScalar radius, const btVector3 &color) override
float btScalar
Definition: PhysicalWorld.h:30
#define LOG_WARNING(x)
Definition: Define.h:91
void drawContactPoint(const btVector3 &pointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color) override
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
Definition: checked.h:198
#define DLLEXPORT
Definition: Include.h:84
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
Represents a world that contains entities.
Definition: GameWorld.h:57