Make step! a proper multi-arity function

This commit is contained in:
oakes
2014-04-20 22:32:00 -04:00
parent bf0ea4f435
commit 6131b99776
2 changed files with 27 additions and 25 deletions

View File

@@ -254,16 +254,17 @@ such as :on-begin-contact."
(defn step!
"Runs the physics simulations for a single frame and optionally returns the
`entities` with their positions updated."
[{:keys [world time-step velocity-iterations position-iterations]
([{:keys [world time-step velocity-iterations position-iterations]
:or {time-step (/ 1 60) velocity-iterations 10 position-iterations 10}
:as screen}
& [entities]]
(.step world time-step velocity-iterations position-iterations)
(when entities
(map (fn [e]
(if (u/get-obj e :body)
(assoc e
:x (body-x e)
:y (body-y e))
e))
entities)))
:as screen}]
(.step world time-step velocity-iterations position-iterations))
([screen entities]
(step! screen)
(when entities
(map (fn [e]
(if (u/get-obj e :body)
(assoc e
:x (body-x e)
:y (body-y e))
e))
entities))))

View File

@@ -311,17 +311,18 @@ such as :on-begin-contact."
(defn step!
"Runs the physics simulations for a single frame and optionally returns the
`entities` with their positions updated."
[{:keys [delta-time max-sub-steps time-step]
([{:keys [delta-time max-sub-steps time-step]
:or {max-sub-steps 5 time-step (/ 1 60)}
:as screen}
& [entities]]
(bullet-3d! screen :step-simulation delta-time max-sub-steps time-step)
(when entities
(map (fn [e]
(if (u/get-obj e :body)
(assoc e
:x (body-x e)
:y (body-y e)
:z (body-z e))
e))
entities)))
:as screen}]
(bullet-3d! screen :step-simulation delta-time max-sub-steps time-step))
([screen entities]
(step! screen)
(when entities
(map (fn [e]
(if (u/get-obj e :body)
(assoc e
:x (body-x e)
:y (body-y e)
:z (body-z e))
e))
entities))))