Skip to content

Commit cf6776f

Browse files
committed
Fixed performance regression.
1 parent cb64207 commit cf6776f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Nu/Nu/Physics/PhysicsEngine2d.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,7 @@ and [<ReferenceEquality>] PhysicsEngine2d =
15491549
match results.TryDequeue () with
15501550
| (true, intersection, _) -> [|intersection|]
15511551
| (false, _, _) -> Array.empty
1552-
else
1553-
Array.init results.Count (fun _ -> results.Dequeue ())
1552+
else Array.init results.Count (fun _ -> results.Dequeue ())
15541553
else Array.empty
15551554

15561555
member physicsEngine.HandleMessage physicsMessage =
@@ -1567,12 +1566,13 @@ and [<ReferenceEquality>] PhysicsEngine2d =
15671566

15681567
// integrate only when time has passed
15691568
if stepTime > 0.0f then
1570-
1571-
// apply body-specific gravity (acceleration). NOTE: does not wake sleeping bodies.
1569+
1570+
// apply body-specific gravity for awake bodies
15721571
for KeyValue (bodyId, gravityOverride) in physicsEngine.BodyGravityOverrides do
15731572
let body = physicsEngine.Bodies.[bodyId]
1574-
let gravity = PhysicsEngine2d.toPhysicsV2 gravityOverride
1575-
B2Bodies.b2Body_SetLinearVelocity (body, B2Bodies.b2Body_GetLinearVelocity body + gravity * stepTime)
1573+
if B2Bodies.b2Body_IsAwake body then
1574+
let gravity = PhysicsEngine2d.toPhysicsV2 gravityOverride
1575+
B2Bodies.b2Body_SetLinearVelocity (body, B2Bodies.b2Body_GetLinearVelocity body + gravity * stepTime)
15761576

15771577
// step the world
15781578
B2Worlds.b2World_Step (physicsEngine.PhysicsContextId, stepTime, Constants.Physics.Collision2dSteps)

0 commit comments

Comments
 (0)