• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Vaclav

Which physics library can also step backwards in time?

10 posts in this topic

Hello
I'm looking for a free, cross-platform (windows and linux is enough for me), C/C++ physics library which can also step physics back in time, not only forward in time.
For example, what I want to do looks like this:
[source lang="cpp"]world.update(0.05);
world.update(0.05);

...

world.update(-0.025);
world.update(-0.05);
world.update(-0.025);[/source]
And I want to get the same state in the end as it was at the beginning.
I have already tried Box2D and chipmunk physics. Box2D only stops time for negative values (does nothing), chipmunk does the thing (ok not very accurately) as long as there are no collisions. If there was a collision meanwhile, I get completely different result when rolling things back in time. Without any collisions it works.

Have you guys ever did this, or know which library can do it well?
I could even try ODE, if it can do this. It's 3D, but I can use it for 2D too I guess.
0

Share this post


Link to post
Share on other sites
Thank you for your reply.
[quote name='Waterlimon' timestamp='1355834227' post='5012016']
b)Save snapshots at some interval, then either interpolate or simulate forward/backward from closest point (whichever works the best)
[/quote]
So I'm going to do this. Set the position, rotation, velocity and angular velocity at the earlier of the two frames next to the desired time. Then advance physics by the difference between the desired time and the frame time.
This should be better than interpolating between two frames myself, because a collision might happen in the meantime.
0

Share this post


Link to post
Share on other sites
[url="http://www.gamedev.net/topic/630356-rewind-of-braid/page__p__4974060#entry4974060"]You may find this interesting[/url]. All of the links Hodgman posted are worth checking out. If you're interested in forking out $4, you can get [url="https://store.cmpgame.com/product/5900/The-Implementation-of-Rewind-in-Braid"]Jonathan Blow's presentation on implementing rewinding here[/url].
0

Share this post


Link to post
Share on other sites
[quote name='Vaclav' timestamp='1355842477' post='5012064']
Thank you for your reply.
[quote name='Waterlimon' timestamp='1355834227' post='5012016']
b)Save snapshots at some interval, then either interpolate or simulate forward/backward from closest point (whichever works the best)
[/quote]
So I'm going to do this. Set the position, rotation, velocity and angular velocity at the earlier of the two frames next to the desired time. Then advance physics by the difference between the desired time and the frame time.
This should be better than interpolating between two frames myself, because a collision might happen in the meantime.
[/quote]

Hi Vaclav,

I'm not sure what your specific use case is here, but be aware that physics systems don't like 'teleporting' collision geometry around. It is a slow process. Consider it (some what) equivalent to setting up the initial scene... more specially, when you teleport an object its potential collision lists will need to be re-updated entirely, rather than the presumably more optimized process used when moving an object with velocity. (Obviously every system/engine is different and this may or may not be applicable).

With the snapshot approach, while 're-winding' you don't need to move all the collision geometry around (only the visual geometry)... only once you go to re-start time do you need to move the collision geometry to the new location (and probably best to do this with a completely re-load of the physics world). This will only result in a performance spike when restarting the simulation which you can hide behind a transition effect.

Cheers,
Brad
2

Share this post


Link to post
Share on other sites
The snapshot approach should be easy, however if you are trying to step to a specific point in time to view an event in a simulation, then there could be problems in stepping forwards. For example, imagine you have 2 objects that are headed towards each other and a snapshot before they collide, and a snapshot of a point in time after the collision, say for example there is a 1 second gap between the snapshots (for example). Now if you reset the objects locations and try to step forwards in 1/10 of a second increments to the point of collision then you are running the simulation with different settings. Sometimes changing the time step can alter the accuracy of the simulation by a large factor, and so you might even find a different result - i.e. a different ending position.
0

Share this post


Link to post
Share on other sites
Well what I want to do is like a multiplayer racing game over network, so something with physics over network.
I have read some articles about it, here is what I think how it would work:
Say I have a client and a server. I measure the latency between them, one direction it's ping/2. Let's say ping is 200 ms, so one way latency is 100 ms.
The physics simulations runs on the server, but the client also tries to approximate it. If the client gets an input for example to move, sends it to the server that it wants to move. Then the server has to roll back time of the physics with 100 ms, because the action of the client happened at that time. Then apply the action, and go forward with time 100 ms again.
The server sends the actual positions and velocities let's say 10 times a second. When the client receives positions, the ones it got are the positions reflecting the physics state 100 ms earlier, so the client sets those positions and velocities and advances time by 100 ms.

For this, restarting the simulation every time when teleporting objects, would be too often to do. I'm going to use Box2D. I don't know if you have problems with collisions when setting the new positions and velocities.
So is it correct what I think of? Or do I make it overcomplicated?
0

Share this post


Link to post
Share on other sites
FWIW

I created my own physics engine that ensures that all motion is constant-velocity and all changes to velocity happen in instantaneous "key frames" (impulses?) that are created at least N times per second but also for every collision

this allows me to scrub backwards and forwards in time by using simple linear interpolation between key frames

also it means that I swap some simulation accuracy (mainly drag effects) for "perfect" collisions so I don't have any interpenetration issues

(so far I haven't needed more than 1000 frames with up to 16 objects (pos + quaternion) covering around 12 seconds)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0