Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1402060 Posts in 68030 Topics- by 61614 Members - Latest Member: mertkasar

August 12, 2022, 04:51:06 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Rotation jitter - impulse based collision
Pages: [1]
Print
Author Topic: Rotation jitter - impulse based collision  (Read 1990 times)
zarovv
Level 0
**


View Profile
« on: February 14, 2020, 11:03:32 AM »

Hi.
I asked in the past about an issue i was having with collision and i was suggested to try out impulse based collision response.

I tried it and it works pretty okayish, but i have some annoying problem of collision jitter.

Basically, when i push the cube in down direction it jitters right and left non-stop.
It just rotate right,left,right and doesn't seem to slow down, stop and align with the ground.

Someone knows or have a clue on how to handle it?




Sorry that i bother with a lot of questions. its just this community seems to be responsive and very helpful )
Logged
qMopey
Level 6
*


View Profile WWW
« Reply #1 on: February 14, 2020, 08:44:50 PM »

Your best bet is to learn from a resource that already works. For example, Box2D Lite (this is the Lite version, not actual Box2D, it's just a tiny demo to learn from). That way you can compare your code to it. Box2D Lite has a sophisticated solver that solves multiple collision points simultaneously to avoid jitter. https://github.com/erincatto/box2d-lite

If you want something even easier to understand, without the sophisticated solver, just some naive impulses, there is also this one: https://github.com/RandyGaul/ImpulseEngine



Logged
buto
Level 0
***



View Profile WWW
« Reply #2 on: March 06, 2020, 11:48:25 AM »

Maybe a little late... just wanted to say that the demo looks super cool!
Logged

zarovv
Level 0
**


View Profile
« Reply #3 on: June 09, 2020, 11:04:43 AM »

If someone is interested... after many attempts, crying and frustration i managed to make it work:

I did it in 3d actually and the main algorithm (Is for 2 colliding objects. A is moving B is stationary and will always be) is:

   Vector rA = contact - center;
   Vector vr = linearVelocity + CROSS(angularVelocity, rA);

   float contactVel = DOT(vr, normal)
   ;

   Vector raCn = CROSS(rA, normal);

   float raI = DOT(raCn, VEC_MULT(invertedInertia, raCn))
   ;

   float lambda = (-contactVel + pushDistInNormalDirection)
         / (1.0f / mass + raI);

   Vector impulse = VEC_MULT_SCALAR(lambda, normal);

   Vector linearVelocityDiff = VEC_MULT_SCALAR(1.0f / mass, impulse) / contactCount;
   Vector radiansVelocityDiff = VEC_MULT(invertedInertia,
         CROSS(rA, impulse)) / contactCount;

Search for Randy Gaul 3D. He has some simple enough impulse based git project also...
Logged
qMopey
Level 6
*


View Profile WWW
« Reply #4 on: June 13, 2020, 03:11:56 PM »

I'm Randy Gaul, and I posted in this topic a while ago Tongue

If anyone has questions about this kind of stuff I'm easy to contact on twitter.
Logged
zarovv
Level 0
**


View Profile
« Reply #5 on: June 19, 2020, 02:46:15 AM »

I'm Randy Gaul, and I posted in this topic a while ago Tongue

If anyone has questions about this kind of stuff I'm easy to contact on twitter.

OOOOOOoooo  Who, Me? Who, Me? Who, Me? Who, Me? Who, Me?
A legend indeed. Your implementation is the easiest I found online.
I struggled for example with the coefficient for the impulse, always used a constant coefficient.
But then looking at your implementation I tried using the push distance(penetration) as the coeff and it worked.
Thanks )
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic