I am new here, hi to everyone
I made my physic engine and I finally reach the point where object resting on top of each other produce some kind of anomally which I kinda know what the cause is.
I try a few method from this series
But I kinda one of some little part of each tutorial and I even have my own method in some small part as well.
So I cannot really say which tutorial I follow..
I took ResolveCollision function from the first tutorial
void ResolveCollision( Object A, Object B )
{
// Calculate relative velocity
Vec2 rv = B.velocity - A.velocity
// Calculate relative velocity in terms of the normal direction
float velAlongNormal = DotProduct( rv, normal )
// Do not resolve if velocities are separating
if(velAlongNormal > 0)
return;
// Calculate restitution
float e = min( A.restitution, B.restitution)
// Calculate impulse scalar
float j = -(1 + e) * velAlongNormal
j /= 1 / A.mass + 1 / B.mass
// Apply impulse
Vec2 impulse = j * normal
A.velocity -= 1 / A.mass * impulse
B.velocity += 1 / B.mass * impulse
}
I use this algorithm to solve impulse problem between 2 object
But the problem is when 1 object collide to another object and then that other object collide with another object and so on...
if it's just one object with another it's not so hard
but if one object collide with 2 or more object simultaneously there occur a problem I cannot solve,
I don't know, I haven't learn physic to that level
Can someone help me ?
Thanks for your reply in Advance...