Commit 82026aba authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Cleanup member shadowing and add a nullcheck to motion classes

parent 61dd419f
......@@ -71,6 +71,9 @@ LLEditingMotion::LLEditingMotion( const LLUUID &id) : LLMotion(id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
// save character for future use
mCharacter = character;
......
......@@ -80,6 +80,9 @@ LLHandMotion::LLHandMotion(const LLUUID &id) : LLMotion(id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLHandMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
return STATUS_SUCCESS;
......
......@@ -89,6 +89,7 @@ LLMotion::LLMotionInitStatus LLHeadRotMotion::onInitialize(LLCharacter *characte
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
mPelvisJoint = character->getJoint("mPelvis");
......@@ -289,6 +290,9 @@ LLEyeMotion::LLEyeMotion(const LLUUID &id) : LLMotion(id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLEyeMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
mHeadJoint = character->getJoint("mHead");
......
......@@ -46,7 +46,6 @@
LLKeyframeFallMotion::LLKeyframeFallMotion(const LLUUID &id) : LLKeyframeMotion(id)
{
mVelocityZ = 0.f;
mCharacter = nullptr;
}
//-----------------------------------------------------------------------------
......@@ -54,11 +53,12 @@ LLKeyframeFallMotion::LLKeyframeFallMotion(const LLUUID &id) : LLKeyframeMotion(
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLKeyframeFallMotion::onInitialize(LLCharacter *character)
{
// save character pointer for later use
mCharacter = character;
// load keyframe data, setup pose and joint states
LLMotion::LLMotionInitStatus result = LLKeyframeMotion::onInitialize(character);
if (result == STATUS_FAILURE)
{
return result;
}
for (U32 jm=0; jm<mJointMotionList->getNumJointMotions(); jm++)
{
......
......@@ -68,7 +68,6 @@ protected:
//-------------------------------------------------------------------------
// Member Data
//-------------------------------------------------------------------------
LLCharacter* mCharacter;
F32 mVelocityZ;
LLPointer<LLJointState> mPelvisState;
LLQuaternion mRotationToGroundNormal;
......
......@@ -430,6 +430,9 @@ LLJoint* LLKeyframeMotion::getJoint(U32 index)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
LLUUID* character_id;
......
......@@ -48,7 +48,6 @@ const F32 POSITION_THRESHOLD = 0.1f;
LLKeyframeStandMotion::LLKeyframeStandMotion(const LLUUID &id) : LLKeyframeMotion(id)
{
mFlipFeet = FALSE;
mCharacter = nullptr;
// create kinematic hierarchy
mPelvisJoint.addChild( &mHipLeftJoint );
......@@ -78,9 +77,6 @@ LLKeyframeStandMotion::LLKeyframeStandMotion(const LLUUID &id) : LLKeyframeMotio
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLKeyframeStandMotion::onInitialize(LLCharacter *character)
{
// save character pointer for later use
mCharacter = character;
mFlipFeet = FALSE;
// load keyframe data, setup pose and joint states
......
......@@ -69,8 +69,6 @@ public:
//-------------------------------------------------------------------------
// Member Data
//-------------------------------------------------------------------------
LLCharacter *mCharacter;
BOOL mFlipFeet;
LLPointer<LLJointState> mPelvisState;
......
......@@ -54,7 +54,6 @@ const F32 SPEED_ADJUST_TIME_CONSTANT = 0.1f; // time constant for speed adjustm
//-----------------------------------------------------------------------------
LLKeyframeWalkMotion::LLKeyframeWalkMotion(const LLUUID &id)
: LLKeyframeMotion(id),
mCharacter(nullptr),
mCyclePhase(0.0f),
mRealTimeLast(0.0f),
mAdjTimeLast(0.0f),
......@@ -66,8 +65,6 @@ LLKeyframeWalkMotion::LLKeyframeWalkMotion(const LLUUID &id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLKeyframeWalkMotion::onInitialize(LLCharacter *character)
{
mCharacter = character;
return LLKeyframeMotion::onInitialize(character);
}
......@@ -148,6 +145,9 @@ LLWalkAdjustMotion::LLWalkAdjustMotion(const LLUUID &id) :
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLWalkAdjustMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
mLeftAnkleJoint = mCharacter->getJoint("mAnkleLeft");
mRightAnkleJoint = mCharacter->getJoint("mAnkleRight");
......@@ -338,6 +338,9 @@ LLFlyAdjustMotion::LLFlyAdjustMotion(const LLUUID &id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
LLJoint* pelvisJoint = mCharacter->getJoint("mPelvis");
......
......@@ -73,7 +73,6 @@ public:
//-------------------------------------------------------------------------
// Member Data
//-------------------------------------------------------------------------
LLCharacter *mCharacter;
F32 mCyclePhase;
F32 mRealTimeLast;
F32 mAdjTimeLast;
......
......@@ -767,8 +767,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
void LLMotionController::updateLoadingMotions()
{
// query pending motions for completion
for (auto iter = mLoadingMotions.begin();
iter != mLoadingMotions.end(); )
for (auto iter = mLoadingMotions.begin(), end = mLoadingMotions.end();
iter != end; )
{
auto curiter = iter++;
LLMotion* motionp = *curiter;
......
......@@ -61,6 +61,9 @@ LLTargetingMotion::LLTargetingMotion(const LLUUID &id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLTargetingMotion::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
// save character for future use
mCharacter = character;
......
......@@ -58,6 +58,9 @@ LLEmote::LLEmote(const LLUUID &id) : LLMotion(id)
//-----------------------------------------------------------------------------
LLMotion::LLMotionInitStatus LLEmote::onInitialize(LLCharacter *character)
{
if (!character)
return STATUS_FAILURE;
mCharacter = character;
return STATUS_SUCCESS;
}
......
......@@ -127,150 +127,153 @@ void LLPhysicsMotionController::onDeactivate()
{
}
LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter *character)
LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter* character)
{
mCharacter = character;
if (!character)
return STATUS_FAILURE;
mMotions.clear();
mCharacter = character;
// Breast Cleavage
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Breast_Physics_Mass";
controller["Gravity"] = "Breast_Physics_Gravity";
controller["Drag"] = "Breast_Physics_Drag";
controller["Damping"] = "Breast_Physics_InOut_Damping";
controller["MaxEffect"] = "Breast_Physics_InOut_Max_Effect";
controller["Spring"] = "Breast_Physics_InOut_Spring";
controller["Gain"] = "Breast_Physics_InOut_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Breast_Physics_InOut_Controller",
"mChest",
character,
LLVector3(-1,0,0),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
mMotions.clear();
// Breast Bounce
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Breast_Physics_Mass";
controller["Gravity"] = "Breast_Physics_Gravity";
controller["Drag"] = "Breast_Physics_Drag";
controller["Damping"] = "Breast_Physics_UpDown_Damping";
controller["MaxEffect"] = "Breast_Physics_UpDown_Max_Effect";
controller["Spring"] = "Breast_Physics_UpDown_Spring";
controller["Gain"] = "Breast_Physics_UpDown_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Breast_Physics_UpDown_Controller",
"mChest",
character,
LLVector3(0,0,1),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Breast Cleavage
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Breast_Physics_Mass";
controller["Gravity"] = "Breast_Physics_Gravity";
controller["Drag"] = "Breast_Physics_Drag";
controller["Damping"] = "Breast_Physics_InOut_Damping";
controller["MaxEffect"] = "Breast_Physics_InOut_Max_Effect";
controller["Spring"] = "Breast_Physics_InOut_Spring";
controller["Gain"] = "Breast_Physics_InOut_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Breast_Physics_InOut_Controller",
"mChest",
character,
LLVector3(-1, 0, 0),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Breast Sway
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Breast_Physics_Mass";
controller["Gravity"] = "Breast_Physics_Gravity";
controller["Drag"] = "Breast_Physics_Drag";
controller["Damping"] = "Breast_Physics_LeftRight_Damping";
controller["MaxEffect"] = "Breast_Physics_LeftRight_Max_Effect";
controller["Spring"] = "Breast_Physics_LeftRight_Spring";
controller["Gain"] = "Breast_Physics_LeftRight_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Breast_Physics_LeftRight_Controller",
"mChest",
character,
LLVector3(0,-1,0),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Butt Bounce
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Butt_Physics_Mass";
controller["Gravity"] = "Butt_Physics_Gravity";
controller["Drag"] = "Butt_Physics_Drag";
controller["Damping"] = "Butt_Physics_UpDown_Damping";
controller["MaxEffect"] = "Butt_Physics_UpDown_Max_Effect";
controller["Spring"] = "Butt_Physics_UpDown_Spring";
controller["Gain"] = "Butt_Physics_UpDown_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Butt_Physics_UpDown_Controller",
"mPelvis",
character,
LLVector3(0,0,-1),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Breast Bounce
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Breast_Physics_Mass";
controller["Gravity"] = "Breast_Physics_Gravity";
controller["Drag"] = "Breast_Physics_Drag";
controller["Damping"] = "Breast_Physics_UpDown_Damping";
controller["MaxEffect"] = "Breast_Physics_UpDown_Max_Effect";
controller["Spring"] = "Breast_Physics_UpDown_Spring";
controller["Gain"] = "Breast_Physics_UpDown_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Breast_Physics_UpDown_Controller",
"mChest",
character,
LLVector3(0, 0, 1),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Butt LeftRight
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Butt_Physics_Mass";
controller["Gravity"] = "Butt_Physics_Gravity";
controller["Drag"] = "Butt_Physics_Drag";
controller["Damping"] = "Butt_Physics_LeftRight_Damping";
controller["MaxEffect"] = "Butt_Physics_LeftRight_Max_Effect";
controller["Spring"] = "Butt_Physics_LeftRight_Spring";
controller["Gain"] = "Butt_Physics_LeftRight_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Butt_Physics_LeftRight_Controller",
"mPelvis",
character,
LLVector3(0,-1,0),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Breast Sway
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Breast_Physics_Mass";
controller["Gravity"] = "Breast_Physics_Gravity";
controller["Drag"] = "Breast_Physics_Drag";
controller["Damping"] = "Breast_Physics_LeftRight_Damping";
controller["MaxEffect"] = "Breast_Physics_LeftRight_Max_Effect";
controller["Spring"] = "Breast_Physics_LeftRight_Spring";
controller["Gain"] = "Breast_Physics_LeftRight_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Breast_Physics_LeftRight_Controller",
"mChest",
character,
LLVector3(0, -1, 0),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Butt Bounce
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Butt_Physics_Mass";
controller["Gravity"] = "Butt_Physics_Gravity";
controller["Drag"] = "Butt_Physics_Drag";
controller["Damping"] = "Butt_Physics_UpDown_Damping";
controller["MaxEffect"] = "Butt_Physics_UpDown_Max_Effect";
controller["Spring"] = "Butt_Physics_UpDown_Spring";
controller["Gain"] = "Butt_Physics_UpDown_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Butt_Physics_UpDown_Controller",
"mPelvis",
character,
LLVector3(0, 0, -1),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Belly Bounce
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Belly_Physics_Mass";
controller["Gravity"] = "Belly_Physics_Gravity";
controller["Drag"] = "Belly_Physics_Drag";
controller["Damping"] = "Belly_Physics_UpDown_Damping";
controller["MaxEffect"] = "Belly_Physics_UpDown_Max_Effect";
controller["Spring"] = "Belly_Physics_UpDown_Spring";
controller["Gain"] = "Belly_Physics_UpDown_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Belly_Physics_UpDown_Controller",
"mPelvis",
character,
LLVector3(0,0,-1),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
return STATUS_SUCCESS;
// Butt LeftRight
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Butt_Physics_Mass";
controller["Gravity"] = "Butt_Physics_Gravity";
controller["Drag"] = "Butt_Physics_Drag";
controller["Damping"] = "Butt_Physics_LeftRight_Damping";
controller["MaxEffect"] = "Butt_Physics_LeftRight_Max_Effect";
controller["Spring"] = "Butt_Physics_LeftRight_Spring";
controller["Gain"] = "Butt_Physics_LeftRight_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Butt_Physics_LeftRight_Controller",
"mPelvis",
character,
LLVector3(0, -1, 0),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
// Belly Bounce
{
LLPhysicsMotion::controller_map_t controller;
controller["Mass"] = "Belly_Physics_Mass";
controller["Gravity"] = "Belly_Physics_Gravity";
controller["Drag"] = "Belly_Physics_Drag";
controller["Damping"] = "Belly_Physics_UpDown_Damping";
controller["MaxEffect"] = "Belly_Physics_UpDown_Max_Effect";
controller["Spring"] = "Belly_Physics_UpDown_Spring";
controller["Gain"] = "Belly_Physics_UpDown_Gain";
auto motion = std::make_unique<LLPhysicsMotion>("Belly_Physics_UpDown_Controller",
"mPelvis",
character,
LLVector3(0, 0, -1),
controller);
if (!motion->initialize())
{
llassert_always(FALSE);
return STATUS_FAILURE;
}
addMotion(std::move(motion));
}
return STATUS_SUCCESS;
}
void LLPhysicsMotionController::addMotion(std::unique_ptr<LLPhysicsMotion> motion)
......
......@@ -320,7 +320,7 @@ public:
// must return true to indicate success and be available for activation
LLMotionInitStatus onInitialize(LLCharacter *character) override
{
if( !mTorsoState->setJoint( character->getJoint("mTorso") ))
if (!character || !mTorsoState->setJoint(character->getJoint("mTorso")))
{
return STATUS_FAILURE;
}
......@@ -379,8 +379,7 @@ public:
// Constructor
LLBreatheMotionRot(const LLUUID &id) :
LLMotion(id),
mBreatheRate(1.f),
mCharacter(nullptr)
mBreatheRate(1.f)
{
mName = "breathe_rot";
mChestState = new LLJointState;
......@@ -427,10 +426,9 @@ public:
// must return true to indicate success and be available for activation
LLMotionInitStatus onInitialize(LLCharacter *character) override
{
mCharacter = character;
BOOL success = true;
if ( !mChestState->setJoint( character->getJoint( "mChest" ) ) )
if (!character || !mChestState->setJoint(character->getJoint("mChest")))
{
success = false;
}
......@@ -479,7 +477,6 @@ private:
//-------------------------------------------------------------------------
LLPointer<LLJointState> mChestState;
F32 mBreatheRate;
LLCharacter* mCharacter;
};
//-----------------------------------------------------------------------------
......@@ -491,7 +488,7 @@ class LLPelvisFixMotion final :
public:
// Constructor
LLPelvisFixMotion(const LLUUID &id)
: LLMotion(id), mCharacter(nullptr)
: LLMotion(id)
{
mName = "pelvis_fix";
......@@ -539,7 +536,8 @@ public:
// must return true to indicate success and be available for activation
LLMotionInitStatus onInitialize(LLCharacter *character) override
{
mCharacter = character;
if (!character)
return STATUS_FAILURE;
if (!mPelvisState->setJoint( character->getJoint("mPelvis")))
{
......@@ -575,7 +573,6 @@ private:
// joint states to be animated
//-------------------------------------------------------------------------
LLPointer<LLJointState> mPelvisState;
LLCharacter* mCharacter;
};
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment