param tweaks

This commit is contained in:
2017-05-11 22:47:25 -07:00
parent 9bf54861a9
commit df87ba02d5

View File

@ -46,8 +46,9 @@
;;; trace ;;; trace
;;; ;;;
(def start-radius 2) (def start-radius 3.0)
(def start-lifespan 20) (def start-lifespan 100)
(def radius-step (/ start-radius start-lifespan))
(defrecord Trace [position velocity radius lifespan]) (defrecord Trace [position velocity radius lifespan])
@ -57,25 +58,27 @@
(defn update-trace [trace bounds] (defn update-trace [trace bounds]
(let [t (Trace. (next-pos (:position trace) (:velocity trace)) (let [t (Trace. (next-pos (:position trace) (:velocity trace))
(next-vel (:velocity trace)) (next-vel (:velocity trace))
start-radius (- (:radius trace) radius-step)
(dec start-lifespan))] (dec (:lifespan trace)))]
(when (and (in-bounds? (:position t) bounds) (if (and (in-bounds? (:position t) bounds)
(> (:radius t) 0) (> (:radius t) 0)
(> (:lifespan t) 0)) (> (:lifespan t) 0))
t))) t
(do #_(println "died at " (:lifespan t))
nil))))
;;; ;;;
;;; physics ;;; physics
;;; ;;;
(def gravity [0 0 -0.2]) (def gravity [0 0 -0.1])
(defn random-vel (defn random-vel
[] []
#_(mapv #(* 2 (- % 0.5)) (repeatedly 3 rand)) #_(mapv #(* 2 (- % 0.5)) (repeatedly 3 rand))
(vector (* 2 (- (rand) 0.5)) (vector (* 8 (- (rand) 0.5))
(* 2 (- (rand) 0.5)) (* 8 (- (rand) 0.5))
(* 4 (rand)))) (* 12 (rand))))
(defn next-pos (defn next-pos
"Position at t+1" "Position at t+1"
@ -99,19 +102,19 @@
(defn trace-trajectory (defn trace-trajectory
[trace bounds] [trace bounds]
(loop [pts [] (loop [traces []
trace trace] trace trace]
(let [new-trace (update-trace trace bounds)] (let [new-trace (update-trace trace bounds)]
(if (not new-trace) (if (not new-trace)
pts traces
(recur (conj pts (:position trace)) new-trace))))) (recur (conj traces trace) new-trace)))))
(defn trajectory-voxels [trajectory] (defn trajectory-voxels [traces]
(reduce set/union (map #(sphere (round-point %) 3) trajectory))) (reduce set/union (map #(sphere (round-point (:position %)) (:radius %)) traces)))
(defn sample-trace [] (defn sample-trace []
(let [bounds [[10 490][10 490][10 490]] (let [bounds [[10 990][10 990][10 990]]
origin [250 250 250]] origin [500 500 500]]
(trajectory-voxels (trace-trajectory (new-trace origin) bounds)))) (trajectory-voxels (trace-trajectory (new-trace origin) bounds))))
(defn sample-traces [count] (defn sample-traces [count]
@ -127,7 +130,7 @@
;;; ;;;
(defn sample-tree [count] (defn sample-tree [count]
(let [tree (svo/voxeltree 500 1.0) (let [tree (svo/voxeltree 1000 1.0)
trace (sample-traces count)] trace (sample-traces count)]
(svo/apply-voxels svo/set-at tree trace))) (svo/apply-voxels svo/set-at tree trace)))