modified tri-vs-sphere fix from O'dell Hicks: ---------------------------------------------------
modified tri-vs-sphere fix from O'dell Hicks:
---------------------------------------------------

The problem is with double-sided trimeshes.  Contacts produced may cause the
sphere to get stuck or pushed through to the other side.  I haven't tested
it, but I guess the problem would also arise at certain velocities/updates
for close triangles with opposite winding orders that aren't necessarily
coplanar (eg, adjacent buildings with little space between them).

I was about to start looking at Tokamak due to this problem (this
funcitonality is important in my current project), but the fix turned out to
be easier than switching physics engines : )

This is probably pointless, as it sounds like Croteam's collider may be used
in the near future, but here it is for anyone interested:

In collision_trimesh_sphere.cpp, at the beginning of the function
GetContactData, add this code:

//calculate plane of triangle

 dVector4 Plane;
 dCROSS(Plane, =, Edge0, Edge1);
 Plane[3] = dDOT(Plane, Origin);

 //normalize
 float magnitude = 1.0f / dSqrt(dDOT(Plane, Plane));
 Plane[0] *= magnitude;
 Plane[1] *= magnitude;
 Plane[2] *= magnitude;
 Plane[3] *= magnitude;

/*If the center of the sphere is within the positive halfspace of the
triangle's plane, allow a contact to be generated.
If the center of the sphere made it into the positive halfspace of a
back-facing triangle, then the physics update and/or velocity needs
 to be adjusted (penetration has occured anyway).
*/

 float side = dDOT(Plane,Center) - Plane[3];

 if(side < 0.0f)
  return false;


git-svn-id: 051f6adb867ae8800663f9d761b7f383ac0911ea@612 685f7672-210f-0410-90b4-fe3ad19314fe

vancegroup-mirrors/open-dynamics-engine-svnmirror,vancegroup-mirrors/open-dynamics-engine-svnmirror,vancegroup-mirrors/open-dynamics-engine-svnmirror,vancegroup-mirrors/open-dynamics-engine-svnmirror,vancegroup-mirrors/open-dynamics-engine-svnmirror