Dynamic btHeightfieldTerrainShape causing jittered collision

Post Reply
User avatar
Dave13h
Posts: 6
Joined: Tue Oct 13, 2015 8:43 am

Dynamic btHeightfieldTerrainShape causing jittered collision

Post by Dave13h »

Hey all,

I'm using a btHeightfieldTerrainShape, I'm animating it each frame with a simple sin() and having it affect a btConvexHullShape -> btRigidBody. It seems to be causing a lot of jittering if the rigidbody is resting on it at larger values. I'm using CCD but that doesn't seem to be helping much, any advice?

It looks like the wave is moving up through the rigidbody then the rigidbody is moving a lot to correct the penetration rather than smoothly moving with it?

Looks like this - http://gfycat.com/WindyZigzagBallpython

On bits where the terrain doesn't move its nice and solid - http://gfycat.com/ObedientKindCollie

I'm updating the data that is passed into the 3rd argument of btHeightfieldTerrainShape(), I'm not recreating the btHeightfieldTerrainShape each time if that makes any difference?

Cheers
Dave
d3x0r
Posts: 51
Joined: Tue Dec 11, 2012 9:59 pm

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Post by d3x0r »

I had similar issues with just a ball colliding with a fixed surface; that the correcting impulse seemed to be much larger than one would expect.

The engine I'm sure isn't doing anything other than realizing that the thing has collided and generating a impulse to push it away.

1) does it change if you change the mass?
2) was thinking about making a test case that starts with a body near, on and in another ground body at various depths and seeing how much the various bodies react in one frame...
User avatar
Dave13h
Posts: 6
Joined: Tue Oct 13, 2015 8:43 am

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Post by Dave13h »

I think I've narrowed down the issue...

At the time of generating the initial heightmap I had tightly clamp the min, max of it. During the animation of it the wave can go outside of that min/max. I've added some padding and it seems to behave much better now, I just need to clean it up and properly calculate the possible min/max now.

http://gfycat.com/ClumsyBareBrahmancow
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Post by xexuxjy »

That still seems a little bit 'bouncy' for what doesn't seem like much deflection in the height field.
Have you tried playing with restitution for you ship a bit ? might get things a little smoother.
User avatar
Dave13h
Posts: 6
Joined: Tue Oct 13, 2015 8:43 am

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Post by Dave13h »

Yeah it is still not quite right, could be because I just bodged in some numbers to pad the min/max and I've not really calculated what it really could be. I'll do that properly tonight (perhaps try and visualise the AABB too, could be useful) and also look at the restitution too (currently its set to 0.1), cheers for the pointer, I hadn't considered that.
User avatar
Dave13h
Posts: 6
Joined: Tue Oct 13, 2015 8:43 am

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Post by Dave13h »

Yay, all sorted now...

http://gfycat.com/DisgustingNeglectedFieldmouse

The min/max of the btHeightfieldTerrainShape is properly calculated and the origin is correctly set. Then the other thing was that some times the ship rigidbody would go to sleep, so making sure that is active when on the moving ground helps. :)
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Post by xexuxjy »

Yay, that looks much better :)
Post Reply