Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue May 08, 2012 3:04 pm 
Offline

Joined: Tue May 08, 2012 2:46 pm
Posts: 3
Hi everybody,
i don't find a concrete answer in this forum, so i ask my question here.
I have a sphere and a shape body. only the sphere is dynamic (i.e. mass !=0)

i initialize my physic word with :
Code:
   myCollisionConfiguration = new btDefaultCollisionConfiguration();
   myDispatcher = new   btCollisionDispatcher(myCollisionConfiguration);
   myBroadphase = new btDbvtBroadphase();
   mySequentialImpulseConstraintSolver = new btSequentialImpulseConstraintSolver();
   myWorld = new btDiscreteDynamicsWorld(myDispatcher,myBroadphase,mySequentialImpulseConstraintSolver,myCollisionConfiguration);
   myWorld->getSolverInfo().m_splitImpulse = true;
   myWorld->setGravity( btVector3(0.0,0.0,0.0) );


and initialize my object with :
Code:
btCollisionShape* shape;
   if (m_shape=="sphere")
   {
      shape = new btSphereShape(btVector3(m_size.x,m_size.y,m_size.z).length()/3.0);
   }
   else
   {
      shape = new btBoxShape(btVector3(m_size.x,m_size.y,m_size.z));
   }
   //shape->setMargin(0.3f);
   m_transform.setIdentity();

   //get the intial position of the object
   FCgetPosition f; /* ... */
   m_transform.setOrigin( btVector3(f.position.x,f.position.y,f.position.z) );

   //On calcule l'inertie suivant le poids.
   btVector3 localInertia(m_localInertia.x,m_localInertia.y,m_localInertia.z);

   if (m_mass)
      shape->calculateLocalInertia( m_mass, localInertia );
   m_motionState = new btDefaultMotionState(m_transform);
   btRigidBody::btRigidBodyConstructionInfo myBoxRigidBodyConstructionInfo( m_mass, m_motionState, shape, localInertia );
   myBoxRigidBodyConstructionInfo.m_friction=0.0f;
   myBoxRigidBodyConstructionInfo.m_restitution=0.9f;
   m_body = new btRigidBody(myBoxRigidBodyConstructionInfo);
   m_body->setLinearFactor(btVector3(1.0,1.0,0.0));
   m_body->setAngularFactor(btVector3(0.0,0.0,0.0));
   //reference to the physic bullet world
   PHYSIC->getWorld()->addRigidBody(m_body);
   m_body->setLinearVelocity(btVector3(5,15,0));


my scene is one ball in center of 4 box which build borders like in a pool.

My problem is when ball collide with borders : the ball stick on the box. I don't success to adjust the collision to have a "classic" bounce, like in pool but with a total restitution of the velocity after the collision

I follow many pist :

* the margin of the body ( if too higher, the ball go through the border)
* to add "myWorld->getSolverInfo().m_splitImpulse = true;" : nothing change
* adjust contact threshold : nothing change
* i read somewhere to switch continous detection to off, but i've don't find something like that in the API

If someone has some advices or ways of reflexion,
feel free to share it.

Thanks in advance
PS : sorry for my english


Top
 Profile  
 
PostPosted: Tue May 08, 2012 6:47 pm 
Offline

Joined: Mon Jul 19, 2010 3:11 am
Posts: 49
have you set restitution value to four bounding boxes?
bullet seems to calculate collision restitution value like min(body1_restitution,body2_restitution)

edit: ok i see now that you did that


Top
 Profile  
 
PostPosted: Tue May 08, 2012 7:32 pm 
Offline

Joined: Tue May 08, 2012 2:46 pm
Posts: 3
Thanks for reply. i didn't know that restitution factor was added.
I precise that the second code posted iterates 5 times, one for sphereShape and 4 for boxshape.


Top
 Profile  
 
PostPosted: Wed May 09, 2012 7:52 pm 
Offline

Joined: Mon Jul 19, 2010 3:11 am
Posts: 49
I know that is not what you want, but can you change sphere shape to box shape and see if problem with restitution still occurs?


Top
 Profile  
 
PostPosted: Thu May 10, 2012 12:30 pm 
Offline

Joined: Tue May 08, 2012 2:46 pm
Posts: 3
i try with only box shape, and it does the same.
if you have any other test ideas, i would greatly appreciated them ;)
I don't have any ideas of making this works


Top
 Profile  
 
PostPosted: Sun May 13, 2012 8:15 am 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 394
I'd probably override the method that Bullet uses to calculate global friction/restitution values through a custom material callback and play around with the values a bit (AFAIK by default the combined friction/restitution is calculated by multiplying the friction/restitution of the two bodies, and probably the result is clamped to 0-1). You might try a linear combination of the values instead (with or without clamping). If you don't know how to do it, please browse the forum, or look closely at the Bullet demos (I'm sure some demo uses it).

Split impulse might probably help.

If there's no improvement you may try replacing the btSphereShape with a btMultisphereShape (with a single sphere inside it): in some (rare) cases somebody reported they behave better.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 10 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