This commit is contained in:
Irlan 2019-06-04 21:35:11 -03:00
parent 56db3517f9
commit 53e1f3a0be
4 changed files with 17 additions and 20 deletions

View File

@ -341,15 +341,15 @@ void Draw::DrawCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const
} }
} }
void Draw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const b3Color& c) void Draw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const b3Transform& transform, const b3Color& c)
{ {
float32 height = b3Length(c1 - c2); float32 height = b3Length(c1 - c2);
{ {
b3Transform xfc; b3Transform xf;
xfc.rotation.SetIdentity(); xf.rotation = transform.rotation;
xfc.position = c1; xf.position = transform * c1;
m_solid->DrawSphere(radius, c, xfc); m_solid->DrawSphere(radius, c, xf);
} }
if (height > 0.0f) if (height > 0.0f)
@ -360,18 +360,18 @@ void Draw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius,
R.z = b3Perp(R.y); R.z = b3Perp(R.y);
R.x = b3Cross(R.y, R.z); R.x = b3Cross(R.y, R.z);
b3Transform xfc; b3Transform xf;
xfc.position = 0.5f * (c1 + c2); xf.position = transform * (0.5f * (c1 + c2));
xfc.rotation = R; xf.rotation = transform.rotation * R;
m_solid->DrawCylinder(radius, height, c, xfc); m_solid->DrawCylinder(radius, height, c, xf);
} }
{ {
b3Transform xfc; b3Transform xf;
xfc.rotation.SetIdentity(); xf.rotation = transform.rotation;
xfc.position = c2; xf.position = transform * c2;
m_solid->DrawSphere(radius, c, xfc); m_solid->DrawSphere(radius, c, xf);
} }
} }
} }

View File

@ -89,7 +89,7 @@ public:
void DrawCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color); void DrawCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color);
void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color); void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Transform& transform, const b3Color& color);
void DrawPlane(const b3Vec3& normal, const b3Vec3& center, float32 radius, const b3Color& color); void DrawPlane(const b3Vec3& normal, const b3Vec3& center, float32 radius, const b3Color& color);

View File

@ -110,8 +110,8 @@ public :
// Draw a capsule with segment, and radius. // Draw a capsule with segment, and radius.
virtual void DrawCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color) = 0; virtual void DrawCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color) = 0;
// Draw a solid capsule with segment, and radius. // Draw a solid capsule with local segment, radius, and transform.
virtual void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color) = 0; virtual void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Transform& transform, const b3Color& color) = 0;
// Draw a AABB. // Draw a AABB.
virtual void DrawAABB(const b3AABB3& aabb, const b3Color& color) = 0; virtual void DrawAABB(const b3AABB3& aabb, const b3Color& color) = 0;

View File

@ -250,10 +250,7 @@ void b3World::DrawSolidShape(const b3Transform& xf, const b3Shape* shape, const
{ {
const b3CapsuleShape* capsule = (b3CapsuleShape*)shape; const b3CapsuleShape* capsule = (b3CapsuleShape*)shape;
b3Vec3 c1 = xf * capsule->m_centers[0]; b3Draw_draw->DrawSolidCapsule(capsule->m_centers[0], capsule->m_centers[1], capsule->m_radius, xf, color);
b3Vec3 c2 = xf * capsule->m_centers[1];
b3Draw_draw->DrawSolidCapsule(c1, c2, capsule->m_radius, color);
break; break;
} }