Jitter.Collision.CollisionSystemPersistentSAP.Raycast C# (CSharp) Method

Raycast() public method

Sends a ray (definied by start and direction) through the scene (all bodies added). NOTE: For performance reasons terrain and trianglemeshshape aren't checked against rays (rays are of infinite length). They are checked against segments which start at rayOrigin and end in rayOrigin + rayDirection.
public Raycast ( Jitter.LinearMath.JVector rayOrigin, Jitter.LinearMath.JVector rayDirection, RaycastCallback raycast, RigidBody &body, Jitter.LinearMath.JVector &normal, float &fraction ) : bool
rayOrigin Jitter.LinearMath.JVector
rayDirection Jitter.LinearMath.JVector
raycast RaycastCallback
body RigidBody
normal Jitter.LinearMath.JVector
fraction float
return bool
        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

Same methods

CollisionSystemPersistentSAP::Raycast ( RigidBody body, Jitter.LinearMath.JVector rayOrigin, Jitter.LinearMath.JVector rayDirection, Jitter.LinearMath.JVector &normal, float &fraction ) : bool