sphere not bouncing ( cant add restitution )

johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

sphere not bouncing ( cant add restitution )

Post by johnsonalpha »

broadphase = new btDbvtBroadphase();

collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
solver = new btSequentialImpulseConstraintSolver;

dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);

dynamicsWorld->setGravity(btVector3(0, -10, 0));


btCollisionShape* fallShape = new btSphereShape(25);
fallShape->calculateLocalInertia(mass, fallInertia);
btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass, fallMotionState, fallShape, fallInertia);
btRigidBody* fallRigidBody = new btRigidBody(fallRigidBodyCI);



How do i add bounce to this i tried these so far but no luck

is it fallRigidBodyCI->setRestitution(bounce); this doesnt seem to be working
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: sphere not bouncing ( cant add restitution )

Post by Flix »

I'd try the following:

1) Set a higher restitution to to the static ground body too (by default the combined restitution is the the product of the restitutions of the two bodies). [I personally use a box shape for the static floor, but that shouldn't make any difference AFAIK].
2) Reduce the sphere mass (a ball of 25 Kg shouldn't bounce that much...). [Edit:] I'm sorry it was not the mass but the ball radius (25 m!): I'd try something smaller in any case...

Not sure these can solve your issue: however in many Bullet Demos you can throw box shapes (at least in the past releases: in the "Demo/OpenGL" folder, search for a method called DemoApplication::shootBox() or something similiar) and they seem to bounce correctly. I bet that if you manage to change their shape into a sphere they'll still continue to bounce... so you should have a "template code" that works.

[Edit:] I remember an older post somewhere in this forum in which somebody asked how to prevent a shape from bouncing: maybe you can answer that :D.

P.S. I've just found two unanswered posts that might be related to the same problem:
http://www.bulletphysics.org/Bullet/php ... p+bouncing
http://www.bulletphysics.org/Bullet/php ... p+bouncing