Draw capsule in world space
This commit is contained in:
parent
53e1f3a0be
commit
b277b8b588
@ -341,14 +341,14 @@ void Draw::DrawCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const b3Transform& transform, const b3Color& c)
|
void Draw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const b3Mat33& rotation, const b3Color& c)
|
||||||
{
|
{
|
||||||
float32 height = b3Length(c1 - c2);
|
float32 height = b3Length(c1 - c2);
|
||||||
|
|
||||||
{
|
{
|
||||||
b3Transform xf;
|
b3Transform xf;
|
||||||
xf.rotation = transform.rotation;
|
xf.rotation = rotation;
|
||||||
xf.position = transform * c1;
|
xf.position = c1;
|
||||||
m_solid->DrawSphere(radius, c, xf);
|
m_solid->DrawSphere(radius, c, xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,20 +357,19 @@ void Draw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius,
|
|||||||
{
|
{
|
||||||
b3Mat33 R;
|
b3Mat33 R;
|
||||||
R.y = (1.0f / height) * (c1 - c2);
|
R.y = (1.0f / height) * (c1 - c2);
|
||||||
R.z = b3Perp(R.y);
|
b3ComputeBasis(R.y, R.z, R.x);
|
||||||
R.x = b3Cross(R.y, R.z);
|
|
||||||
|
|
||||||
b3Transform xf;
|
b3Transform xf;
|
||||||
xf.position = transform * (0.5f * (c1 + c2));
|
xf.position = (0.5f * (c1 + c2));
|
||||||
xf.rotation = transform.rotation * R;
|
xf.rotation = R;
|
||||||
|
|
||||||
m_solid->DrawCylinder(radius, height, c, xf);
|
m_solid->DrawCylinder(radius, height, c, xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
b3Transform xf;
|
b3Transform xf;
|
||||||
xf.rotation = transform.rotation;
|
xf.rotation = rotation;
|
||||||
xf.position = transform * c2;
|
xf.position = c2;
|
||||||
m_solid->DrawSphere(radius, c, xf);
|
m_solid->DrawSphere(radius, c, xf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 b3Transform& transform, const b3Color& color);
|
void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Mat33& rotation, 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);
|
||||||
|
|
||||||
|
@ -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 local segment, radius, and transform.
|
// Draw a solid capsule with local segment, radius, and rotation.
|
||||||
virtual void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Transform& transform, const b3Color& color) = 0;
|
virtual void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Mat33& rotation, 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;
|
||||||
|
@ -250,7 +250,10 @@ void b3World::DrawSolidShape(const b3Transform& xf, const b3Shape* shape, const
|
|||||||
{
|
{
|
||||||
const b3CapsuleShape* capsule = (b3CapsuleShape*)shape;
|
const b3CapsuleShape* capsule = (b3CapsuleShape*)shape;
|
||||||
|
|
||||||
b3Draw_draw->DrawSolidCapsule(capsule->m_centers[0], capsule->m_centers[1], capsule->m_radius, xf, color);
|
b3Vec3 c1 = xf * capsule->m_centers[0];
|
||||||
|
b3Vec3 c2 = xf * capsule->m_centers[1];
|
||||||
|
|
||||||
|
b3Draw_draw->DrawSolidCapsule(c1, c2, capsule->m_radius, xf.rotation, color);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user