Buildings.IntersectsRoad C# (CSharp) Method

IntersectsRoad() private method

check if a given building intersecs a road
private IntersectsRoad ( Building, building ) : bool
building Building,
return bool
    private bool IntersectsRoad(Building building)
    {
        //can be made more efficient, currently evaluates all roads, check distance if needed
        foreach (RoadSegment segment in this.control.RoadSegments) {
            Ray ray = new Ray(segment.GetVector3(true),segment.GetVector3(false) - segment.GetVector3(true));
            RaycastHit hit = new RaycastHit();
            float distance = Vector2.Distance(segment.PointA.point,segment.PointB.point);
            building.MyCollider.Raycast(ray,out hit,distance);

            if(building.MyCollider.Raycast(ray,out hit,distance))
                return true;
        }

        return false;
    }