public override bool Raycast(JVector rayOrigin, JVector rayDirection, RaycastCallback raycast, out RigidBody body, out JVector normal, out float fraction)
{
body = null; normal = JVector.Zero; fraction = float.MaxValue;
JVector tempNormal;float tempFraction;
bool result = false;
// TODO: This can be done better in CollisionSystemPersistenSAP
foreach (IBroadphaseEntity e in bodyList)
{
if (e is SoftBody)
{
SoftBody softBody = e as SoftBody;
foreach (RigidBody b in softBody.points)
{
if (this.Raycast(b, rayOrigin, rayDirection, out tempNormal, out tempFraction))
{
if (tempFraction < fraction && (raycast == null || raycast(b, tempNormal, tempFraction)))
{
body = b;
normal = tempNormal;
fraction = tempFraction;
result = true;
}
}
}
}
else
{
RigidBody b = e as RigidBody;
if (this.Raycast(b, rayOrigin, rayDirection, out tempNormal, out tempFraction))
{
if (tempFraction < fraction && (raycast == null || raycast(b, tempNormal, tempFraction)))
{
body = b;
normal = tempNormal;
fraction = tempFraction;
result = true;
}
}
}
}
return result;
}
#endregion