applyForce method
Apply force to a point of the body. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.torque. @param force The amount of force to add. @param relativePoint A point relative to the center of mass to apply the force on.
Implementation
void applyForce(Vec3 force, [Vec3? relativePoint]) {
relativePoint ??= Vec3();
// Needed?
if (type != BodyTypes.dynamic) {
return;
}
if (sleepState == BodySleepStates.sleeping) {
wakeUp();
}
// Compute produced rotational force
final rotForce = _bodyApplyRotateForce;
relativePoint.cross(force, rotForce);
// Add linear force
this.force.vadd(force, this.force);
// Add rotational force
torque.vadd(rotForce, torque);
}