Flatten raytrace cycle.

Use  only one for cycle for raytracing to achieve better workload
balance between threads.