🔒 Locked
Performing Calculations while Rendering
Advertisement
Original Post
This is my problem: When I have vsync off, my game loop runs at maximum speed, and my collision calculations are done ~150 times per second. When I turn vsync on, it slows down everything, and the calculations are only done 60 times per second, the collision calculations are less accurate. Should I disable vsync in code? Is there any way to have the rendering execute every 1/60 of a second (it should only take about 1/150), and then have the calculations done every 1/150 of a second? I would really appreciate some help with this. Thanks! -Shane
dont force v-sync on or off, leave that upto the end user, its good maners [smile]
As to your problem you could flip the calculations out to a seperate thread, but that might not be the best path, someone else would have to advise here I think [smile]
the other option is to try and make them less dependant on being updated lots and try to make them more dependant on the time things collide.
However, again, someone else would have to help you here [smile]
As to your problem you could flip the calculations out to a seperate thread, but that might not be the best path, someone else would have to advise here I think [smile]
the other option is to try and make them less dependant on being updated lots and try to make them more dependant on the time things collide.
However, again, someone else would have to help you here [smile]
LOL, you never actually answered my question though...
you instead asked why I was asking the question, which doesn't help anyone.
I guess I could make it more dependant on the time things collide - but wouldn't that expose the same problem?
There would still exist the issue of inaccurate calculations.
you instead asked why I was asking the question, which doesn't help anyone.
I guess I could make it more dependant on the time things collide - but wouldn't that expose the same problem?
There would still exist the issue of inaccurate calculations.
same thing goes for shoving it in a thread on its own
As other people said, just scale your physics over time.
If you have an object that rotates 2 radians per second, and the physics "tick" has taken 300ms then scale it accordingly eg.
Edit: oh and dont use the windows msg pump for the timer, or the "SetTimer()" functionality. There are plenty of examples of timers here on gamedev, and there are some artilces about them too. Just do a search.
If you have an object that rotates 2 radians per second, and the physics "tick" has taken 300ms then scale it accordingly eg.
OnTick(long elapsed /* in miliseconds */){ mObject.Rotate(2.0f * (elapsed * 0.001));}Edit: oh and dont use the windows msg pump for the timer, or the "SetTimer()" functionality. There are plenty of examples of timers here on gamedev, and there are some artilces about them too. Just do a search.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement