Skip to content

Commit

Permalink
revert debug draw name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
erincatto committed Jan 20, 2025
1 parent 2a39a3b commit 7605ccf
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 100 deletions.
18 changes: 9 additions & 9 deletions include/box2d/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1345,32 +1345,32 @@ typedef enum b2HexColor
typedef struct b2DebugDraw
{
/// Draw a closed polygon provided in CCW order.
void ( *drawPolygon )( const b2Vec2* vertices, int vertexCount, b2HexColor color, void* context );
void ( *DrawPolygon )( const b2Vec2* vertices, int vertexCount, b2HexColor color, void* context );

/// Draw a solid closed polygon provided in CCW order.
void ( *drawSolidPolygon )( b2Transform transform, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor color,
void ( *DrawSolidPolygon )( b2Transform transform, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor color,
void* context );

/// Draw a circle.
void ( *drawCircle )( b2Vec2 center, float radius, b2HexColor color, void* context );
void ( *DrawCircle )( b2Vec2 center, float radius, b2HexColor color, void* context );

/// Draw a solid circle.
void ( *drawSolidCircle )( b2Transform transform, float radius, b2HexColor color, void* context );
void ( *DrawSolidCircle )( b2Transform transform, float radius, b2HexColor color, void* context );

/// Draw a solid capsule.
void ( *drawSolidCapsule )( b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context );
void ( *DrawSolidCapsule )( b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context );

/// Draw a line segment.
void ( *drawSegment )( b2Vec2 p1, b2Vec2 p2, b2HexColor color, void* context );
void ( *DrawSegment )( b2Vec2 p1, b2Vec2 p2, b2HexColor color, void* context );

/// Draw a transform. Choose your own length scale.
void ( *drawTransform )( b2Transform transform, void* context );
void ( *DrawTransform )( b2Transform transform, void* context );

/// Draw a point.
void ( *drawPoint )( b2Vec2 p, float size, b2HexColor color, void* context );
void ( *DrawPoint )( b2Vec2 p, float size, b2HexColor color, void* context );

/// Draw a string in world space
void ( *drawString )( b2Vec2 p, const char* s, b2HexColor color, void* context );
void ( *DrawString )( b2Vec2 p, const char* s, b2HexColor color, void* context );

/// Bounds to use if restricting drawing to a rectangular region
b2AABB drawingBounds;
Expand Down
18 changes: 9 additions & 9 deletions samples/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,15 +1368,15 @@ void Draw::Create()

m_debugDraw = {};

m_debugDraw.drawPolygon = DrawPolygonFcn;
m_debugDraw.drawSolidPolygon = DrawSolidPolygonFcn;
m_debugDraw.drawCircle = DrawCircleFcn;
m_debugDraw.drawSolidCircle = DrawSolidCircleFcn;
m_debugDraw.drawSolidCapsule = DrawSolidCapsuleFcn;
m_debugDraw.drawSegment = DrawSegmentFcn;
m_debugDraw.drawTransform = DrawTransformFcn;
m_debugDraw.drawPoint = DrawPointFcn;
m_debugDraw.drawString = DrawStringFcn;
m_debugDraw.DrawPolygon = DrawPolygonFcn;
m_debugDraw.DrawSolidPolygon = DrawSolidPolygonFcn;
m_debugDraw.DrawCircle = DrawCircleFcn;
m_debugDraw.DrawSolidCircle = DrawSolidCircleFcn;
m_debugDraw.DrawSolidCapsule = DrawSolidCapsuleFcn;
m_debugDraw.DrawSegment = DrawSegmentFcn;
m_debugDraw.DrawTransform = DrawTransformFcn;
m_debugDraw.DrawPoint = DrawPointFcn;
m_debugDraw.DrawString = DrawStringFcn;
m_debugDraw.drawingBounds = bounds;

m_debugDraw.useDrawingBounds = false;
Expand Down
14 changes: 7 additions & 7 deletions src/distance_joint.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,28 +529,28 @@ void b2DrawDistanceJoint( b2DebugDraw* draw, b2JointSim* base, b2Transform trans
if ( joint->minLength > B2_LINEAR_SLOP )
{
// draw->DrawPoint(pMin, 4.0f, c2, draw->context);
draw->drawSegment( b2Sub( pMin, offset ), b2Add( pMin, offset ), b2_colorLightGreen, draw->context );
draw->DrawSegment( b2Sub( pMin, offset ), b2Add( pMin, offset ), b2_colorLightGreen, draw->context );
}

if ( joint->maxLength < B2_HUGE )
{
// draw->DrawPoint(pMax, 4.0f, c3, draw->context);
draw->drawSegment( b2Sub( pMax, offset ), b2Add( pMax, offset ), b2_colorRed, draw->context );
draw->DrawSegment( b2Sub( pMax, offset ), b2Add( pMax, offset ), b2_colorRed, draw->context );
}

if ( joint->minLength > B2_LINEAR_SLOP && joint->maxLength < B2_HUGE )
{
draw->drawSegment( pMin, pMax, b2_colorGray, draw->context );
draw->DrawSegment( pMin, pMax, b2_colorGray, draw->context );
}
}

draw->drawSegment( pA, pB, b2_colorWhite, draw->context );
draw->drawPoint( pA, 4.0f, b2_colorWhite, draw->context );
draw->drawPoint( pB, 4.0f, b2_colorWhite, draw->context );
draw->DrawSegment( pA, pB, b2_colorWhite, draw->context );
draw->DrawPoint( pA, 4.0f, b2_colorWhite, draw->context );
draw->DrawPoint( pB, 4.0f, b2_colorWhite, draw->context );

if ( joint->hertz > 0.0f && joint->enableSpring )
{
b2Vec2 pRest = b2MulAdd( pA, joint->length, axis );
draw->drawPoint( pRest, 4.0f, b2_colorBlue, draw->context );
draw->DrawPoint( pRest, 4.0f, b2_colorBlue, draw->context );
}
}
16 changes: 8 additions & 8 deletions src/joint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,17 +1218,17 @@ void b2DrawJoint( b2DebugDraw* draw, b2World* world, b2Joint* joint )
b2Vec2 target = jointSim->mouseJoint.targetA;

b2HexColor c1 = b2_colorGreen;
draw->drawPoint( target, 4.0f, c1, draw->context );
draw->drawPoint( pB, 4.0f, c1, draw->context );
draw->DrawPoint( target, 4.0f, c1, draw->context );
draw->DrawPoint( pB, 4.0f, c1, draw->context );

b2HexColor c2 = b2_colorLightGray;
draw->drawSegment( target, pB, c2, draw->context );
draw->DrawSegment( target, pB, c2, draw->context );
}
break;

case b2_nullJoint:
{
draw->drawSegment( pA, pB, b2_colorGold, draw->context );
draw->DrawSegment( pA, pB, b2_colorGold, draw->context );
}
break;

Expand All @@ -1245,9 +1245,9 @@ void b2DrawJoint( b2DebugDraw* draw, b2World* world, b2Joint* joint )
break;

default:
draw->drawSegment( transformA.p, pA, color, draw->context );
draw->drawSegment( pA, pB, color, draw->context );
draw->drawSegment( transformB.p, pB, color, draw->context );
draw->DrawSegment( transformA.p, pA, color, draw->context );
draw->DrawSegment( pA, pB, color, draw->context );
draw->DrawSegment( transformB.p, pB, color, draw->context );
}

if ( draw->drawGraphColors )
Expand All @@ -1260,7 +1260,7 @@ void b2DrawJoint( b2DebugDraw* draw, b2World* world, b2Joint* joint )
if ( colorIndex != B2_NULL_INDEX )
{
b2Vec2 p = b2Lerp( pA, pB, 0.5f );
draw->drawPoint( p, 5.0f, colors[colorIndex], draw->context );
draw->DrawPoint( p, 5.0f, colors[colorIndex], draw->context );
}
}
}
14 changes: 7 additions & 7 deletions src/prismatic_joint.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,22 +633,22 @@ void b2DrawPrismaticJoint( b2DebugDraw* draw, b2JointSim* base, b2Transform tran
b2HexColor c4 = b2_colorBlue;
b2HexColor c5 = b2_colorDimGray;

draw->drawSegment( pA, pB, c5, draw->context );
draw->DrawSegment( pA, pB, c5, draw->context );

if ( joint->enableLimit )
{
b2Vec2 lower = b2MulAdd( pA, joint->lowerTranslation, axis );
b2Vec2 upper = b2MulAdd( pA, joint->upperTranslation, axis );
b2Vec2 perp = b2LeftPerp( axis );
draw->drawSegment( lower, upper, c1, draw->context );
draw->drawSegment( b2MulSub( lower, 0.1f, perp ), b2MulAdd( lower, 0.1f, perp ), c2, draw->context );
draw->drawSegment( b2MulSub( upper, 0.1f, perp ), b2MulAdd( upper, 0.1f, perp ), c3, draw->context );
draw->DrawSegment( lower, upper, c1, draw->context );
draw->DrawSegment( b2MulSub( lower, 0.1f, perp ), b2MulAdd( lower, 0.1f, perp ), c2, draw->context );
draw->DrawSegment( b2MulSub( upper, 0.1f, perp ), b2MulAdd( upper, 0.1f, perp ), c3, draw->context );
}
else
{
draw->drawSegment( b2MulSub( pA, 1.0f, axis ), b2MulAdd( pA, 1.0f, axis ), c1, draw->context );
draw->DrawSegment( b2MulSub( pA, 1.0f, axis ), b2MulAdd( pA, 1.0f, axis ), c1, draw->context );
}

draw->drawPoint( pA, 5.0f, c1, draw->context );
draw->drawPoint( pB, 5.0f, c4, draw->context );
draw->DrawPoint( pA, 5.0f, c1, draw->context );
draw->DrawPoint( pB, 5.0f, c4, draw->context );
}
18 changes: 9 additions & 9 deletions src/revolute_joint.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,21 +500,21 @@ void b2DrawRevoluteJoint( b2DebugDraw* draw, b2JointSim* base, b2Transform trans
const float L = drawSize;
// draw->drawPoint(pA, 3.0f, b2_colorGray40, draw->context);
// draw->drawPoint(pB, 3.0f, b2_colorLightBlue, draw->context);
draw->drawCircle( pB, L, c1, draw->context );
draw->DrawCircle( pB, L, c1, draw->context );

float angle = b2RelativeAngle( transformB.q, transformA.q );

b2Rot rot = b2MakeRot( angle );
b2Vec2 r = { L * rot.c, L * rot.s };
b2Vec2 pC = b2Add( pB, r );
draw->drawSegment( pB, pC, c1, draw->context );
draw->DrawSegment( pB, pC, c1, draw->context );

if ( draw->drawJointExtras )
{
float jointAngle = b2UnwindAngle( angle - joint->referenceAngle );
char buffer[32];
snprintf( buffer, 32, " %.1f deg", 180.0f * jointAngle / B2_PI );
draw->drawString( pC, buffer, b2_colorWhite, draw->context );
draw->DrawString( pC, buffer, b2_colorWhite, draw->context );
}

float lowerAngle = joint->lowerAngle + joint->referenceAngle;
Expand All @@ -528,18 +528,18 @@ void b2DrawRevoluteJoint( b2DebugDraw* draw, b2JointSim* base, b2Transform trans
b2Rot rotHi = b2MakeRot( upperAngle );
b2Vec2 rhi = { L * rotHi.c, L * rotHi.s };

draw->drawSegment( pB, b2Add( pB, rlo ), c2, draw->context );
draw->drawSegment( pB, b2Add( pB, rhi ), c3, draw->context );
draw->DrawSegment( pB, b2Add( pB, rlo ), c2, draw->context );
draw->DrawSegment( pB, b2Add( pB, rhi ), c3, draw->context );

b2Rot rotRef = b2MakeRot( joint->referenceAngle );
b2Vec2 ref = ( b2Vec2 ){ L * rotRef.c, L * rotRef.s };
draw->drawSegment( pB, b2Add( pB, ref ), b2_colorBlue, draw->context );
draw->DrawSegment( pB, b2Add( pB, ref ), b2_colorBlue, draw->context );
}

b2HexColor color = b2_colorGold;
draw->drawSegment( transformA.p, pA, color, draw->context );
draw->drawSegment( pA, pB, color, draw->context );
draw->drawSegment( transformB.p, pB, color, draw->context );
draw->DrawSegment( transformA.p, pA, color, draw->context );
draw->DrawSegment( pA, pB, color, draw->context );
draw->DrawSegment( transformB.p, pB, color, draw->context );

// char buffer[32];
// sprintf(buffer, "%.1f", b2Length(joint->impulse));
Expand Down
18 changes: 9 additions & 9 deletions src/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ b2DebugDraw b2DefaultDebugDraw(void)
b2DebugDraw draw = { 0 };

// These allow the user to skip some implementations and not hit null exceptions.
draw.drawPolygon = b2EmptyDrawPolygon;
draw.drawSolidPolygon = b2EmptyDrawSolidPolygon;
draw.drawCircle = b2EmptyDrawCircle;
draw.drawSolidCircle = b2EmptyDrawSolidCircle;
draw.drawSolidCapsule = b2EmptyDrawSolidCapsule;
draw.drawSegment = b2EmptyDrawSegment;
draw.drawTransform = b2EmptyDrawTransform;
draw.drawPoint = b2EmptyDrawPoint;
draw.drawString = b2EmptyDrawString;
draw.DrawPolygon = b2EmptyDrawPolygon;
draw.DrawSolidPolygon = b2EmptyDrawSolidPolygon;
draw.DrawCircle = b2EmptyDrawCircle;
draw.DrawSolidCircle = b2EmptyDrawSolidCircle;
draw.DrawSolidCapsule = b2EmptyDrawSolidCapsule;
draw.DrawSegment = b2EmptyDrawSegment;
draw.DrawTransform = b2EmptyDrawTransform;
draw.DrawPoint = b2EmptyDrawPoint;
draw.DrawString = b2EmptyDrawString;
return draw;
}
14 changes: 7 additions & 7 deletions src/wheel_joint.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,22 +528,22 @@ void b2DrawWheelJoint( b2DebugDraw* draw, b2JointSim* base, b2Transform transfor
b2HexColor c4 = b2_colorDimGray;
b2HexColor c5 = b2_colorBlue;

draw->drawSegment( pA, pB, c5, draw->context );
draw->DrawSegment( pA, pB, c5, draw->context );

if ( joint->enableLimit )
{
b2Vec2 lower = b2MulAdd( pA, joint->lowerTranslation, axis );
b2Vec2 upper = b2MulAdd( pA, joint->upperTranslation, axis );
b2Vec2 perp = b2LeftPerp( axis );
draw->drawSegment( lower, upper, c1, draw->context );
draw->drawSegment( b2MulSub( lower, 0.1f, perp ), b2MulAdd( lower, 0.1f, perp ), c2, draw->context );
draw->drawSegment( b2MulSub( upper, 0.1f, perp ), b2MulAdd( upper, 0.1f, perp ), c3, draw->context );
draw->DrawSegment( lower, upper, c1, draw->context );
draw->DrawSegment( b2MulSub( lower, 0.1f, perp ), b2MulAdd( lower, 0.1f, perp ), c2, draw->context );
draw->DrawSegment( b2MulSub( upper, 0.1f, perp ), b2MulAdd( upper, 0.1f, perp ), c3, draw->context );
}
else
{
draw->drawSegment( b2MulSub( pA, 1.0f, axis ), b2MulAdd( pA, 1.0f, axis ), c1, draw->context );
draw->DrawSegment( b2MulSub( pA, 1.0f, axis ), b2MulAdd( pA, 1.0f, axis ), c1, draw->context );
}

draw->drawPoint( pA, 5.0f, c1, draw->context );
draw->drawPoint( pB, 5.0f, c4, draw->context );
draw->DrawPoint( pA, 5.0f, c1, draw->context );
draw->DrawPoint( pB, 5.0f, c4, draw->context );
}
Loading

0 comments on commit 7605ccf

Please sign in to comment.