private int RayCastFilter(Ray ray, IDrawable d, List <RayCastHit <IDrawable> > hits) { var bb = d.GetBounds(); //var dist = (ray.Origin - bb.GetCenter()).Length(); float dist; //if (ray.Intersects(bb) && dist < RCDist) if ((((d.DrawFilter & DrawFilter) > 0 && d.DrawGroups.IsInDisplayGroup(DisplayGroup) && d.IsVisible) || d.Highlighted) && ray.Intersects(bb) && d.RayCast(ray, out dist) && dist < RCDist) { RCDist = dist; hits.Clear(); hits.Add(new RayCastHit <IDrawable>(d, ray.Origin + ray.Direction * dist, dist)); return(1); } return(0); }