Bug in btRigidBody::applyImpulse's use of m_linearFactor?

DavidSmith
Posts: 2
Joined: Fri May 11, 2012 4:13 pm

Bug in btRigidBody::applyImpulse's use of m_linearFactor?

Post by DavidSmith »

If I have an object with a linear factor of (0,0,0) and an angular factor of (1,1,1), I'd expect an impulse applied to this object to cause it to rotate (unless the impulse is aimed directly at the objects centre of mass).
But the impulse is scaled by the linear factor before being appllied as a torque impulse, which means that the object currently fails to rotate. :(

I have locally fixed this by going into this function:
btRigidBody::applyImpulse
And changing this line:
applyTorqueImpulse(rel_pos.cross(impulse*m_linearFactor));
To this:
applyTorqueImpulse(rel_pos.cross(impulse));

I'd be interested in knowing if this is indeed a bug, or I am misunderstanding the meaning of the m_linearFactor variable.
Thanks! :)
User avatar
jarno
Posts: 57
Joined: Tue Mar 16, 2010 1:42 am

Re: Bug in btRigidBody::applyImpulse's use of m_linearFactor

Post by jarno »

It does look like the code is a bit confused about whether the linear factor is a scale factor that is applied to the forces/impulses acting on the body, or only on that part that induces a linear motion.

Usually the linear factor isn't changed from its default of (1,1,1), in which case it isn't an issue. To prevent a body from moving linearly a constraint would be used instead, which has the advantage of preserving the energy of the system (unlike scaling the forces to 0).

---JvdL---
DavidSmith
Posts: 2
Joined: Fri May 11, 2012 4:13 pm

Re: Bug in btRigidBody::applyImpulse's use of m_linearFactor

Post by DavidSmith »

Thanks for the reply :)
For my purposes, I'm not worried about a loss of energy if it gives me higher stability and performance than using a constraint (and less code to write!).
It sounds like it's probably just a bit buggy (or inconsistent) due to being rarely used.
cadabra
Posts: 3
Joined: Thu May 10, 2012 4:51 am
Location: sfbay

Re: Bug in btRigidBody::applyImpulse's use of m_linearFactor

Post by cadabra »