Hello,
I want to use Bullet for my game. I need to set a Spatial kinematic and then set it back to dynamic.
Setting to kinematic and back work just fine. The issue I discovered is that after setting/remove the RigidBody stays in “active” mode forever and never falls to “sleep”.
I’ve digged into the code of jBullet and bullet-native and I have found the lines of code causing this issue.
PhysicsRigidBody.class
public void setKinematic(boolean kinematic) {
this.kinematic = kinematic;
if (kinematic) {
rBody.setCollisionFlags(rBody.getCollisionFlags() | CollisionFlags.KINEMATIC_OBJECT);
rBody.setActivationState(com.bulletphysics.collision.dispatch.CollisionObject.DISABLE_DEACTIVATION);
} else {
rBody.setCollisionFlags(rBody.getCollisionFlags() & ~CollisionFlags.KINEMATIC_OBJECT);
rBody.setActivationState(com.bulletphysics.collision.dispatch.CollisionObject.ACTIVE_TAG);
}
}
CollisionObject.java (rBody)
public void setActivationState(int newState) {
if ((activationState1 != DISABLE_DEACTIVATION) && (activationState1 != DISABLE_SIMULATION)) {
this.activationState1 = newState;
}
}
If DISABLE_DEACTIVATION is set. It will never be changed to ACTIVE_TAG.
I’ve fixed it locally and created a pull request.