BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
{
    // Skip if disabled globally.
    if (!gSavedSettings.getBOOL("AvatarPhysics"))
    {
        return TRUE;
    }

    BOOL update_visuals = FALSE;
    for (motion_vec_t::iterator iter = mMotions.begin();
            iter != mMotions.end();
            ++iter)
    {
        LLPhysicsMotion *motion = (*iter);
        update_visuals |= motion->onUpdate(time);
    }

    if (update_visuals)
        mCharacter->updateVisualParams();

    return TRUE;
}
BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
{
        // Skip if disabled globally.
		static const LLCachedControl<bool> avatar_physics("AvatarPhysics",false);
		bool supports_physics = !avatar_physics || (!((LLVOAvatar*)mCharacter)->isSelf() && !((LLVOAvatar*)mCharacter)->mSupportsPhysics);
		//Treat lod 0 as AvatarPhyiscs:FALSE. AvatarPhyiscs setting is superfluous unless we decide to hook it into param sending.
        if (supports_physics || !LLVOAvatar::sPhysicsLODFactor)
        {
			if(!mIsDefault)
			{
				mIsDefault = true;
				for (motion_vec_t::iterator iter = mMotions.begin();iter != mMotions.end();++iter)
				{
					(*iter)->reset();
				}
				mCharacter->updateVisualParams();
			}
			if(!supports_physics) //Only use emerald physics if avatarphysiscs is really off, or the client doesn't seem to support new physics.
			((LLVOAvatar*)mCharacter)->idleUpdateBoobEffect(); //Fall back to emerald physics	
			return TRUE;
		}
        
		mIsDefault = false;

        BOOL update_visuals = FALSE;
        for (motion_vec_t::iterator iter = mMotions.begin();
             iter != mMotions.end();
             ++iter)
        {
                LLPhysicsMotion *motion = (*iter);
                update_visuals |= motion->onUpdate(time);
        }
                
        if (update_visuals)
                mCharacter->updateVisualParams();
        
        return TRUE;
}
BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
{
        // Skip if disabled globally.
		static LLCachedControl<bool> avatar_physics(gSavedSettings, "AvatarPhysics");
        if (!avatar_physics || (!((LLVOAvatar*)mCharacter)->isSelf() && !((LLVOAvatar*)mCharacter)->mSupportsPhysics))
        {
			if(!mIsDefault)
			{
				mIsDefault = true;
				for (motion_vec_t::iterator iter = mMotions.begin();iter != mMotions.end();++iter)
				{
					(*iter)->reset();
				}
				mCharacter->updateVisualParams();
			}
#ifdef OLD_BREAST_PHYSICS
			((LLVOAvatar*)mCharacter)->idleUpdateBoobEffect(); //Fall back to emerald physics	
#endif
			return TRUE;
		}
        
		mIsDefault = false;

        BOOL update_visuals = FALSE;
        for (motion_vec_t::iterator iter = mMotions.begin();
             iter != mMotions.end();
             ++iter)
        {
                LLPhysicsMotion *motion = (*iter);
                update_visuals |= motion->onUpdate(time);
        }
                
        if (update_visuals)
                mCharacter->updateVisualParams();
        
        return TRUE;
}