Page 1 of 1

Dynamic btHeightfieldTerrainShape causing jittered collision

Posted: Tue Oct 13, 2015 9:05 am
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

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Posted: Thu Oct 15, 2015 12:35 am
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...

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Posted: Thu Oct 15, 2015 9:40 am
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

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Posted: Thu Oct 15, 2015 10:53 am
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.

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Posted: Thu Oct 15, 2015 1:55 pm
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.

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Posted: Fri Oct 16, 2015 12:20 pm
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. :)

Re: Dynamic btHeightfieldTerrainShape causing jittered colli

Posted: Fri Oct 16, 2015 1:52 pm
by xexuxjy
Yay, that looks much better :)