Bullet and Kinematic RigidBody issue?


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.


public void setKinematic(boolean kinematic) {
    this.kinematic = kinematic;
    if (kinematic) {
        rBody.setCollisionFlags(rBody.getCollisionFlags() | CollisionFlags.KINEMATIC_OBJECT);  
    } else {
        rBody.setCollisionFlags(rBody.getCollisionFlags() & ~CollisionFlags.KINEMATIC_OBJECT);

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.


:+1: Nice find!