Archived

This topic is now archived and is closed to further replies.

maun

what happens when timestep goes big ?

Recommended Posts

maun    122
I wonder what you guys do with your physical stuffs when the timestep goes big (when the framerate suddently falls) ??? It''s a very open question as I haven''t found yet a valuable solution (setting the timestep to a max value isn''t a valuable solution in my opinion...) any ideas ?

Share this post


Link to post
Share on other sites
Waverider    169
I handled it by chopping the elapsed time into 100ms chunks and calling the behavior routine over and over until the time was consumed. That way anything travelling in a curve wasn't thrown too far off.

Diablo 2 handles it by locking the frame rate at around 30 (meaning everything operates on an elapsed time of 33ms or so), I think, so that if a slowdown occurs, you suddenly see everything catching up quickly to work its way back up to where it would have been without the slowdown.

If you can calculate everything accurately based ONLY on time, OR lock everything to behave with a constant elapsed time (like Diablo 2 did), it shouldn't throw anything off. Otherwise, chop up the elapsed time and call the behavior routine multiple times to consume it until everything is caught up.

That's my two cents.

EDIT: For collision detection, I prefer to calculate for a point of collision given two shapes and their travel paths (such that if so much time elapses that two objects actually pass through and beyond each other - I'm not checking for their geometries to intersect at the current point in time, I'm checking for a point of collision along their paths. That way, I'll detect a point of collision no matter how much time elapses.)


[edited by - Waverider on October 22, 2002 11:49:03 AM]

Share this post


Link to post
Share on other sites
sjelkjd    171
quote:
Original post by Waverider
EDIT: For collision detection, I prefer to calculate for a point of collision given two shapes and their travel paths (such that if so much time elapses that two objects actually pass through and beyond each other - I''m not checking for their geometries to intersect at the current point in time, I''m checking for a point of collision along their paths. That way, I''ll detect a point of collision no matter how much time elapses.)



Is this in 3d or 2d? Do you have rotation in your objects? Are you calculating intersections of bounding spheres, boxes, or actual geometry?

I''d love to hear how you did it, since I ran into a similar issue and ended up using the binary search method(See Orielly''s Physics for Game Developers).

Share this post


Link to post
Share on other sites
Waverider    169
I haven't done it yet with objects that are also rotating. Most collision detection I've done is between two spheres only, on a linear path from one frame to the next. I once tried to formulate collision detection between a vertical cylinder and a static BSP level, but never quite got there.

I have not yet endeavored to solve the problem with complex, rotating geometry. Frankly I'm not sure how to calculate the point of impact that results from two objects rotating into each other!

The collisions I was working with were in 3D.

Basically, for two spheres of radius r1 and r2, I just solved for the point at which the two centers, travelling along their linear paths that frame, were of distance (r1 + r2) from each other. I solved for the earliest non-negative time t, and as long as t was less than the elapsed time during the frame, there was a collision. The parameters for the collision function where their initial positions at the beginning of the frame, their velocity vectors and their radii.

Since I'm solving for t, not only do I know exactly when they collided, I know where. That allows me to accurately redirect their velocities during the collision based on their position in relation to each other and move them to the correct place before the frame is rendered, which would also work well for a billiard game, for instance.


[edited by - Waverider on October 24, 2002 4:19:49 PM]

[edited by - Waverider on October 24, 2002 4:21:18 PM]

Share this post


Link to post
Share on other sites
Deyja    920
I agree with LilBudy.

I have my timestep locked at 10 ms, and if my framerate drops to low I just skip some updates. Otherwise, it will be running while the player can''t see it, with the possibility of doing things without giving the player a chance to react.

(I''m using 10ms because it''s small enough that I don''t need to interpolate positions between frames. Call me lazy.)

Share this post


Link to post
Share on other sites