(bind-func psystem-particle-check
(lambda (psys:psystem* idx)
(let ((states (psystem_states psys))
(size (psystem_size psys)))
(if (> idx (- size 1)) -1
(if (< (pref states idx) 1)
idx
(psystem-particle-check psys (+ idx 1)))))))