Make step! a proper multi-arity function
This commit is contained in:
@@ -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))))
|
||||
|
||||
@@ -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))))
|
||||
|
||||
Reference in New Issue
Block a user