# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Problem with restitution and small time stepsPosted: Fri Jun 15, 2012 4:51 pm

Joined: Sun Oct 30, 2011 12:33 am
Posts: 6
Hi,

I'm having a problem with restitution when using small time steps. I've modified BasicDemo.cpp to demonstrate. I'm having problems actually uploading the file, but the important lines are below There's a static box (ground), and a sphere, each with a restitution coefficient of .98. So the sphere should be pretty bouncy, but it doesn't bounce at all. If I change the internal time step from 1/1000 to 1/60 (the default), there is some bounce, but for a restitution of .98 the bounce doesn't seem high enough to me. Am I misunderstanding something?

Thanks for the help!

Code:
m_dynamicsWorld->stepSimulation(ms / 1000000.f, 10000, 1/1000.);

This line seems to be causing the problem. If I change it to
Code:
m_dynamicsWorld->stepSimulation(ms / 1000000.f, 10000, 1/60.);

the ball bounces.

Code:
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
//   btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);

m_collisionShapes.push_back(groundShape);

btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));

//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
{
btScalar mass(0.);

//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);

btVector3 localInertia(0,0,0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);

//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
body->setRestitution(.98);

//add the body to the dynamics world
}

{
//create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance

btCollisionShape* colShape = new btSphereShape(5);
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(colShape);

/// Create Dynamic Objects
btTransform startTransform;
startTransform.setIdentity();

btScalar   mass(1.f);

//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);

btVector3 localInertia(0,0,0);
if (isDynamic)
colShape->calculateLocalInertia(mass,localInertia);

startTransform.setOrigin(btVector3(5,20,5));

//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);

body->setRestitution(.98);

Top

 Post subject: Re: Problem with restitution and small time stepsPosted: Fri Jun 15, 2012 5:25 pm

Joined: Sun Oct 30, 2011 12:33 am
Posts: 6
Update: If I give the sphere a lot of downward velocity (200), then it will bounce once. So I'm assuming there's some threshold for how fast the object needs to be moving, or how much it has to penetrate, to activate restitution? But I'm not sure which threshold it is.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 8 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities