6
\$\begingroup\$

I'm looking for physics engines that doesn't use time steps. I don't think time steps are reliable, and I don't like how without tweaking the engine a bullet going too fast can pass through a wall without colliding it. Moreover I suspect they do a lot of unnecessary computations.

I thought of a physics engine concept where all the movements are represented by forces and movement beginning time. In such an environment as long as no event occur the engine would not do any computation.

I imagine the following:

  • I shoot a bullet in space, an object is created representing its physics properties.
  • The engine compare the bullet trajectory with other's to find if it's gonna collide with an other object.
  • It finds a collision, in 3 seconds.
  • An callback is programmed to trigger in 3s to process the collision.
  • In the meantime if no other event occur (like shooting an other bullet, changing an object trajectory, etc...) no other computation is done.

Does such an engine exists? Is there a name to this technique? Have you ever tried using this approach?

\$\endgroup\$
  • 1
    \$\begingroup\$ This is highly opinion-baseed. You do not trust timesteps, and you believe engines do too many computations, you think it is possible to compute a trajectory without timesteps… where do these beliefs come from? Are you aware that there is no closed-form solution even for three bodies and the gravitational force? \$\endgroup\$ – sam hocevar May 4 '18 at 13:30
  • 1
    \$\begingroup\$ @samhocevar wanting to use a specific approach is hardly opinion-based, especially when you show a proof of it not being feasible. On the other hand, it definitely is a technology recommendation request. \$\endgroup\$ – wondra May 6 '18 at 10:33
  • \$\begingroup\$ @samhocevar Not trusting is because I think time steps approachs have lower precision than the solution I imagined and can miss collisions. The too many computations part is relative to the single computation potential of the scenario I propose. For the faisability part, that's what I'm asking about. I have little physics knowledge and the counter example you provided answers my question and help me understand why this is not a thing. \$\endgroup\$ – Yovar May 6 '18 at 16:03
7
\$\begingroup\$

The problem is this only works if movement is linear and there is no possibility of other moving objects hitting one another.

As soon as you have multiple forces changing the direction in non-linear ways (eg: friction, gravity, wind) you're forced to do integration which involves slicing everything down into infinitely small time slices.

This is why and for reasons of numerical stability fixed time steps are usually used.

\$\endgroup\$
  • \$\begingroup\$ Thank you! Being a mathematics newbie I thought everything could be transformed to functions and resolved by equations. \$\endgroup\$ – Yovar May 3 '18 at 0:51
  • 1
    \$\begingroup\$ I was on a research project that basically did that. The simulator could find collisions via equation, but didn't have to do anything with them (i.e. things were either crashed or not crashed). It was a lot of extra math & at the end of the day, I'm not sure if it really gained us anything beyond saying that it was a bit more exact. Given that real numbers don't have precise computational representation, you'll still have to compromise somewhere. \$\endgroup\$ – Pikalek May 3 '18 at 1:05
  • \$\begingroup\$ @Pikalek I wanted to use such an engine with a fractional representation of numbers to have a "perfect" precision engine. Instead of using x = 0.333332 I would use x = "1/3" but this could get very messy if I start using values like PI... Again bad math knowledge haha. I think this approach makes more sense from an human perspective though. As a human I know the bullet is gonna hit the wall from the beginning. \$\endgroup\$ – Yovar May 3 '18 at 1:17
  • 1
    \$\begingroup\$ @Yovar Yes, as you noted, there's still the problem of dealing with irrational numbers. You can read more about that in this post: cs.stackexchange.com/questions/28347/… Also, when dealing with equivalence, the imprecision of reals can lead to even more problems: floating-point-gui.de/errors/comparison \$\endgroup\$ – Pikalek May 3 '18 at 19:19
2
\$\begingroup\$

I have created a 2D collision detection engine which I used in one of my games. All the objects moved in linear segments, and their bodies were defined as circles with a given radius. The distances at a time t could be defined as quadratic equations, which are easy to solve. (I had to do a bit of algebra on paper to get my equations to be number-crunchable) I solved the equations for the time of collision and in my case i scheduled a collision event at that time in the future.

In 2d, this is entirely doable. It gets more complicated with non-circular objects, but that's just complexity. The quadratic equation gives two solutions, but it's easy to find out which is the one you are looking for.

Obviously all collisions need to be recalculated every time something changes. This could be a problem for a game with many actors in the same space. The same is true for a step-based solution, however. You could argue that the problem in both cases comes down to computational speed.

It's worth noting that objects will usually move linearly in computer games. Some will move in parabolas, such as things falling under gravity. This should also be perfectly solvable in 2D, but I have never tried. You could also have hyperbolic and elliptic motions in games focusing on space travel. The physics in these games could also be solved without being step-based, but it would require the whole engine to do so.

In a 3D space the maths become much more difficult, but you could still get good results with approximate or numerical methods. They would be less accurate, but you could still avoid the problems of "idle computing" of a step-based approach. You could also use the numbers from low iterations as early warning, so to speak.

\$\endgroup\$
1
\$\begingroup\$

Physics systems require time steps to work. They are integration engines, which perform calculus in order to model physical interactions.

What makes a physics engine work best is a fixed time step. This means that even if the engine slows down, the engine still moves things in acceptably small increments to be stable. This makes the engine reliable.

Variable time step physics engines are far less stable, because if the update time since the last is too large, you can end up with velocities or impulses being too large, destabilising the simulation, or objects tunnelling through each other, reducing the accuracy of the system.

\$\endgroup\$
1
\$\begingroup\$

Does a name for such a technique exist? Well, it's effectively solving the equations of motion exactly, which typically is not impossible. This basically gets into the arguments of a deterministic universe; if you know all the data, you can predict the future with 100% accuracy.

Problem: The universe isn't deterministic. No, this isn't a quantum mechanics argument, but rather that there's one aspect that's very uncertain: the Player. Games are a notoriously interactive medium, no matter what people like David Cage are trying to do.

Now, you did address this: As long nothing occurs, we don't have to do anything. Fair enough, but at that point you'll be checking whether or not you need to recalculate every frame as opposed to doing a calculation every frame and updating it, which is, in practice, not different, and definitely not as flexible. Additionally, depending on the circumstances, the computations can be far harder to do, and they require a lot more data, which is bad for many reasons.

Are there any alternatives? Yes. You could use pre-scripted physics or use a stochastic system which I have used in the past for a variety of applications. However, these cannot replace traditional physics engines in all situations.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.