update a test

This commit is contained in:
Irlan 2018-10-06 20:48:16 -03:00
parent 69e2cd4c56
commit f598c72fae

View File

@ -83,7 +83,12 @@ private:
{
Plane plane = planes[i];
if (b3Dot(b3Vec3_y, plane.n) > 0.0f)
float32 cosine = b3Dot(b3Vec3_y, plane.n);
// ~80 degrees
const float32 kTol = 0.17f;
if (cosine > kTol)
{
m_isGrounded = true;
break;
@ -107,11 +112,6 @@ private:
for (b3Shape* s = b->GetShapeList().m_head; s; s = s->GetNext())
{
if (s->GetType() == e_meshShape)
{
continue;
}
shapes.PushBack(s);
}
}
@ -128,14 +128,18 @@ private:
b3Body* body1 = shape1->GetBody();
b3Transform xf1 = body1->GetTransform();
b3TestSphereOutput output;
bool overlap = shape1->TestSphere(&output, sphere2, xf1);
if (overlap == false)
if (shape1->GetType() == e_meshShape)
{
continue;
}
b3MeshShape* meshShape1 = (b3MeshShape*)shape1;
const b3Mesh* mesh1 = meshShape1->m_mesh;
for (u32 j = 0; j < mesh1->triangleCount; ++j)
{
b3TestSphereOutput output;
bool overlap = meshShape1->TestSphere(&output, sphere2, xf1, j);
if (overlap)
{
Plane plane;
plane.n = output.normal;
plane.p = output.point;
@ -143,6 +147,23 @@ private:
planes.PushBack(plane);
}
}
}
else
{
b3TestSphereOutput output;
bool overlap = shape1->TestSphere(&output, sphere2, xf1);
if (overlap)
{
Plane plane;
plane.n = output.normal;
plane.p = output.point;
planes.PushBack(plane);
}
}
}
}
void CollectSweepPlanes(b3Array<Plane>& planes,
const b3Array<b3Shape*>& shapes,
@ -165,17 +186,39 @@ private:
b3Transform xf1 = body1->GetTransform();
if (shape1->GetType() == e_meshShape)
{
b3MeshShape* meshShape1 = (b3MeshShape*)shape1;
const b3Mesh* mesh1 = meshShape1->m_mesh;
for (u32 j = 0; j < mesh1->triangleCount; ++j)
{
b3ShapeGJKProxy proxy1;
proxy1.Set(shape1, j);
b3GJKShapeCastOutput output;
bool hit = b3GJKShapeCast(&output, xf1, proxy1, xf2, proxy2, translation2);
if (hit)
{
Plane plane;
plane.n = output.normal;
plane.p = output.point;
planes.PushBack(plane);
}
}
}
else
{
b3ShapeGJKProxy proxy1;
proxy1.Set(shape1, 0);
b3GJKShapeCastOutput output;
bool hit = b3GJKShapeCast(&output, xf1, proxy1, xf2, proxy2, translation2);
if (hit == false)
if (hit)
{
continue;
}
Plane plane;
plane.n = output.normal;
plane.p = output.point;
@ -183,6 +226,8 @@ private:
planes.PushBack(plane);
}
}
}
}
b3Vec3 SolvePositionConstraints(const b3Array<Plane>& planes, const b3Vec3& position) const
{