Pushed code to draw a plane

This commit is contained in:
Irlan
2019-06-04 19:38:43 -03:00
parent 552970cfe7
commit 43085c8cc1
4 changed files with 69 additions and 43 deletions

View File

@ -107,6 +107,12 @@ public :
// Draw a solid capsule with segment and radius.
virtual void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color) = 0;
// Draw a plane with center, normal and radius.
virtual void DrawPlane(const b3Vec3& center, const b3Vec3& normal, float32 radius, const b3Color& color) = 0;
// Draw a solid plane with center, normal and radius.
virtual void DrawSolidPlane(const b3Vec3& center, const b3Vec3& normal, float32 radius, const b3Color& color) = 0;
// Draw a AABB.
virtual void DrawAABB(const b3AABB3& aabb, const b3Color& color) = 0;

View File

@ -233,22 +233,20 @@ inline b3Mat33 b3Outer(const b3Vec3& a, const b3Vec3& b)
// Compute an orthogonal basis given one of its vectors.
// The vector must be normalized.
inline b3Mat33 b3Basis(const b3Vec3& a)
inline void b3ComputeBasis(const b3Vec3& a, b3Vec3& b, b3Vec3& c)
{
// Box2D
b3Mat33 A;
// https://box2d.org/2014/02/computing-a-basis/
if (b3Abs(a.x) >= float32(0.57735027))
{
A.y.Set(a.y, -a.x, 0.0f);
b.Set(a.y, -a.x, 0.0f);
}
else
{
A.y.Set(0.0f, a.z, -a.y);
b.Set(0.0f, a.z, -a.y);
}
A.x = a;
A.y = b3Normalize(A.y);
A.z = b3Cross(a, A.y);
return A;
b.Normalize();
c = b3Cross(a, b);
}
// Rotation about the x-axis.