src/body/RigidBody.cpp
void RigidBody::applyWorldForceAtWorldPosition(const Vector3& force, const Vector3& point) {

    // If it is not a dynamic body, we do nothing
    if (mWorld.mRigidBodyComponents.getBodyType(mEntity) != BodyType::DYNAMIC) return;

    // Awake the body if it was sleeping
    if (mWorld.mRigidBodyComponents.getIsSleeping(mEntity)) {
        setIsSleeping(false);
    }

    // Add the force
    const Vector3& externalForce = mWorld.mRigidBodyComponents.getExternalForce(mEntity);
    mWorld.mRigidBodyComponents.setExternalForce(mEntity, externalForce + force);

    // Add the torque
    const Vector3& externalTorque = mWorld.mRigidBodyComponents.getExternalTorque(mEntity);
    const Vector3& centerOfMassWorld = mWorld.mRigidBodyComponents.getCenterOfMassWorld(mEntity);
    mWorld.mRigidBodyComponents.setExternalTorque(mEntity, externalTorque + (point - centerOfMassWorld).cross(force));
}
// Manually apply an external force (in world-space) to the body at a given point (in world-space).
/// If the point is not at the center of mass of the body, it will also
/// generate some torque and therefore, change the angular velocity of the body.
/// If the body is sleeping, calling this method will wake it up. Note that the
/// force will we added to the sum of the applied forces and that this sum will be
/// reset to zero at the end of each call of the PhyscisWorld::update() method.
/// You can only apply a force to a dynamic body otherwise, this method will do nothing.
/**
 * @param force The force (in world-space) to apply on the body (in Newtons)
 * @param point The point where the force is applied (in world-space)
 */
Manually apply an external force (in world-space) to the body at a given point (in world-space).
If the point is not at the center of mass of the body, it will also
generate some torque and therefore, change the angular velocity of the body.
If the body is sleeping, calling this method will wake it up. Note that the
force will we added to the sum of the applied forces and that this sum will be
reset to zero at the end of each call of the PhyscisWorld::update() method.
You can only apply a force to a dynamic body otherwise, this method will do nothing.

@param force The force (in world-space) to apply on the body (in Newtons)
@param point The point where the force is applied (in world-space)
Manually apply an external force ( in world - space ) to the body at a given point ( in world - space ) . If the point is not at the center of mass of the body it will also generate some torque and therefore change the angular velocity of the body . If the body is sleeping calling this method will wake it up . Note that the force will we added to the sum of the applied forces and that this sum will be reset to zero at the end of each call of the PhyscisWorld :: update () method . You can only apply a force to a dynamic body otherwise this method will do nothing . @param force The force ( in world - space ) to apply on the body ( in Newtons ) @param point The point where the force is applied ( in world - space )
void RigidBody::applyWorldForceAtWorldPosition(const Vector3& force, const Vector3& point) {
    if (mWorld.mRigidBodyComponents.getBodyType(mEntity) != BodyType::DYNAMIC) return;
    if (mWorld.mRigidBodyComponents.getIsSleeping(mEntity)) {
        setIsSleeping(false);
    }
    const Vector3& externalForce = mWorld.mRigidBodyComponents.getExternalForce(mEntity);
    mWorld.mRigidBodyComponents.setExternalForce(mEntity, externalForce + force);
    const Vector3& externalTorque = mWorld.mRigidBodyComponents.getExternalTorque(mEntity);
    const Vector3& centerOfMassWorld = mWorld.mRigidBodyComponents.getCenterOfMassWorld(mEntity);
    mWorld.mRigidBodyComponents.setExternalTorque(mEntity, externalTorque + (point - centerOfMassWorld).cross(force));
}
void RigidBody :: applyWorldForceAtWorldPosition ( const Vector3 & force , const Vector3 & point ) { if ( mWorld . mRigidBodyComponents . getBodyType ( mEntity ) != BodyType :: DYNAMIC ) return ; if ( mWorld . mRigidBodyComponents . getIsSleeping ( mEntity ) ) { setIsSleeping ( false ) ; } const Vector3 & externalForce = mWorld . mRigidBodyComponents . getExternalForce ( mEntity ) ; mWorld . mRigidBodyComponents . setExternalForce ( mEntity , externalForce + force ) ; const Vector3 & externalTorque = mWorld . mRigidBodyComponents . getExternalTorque ( mEntity ) ; const Vector3 & centerOfMassWorld = mWorld . mRigidBodyComponents . getCenterOfMassWorld ( mEntity ) ; mWorld . mRigidBodyComponents . setExternalTorque ( mEntity , externalTorque + ( point - centerOfMassWorld ) . cross ( force ) ) ; }
Manually apply an external force (in world-space) to the body at a given point (in world-space).
Manually apply an external force ( in world - space ) to the body at a given point ( in world - space ) .
// If it is not a dynamic body, we do nothing // Awake the body if it was sleeping // Add the force // Add the torque