Physics Pause Simulation

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Physics Pause Simulation

Post by mikembley »

As my bodies are colliding fine, I move the window by dragging the title bar, This seems to pause the graphics rendering, But upon stopping the drag, The physics seem to display awkward behaviour as if it had continued simulating the physics whilst i was dragging, but it had failed to do collisions as such.

I would like to elaborate more but i was hoping maybe somebody had already experienced this before and could maybe post a solution because i couldnt find anything via search

Thanks much :)
User avatar
athanazio
Citizen
Posts: 96
Joined: Fri Apr 10, 2009 3:12 am
Location: Rio de Janeiro - Brazil
Contact:

Re: Physics Pause Simulation

Post by athanazio »

I had the same problem,
and for any reason it seems that the position of the physical objects are related to the screen itself instead of related to the current window, When I was doing my water simulation I saw that behavior like shaking the objects around when dragging the window

EDIT
try to run this sample and shake the window ...
http://love2d.org/forum/viewtopic.php?f=5&t=686

the balls will get crazy !!
Nothing is simple but everything is possible.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Physics Pause Simulation

Post by rude »

When you drag the window, everything stops except the timer. When you release the window, a lot of time may have passed since last frame, and so the timestep supplied to World:update(dt) is possible huge.
athanazio wrote:the physical objects are related to the screen itself
:rofl: Haha, I certainly hope that is not the case.

I remember looking into this some years ago, and I think I found out that SDL has no way of detecting when windows are being moved (but please prove me wrong). The only solution available now is to not drag the window and/or use love.system.grabInput(true) to restrict the mouse to the window area.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Physics Pause Simulation

Post by bartbes »

The following lua code could be used (and possibly included in LÖVE, in lua or C):

Code: Select all

maxdt = 1 --1 second, maybe, experiment with this
function update(dt)
    while dt > 0 then
          local tempdt = dt --you should rename this to something more useful, but for the sake of examples
          if tempdt > maxdt then tempdt = maxdt end
          --do your update stuff with tempdt instead of dt
    end
end
@rude: I did find a page where they said 'video expose' events are sent during dragging (and after) and (of course) active events (because mouse leaves and enters) surrounding those. Here it is
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest