 : ray-g ( hit -- g ) normal>> light v. ; inline
 
 : cast-ray ( ray scene -- g )
-    2dup initial-intersect dup lambda>> 1.0/0.0 = [
+    2dup initial-intersect dup lambda>> 1/0. = [
         3drop 0.0
     ] [
-        [ sray-intersect lambda>> 1.0/0.0 = ] keep swap
+        [ sray-intersect lambda>> 1/0. = ] keep swap
         [ ray-g neg ] [ drop 0.0 ] if
     ] if ; inline
 


USING: arrays accessors float-arrays io io.files
io.encodings.binary kernel math math.functions math.vectors
math.parser make sequences sequences.private words ;
IN: benchmark.raytracer

! parameters

    swap [ { } make ] dip <group> ; inline

M: group intersect-scene ( hit ray group -- hit )
    [ drop objs>> [ intersect-scene ] with each ] if-ray-sphere ;

: initial-hit T{ hit f F{ 0.0 0.0 0.0 } 1/0. } ; inline

: initial-intersect ( ray scene -- hit )
    [ initial-hit ] 2dip intersect-scene ; inline

: ray-o ( ray hit -- o )
    [ [ orig>> ] [ normal>> delta v*n ] bi* ]
    [ [ dir>> ] [ lambda>> ] bi* v*n ]
    2bi v+ v+ ; inline

: sray-intersect ( ray scene hit -- ray )
    swap [ ray-o light vneg <ray> ] dip initial-intersect ; inline
