Browse Source

Merge pull request #389 from Mystler/plAvatar

Fixes for plAvatar
Adam Johnson 11 years ago
parent
commit
97cff0e8a9
  1. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp
  2. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp
  3. 29
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp
  4. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCoop.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCoop.h
  6. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp
  7. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.h
  8. 5
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp
  9. 13
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  10. 3
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp
  11. 3
      Sources/Plasma/PubUtilLib/plAvatar/plClothingSDLModifier.cpp
  12. 8
      Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp
  13. 19
      Sources/Plasma/PubUtilLib/plAvatar/plMatrixChannel.cpp
  14. 15
      Sources/Plasma/PubUtilLib/plAvatar/plPointChannel.cpp
  15. 16
      Sources/Plasma/PubUtilLib/plAvatar/plQuatChannel.cpp
  16. 15
      Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp

2
Sources/Plasma/PubUtilLib/plAvatar/plAGModifier.cpp

@ -171,7 +171,7 @@ void plAGModifier::SetApplicator(plAGApplicator *newApp)
plAGChannel *newChannel = newApp->GetChannel();
hsAssert(newChannel = nil, "Trying to merge in new applicator which already has channel. Incomplete.");
hsAssert(!newChannel, "Trying to merge in new applicator which already has channel. Incomplete.");
// *** right now I just want to support the case of putting in a new applicator - not merging animations

2
Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp

@ -309,7 +309,7 @@ bool plAnimStage::ISendNotify(uint32_t notifyMask, uint32_t notifyType, plArmatu
int stageNum = genBrain ? genBrain->GetStageNum(this) : -1;
msg->AddMultiStageEvent(stageNum, notifyType, armature->GetTarget(0)->GetKey());
if (! genBrain->RelayNotifyMsg(msg) )
if (!genBrain || !genBrain->RelayNotifyMsg(msg))
{
msg->UnRef(); // couldn't send; destroy...
}

29
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp

@ -177,20 +177,21 @@ plAvBrainClimb::~plAvBrainClimb()
if(fExitStage)
fExitStage->Detach(fAvMod);
}
if(fUp) delete fUp;
if(fDown) delete fDown;
if(fLeft) delete fLeft;
if(fRight) delete fRight;
if(fMountUp) delete fMountUp;
if(fMountDown) delete fMountDown;
if(fMountLeft) delete fMountLeft;
if(fMountRight) delete fMountRight;
if(fDismountUp) delete fDismountUp;
if(fDismountLeft) delete fDismountLeft;
if(fDismountRight) delete fDismountRight;
if(fIdle) delete fIdle;
// if(fRelease) delete fRelease;
// if(fFallOff) delete fFallOff;
delete fUp;
delete fDown;
delete fLeft;
delete fRight;
delete fMountUp;
delete fMountDown;
delete fMountLeft;
delete fMountRight;
delete fDismountUp;
delete fDismountDown;
delete fDismountLeft;
delete fDismountRight;
delete fIdle;
delete fRelease;
delete fFallOff;
}
// ACTIVATE

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCoop.cpp

@ -251,7 +251,7 @@ plKey plAvBrainCoop::GetRecipient()
return fRecipients[0];
}
void plAvBrainCoop::SetRecipient(plKey &recipient)
void plAvBrainCoop::SetRecipient(const plKey &recipient)
{
fRecipients.push_back(recipient);
}

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCoop.h

@ -79,7 +79,7 @@ public:
uint16_t GetInitiatorSerial();
virtual plKey GetRecipient();
virtual void SetRecipient(plKey &recipient);
virtual void SetRecipient(const plKey &recipient);
private:
uint32_t fInitiatorID;

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.cpp

@ -214,7 +214,7 @@ void plAvBrainGeneric::Activate(plArmatureModBase *avMod)
fAvMod->SetReverseFBOnIdle(true);
}
bool plAvBrainGeneric::IsRunningTask()
bool plAvBrainGeneric::IsRunningTask() const
{
if ( fStages->size() > 0 )
return true;

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainGeneric.h

@ -169,7 +169,7 @@ public:
/** We're leaving the age. Clean up. */
virtual bool LeaveAge();
virtual bool IsRunningTask();
virtual bool IsRunningTask() const;
/** Compare the names of the anims in our stages.
Return true on a match (order matters). */

5
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainSwim.cpp

@ -232,9 +232,10 @@ public:
const float plAvBrainSwim::kMinSwimDepth = 4.0f;
plAvBrainSwim::plAvBrainSwim() :
fSwimStrategy(nil),
fSwimStrategy(nullptr),
fMode(kWalking),
fSurfaceDistance(0.f)
fSurfaceDistance(0.f),
fCurrentRegion(nullptr)
{
fSurfaceProbeMsg = new plLOSRequestMsg();
fSurfaceProbeMsg->SetReportType(plLOSRequestMsg::kReportHitOrMiss);

13
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp

@ -701,10 +701,9 @@ hsColorRGBA plClothingOutfit::GetItemTint(plClothingItem *item, uint8_t layer /*
bool plClothingOutfit::IMorphItem(plClothingItem *item, uint8_t layer, uint8_t delta, float weight)
{
uint32_t index = fItems.Find(item);
if (index != fItems.kMissingIndex)
if (fAvatar && index != fItems.kMissingIndex)
{
int i;
for (i = 0; i < fAvatar->GetNumLOD(); i++)
for (uint8_t i = 0; i < fAvatar->GetNumLOD(); i++)
{
if (item->fMeshes[i]->fMorphSet == nil)
continue;
@ -1420,14 +1419,16 @@ bool plClothingOutfit::DirtySynchState(const plString& SDLStateName, uint32_t sy
// we'll be good about this, but I wanted to get it working first.
void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item)
{
if (fAvatar)
fAvatar->ValidateMesh();
if (!fAvatar)
return;
fAvatar->ValidateMesh();
bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0);
for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
{
const plSceneObject *so = fAvatar->GetClothingSO(i);
if (so != nil && item->fMeshes[i] != nil)
if (so && item->fMeshes[i])
{
plInstanceDrawInterface *idi = const_cast<plInstanceDrawInterface*>(plInstanceDrawInterface::ConvertNoRef(so->GetDrawInterface()));
if (idi)

3
Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp

@ -660,9 +660,6 @@ bool plAvOneShotTask::Process(plArmatureMod *avatar, plArmatureBrain *brain, dou
if(--fWaitFrames == 0)
{
plSceneObject *handle = avatar->GetTarget(0);
avatar->DetachAnimation(fAnimInstance);
avatar->GetRootAnimator()->Enable(false);
plAvBrainHuman *humanBrain = plAvBrainHuman::ConvertNoRef(brain);

3
Sources/Plasma/PubUtilLib/plAvatar/plClothingSDLModifier.cpp

@ -302,7 +302,8 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
{
uint8_t blend;
faceBlends->Get(&blend, i);
clothing->fSkinBlends[i] = (float)blend / 255;
if (clothing)
clothing->fSkinBlends[i] = (float)blend / 255;
}
}
}

8
Sources/Plasma/PubUtilLib/plAvatar/plCoopCoordinator.cpp

@ -327,11 +327,9 @@ void plCoopCoordinator::IStartGuest()
const plSceneObject *targetBone = hostAv->FindBone(fSynchBone);
if(targetBone)
{
plAvSeekMsg *seekMsg = new plAvSeekMsg( nil, nil,targetBone->GetKey(), 0, true, kAlignHandle, "", false, plAvSeekMsg::kSeekFlagNoWarpOnTimeout, GetKey());
plAvTaskSeek *seekT = new plAvTaskSeek(seekMsg);
plAvTaskMsg *seekM = new plAvTaskMsg(GetKey(), fGuestKey, seekT);
seekM->SetBCastFlag(plMessage::kPropagateToModifiers);
seekM->Send();
plAvSeekMsg *seekMsg = new plAvSeekMsg(GetKey(), fGuestKey, targetBone->GetKey(), 0, true, kAlignHandle, "", false, plAvSeekMsg::kSeekFlagNoWarpOnTimeout, GetKey());
seekMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
seekMsg->Send();
}
}
}

19
Sources/Plasma/PubUtilLib/plAvatar/plMatrixChannel.cpp

@ -317,9 +317,12 @@ void plMatrixTimeScale::Dump(int indent, bool optimized, double time)
// ctor ----------------------
// -----
plMatrixBlend::plMatrixBlend()
: fChannelA(nil),
fChannelB(nil),
fChannelBias(nil)
: fChannelA(nullptr),
fOptimizedA(nullptr),
fChannelB(nullptr),
fOptimizedB(nullptr),
fChannelBias(nullptr),
fPriority(0)
{
}
@ -793,11 +796,8 @@ void plMatrixDelayedCorrectionApplicator::SetCorrection(hsMatrix44 &cor)
bool plMatrixDelayedCorrectionApplicator::CanBlend(plAGApplicator *app)
{
plMatrixChannelApplicator *matChannelApp = plMatrixChannelApplicator::ConvertNoRef(app);
if( plMatrixChannelApplicator::ConvertNoRef(app) )
{
if (matChannelApp)
return true;
}
return false;
}
@ -875,11 +875,8 @@ void plMatrixDifferenceApp::Reset(double time)
bool plMatrixDifferenceApp::CanBlend(plAGApplicator *app)
{
plMatrixChannelApplicator *matChannelApp = plMatrixChannelApplicator::ConvertNoRef(app);
if( plMatrixChannelApplicator::ConvertNoRef(app) )
{
if (matChannelApp)
return true;
}
return false;
}

15
Sources/Plasma/PubUtilLib/plAvatar/plPointChannel.cpp

@ -214,8 +214,9 @@ plAGChannel * plPointTimeScale::Detach(plAGChannel * channel)
// ctor --------------------
// -----
plPointBlend::plPointBlend()
: fPointA(nil),
fPointB(nil)
: fPointA(nullptr),
fPointB(nullptr),
fChannelBias(nullptr)
{
}
@ -274,14 +275,10 @@ const hsPoint3 &plPointBlend::Value(double time)
}
}
} else {
if (fPointA)
{
if (fPointA) {
fResult = fPointA->Value(time);
} else {
if (fPointB)
{
fResult = fPointA->Value(time);
}
} else if (fPointB) {
fResult = fPointB->Value(time);
}
}
return fResult;

16
Sources/Plasma/PubUtilLib/plAvatar/plQuatChannel.cpp

@ -82,24 +82,20 @@ void plQuatChannel::Value(hsQuat &quat, double time)
// CANCOMBINE
bool plQuatChannel::CanCombine(plAGChannel *channelA)
{
return false;
if(plPointChannel::ConvertNoRef(channelA))
{
return true;
} else {
else
return false;
}
}
// MAKECOMBINE
plAGChannel * plQuatChannel::MakeCombine(plAGChannel *channelA)
{
if(plPointChannel::ConvertNoRef(channelA))
{
return new plQuatPointCombine(this, (plPointChannel *)channelA);
} else {
return nil;
}
plPointChannel* channel = plPointChannel::ConvertNoRef(channelA);
if(channel)
return new plQuatPointCombine(this, channel);
else
return nullptr;
}
// MAKEBLEND

15
Sources/Plasma/PubUtilLib/plAvatar/plSittingModifier.cpp

@ -302,20 +302,19 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe
{
plArmatureMod *avatar = plArmatureMod::ConvertNoRef(avModKey->ObjectIsLoaded());
plSceneObject *seekObj = plSceneObject::ConvertNoRef(seekKey->ObjectIsLoaded());
hsMatrix44 animEndToStart;
hsMatrix44 sitGoal = seekObj->GetLocalToWorld();
hsMatrix44 candidateGoal;
float closestDist = 0.0f;
uint8_t closestApproach = 0;
hsPoint3 curPosition = avatar->GetTarget(0)->GetLocalToWorld().GetTranslate();
const char* sitAnimName = nil;
const char* sitAnimName = nullptr;
const char* standAnimName = "StandUpFront"; // always prefer to stand facing front
bool frontClear = fMiscFlags & kApproachFront;
plAvBrainGeneric *brain = nil;
plAvBrainGeneric *brain = nullptr;
if(avatar)
if(avatar && seekObj)
{
hsMatrix44 sitGoal = seekObj->GetLocalToWorld();
hsPoint3 curPosition = avatar->GetTarget(0)->GetLocalToWorld().GetTranslate();
if(fMiscFlags & kApproachLeft && IIsClosestAnim("SitLeft", sitGoal, closestDist, curPosition, avatar))
{
closestApproach = kApproachLeft;
@ -323,6 +322,7 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe
if(!frontClear)
standAnimName = "StandUpLeft";
}
if(fMiscFlags & kApproachRight && IIsClosestAnim("SitRight", sitGoal, closestDist, curPosition, avatar))
{
closestApproach = kApproachRight;
@ -330,6 +330,7 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe
if(!frontClear)
standAnimName = "StandUpRight";
}
if(frontClear && IIsClosestAnim("SitFront", sitGoal, closestDist, curPosition, avatar))
{
sitAnimName = "SitFront";

Loading…
Cancel
Save