-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrameworkDebugDrawer.cpp
93 lines (78 loc) · 1.72 KB
/
FrameworkDebugDrawer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "FrameworkDebugDrawer.h"
#include "framework.h"
FrameworkDebugDrawer::FrameworkDebugDrawer()
{
}
FrameworkDebugDrawer::~FrameworkDebugDrawer()
{
}
FrameworkDebugDrawer::DefaultColors FrameworkDebugDrawer::getDefaultColors() const
{
return m_ourColors;
}
void FrameworkDebugDrawer::setDefaultColors(const DefaultColors & colors)
{
m_ourColors = colors;
}
void FrameworkDebugDrawer::drawLine(
const btVector3 & from,
const btVector3 & to,
const btVector3 & color)
{
m_linePoints[m_numLines*2+0] = from;
m_linePoints[m_numLines*2+1] = to;
m_lineColors[m_numLines] = color;
m_numLines++;
if (m_numLines == BT_LINE_BATCH_SIZE)
{
flushLines();
}
}
void FrameworkDebugDrawer::drawContactPoint(
const btVector3 & PointOnB,
const btVector3 & normalOnB,
btScalar distance,
int lifeTime,
const btVector3 & color)
{
drawLine(PointOnB, PointOnB + normalOnB * distance, color);
static const btVector3 ncolor(0, 0, 0);
drawLine(PointOnB, PointOnB + normalOnB * 0.01f, ncolor);
}
void FrameworkDebugDrawer::reportErrorWarning(const char * warningString)
{
}
void FrameworkDebugDrawer::draw3dText(const btVector3 & location, const char * textString)
{
Assert(false);
}
void FrameworkDebugDrawer::setDebugMode(int debugMode)
{
m_debugMode = debugMode;
}
int FrameworkDebugDrawer::getDebugMode() const
{
return m_debugMode;
}
void FrameworkDebugDrawer::flushLines()
{
if (m_numLines > 0)
{
pushDepthBias(1, 1);
gxBegin(GX_LINES);
{
for (int i = 0; i < m_numLines; ++i)
{
gxColor4f(
m_lineColors[i][0],
m_lineColors[i][1],
m_lineColors[i][2], 1.f);
gxVertex3fv(&m_linePoints[i*2+0][0]);
gxVertex3fv(&m_linePoints[i*2+1][0]);
}
}
gxEnd();
popDepthBias();
m_numLines = 0;
}
}