updatePosition method

void updatePosition(
  1. double timeStep
)

The time integration of the motion of a rigid body, you can update the information such as the shape. This method is invoked automatically when calling the step of the World, There is no need to call from outside usually.

Implementation

void updatePosition(double timeStep) {
  switch(type){
    case RigidBodyType.static:
      linearVelocity.set(0,0,0);
      angularVelocity.set(0,0,0);
      break;
    case RigidBodyType.dynamic:
      position.addScaledVector(linearVelocity, timeStep.toDouble());
      if(fixedRotation){
        angularVelocity.set(0,0,0);
      }
      else{
        orientation.addTime(angularVelocity, timeStep.toDouble());
      }
      break;
    case RigidBodyType.kinematic:
      // linearVelocity.set(0,0,0);
      if(fixedRotation){
        angularVelocity.set(0,0,0);
      }
      else{
        orientation.addTime(angularVelocity, timeStep.toDouble());
      }
      position.addScaledVector(linearVelocity, timeStep.toDouble());
      break;
    default: printError("RigidBody", "Invalid type.");
  }

  syncShapes();
}