16#ifndef BT_IDEBUG_DRAW__H
17#define BT_IDEBUG_DRAW__H
41 : m_activeObject(1, 1, 1),
42 m_deactivatedObject(0, 1, 0),
43 m_wantsDeactivationObject(0, 1, 1),
44 m_disabledDeactivationObject(1, 0, 0),
45 m_disabledSimulationObject(1, 1, 0),
47 m_contactPoint(1, 1, 0)
102 drawSpherePatch(center, up, axis, radius, minTh, maxTh, minPs, maxPs, color, stepDegrees,
false);
103 drawSpherePatch(center, up, -axis, radius, minTh, maxTh, minPs, maxPs, color, stepDegrees,
false);
137 btVector3 halfExtents = (to - from) * 0.5f;
141 btVector3 edgecoord(1.f, 1.f, 1.f), pa, pb;
142 for (i = 0; i < 4; i++)
144 for (j = 0; j < 3; j++)
146 pa =
btVector3(edgecoord[0] * halfExtents[0], edgecoord[1] * halfExtents[1],
147 edgecoord[2] * halfExtents[2]);
150 int othercoord = j % 3;
151 edgecoord[othercoord] *= -1.f;
152 pb =
btVector3(edgecoord[0] * halfExtents[0], edgecoord[1] * halfExtents[1],
153 edgecoord[2] * halfExtents[2]);
160 edgecoord[i] *= -1.f;
177 int nSteps = (int)
btFabs((maxAngle - minAngle) / step);
178 if (!nSteps) nSteps = 1;
184 for (
int i = 1; i <= nSteps; i++)
225 drawN = drawS =
true;
227 int n_hor = (int)((maxTh - minTh) / step) + 1;
228 if (n_hor < 2) n_hor = 2;
230 bool isClosed =
false;
245 int n_vert = (int)((maxPs - minPs) / step) + 1;
246 if (n_vert < 2) n_vert = 2;
248 for (
int i = 0; i < n_hor; i++)
253 for (
int j = 0; j < n_vert; j++)
258 pvB[j] = center + cth * cps * iv + cth * sps * jv + sth * kv;
269 drawLine(pvB[j - 1], pvB[j], color);
275 if ((i == (n_hor - 1)) && drawN)
284 if (j == (n_vert - 1))
291 if (((!i) || (i == (n_hor - 1))) && ((!j) || (j == (n_vert - 1))))
337 int stepDegrees = 30;
340 capStart[upAxis] = -halfHeight;
343 capEnd[upAxis] = halfHeight;
348 childTransform.
getOrigin() = transform * capStart;
358 drawSpherePatch(center, up, axis, radius, minTh, maxTh, minPs, maxPs, color,
btScalar(stepDegrees),
false);
364 childTransform.
getOrigin() = transform * capEnd;
373 drawSpherePatch(center, up, axis, radius, minTh, maxTh, minPs, maxPs, color,
btScalar(stepDegrees),
false);
380 for (
int i = 0; i < 360; i += stepDegrees)
392 offsetHeight[upAxis] = halfHeight;
393 int stepDegrees = 30;
395 capStart[upAxis] = -halfHeight;
397 capEnd[upAxis] = halfHeight;
399 for (
int i = 0; i < 360; i += stepDegrees)
409 xaxis[(upAxis + 1) % 3] =
btScalar(1.0);
416 int stepDegrees = 30;
421 offsetHeight[upAxis] = halfHeight;
423 offsetRadius[(upAxis + 1) % 3] = radius;
425 offset2Radius[(upAxis + 2) % 3] = radius;
428 capEnd[upAxis] = -halfHeight;
430 for (
int i = 0; i < 360; i += stepDegrees)
437 drawLine(start + transform.
getBasis() * (offsetHeight), start + transform.
getBasis() * (-offsetHeight + offsetRadius), color);
438 drawLine(start + transform.
getBasis() * (offsetHeight), start + transform.
getBasis() * (-offsetHeight - offsetRadius), color);
439 drawLine(start + transform.
getBasis() * (offsetHeight), start + transform.
getBasis() * (-offsetHeight + offset2Radius), color);
440 drawLine(start + transform.
getBasis() * (offsetHeight), start + transform.
getBasis() * (-offsetHeight - offset2Radius), color);
446 xaxis[(upAxis + 1) % 3] =
btScalar(1.0);
452 btVector3 planeOrigin = planeNormal * planeConst;
456 btVector3 pt0 = planeOrigin + vec0 * vecLen;
457 btVector3 pt1 = planeOrigin - vec0 * vecLen;
458 btVector3 pt2 = planeOrigin + vec1 * vecLen;
459 btVector3 pt3 = planeOrigin - vec1 * vecLen;
460 drawLine(transform * pt0, transform * pt1, color);
461 drawLine(transform * pt2, transform * pt3, color);
#define SIMD_RADS_PER_DEG
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
btScalar btSin(btScalar x)
btScalar btFabs(btScalar x)
btScalar btCos(btScalar x)
void btPlaneSpace1(const T &n, T &p, T &q)
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform &transform, const btVector3 &color)
virtual void drawPlane(const btVector3 &planeNormal, btScalar planeConst, const btTransform &transform, const btVector3 &color)
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &fromColor, const btVector3 &toColor)
virtual void drawBox(const btVector3 &bbMin, const btVector3 &bbMax, const btTransform &trans, const btVector3 &color)
virtual void drawArc(const btVector3 ¢er, const btVector3 &normal, const btVector3 &axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle, const btVector3 &color, bool drawSect, btScalar stepDegrees=btScalar(10.f))
virtual void draw3dText(const btVector3 &location, const char *textString)=0
virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color)
virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &, const btVector3 &, const btVector3 &, const btVector3 &color, btScalar alpha)
virtual void flushLines()
virtual void reportErrorWarning(const char *warningString)=0
virtual void clearLines()
virtual void drawSphere(const btVector3 &p, btScalar radius, const btVector3 &color)
virtual void setDebugMode(int debugMode)=0
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
virtual void drawContactPoint(const btVector3 &PointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color)=0
virtual int getDebugMode() const =0
virtual void drawBox(const btVector3 &bbMin, const btVector3 &bbMax, const btVector3 &color)
virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform &transform, const btVector3 &color)
virtual void drawSpherePatch(const btVector3 ¢er, const btVector3 &up, const btVector3 &axis, btScalar radius, btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3 &color, btScalar stepDegrees=btScalar(10.f), bool drawCenter=true)
@ DBG_MAX_DEBUG_DRAW_MODE
@ DBG_EnableSatComparison
@ DBG_DrawConstraintLimits
virtual DefaultColors getDefaultColors() const
virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &color, btScalar)
virtual void drawAabb(const btVector3 &from, const btVector3 &to, const btVector3 &color)
virtual void drawCapsule(btScalar radius, btScalar halfHeight, int upAxis, const btTransform &transform, const btVector3 &color)
virtual void setDefaultColors(const DefaultColors &)
the default implementation for setDefaultColors has no effect. A derived class can implement it and s...
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
btVector3 can be used to represent 3D points and vectors.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btVector3 m_wantsDeactivationObject
btVector3 m_deactivatedObject
btVector3 m_disabledSimulationObject
btVector3 m_disabledDeactivationObject