bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.18k stars 2.85k forks source link

`btRigidBody` with all-zero `m_linearFactor` and non-zero `m_angularFactor` will not collide with onther static objects #4579

Open JiangboYu13 opened 4 months ago

JiangboYu13 commented 4 months ago

A btRigidBody with all zero m_linearFactor but non-zero m_angularFactor should still collide with other static objects which changes the angular velocity. But due to the code in btSequentialImpulseConstraintSolver.cpp: solverBody->internalSetInvMass(btVector3(rb->getInvMass(), rb->getInvMass(), rb->getInvMass()) * rb->getLinearFactor()); in btSequentialImpulseConstraintSolver::initSolverBody and if (!solverBodyA || (solverBodyA->m_invMass.fuzzyZero() && (!solverBodyB || solverBodyB->m_invMass.fuzzyZero()))) in btSequentialImpulseConstraintSolver::convertContact the collision will not occur

bgossage commented 4 months ago

The expression: if (m_angularFactor) { ... } is always true. Looks like the compiler implicitly casts "operator btScalar *()" from pointer to bool.