# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Problem to adjust collision behaviourPosted: Tue May 08, 2012 3:04 pm

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);
mySequentialImpulseConstraintSolver = new btSequentialImpulseConstraintSolver();
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
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

* 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.

PS : sorry for my english

Top

 Post subject: Re: Problem to adjust collision behaviourPosted: Tue May 08, 2012 6:47 pm

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

 Post subject: Re: Problem to adjust collision behaviourPosted: Tue May 08, 2012 7:32 pm

Joined: Tue May 08, 2012 2:46 pm
Posts: 3
I precise that the second code posted iterates 5 times, one for sphereShape and 4 for boxshape.

Top

 Post subject: Re: Problem to adjust collision behaviourPosted: Wed May 09, 2012 7:52 pm

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

 Post subject: Re: Problem to adjust collision behaviourPosted: Thu May 10, 2012 12:30 pm

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

 Post subject: Re: Problem to adjust collision behaviourPosted: Sun May 13, 2012 8:15 am

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 318
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

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

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 3 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