Make step! a proper multi-arity function
This commit is contained in:
@@ -254,16 +254,17 @@ such as :on-begin-contact."
|
|||||||
(defn step!
|
(defn step!
|
||||||
"Runs the physics simulations for a single frame and optionally returns the
|
"Runs the physics simulations for a single frame and optionally returns the
|
||||||
`entities` with their positions updated."
|
`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}
|
:or {time-step (/ 1 60) velocity-iterations 10 position-iterations 10}
|
||||||
:as screen}
|
:as screen}]
|
||||||
& [entities]]
|
(.step world time-step velocity-iterations position-iterations))
|
||||||
(.step world time-step velocity-iterations position-iterations)
|
([screen entities]
|
||||||
(when entities
|
(step! screen)
|
||||||
(map (fn [e]
|
(when entities
|
||||||
(if (u/get-obj e :body)
|
(map (fn [e]
|
||||||
(assoc e
|
(if (u/get-obj e :body)
|
||||||
:x (body-x e)
|
(assoc e
|
||||||
:y (body-y e))
|
:x (body-x e)
|
||||||
e))
|
:y (body-y e))
|
||||||
entities)))
|
e))
|
||||||
|
entities))))
|
||||||
|
|||||||
@@ -311,17 +311,18 @@ such as :on-begin-contact."
|
|||||||
(defn step!
|
(defn step!
|
||||||
"Runs the physics simulations for a single frame and optionally returns the
|
"Runs the physics simulations for a single frame and optionally returns the
|
||||||
`entities` with their positions updated."
|
`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)}
|
:or {max-sub-steps 5 time-step (/ 1 60)}
|
||||||
:as screen}
|
:as screen}]
|
||||||
& [entities]]
|
(bullet-3d! screen :step-simulation delta-time max-sub-steps time-step))
|
||||||
(bullet-3d! screen :step-simulation delta-time max-sub-steps time-step)
|
([screen entities]
|
||||||
(when entities
|
(step! screen)
|
||||||
(map (fn [e]
|
(when entities
|
||||||
(if (u/get-obj e :body)
|
(map (fn [e]
|
||||||
(assoc e
|
(if (u/get-obj e :body)
|
||||||
:x (body-x e)
|
(assoc e
|
||||||
:y (body-y e)
|
:x (body-x e)
|
||||||
:z (body-z e))
|
:y (body-y e)
|
||||||
e))
|
:z (body-z e))
|
||||||
entities)))
|
e))
|
||||||
|
entities))))
|
||||||
|
|||||||
Reference in New Issue
Block a user