コード例 #1
0
  protected void updateActivationState(float timeStep) {
    Vector3f tmp = Stack.alloc(Vector3f.class);

    for (int i = 0; i < collisionObjects.size(); i++) {
      CollisionObject colObj = collisionObjects.getQuick(i);
      RigidBody body = RigidBody.upcast(colObj);
      if (body != null) {
        body.updateDeactivation(timeStep);

        if (body.wantsSleeping()) {
          if (body.isStaticOrKinematicObject()) {
            body.setActivationState(CollisionObject.ISLAND_SLEEPING);
          } else {
            if (body.getActivationState() == CollisionObject.ACTIVE_TAG) {
              body.setActivationState(CollisionObject.WANTS_DEACTIVATION);
            }
            if (body.getActivationState() == CollisionObject.ISLAND_SLEEPING) {
              tmp.set(0f, 0f, 0f);
              body.setAngularVelocity(tmp);
              body.setLinearVelocity(tmp);
            }
          }
        } else {
          if (body.getActivationState() != CollisionObject.DISABLE_DEACTIVATION) {
            body.setActivationState(CollisionObject.ACTIVE_TAG);
          }
        }
      }
    }
  }
コード例 #2
0
 protected void saveKinematicState(float timeStep) {
   for (int i = 0; i < collisionObjects.size(); i++) {
     CollisionObject colObj = collisionObjects.getQuick(i);
     RigidBody body = RigidBody.upcast(colObj);
     if (body != null) {
       // Transform predictedTrans = new Transform();
       if (body.getActivationState() != CollisionObject.ISLAND_SLEEPING) {
         if (body.isKinematicObject()) {
           // to calculate velocities next frame
           body.saveKinematicState(timeStep);
         }
       }
     }
   }
 }