(bind-func set-data-particles
(lambda (cube:fluidcube* psys:psystem* cnt:i64 xoffset:float yoffset:float)
(let ((densities (tref cube 5))
(ii:i64 0)
(jj:i64 0)
(kk:i64 0)
(Vx (tref cube 6))
(Vy (tref cube 7))
(size (tref cube 0))
(size-y (tref cube 10))
(cvar:float 0.0)
(maxcvar:float 0.0)
(mincvar:float 0.0)
(xs (psystem_xs psys))
(ys (psystem_ys psys))
(sizes (psystem_sizes psys))
(states (psystem_states psys))
(reds (psystem_reds psys))
(greens (psystem_greens psys))
(blues (psystem_blues psys))
(alphas (psystem_alphas psys))
(red (* 10.0 (dtof 0.1)))
(blue (* 10.0 (dtof 0.01)))
(green (* 10.0 (dtof 0.1))))
(dotimes (kk (- 50000 cnt))
(pset! states (+ cnt kk) 0))
(dotimes (ii (- size 2))
(dotimes (jj (- size-y 2))
(let ((idx (+ (+ ii 1)
(* (+ jj 1) size))))
(if (and (< cnt 50000)
(> (pref densities idx) 1.0))
(begin (pset! xs cnt (+ xoffset (i64tof ii)))
(if (< ii 320)
(add-velocity-1 ii jj
(* 0.05 (- (random) .5))
(* 0.05 (- (random) .5)))
(add-velocity-2 ii jj
(* 0.05 (- (random) .5))
(* 0.05 (- (random) .5))))
(pset! ys cnt (+ yoffset (i64tof jj)))
(set! cvar (dtof (* 0.001 (pref densities idx))))
;; ;; (set! cvar (dtof (pow (* 0.9 (pref densities idx)) 4.0)))
;; (set! cvar (/ (dtof (* 0.5 (pref densities idx))) 50.0))
(if (< cvar mincvar) (set! mincvar cvar))
(if (> cvar maxcvar) (set! maxcvar cvar))
(pset! reds cnt red); (* cvar red))
(pset! greens cnt green) ;(* cvar green))
(pset! blues cnt blue) ;(* cvar blue)) ;(* cvar (- 1.0 blue)))
(pset! alphas cnt (* 1.0 cvar))
(pset! sizes cnt (* .1 (- 1.0 cvar))) ;(+ .02 (* .1 (- 1.0 cvar)))) ;(+ 15.0 (* (- 1.0 cvar) 15.0)))
(pset! states cnt 1)
(set! cnt (+ cnt 1))
1)
1))))
(printf "min:%f max:%f cnt:%lld\n" (ftod mincvar) (ftod maxcvar) cnt)
)
cnt))