Fixing "Hopping" - Rolling Sphere Collision

Post Reply
Xenoprimate
Posts: 14
Joined: Fri Jun 26, 2015 4:59 pm

Fixing "Hopping" - Rolling Sphere Collision

Post by Xenoprimate » Wed Feb 08, 2017 8:45 am

Hey guys, I'm having an issue where occasionally while rolling a ball along a surface, the ball "hops"/skips in to the air as though it's 'caught' on something invisible- even though the underlying surface is often a straight flat one.

I made a GFYCAT to demonstrate the issue: https://gfycat.com/GrandBetterCuscus - Hopefully you can see what I'm talking about, the ball will occasionally 'fly up' in to the air even though there is nothing (visible or invisible) to warrant that.

So of course here are some details about my simulation:

Ball
Shape type: btSphereShape
Radius: 4.0f
Mass: 1.0f
Restitution: 0.1f
CCD enabled (0.5f min speed, 0.04f radius)

Floors
Shape type: Mixed, but usually btBoxShape
Collision Flags: result->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT
Restitution: 1.0f
Mass: 1000.0f

World / Simulation
Gravity: [0.0f, -490.50f, 0.0f]
Internal tickrate: 1000.0f

I also tried messing with the "split impulse" options:

Code: Select all

btContactSolverInfo& contactSolver = dynamicsWorld->getSolverInfo();
contactSolver.m_numIterations = 750;
contactSolver.m_splitImpulse = 1;
contactSolver.m_splitImpulsePenetrationThreshold = -0.02f;
But it hasn't made any difference.

I *think* that making the difference in masses (1000.0f vs 1.0f) less huge makes a difference, but then the ball easily flies *through* some geometry, even with CCD enabled?

Really open to any and all ideas here, thank you all in advance. I will of course provide any extra information that you feel might be relevant.

ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Fixing "Hopping" - Rolling Sphere Collision

Post by ktfh » Wed Feb 08, 2017 5:30 pm

kinematic objects are massless so the difference between the objects shouldn't matter.

It looks possible that the ball intersects the ground between frames and a large vertical force is added to correct this. Also your simulation rate and gravity seem very large, earth gravity is like -10.f and most games run around 60hz.

Xenoprimate
Posts: 14
Joined: Fri Jun 26, 2015 4:59 pm

Re: Fixing "Hopping" - Rolling Sphere Collision

Post by Xenoprimate » Thu Feb 09, 2017 11:21 am

ktfh wrote:It looks possible that the ball intersects the ground between frames and a large vertical force is added to correct this.
This is my thinking too- hence trying "split impulse", but to no effect.
ktfh wrote:Also your simulation rate and gravity seem very large, earth gravity is like -10.f and most games run around 60hz.
My gravity is quite large but that's because my game treats 50.0f as one metre. 50.0f * 9.81f gets 490.50f. The simulation rate is so high because I found that a higher tickrate reduces the frequency with which this bug occurs.

DannyChapman
Posts: 85
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: Fixing "Hopping" - Rolling Sphere Collision

Post by DannyChapman » Thu Feb 09, 2017 4:04 pm

This can (will) happen if the ball hits internal edges in the surface it's rolling on. Difficult to tell from the video if that's the case as we'd need to see the collision shapes.

Certainly if you have two boxes, A and B, next to each other with their top surfaces in the same plane, then as a ball rolls on the top of box A towards box B, as it goes over the invisible/internal edge, Bullet will detect that as a collision and kick the ball into the air - just like you're seeing.

The same will happen even if the shape is a mesh - internal triangle edges will register as collisions.

For a mesh you can prevent this happening - don't have the details with me now, but search the forum.

It may be harder if your world is made up of boxes that are next to each other, since there's no connectivity information there. You might find a way to do it though, if you look at how it's done with meshes. Alternatively, perhaps you can make your world out of meshes instead?

Xenoprimate
Posts: 14
Joined: Fri Jun 26, 2015 4:59 pm

Re: Fixing "Hopping" - Rolling Sphere Collision

Post by Xenoprimate » Thu Feb 09, 2017 6:04 pm

Thanks for the reply Danny.

Unfortunately the geometry in the video is one whole piece and is defined as a btBoxShape, not a mesh. Still, interesting to hear that meshes can exhibit that behaviour- I'll keep that in mind.

Post Reply