Browse Source

Physics examples use dt for world update;

bjorn 1 year ago
parent
commit
2be9c57130

+ 1 - 1
examples/Physics/Boxes/main.lua

@@ -26,7 +26,7 @@ local isFirstFrame = true
 
 
 function lovr.update(dt)
 function lovr.update(dt)
   -- Update the physics simulation
   -- Update the physics simulation
-  world:update(1 / 60)
+  world:update(dt)
 
 
   -- Place boxes on controllers
   -- Place boxes on controllers
   for i, hand in ipairs(lovr.headset.getHands()) do
   for i, hand in ipairs(lovr.headset.getHands()) do

+ 1 - 2
examples/Physics/Hand_Physics/main.lua

@@ -36,7 +36,6 @@ local world
 local collisionCallbacks = {}
 local collisionCallbacks = {}
 local boxes = {}
 local boxes = {}
 
 
-local framerate = 1 / 72 -- fixed framerate is recommended for physics updates
 local hand_torque = 20
 local hand_torque = 20
 local hand_force = 30000
 local hand_force = 30000
 
 
@@ -74,7 +73,7 @@ end
 
 
 function lovr.update(dt)
 function lovr.update(dt)
   -- override collision resolver to notify all colliders that have registered their callbacks
   -- override collision resolver to notify all colliders that have registered their callbacks
-  world:update(framerate, function(world)
+  world:update(dt, function(world)
     world:computeOverlaps()
     world:computeOverlaps()
     for shapeA, shapeB in world:overlaps() do
     for shapeA, shapeB in world:overlaps() do
       local areColliding = world:collide(shapeA, shapeB)
       local areColliding = world:collide(shapeA, shapeB)

+ 1 - 1
examples/Physics/Newtons_Cradle/main.lua

@@ -46,5 +46,5 @@ end
 
 
 
 
 function lovr.update(dt)
 function lovr.update(dt)
-  world:update(1 / 72)
+  world:update(dt)
 end
 end

+ 1 - 1
examples/Physics/Saloon_Door/main.lua

@@ -32,7 +32,7 @@ function lovr.draw(pass)
 end
 end
 
 
 function lovr.update(dt)
 function lovr.update(dt)
-  world:update(1 / 72)
+  world:update(dt)
   -- every few seconds simulate a push
   -- every few seconds simulate a push
   if lovr.timer.getTime() % 3 < dt then
   if lovr.timer.getTime() % 3 < dt then
     door1:applyForce(0, 0, -50)
     door1:applyForce(0, 0, -50)

+ 1 - 1
examples/Physics/Terrain/main.lua

@@ -42,7 +42,7 @@ function lovr.update(dt)
       1)
       1)
     table.insert(box_colliders, collider)
     table.insert(box_colliders, collider)
   end
   end
-  world:update(1 / 60)
+  world:update(dt)
 end
 end
 
 
 function lovr.draw(pass)
 function lovr.draw(pass)

+ 1 - 1
examples/Physics/Wrecking_Ball/main.lua

@@ -47,7 +47,7 @@ end
 
 
 
 
 function lovr.update(dt)
 function lovr.update(dt)
-  world:update(1 / 72)
+  world:update(dt)
 end
 end
 
 
 
 

+ 1 - 1
examples/Physics/Zip_Line/main.lua

@@ -29,7 +29,7 @@ end
 
 
 
 
 function lovr.update(dt)
 function lovr.update(dt)
-  world:update(1 / 72)
+  world:update(dt)
 end
 end