btRigidBody angular factor

Post Reply
rrck
Posts: 26
Joined: Mon Sep 21, 2009 7:30 am

btRigidBody angular factor

Post by rrck »

Hello,

I noticed some code in btRigidBody, which I can't understand. In applyImpulse() functions there is such code:

Code: Select all

if (m_angularFactor){...}
After last rbtRigidBody changes m_angularFactor become btVector3. I debug that code and it seems that btScalar*() operator is called in that if. Is that supposed behaviour? Sorry may be I don't understand something.
Jasonrun
Posts: 11
Joined: Fri Oct 30, 2009 7:44 pm
Contact:

Re: btRigidBody angular factor

Post by Jasonrun »

As far as I can tell is that this is simply checking to make sure that the angular factor is not a null pointer before continuing.
rrck
Posts: 26
Joined: Mon Sep 21, 2009 7:30 am

Re: btRigidBody angular factor

Post by rrck »

Jasonrun wrote:As far as I can tell is that this is simply checking to make sure that the angular factor is not a null pointer before continuing.
But m_angularFactor is btVector3 (in previous Bullet versions it was btSalar) and not pointer. If I properly understand angular factor purpose, maybe code should be something like:

Code: Select all

if (m_angularFactor.len2() > 0)
 {
    do something with body angular vel
}
Or I'm wrong?
Jasonrun
Posts: 11
Joined: Fri Oct 30, 2009 7:44 pm
Contact:

Re: btRigidBody angular factor

Post by Jasonrun »

I suppose it just depends on the purpose of the check. If it's to save some computation then you are probably correct. If it's just to protect against bad data then m_angularFactor.length2()==0 is still valid data. I'm not sure how it might get set to null though, but maybe it was a concern at some point?
Post Reply