Hi James,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>sph-list is a list, and you are using for/fold to iterate over the elements in the list (inside a future). This is problematic for a number of reasons; </div>
</div></blockquote><div><br>could you pls elaborate on that? why there would be any performance implications on iterating over immutable list inside the future?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>instead, you could convert it to a vector (or just change your definition to use a vector) and change `ray-cast&#39; accordingly:</div>
<div><br></div><div><div>(define (ray-cast x y object-list)</div><div>  (let ([view-ray (screen-ray x y)])</div><div>    (define closest-int (int-res #f 10000.0 null-point))</div><div>    (for ([i (in-range 0 (vector-length object-list))])</div>

<div>      (define obj (vector-ref object-list i))</div><div>      (set! closest-int (get-closer-res closest-int</div><div>                                        (hit-sphere3D view-ray obj))))</div><div>    closest-int))</div>
</div></div></blockquote><div><br>i&#39;ve changed list of objects -&gt; vector of objects and used your implementation.<br>and with (time (run-no-render)) <br>i get these results:<br><br>cpu time: 3595 real time: 3591 gc time: 52<br>
<br>but, on keeping list implementation and adding in-list to for i get these:<br><br>cpu time: 3186 real time: 3184 gc time: 26<br><br>the change:<br>+   ([obj (in-list object-list)])<br>-    ([obj object-list])<br><br></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>
<div><br></div><div>Also, there are two places where I think you may have forgotten to use flonum primitives (on lines 99 and 100) -- just change `sqrt&#39; to `flsqrt&#39;, as you have done elsewhere in the code.  </div>

<div><br></div></div></div></blockquote><div><br>right! thanks.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div></div><br></div>
</div></blockquote></div>-- <br>With best regards,<br>Dmitry<br>