How can I make balls not to stick to wall?

drawtree
Posts: 7
Joined: Sat May 07, 2011 2:02 am

How can I make balls not to stick to wall?

Post by drawtree »

(I'm cross-posting this stackoverflow/box2d/bulletphysics forums.)

----

I'm making a pool game like game which needs exact bounces.
But something like this happens when I tested my configuration.


Image


If there is a wall on top of this image, red line is regular course of the regular pool game. But the engine shows green line course so often. Especially,

1. This happens after a ball moving slowly hits the wall.
2. Sometimes a ball moving fast get slower suddenly.

I know the green line course can be happen in real pool game, but it should be rarely. The problem is it happens too often. Finally, most of balls stick to walls, only a few balls are remain in center.

At first, I understood this as limitation of engine by approximation for performance. So I asked another engine in stackoverflow.com. But people said this is problem of configuration. I tried many configurations over few days, but I couldn't find solution.

----

In Box2D forum, Erin Catto said me there's a configuration setting and I solved this in Box2D by setting b2_velocityThreshold in b2Settings.h file.
http://www.box2d.org/forum/viewtopic.ph ... 782#p30782

I believe something equivalent should be in Bullet too. Can I know where it is?

----

I attach my current configuration:

Walls

Code: Select all

				wallBody->setFriction(0.0f);
				wallBody->setRestitution(1.0f);
				wallBody->setDamping(0.01f, 0.01f);
				wallBody->setContactProcessingThreshold(0.1f);
				wallBody->setHitFraction(0.01f);
				world->addRigidBody(wallBody);	
Balls

Code: Select all

			body->setFriction(0.0f);
			body->setRestitution(1.0f);
			body->setDamping(0.01f, 0.01f);
			body->setHitFraction(0.01f);
			body->setSleepingThresholds(0.1f, 0.1f);
			body->setContactProcessingThreshold(0.1f);