Merge remote-tracking branch 'origin/CollisionResponse' into Physics

This commit is contained in:
Dander7BD 2014-01-16 11:36:18 +01:00
commit 2e32ac02fa
1 changed files with 17 additions and 14 deletions

View File

@ -204,7 +204,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
return true; return true;
} }
bool SeperatingAxisTest_AxisAlignedVsTransformedBox( const Float4 &boundingOffsetA, const Float4 &boundingOffsetB, const Float4x4 &rotationB, const Float4 &worldOffset, Float4 &worldPointOfContact ) bool SeperatingAxisTest_AxisAlignedVsTransformedBox( const Float4 &boundingOffsetA, const Float4 &boundingOffsetB, const Float4x4 &rotationB, const Float4 &worldOffset, Float4 &localPointOfContact )
{ // by Dan Andersson { // by Dan Andersson
/***************************************************************** /*****************************************************************
@ -241,7 +241,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
{ // no intersection { // no intersection
return false; return false;
} }
worldPointOfContact = s * ( centerSeperation * eA / edgeSeperation ); localPointOfContact = s * ( centerSeperation * eA / edgeSeperation );
s = Float4::standard_unit_y; s = Float4::standard_unit_y;
centerSeperation = t.Dot(s); centerSeperation = t.Dot(s);
@ -251,7 +251,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
{ // no intersection { // no intersection
return false; return false;
} }
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
s = Float4::standard_unit_z; s = Float4::standard_unit_z;
centerSeperation = t.Dot(s); centerSeperation = t.Dot(s);
@ -261,7 +261,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
{ // no intersection { // no intersection
return false; return false;
} }
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
s = rotationB.v[0]; s = rotationB.v[0];
centerSeperation = t.Dot(s); centerSeperation = t.Dot(s);
@ -271,7 +271,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
{ // no intersection { // no intersection
return false; return false;
} }
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
s = rotationB.v[1]; s = rotationB.v[1];
centerSeperation = t.Dot(s); centerSeperation = t.Dot(s);
@ -281,7 +281,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
{ // no intersection { // no intersection
return false; return false;
} }
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
s = rotationB.v[2]; s = rotationB.v[2];
centerSeperation = t.Dot(s); centerSeperation = t.Dot(s);
@ -291,7 +291,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
{ // no intersection { // no intersection
return false; return false;
} }
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); // enough point of contact data gathered for approximative result. localPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); // enough point of contact data gathered for approximative result.
s = Float4( Float3::standard_unit_x.Cross(rotationB.v[0].xyz), 0.0f ); s = Float4( Float3::standard_unit_x.Cross(rotationB.v[0].xyz), 0.0f );
centerSeperation = t.Dot(s); centerSeperation = t.Dot(s);
@ -374,7 +374,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
return false; return false;
} }
worldPointOfContact *= 0.5f; localPointOfContact *= 0.5f;
return true; return true;
} }
} }
@ -821,10 +821,11 @@ namespace Oyster { namespace Collision3D { namespace Utility
Float4 alignedOffsetBoundaries = (boxB.maxVertex - boxB.minVertex) * 0.5f, Float4 alignedOffsetBoundaries = (boxB.maxVertex - boxB.minVertex) * 0.5f,
offset = boxA.center - Average( boxB.maxVertex, boxB.minVertex ); offset = boxA.center - Average( boxB.maxVertex, boxB.minVertex );
Float4 pointOfContact; Float4 localPointOfContact;
if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( alignedOffsetBoundaries, boxA.boundingOffset, boxA.rotation, offset, pointOfContact ) ) if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( alignedOffsetBoundaries, boxA.boundingOffset, boxA.rotation, offset, localPointOfContact ) )
{ {
worldPointOfContact = pointOfContact.xyz; worldPointOfContact = localPointOfContact + boxA.center;
worldPointOfContact.w = 1.0f;
return true; return true;
} }
else return false; else return false;
@ -843,10 +844,12 @@ namespace Oyster { namespace Collision3D { namespace Utility
Float4x4 rotationB = TransformMatrix( InverseRotationMatrix(boxA.rotation), boxB.rotation ); Float4x4 rotationB = TransformMatrix( InverseRotationMatrix(boxA.rotation), boxB.rotation );
Float4 posB = boxB.center - boxA.center; Float4 posB = boxB.center - boxA.center;
Float4 pointOfContact; Float4 localPointOfContact;
if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( boxA.boundingOffset, boxB.boundingOffset, rotationB, posB, pointOfContact ) ) if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( boxA.boundingOffset, boxB.boundingOffset, rotationB, posB, localPointOfContact ) )
{ {
worldPointOfContact = TransformVector( boxA.rotation, pointOfContact, pointOfContact ).xyz; worldPointOfContact = TransformVector( boxA.rotation, localPointOfContact, localPointOfContact );
worldPointOfContact += boxA.center;
worldPointOfContact.w = 1.0f;
return true; return true;
} }
else return false; else return false;