Using particle physics with rigid bodies

Adversus
Posts: 19
Joined: Mon Nov 10, 2008 11:24 am

Using particle physics with rigid bodies

Post by Adversus »

Is there a way to turn off the angular momentum part of bullet for Rigid Bodies so they behave like particles except have non-spherical collision shapes?
IGDbonbon
Posts: 5
Joined: Sun Aug 03, 2008 7:31 am

Re: Using particle physics with rigid bodies

Post by IGDbonbon »

Hi,
you can body->setAngularFactor(0); then the body will not receive torque force...

if you use SIMD, which is msvc and 32bit only.
you also need to fix the code in btSequentialImpulseConstraintSolver.cpp
btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimitSIMD()
and
btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD()

find and change:

body1.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body1.m_deltaAngularVelocity.mVec128 ,
_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude));

to:

body1.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body1.m_deltaAngularVelocity.mVec128 ,
_mm_mul_ps(c.m_angularComponentA.mVec128,_mm_mul_ps(impulseMagnitude,_mm_set1_ps(body1.m_angularFactor))));

and the same for body2, in both functions.

the original code in v2.73 ignored m_angularFactor. so the body will roll...
Adversus
Posts: 19
Joined: Mon Nov 10, 2008 11:24 am

Re: Using particle physics with rigid bodies

Post by Adversus »

Thanks that worked great,