# Tag Info

53

On handling floating point numbers in a deterministic way Floating point is deterministic. Well, it should be. It is complicated. There is plenty of literature on floating point numbers: What Every Computer Scientist Should Know About Floating-Point Arithmetic THE NEW IEEE-754 STANDARD FOR FLOATING POINT ARITHMETIC IEEE 754-2008 revision And how they ...

34

...the inner workings of that function are generated via the appropriate mathematical formula... This will work for certain classes of problems, and the key phrase to search for is a closed-form solution. For example, in Kerbal Space Program, the motion of a spacecraft in orbit is calculated this way. Unfortunately, most non-trivial problems (e.g. ...

28

What is tunneling and why it happens In video games, physic objects will have an specific position which is updated by the physics engine each frame based on its velocity and any forces applied to it. Motion depicted with very low frame rate to draw attention to the fact that it is not continuous. Note that although the depiction is 2D, this is not specific ...

19

Spatial division is always O(N^2) in worst case and that is what complexity in informatics is about. However there are algorithms that work in linear time O(N). All of them are based on some kind of sweep line. Basically you need to have your objects sorted by one coordinate. Let's say X. If you perform the sort every time before collision detection, the ...

10

In the vast majority of situations, calling getVelocity is a vastly preferable approach. You don't have to be polling objects on the off chance that next frame you are going to need a velocity (which requires the position from last frame). If I have 10,000 objects and nee the velocity of 10 of them on any given frame, there's no point in storing off 10,000 ...

9

No. Collision detection is not always O(N^2). For instance, say we have a 100x100 space with objects with size 10x10. We could divide this space in cells of 10x10 with a grid. Each object can be in up to 4 grid cells (it could fit right in a block or be "between" cells). We could keep a list of objects in each cell. We only need to check for collisions in ...

9

The problem with your approach is, that you don't have a history of your object. You can calculate the position if you move in a direction, but what happens if you hit something and bounce back? If you accumulate from your last known position, you can handle the impact and go on from there. If you try to calculate it from the start, you have to recalculate ...

8

However, I don't understand why it's accumulated like this when it could just as easily be gotten by changing a function. For example: getPosition = makeNewFunction() which could return something that has the signature of Time -> Position, and the inner workings of that function are generated via the appropriate mathematical formula. You can! It is ...

8

In the case of just a simple bouncing ball, coming up with closed form solutions is easy. However, the more complex systems tend to require solving an Ordinary Differential Equation (ODE). Numerical solvers are required to handle all but the simplest cases. There are indeed two classes of numeric ODE solvers: explicit and implicit. Explicit solvers ...

8

I work for a company which makes a certain well known real-time strategy game, and I can tell you that floating point determinism is possible. Using different compilers, or the same compiler with different settings, or even different versions of the same compiler, can all break determinism. If you need crossplay between platforms or game versions then I ...

7

Your solver needs multiple iterations (aka sequential impulse) over its contacts. Treat each contact point independently and calculate the impulse to resolve its contact constraint for that iteration. This may cause previously resolved contact points to be pushed back into the colliding object, but not by as much as the initial penetration. Perform ...

7

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 ...

7

This is what I do in my N-Body simulation: particles far away can be aggregated in combined cells on a grid. (Multi-resolution Grid.) I use gravity calculations, but I am sure that charged attraction/repulsion works similarly over distance: it has the same 1/(r*r) scale. So particles in the same cell, or neighbour cell, you need to fully compute the ...

6

When you say 'synthesis' do you mean pure analog/additive/FM synthesis from scratch, or would a sample-based approach be acceptable? If you can't use combinations of real-world audio samples then this is more complicated process. Trying to generate truly realistic sounds through synthesis isn't the standard way that most game/virtual instruments/sound ...

6

The input it speed, mass, and time, the output is new speeds. Sometimes rotation/angular momentum is an input and output too. Essentially Physics engines try to simulate the effects of both gravity and collisions. For better physics engines that means they include both permanent and temporary deformation of objects, including splitting objects into multiple ...

5

Your problem lies in the fact that you have no "resting" state for your bodies. Any physics system has an amount of energy, be that kinetic, thermal, and so on. In reality, solid object deform slightly, and tranform some kinetic energy into heat, though it is hardly measurable. It's also worth noting that in reality there is no such thing as a completely ...

5

One solution I have found when using position correcting is to have a few iterations and vary the strength with each iteration. doPhysics(); int num_iterations = 5; for(int iteration=0; iteration<num_iterations; ++iteration) { float strength = float(iteration+1)/num_iterations; correctPositions(strength); } So the first iteration has a strength ...

5

I'm not sure if this is the type of answer you're looking for, but an alternative might be to run the calculations on a central server. Have the clients send the configuration to your server, let it perform the simulation (or retrieve a cached one) and send back the results, which are then interpreted by the client and processed into graphics. Of course, ...

4

One major advantage is that many collision detection operations are more efficient when performed at the origin. A classic example is box vs sphere. When done in a box's local space the tests are very simple axis aligned distance point-plane tests instead of the more costly non-axis aligned planes. Furthermore objects moving through space may not actually ...

4

Typically a physics engine is used to make object in a game behave in a realistic manner relative to their environment without having to design specific animations for every possible scenario. Specifically a physics engine will take a model with a set of properties (mass, joints etc) and render it in-game according to a set of parameters. An early ...

4

A physics engine is responsible for simulating the motion of objects in "the world" (whatever that means in the context of the engine). Most physics engines nowadays use Newtonian mechanics to do this, as they are relatively simple to simulate and "accurate enough" for most purposes unless you're doing a space sim. In theory, a "pure" physics engine would ...

4

I believe what we're looking at here more specifically refers to rotational inertia and inverse rotational inertia; not to linear inertia (nor inverse linear inertia). Wikipedia explains that rotational inertia is also known as the moment of inertia. From here you can take a look at Wikipedia's List of Moment of Inertia where the constant integer 12, shows ...

4

When developing games it is important to separate the game mechanics from the game representation on the screen. The game mechanics of bowling can be simplified to a pure 2d simulation by looking at the game from above: You wouldn't lose too much of the core gameplay of bowling by not allowing the ball and pins to jump up from the lane. But using a 3d ...

4

There are almost no algorithms to detect collision with a concave object, because there's no reason to have one. Every concave object can be approximated with convex object. See the following image for an example: There are algorithms to convert a set of points defining a concave polygon to multiply convex ones. A very easy, but inefficient one would be to ...

4

I most often encounter this in the context of Unity, which has the following attributes: Input is checked once per displayed frame, before any of that frame's fixed/variable timestep updates Input is interpreted as one flat state for the entirety of the current display frame, not a queue of events Each logical button has three independent boolean states: ...

4

TL;DR they work exactly the same; the difference comes from trade-offs like performance, value range and (sometimes) syntax. It's is possible to simulate floating- or fixed-point math, you just have to write all logic yourself (or use library). The only limits are your creativity and resulting performance overhead. Fixed-point math may be considered a subset ...

3

Bare minimum you need to know how the physics SYSTEM works within the engine. Most of these may sound daunting but it's really not that difficult and you CAN simply stumble through things but it will make it significantly easier if you understand these going in. What is a RigidBody? What is a Collider? What is the relationship between the two? How is it ...

3

You're in luck. I did a full translation of Randy Gaul's 2D physics engine into C# and XNA. He hasn't really explained things well for beginners like me. For your answer, you should just multiply the cross product with the inverse of the inertia of the body. This is from my translation: angularVelocity += inverseInertia * Vector2D.Cross(contactVector, ...

3

Whatever collision be, angular momentum is conserved. ie Iw = constant with the coefficient of restitution (in translation, i dont know if its said the same in rotation) u define, and with the moment of inertia, you should be able to figure it out. And i think this would similar to collisions in 1D, since only one axis is used :) Goodluck :)

Only top voted, non community-wiki answers of a minimum length are eligible