src/body/RigidBody.cpp
void RigidBody::setMass(decimal mass) {

    if (mass < decimal(0.0)) {

        RP3D_LOG(mWorld.mConfig.worldName, Logger::Level::Error, Logger::Category::Body,
                 "Error when setting mass of body " + std::to_string(mEntity.id) + ": mass cannot be negative",  __FILE__, __LINE__);

        return;
    }

    mWorld.mRigidBodyComponents.setMass(mEntity, mass);

    // If it is a dynamic body
    const BodyType type = mWorld.mRigidBodyComponents.getBodyType(mEntity);
    if (type == BodyType::DYNAMIC) {

        if (mass > decimal(0.0)) {
            mWorld.mRigidBodyComponents.setMassInverse(mEntity, decimal(1.0) / mass);
        }
        else {
            mWorld.mRigidBodyComponents.setMassInverse(mEntity, decimal(0.0));

        }
    }

    RP3D_LOG(mWorld.mConfig.worldName, Logger::Level::Information, Logger::Category::Body,
             "Body " + std::to_string(mEntity.id) + ": Set mass=" + std::to_string(mass),  __FILE__, __LINE__);
}
// Set the mass of the rigid body
/// Note that a mass of zero is interpreted as infinite mass.
/**
 * @param mass The mass (in kilograms) of the body
 */
Set the mass of the rigid body
Note that a mass of zero is interpreted as infinite mass.

@param mass The mass (in kilograms) of the body
Set the mass of the rigid body Note that a mass of zero is interpreted as infinite mass . @param mass The mass ( in kilograms ) of the body
void RigidBody::setMass(decimal mass) {
    if (mass < decimal(0.0)) {
        RP3D_LOG(mWorld.mConfig.worldName, Logger::Level::Error, Logger::Category::Body,
                 "Error when setting mass of body " + std::to_string(mEntity.id) + ": mass cannot be negative",  __FILE__, __LINE__);
        return;
    }
    mWorld.mRigidBodyComponents.setMass(mEntity, mass);
    const BodyType type = mWorld.mRigidBodyComponents.getBodyType(mEntity);
    if (type == BodyType::DYNAMIC) {
        if (mass > decimal(0.0)) {
            mWorld.mRigidBodyComponents.setMassInverse(mEntity, decimal(1.0) / mass);
        }
        else {
            mWorld.mRigidBodyComponents.setMassInverse(mEntity, decimal(0.0));
        }
    }
    RP3D_LOG(mWorld.mConfig.worldName, Logger::Level::Information, Logger::Category::Body,
             "Body " + std::to_string(mEntity.id) + ": Set mass=" + std::to_string(mass),  __FILE__, __LINE__);
}
void RigidBody :: setMass ( decimal mass ) { if ( mass < decimal ( 0.0 ) ) { RP3D_LOG ( mWorld . mConfig . worldName , Logger :: Level :: Error , Logger :: Category :: Body , " " + std :: to_string ( mEntity . id ) + " " , __FILE__ , __LINE__ ) ; return ; } mWorld . mRigidBodyComponents . setMass ( mEntity , mass ) ; const BodyType type = mWorld . mRigidBodyComponents . getBodyType ( mEntity ) ; if ( type == BodyType :: DYNAMIC ) { if ( mass > decimal ( 0.0 ) ) { mWorld . mRigidBodyComponents . setMassInverse ( mEntity , decimal ( 1.0 ) / mass ) ; } else { mWorld . mRigidBodyComponents . setMassInverse ( mEntity , decimal ( 0.0 ) ) ; } } RP3D_LOG ( mWorld . mConfig . worldName , Logger :: Level :: Information , Logger :: Category :: Body , " " + std :: to_string ( mEntity . id ) + " " + std :: to_string ( mass ) , __FILE__ , __LINE__ ) ; }
Set the mass of the rigid body
Note that a mass of zero is interpreted as infinite mass.
Set the mass of the rigid body Note that a mass of zero is interpreted as infinite mass .
// If it is a dynamic body