inifinite mass and a jitter problem

Started by
15 comments, last by _WeirdCat_ 8 years, 11 months ago

Hi again,

It looks like your program is first lifting the finite mass object free of contact with the infinite mass object (SolvePenetration), and then applies a separation impulse of some magnitude (SolveImpulse). So in short, your code lifts the movable object free of the ground and then applies a velocity away from it. This will always create jitter.

I would drop SolvePenetration completely and only apply an iterative impulse that separates the objects and dampens them, in principle like a damped spring but formulated as an impulse. Something like this, where k and d are stiffnes and damping coefficients between 0 and 1 (start with 0.3 or something like that). Number of iterations could be anything from 1 to 20, you should see a noticeable difference. You may need to swap signs somewhere to make it work properly, remember I can't test this, only compare to my own code.

Cheers,

Mike


void Contact::solveImpulse(){
    
    Vec2 rel_vel=b2->vel-b1->vel;

    float sep_vel=rel_vel.dot(ci.normal);

    float tot_i_mass=b1->i_mass+b2->i_mass;

    b1->vel+=ci.normal*(-ci.pen*(1.0f/(float)FPS)*k+sep_vel*d)*((b1->i_mass/(tot_i_mass));
    b2->vel-=ci.normal*(-ci.pen*(1.0f/(float)FPS)*k+sep_vel*d)*((b2->i_mass/(tot_i_mass));

}
Advertisement

@h4tt3n

I have implemented your algorithm and here's what I found by playing around with the numbers. Note, that this is after commenting out the solvePenetration() method, thereby, transferring all contact resolution to a velocity based system.

1.) The jittering stopped when standing on two inverse mass=0.0f tiles. This was the exact result I was looking for, and by playing with three parameters, the iterations, the "d" and the "k" I was able to come up with a global solution that was stable (of course it's only a 2d game where block stacking is not necessary, therefore, I did not do a full body physics test). But all things considered, it works very well.

2.) A new problem now cropped up. When an AABB with finite mass is "walking" along infinate mass tiles which are placed adjacent to each other (horizontaly), the algo you supplied allows for a little sinking into the existing tile, which means that if I am "walking" right, the bottom right corner of finite mass AABB snags the top left corner of the tile being walked on providing for a rough jerking motion which should be smooth acceleration.

If you have any ideas how to solve this, please let me know. I tried a few hacks, for example turning off gravity when the entity is standing on a mass=0.0f ground, but non of these have proved to adequate for realistic non snagging movement.

Thanks,

Mike

Could you pass me the values of k, d, and iterations? If k and d are both 1.0 you should reach the exact solution within just one iteration, ie. the moving box is exactly touching but not overlapping the non-moving box and has a tangent velocity of exactly 0.0. Could you check if it really does that, just to make sure everything is okay? You may improve the result by applying gravity as an impulse before the solver, so it can take it into account and get rid of sinking.

Cheers,

Mike

Hi Mike,

Just heard another response from Paul. It appears I now may have to take into account something called "internal edges." He was kind enough to provide a link

http://www.wildbunny.co.uk/blog/2012/10/31/2d-polygonal-collision-detection-and-internal-edges/

I will have another look tonight at what you recommened and these internal edges.

Thanks for the help!

Mike

I don't get it. The moving body rests when sitting on two adjacent infinite masses, but doesn't when sitting on two infinite masses joined by an internal edge. It's the same thing.

I don't get it. The moving body rests when sitting on two adjacent infinite masses, but doesn't when sitting on two infinite masses joined by an internal edge. It's the same thing.

The collision detection is different, so this is 95% chance a collision detection bug.

Randy maye tell whole froum whats your problem to me and be off with stupid downvotes without any reason.

This topic is closed to new replies.

Advertisement