Box2DX.Dynamics.World.Raycast C# (CSharp) Method

Raycast() public method

Query the world for all shapes that intersect a given segment. You provide a shap pointer buffer of specified size. The number of shapes found is returned, and the buffer is filled in order of intersection.
public Raycast ( Segment segment, Shape shapes, int maxCount, bool solidShapes, object userData ) : int
segment Segment Defines the begin and end point of the ray cast, from p1 to p2. /// Use Segment.Extend to create (semi-)infinite rays.
shapes Shape A user allocated shape pointer array of size maxCount (or greater).
maxCount int The capacity of the shapes array.
solidShapes bool Determines if shapes that the ray starts in are counted as hits.
userData object Passed through the worlds contact filter, with method RayCollide. This can be used to filter valid shapes.
return int
        public int Raycast(Segment segment, Shape[] shapes, int maxCount, bool solidShapes, object userData)
        {
            #warning "PTR"
            _raycastSegment = segment;
            _raycastUserData = userData;
            _raycastSolidShape = solidShapes;

            object[] results = new object[maxCount];
            int count = _broadPhase.QuerySegment(segment, results, maxCount, RaycastSortKey);
            for (int i = 0; i < count; ++i)
            {
                shapes[i] = (Shape)results[i];
            }
            results = null;
            return count;
        }