improve segment vs segment collision, small fixes

This commit is contained in:
Irlan
2017-02-17 13:52:24 -02:00
parent a346a1472d
commit 012460f6b0
16 changed files with 175 additions and 150 deletions

View File

@ -106,7 +106,7 @@ public:
void Draw(const b3World& world);
void Draw();
void Submit();
private:
friend struct DrawShapes;

View File

@ -204,18 +204,12 @@ public:
void CastRay(const b3Vec3 p1, const b3Vec3 p2) const
{
// Perform the ray cast
RayCastListener listener;
listener.hit.shape = NULL;
m_world.RayCastFirst(&listener, p1, p2);
RayCastHit hit = listener.hit;
if (hit.shape)
b3RayCastSingleOutput out;
if (m_world.RayCastSingle(&out, p1, p2))
{
// Replace current hit
g_debugDraw->DrawSegment(p1, hit.point, b3Color(0.0f, 1.0f, 0.0f));
g_debugDraw->DrawPoint(hit.point, 4.0f, b3Color(1.0f, 0.0f, 0.0f));
g_debugDraw->DrawSegment(hit.point, hit.point + hit.normal, b3Color(1.0f, 1.0f, 1.0f));
g_debugDraw->DrawSegment(p1, out.point, b3Color(0.0f, 1.0f, 0.0f));
g_debugDraw->DrawPoint(out.point, 4.0f, b3Color(1.0f, 0.0f, 0.0f));
g_debugDraw->DrawSegment(out.point, out.point + out.normal, b3Color(1.0f, 1.0f, 1.0f));
}
else
{

View File

@ -88,14 +88,6 @@ struct TestEntry
extern TestEntry g_tests[];
struct RayCastHit
{
b3Shape* shape;
b3Vec3 point;
b3Vec3 normal;
float32 fraction;
};
class RayCastListener : public b3RayCastListener
{
public:
@ -108,7 +100,7 @@ public:
return 1.0f;
}
RayCastHit hit;
b3RayCastSingleOutput hit;
};
class Test : public b3ContactListener
@ -142,7 +134,7 @@ public:
b3Profile m_profile;
b3Profile m_maxProfile;
RayCastHit m_rayHit;
b3RayCastSingleOutput m_rayHit;
b3BoxHull m_groundHull;
b3BoxHull m_boxHull;
b3BoxHull m_tallHull;