Browse Source

Fixes for plAvatar

Florian Meißner 11 years ago
parent
commit
cedc2482e3
  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. 11
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  10. 3
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarTasks.cpp
  11. 1
      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(); 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 // *** 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; int stageNum = genBrain ? genBrain->GetStageNum(this) : -1;
msg->AddMultiStageEvent(stageNum, notifyType, armature->GetTarget(0)->GetKey()); msg->AddMultiStageEvent(stageNum, notifyType, armature->GetTarget(0)->GetKey());
if (! genBrain->RelayNotifyMsg(msg) ) if (!genBrain || !genBrain->RelayNotifyMsg(msg))
{ {
msg->UnRef(); // couldn't send; destroy... msg->UnRef(); // couldn't send; destroy...
} }

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

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

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

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

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

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

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

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

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

@ -169,7 +169,7 @@ public:
/** We're leaving the age. Clean up. */ /** We're leaving the age. Clean up. */
virtual bool LeaveAge(); virtual bool LeaveAge();
virtual bool IsRunningTask(); virtual bool IsRunningTask() const;
/** Compare the names of the anims in our stages. /** Compare the names of the anims in our stages.
Return true on a match (order matters). */ 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; const float plAvBrainSwim::kMinSwimDepth = 4.0f;
plAvBrainSwim::plAvBrainSwim() : plAvBrainSwim::plAvBrainSwim() :
fSwimStrategy(nil), fSwimStrategy(nullptr),
fMode(kWalking), fMode(kWalking),
fSurfaceDistance(0.f) fSurfaceDistance(0.f),
fCurrentRegion(nullptr)
{ {
fSurfaceProbeMsg = new plLOSRequestMsg(); fSurfaceProbeMsg = new plLOSRequestMsg();
fSurfaceProbeMsg->SetReportType(plLOSRequestMsg::kReportHitOrMiss); fSurfaceProbeMsg->SetReportType(plLOSRequestMsg::kReportHitOrMiss);

11
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) bool plClothingOutfit::IMorphItem(plClothingItem *item, uint8_t layer, uint8_t delta, float weight)
{ {
uint32_t index = fItems.Find(item); uint32_t index = fItems.Find(item);
if (index != fItems.kMissingIndex) if (fAvatar && index != fItems.kMissingIndex)
{ {
int i; for (uint8_t i = 0; i < fAvatar->GetNumLOD(); i++)
for (i = 0; i < fAvatar->GetNumLOD(); i++)
{ {
if (item->fMeshes[i]->fMorphSet == nil) if (item->fMeshes[i]->fMorphSet == nil)
continue; 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. // we'll be good about this, but I wanted to get it working first.
void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item) void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item)
{ {
if (fAvatar) if (!fAvatar)
return;
fAvatar->ValidateMesh(); fAvatar->ValidateMesh();
bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0); bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0);
for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++) for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
{ {
const plSceneObject *so = fAvatar->GetClothingSO(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())); plInstanceDrawInterface *idi = const_cast<plInstanceDrawInterface*>(plInstanceDrawInterface::ConvertNoRef(so->GetDrawInterface()));
if (idi) if (idi)

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

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

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

@ -302,6 +302,7 @@ void plClothingSDLModifier::HandleSingleSDR(const plStateDataRecord *sdr, plClot
{ {
uint8_t blend; uint8_t blend;
faceBlends->Get(&blend, i); faceBlends->Get(&blend, i);
if (clothing)
clothing->fSkinBlends[i] = (float)blend / 255; 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); const plSceneObject *targetBone = hostAv->FindBone(fSynchBone);
if(targetBone) if(targetBone)
{ {
plAvSeekMsg *seekMsg = new plAvSeekMsg( nil, nil,targetBone->GetKey(), 0, true, kAlignHandle, "", false, plAvSeekMsg::kSeekFlagNoWarpOnTimeout, GetKey()); plAvSeekMsg *seekMsg = new plAvSeekMsg(GetKey(), fGuestKey, targetBone->GetKey(), 0, true, kAlignHandle, "", false, plAvSeekMsg::kSeekFlagNoWarpOnTimeout, GetKey());
plAvTaskSeek *seekT = new plAvTaskSeek(seekMsg); seekMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
plAvTaskMsg *seekM = new plAvTaskMsg(GetKey(), fGuestKey, seekT); seekMsg->Send();
seekM->SetBCastFlag(plMessage::kPropagateToModifiers);
seekM->Send();
} }
} }
} }

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

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

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

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

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

@ -82,24 +82,20 @@ void plQuatChannel::Value(hsQuat &quat, double time)
// CANCOMBINE // CANCOMBINE
bool plQuatChannel::CanCombine(plAGChannel *channelA) bool plQuatChannel::CanCombine(plAGChannel *channelA)
{ {
return false;
if(plPointChannel::ConvertNoRef(channelA)) if(plPointChannel::ConvertNoRef(channelA))
{
return true; return true;
} else { else
return false; return false;
}
} }
// MAKECOMBINE // MAKECOMBINE
plAGChannel * plQuatChannel::MakeCombine(plAGChannel *channelA) plAGChannel * plQuatChannel::MakeCombine(plAGChannel *channelA)
{ {
if(plPointChannel::ConvertNoRef(channelA)) plPointChannel* channel = plPointChannel::ConvertNoRef(channelA);
{ if(channel)
return new plQuatPointCombine(this, (plPointChannel *)channelA); return new plQuatPointCombine(this, channel);
} else { else
return nil; return nullptr;
}
} }
// MAKEBLEND // 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()); plArmatureMod *avatar = plArmatureMod::ConvertNoRef(avModKey->ObjectIsLoaded());
plSceneObject *seekObj = plSceneObject::ConvertNoRef(seekKey->ObjectIsLoaded()); plSceneObject *seekObj = plSceneObject::ConvertNoRef(seekKey->ObjectIsLoaded());
hsMatrix44 animEndToStart;
hsMatrix44 sitGoal = seekObj->GetLocalToWorld();
hsMatrix44 candidateGoal;
float closestDist = 0.0f; float closestDist = 0.0f;
uint8_t closestApproach = 0; uint8_t closestApproach = 0;
hsPoint3 curPosition = avatar->GetTarget(0)->GetLocalToWorld().GetTranslate(); const char* sitAnimName = nullptr;
const char* sitAnimName = nil;
const char* standAnimName = "StandUpFront"; // always prefer to stand facing front const char* standAnimName = "StandUpFront"; // always prefer to stand facing front
bool frontClear = fMiscFlags & kApproachFront; 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)) if(fMiscFlags & kApproachLeft && IIsClosestAnim("SitLeft", sitGoal, closestDist, curPosition, avatar))
{ {
closestApproach = kApproachLeft; closestApproach = kApproachLeft;
@ -323,6 +322,7 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe
if(!frontClear) if(!frontClear)
standAnimName = "StandUpLeft"; standAnimName = "StandUpLeft";
} }
if(fMiscFlags & kApproachRight && IIsClosestAnim("SitRight", sitGoal, closestDist, curPosition, avatar)) if(fMiscFlags & kApproachRight && IIsClosestAnim("SitRight", sitGoal, closestDist, curPosition, avatar))
{ {
closestApproach = kApproachRight; closestApproach = kApproachRight;
@ -330,6 +330,7 @@ plAvBrainGeneric *plSittingModifier::IBuildSitBrain(plKey avModKey, plKey seekKe
if(!frontClear) if(!frontClear)
standAnimName = "StandUpRight"; standAnimName = "StandUpRight";
} }
if(frontClear && IIsClosestAnim("SitFront", sitGoal, closestDist, curPosition, avatar)) if(frontClear && IIsClosestAnim("SitFront", sitGoal, closestDist, curPosition, avatar))
{ {
sitAnimName = "SitFront"; sitAnimName = "SitFront";

Loading…
Cancel
Save