64-bit hashes (#126)
- ContactEvent sample - Improved shadows - #120 - Triangle collision fixes
This commit is contained in:
parent
3fc20f5b45
commit
f42be210a2
49 changed files with 19835 additions and 17544 deletions
|
|
@ -141,7 +141,7 @@ static bool b3ClipSegmentToTriangleFace( b3ClipVertex segment[2], const b3Vec3*
|
|||
}
|
||||
|
||||
// If the points are on different sides of the plane
|
||||
if ( distance1 * distance2 < 0.0f )
|
||||
if ( ( distance1 > 0.0f ) != ( distance2 > 0.0f ) )
|
||||
{
|
||||
// Find intersection point of edge and plane
|
||||
float t = distance1 / ( distance1 - distance2 );
|
||||
|
|
@ -199,6 +199,7 @@ static b3SeparatingAxis b3QueryTriangleAndCapsuleEdges( const b3Vec3* vertices,
|
|||
float squaredTolerance = 0.005f * 0.005f;
|
||||
|
||||
int edgeIndex = 2;
|
||||
float a = b3Dot( capsuleEdge, plane.normal );
|
||||
b3Vec3 v1 = vertices[2];
|
||||
for ( int index = 0; index < 3; ++index )
|
||||
{
|
||||
|
|
@ -209,12 +210,13 @@ static b3SeparatingAxis b3QueryTriangleAndCapsuleEdges( const b3Vec3* vertices,
|
|||
// Pretend the triangle edge embeds a zero area face with a side normal. This
|
||||
// provides a way to find an edge-edge normal that points outward from
|
||||
// the triangle.
|
||||
float a = b3Dot( capsuleEdge, plane.normal );
|
||||
float b = b3Dot( capsuleEdge, sideNormal );
|
||||
|
||||
// Is the capsule edge parallel to the triangle edge? If so, face contact can handle it.
|
||||
if ( a * a + b * b < squaredTolerance * b3LengthSquared( capsuleEdge ) )
|
||||
{
|
||||
v1 = v2;
|
||||
edgeIndex = index;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -346,9 +348,8 @@ static void b3BuildTriangleAndCapsuleEdgeContact( b3LocalManifold* manifold, con
|
|||
return;
|
||||
}
|
||||
|
||||
b3Vec3 point = b3Lerp( b3MulSub( result.point1, capsule->radius, normal ), result.point2, 0.5f );
|
||||
b3Vec3 point = b3Lerp( result.point1, b3MulSub( result.point2, capsule->radius, normal ), 0.5f );
|
||||
float separation = b3Dot( normal, b3Sub( p1, v1 ) );
|
||||
B3_VALIDATE( b3AbsFloat( separation - query.separation ) < B3_LINEAR_SLOP );
|
||||
|
||||
manifold->normal = normal;
|
||||
manifold->pointCount = 1;
|
||||
|
|
@ -448,7 +449,7 @@ void b3CollideTriangleAndCapsule( b3LocalManifold* manifold, int capacity, const
|
|||
}
|
||||
|
||||
// Create contact from closest points.
|
||||
b3Vec3 point = b3MulSV( 0.5f, b3Add( b3Sub( distanceOutput.pointA, b3MulSV( radius, delta ) ), distanceOutput.pointB ) );
|
||||
b3Vec3 point = b3Lerp( distanceOutput.pointA, b3MulSub( distanceOutput.pointB, radius, delta ), 0.5f );
|
||||
|
||||
// Normal points from triangle to capsule.
|
||||
manifold->normal = delta;
|
||||
|
|
@ -489,6 +490,12 @@ void b3CollideTriangleAndCapsule( b3LocalManifold* manifold, int capacity, const
|
|||
faceSeparation = b3MinFloat( manifold->points[0].separation, manifold->points[1].separation );
|
||||
}
|
||||
|
||||
if ( edgeQuery.indexA == B3_NULL_INDEX )
|
||||
{
|
||||
// No valid edge contact.
|
||||
return;
|
||||
}
|
||||
|
||||
// Face contact can be empty if it does not realize the axis of minimum penetration.
|
||||
// Create edge contact if face contact fails or edge contact is significantly better!
|
||||
float linearSlop = B3_LINEAR_SLOP;
|
||||
|
|
@ -926,10 +933,7 @@ static void b3CollideTriangleAndHullEdges( b3LocalManifold* manifold, int capaci
|
|||
return;
|
||||
}
|
||||
|
||||
// This can slide off the end from caching
|
||||
float separation = b3Dot( query.normal, b3Sub( pB, pA ) );
|
||||
B3_VALIDATE( b3AbsFloat( separation - query.separation ) < B3_LINEAR_SLOP );
|
||||
|
||||
b3Vec3 point = b3MulSV( 0.5f, b3Add( result.point1, result.point2 ) );
|
||||
|
||||
b3LocalManifoldPoint* pt = manifold->points + 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue