static bool draw_traced_ray_recurs(Renderer renderer, TracedRay ray, double lost_len, Element ref_, bool hit_image, int D, bool draw_lost) { Transform3 t1 = ray.get_creator().get_transform_to(ref_); Element i_element = null; Vector3 v0 = t1.transform(ray.get_ray().origin()); Vector3 v1; if (ray.is_lost()) { if (!draw_lost) { return(false); } v1 = t1.transform(ray.get_ray().origin().plus(ray.get_ray().direction().times(lost_len))); } else { i_element = ray.get_intercept_element(); Transform3 t2 = i_element.get_transform_to(ref_); v1 = t2.transform(ray.get_intercept_point()); } Vector3Pair p = new Vector3Pair(v0, v1); bool done = false; for (TracedRay child_ray = ray.get_first_child(); child_ray != null; child_ray = child_ray.get_next_child()) { if (draw_traced_ray_recurs(renderer, child_ray, lost_len, ref_, hit_image, 2, false)) { done = true; } } if (!done && hit_image && !(i_element is Image)) { return(false); } switch (D) { case 2: // skip non tangential rays in 2d mode if (Math.Abs(p.x1()) > 1e-6) { return(false); } draw_ray_line(renderer, new Vector2Pair(p.v0.project_zy(), p.v1.project_zy()), ray); break; case 3: draw_ray_line(renderer, p, ray); break; } return(true); }