Elastic vs. Inelastic Collisions?

El_Guapo
Posts: 5
Joined: Sun Feb 22, 2009 2:48 am

Elastic vs. Inelastic Collisions?

Post by El_Guapo »

I was wondering if Bullet had any means of setting the elasticity of objects either on an individual or global scale or possibly spoofing the same effect.

Basically, I want two objects that can collide in zero grav without losing much if any of their energy and my current system using Bullet produces mostly inelastic collisions which drains the majority of energy out of every collision.

Is there a way to set or spoof this?

Thanks in advance.
cjcliffe
Posts: 3
Joined: Sun Feb 22, 2009 6:59 pm
Location: Kingston, Ontario

Re: Elastic vs. Inelastic Collisions?

Post by cjcliffe »

Ahoy,

In Bullet I found no 'elasticity' setting however there is a parameter known as 'restitution'. This is actually pretty simple yet it wasn't easily available as an example, here's a snippet from the rigid body setup in my own engine, it should do what you're looking for:

Code: Select all

btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo cInfo(mass,myMotionState,colShape,localInertia);		

if (restitution != 0.0)
{
	cInfo.m_additionalDamping = true; // Not sure if this is required anymore since restitution was moved from cInfo
}

mRigidBody = new btRigidBody(cInfo);

if (restitution != 0.0)
{
	mRigidBody->setRestitution(restitution);
}
else if (mass == 0)
{
	mRigidBody->setRestitution(1.0);	
}
What you may want to note is that static objects (no mass) should have a restitution of 1.0 or else there will be no 'elastic' behavior when hitting a static shape with a dynamic one with restitution (restitution result = Object1.restitution*Object2.restitution)

Hope that helps.

Cheers,
----
Charles J. Cliffe
CubicVR 3D engine (http://www.cubicvr.org)
El_Guapo
Posts: 5
Joined: Sun Feb 22, 2009 2:48 am

Re: Elastic vs. Inelastic Collisions?

Post by El_Guapo »

That should be perfect!

Thank you very much. :D