Discrete Time Issue - Overlapping

Hi, i’m implementing a snooker game, and i am onto doing the ball-to-ball collision, the problem is when a collision has been detected in my game, the 2 balls are slightly overlapping, as it hasn’t detected the collision in time, does anyone have any ideas on how to deal with this overlapping?

Do i need some kind of step-by-step method, or another thread running?

have you tried decreasing the time step and/or setting the stepInteractions to a higher value? are you using step or stepFast?

The collision type that you are doing currenlty is called “static collision detection” i.e only when they touch, do you know they are touching. Which makes sense in first person shooters or whatever.

But for a snooker, game, i would opt for “dynamic collision detection”. However, this is a little bit more complex than static, but it does provide you with a very powerful collision system…

The idea behind it is to preempt a collision by using the directional matrix of the object and ray casting forwards in that direction (across all extremeties ofcourse, not just the centre of the ball). Find out if the ray is going to collide with any other ball. If so, you can find out the distance between them. From that distance, and given the speed of the snooker ball (you have to work that one out yourself im afraid using speed = distance/time, the time is the interpolation between the current aned last frame, distance is the distance covered between the current and last frame).

Using speed = distance/time. GIven the speed, and the distance between the objects, you can find out when the objects will collide. And decrement that counter by the interpolation everytime, untill you get to 0 or around that figure and do your collision response.

A complication arrises when the two objects are moving. So you need to work out if they are going to intersect and where. Say a ball is moving at 1mph east (located at (-1, 0, 0)) and a ball is traveling north at 1mph located (0, -1, 0) then they are definetly going to collide. So you need to make adjustments as necessary.

That would be my solution. But there is another solution to the problem. And that is to find the distance between the two objects before collision, if the distance is less than a given threshold, then they have collided and you should initiate your response.

Choose whichever is more suitable to your needs.

DP

oh, thought you where using ODE, my bad :wink:
perhaps you should though, it would make things easier ;D

I wouldn’t use ODE for a snooker game. How much experience do you have with physics/maths? Maybe you could create your own engine, doesn’t need to be extensive, since your only using spheres and lines. I would do the dynamic collision thing mentioned a couple of posts earlier, however you will also need to take into account deceleration due to friction, not only the velocity.

Just brainstorming right now, I would set the a start state at each collision, use current positions and velocities to find the next collision and the positions and velocities of the balls at [just after?] that next collision. A collision includes ball-to-ball and ball-to-wall collisions, maybe include pocketing as a collision. I would then interpolate (with changes in velocity due to friction) intermediate positions of all the balls between the two collisions and play each interpolation to the user per frame. (Note, you can use interpolated velocities for motion blur if you wish).

Once you have this first prototype working correctly, I would then move on to allowing the balls to spin, which includes curved paths on the table, which is a big step from simple straight-line motions between collisions.

One very hard problem with snooker is when you have more than two balls collide with eachother at exactly the same time. However, with dynamic collision this will hardly ever happen, so you probably don’t need to watch out for it.