Box2D Physics Slows Down but rest of sim doesn't

Box2D / Chipmunk

Moderators: ezraanderson, stun

Box2D Physics Slows Down but rest of sim doesn't

Postby naturally » Wed May 11, 2016 8:56 pm

A user was playing the game and the Box2d physics calculations looked to be too slow, but the rest of the sim wasn't slowing down with it. Is there any way to tie the rest of the sim to the "slowest" framerate, in this case Box2D?

:?
Image - Don't Be Patchman - a sneak-and-grow adventure!
User avatar
naturally
 
Posts: 689
Joined: Thu Aug 29, 2013 8:05 pm
Location: Canada

Re: Box2D Physics Slows Down but rest of sim doesn't

Postby naturally » Wed May 11, 2016 9:00 pm

Some settings I have:

Code: Select all
  1. -- ENGINE THREAD

  2. MOAISim.setStep(1 / 60)

  3. MOAISim.setStepMultiplier(1)

  4. MOAISim.clearLoopFlags()

  5. MOAISim.setLoopFlags(MOAISim.LOOP_FLAGS_FIXED)

  6. MOAISim.setLoopFlags(MOAISim.SIM_LOOP_LONG_DELAY)

  7. MOAISim.setLoopFlags(MOAISim.SIM_LOOP_ALLOW_SOAK)

  8. if Game.mobile then

  9.         --  will allow the simulation step to run multiple times per update to try

  10.         -- and catch up with device time, but will abort if processing the

  11.         -- simulation exceeds the configfured step time

  12.         MOAISim.setLoopFlags(MOAISim.SIM_LOOP_ALLOW_SPIN)

  13.         --MOAISim.setLoopFlags(MOAISim.LOOP_FLAGS_MULTISTEP)

  14. end

  15. if Game.desktop then

  16.         --  will permit a *variable* update step if simulation time falls too far behind

  17.         --   device time (based on the boost threshold). Be warned: this can wreak havok

  18.         --   with physics and stepwise animation or game AI

  19.         MOAISim.setLoopFlags(MOAISim.SIM_LOOP_ALLOW_BOOST)

  20. end

  21. --MOAISim.setLeakTrackingEnabled(false)

  22. MOAISim.setBoostThreshold(0)

Image - Don't Be Patchman - a sneak-and-grow adventure!
User avatar
naturally
 
Posts: 689
Joined: Thu Aug 29, 2013 8:05 pm
Location: Canada

Re: Box2D Physics Slows Down but rest of sim doesn't

Postby naturally » Fri May 13, 2016 10:00 am

It was the BOOST flag.

When a system couldn't handle 60 FPS, it would slow down or skip the physics to compensate, resulting in really weird behaviour (usually noticeable as some projectiles slowing down).

I also added a 30FPS option to our game for slower systems.
Image - Don't Be Patchman - a sneak-and-grow adventure!
User avatar
naturally
 
Posts: 689
Joined: Thu Aug 29, 2013 8:05 pm
Location: Canada

Re: Box2D Physics Slows Down but rest of sim doesn't

Postby ibisum » Mon May 16, 2016 9:32 am

It was the BOOST flag.


Good catch! Can confirm this on one of my box2d games..
;
--
Email: ibisum@gmail.com
IRC: torpor on FreeNode, see you in the #moai channel
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info/
User avatar
ibisum
 
Posts: 1501
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria


Return to Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x