Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Jun 15, 2012 4:51 pm 
Offline

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
      m_dynamicsWorld->addRigidBody(body);
   }


   {
      //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);

    m_dynamicsWorld->addRigidBody(body);


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 5:25 pm 
Offline

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 3 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group