FIRE-35794: Only save pose information for things you own

master
Angeldark Raymaker 2025-09-17 20:26:12 +01:00
parent dddce2b568
commit f0061fcd95
2 changed files with 50 additions and 30 deletions

View File

@ -18,10 +18,11 @@ void FSPoseState::captureMotionStates(LLVOAvatar* avatar)
continue;
fsMotionState newState;
newState.avatarId = avatar->getID();
newState.motionId = anim_it->first;
newState.avatarId = avatar->getID();
newState.motionId = anim_it->first;
newState.lastUpdateTime = motion->getLastUpdateTime();
newState.captureOrder = 0;
newState.avatarOwnsPose = canSaveMotionId(avatar, anim_it->first);
sMotionStates[avatar->getID()].push_back(newState);
}
@ -78,6 +79,7 @@ void FSPoseState::updateMotionStates(LLVOAvatar* avatar, FSPosingMotion* posingM
newState.lastUpdateTime = motion->getLastUpdateTime();
newState.jointNamesAnimated = jointNamesRecaptured;
newState.captureOrder = sCaptureOrder[avatar->getID()];
newState.avatarOwnsPose = canSaveMotionId(avatar, anim_it->first);
sMotionStates[avatar->getID()].push_back(newState);
}
@ -108,6 +110,8 @@ void FSPoseState::writeMotionStates(LLVOAvatar* avatar, LLSD* saveRecord)
{
if (it->avatarId != avatar->getID())
continue;
if (!it->avatarOwnsPose)
continue;
std::string uniqueAnimId = "poseState" + std::to_string(animNumber++);
(*saveRecord)[uniqueAnimId]["animationId"] = it->motionId.asString();
@ -181,12 +185,6 @@ bool FSPoseState::applyMotionStatesToPosingMotion(LLVOAvatar* avatar, FSPosingMo
if (it->motionApplied)
continue;
if (!avatarCanUsePose(avatar, it->motionId))
{
it->motionApplied = true;
continue;
}
LLKeyframeMotion* kfm = dynamic_cast<LLKeyframeMotion*>(avatar->findMotion(it->motionId));
if (kfm)
@ -194,7 +192,6 @@ bool FSPoseState::applyMotionStatesToPosingMotion(LLVOAvatar* avatar, FSPosingMo
if (needPriorityReset)
{
lastCaptureOrder = it->captureOrder;
LL_WARNS("Posing") << "Resetting priority at cap order: " << lastCaptureOrder << LL_ENDL;
resetPriorityForCaptureOrder(avatar, posingMotion, lastCaptureOrder);
}
@ -225,25 +222,37 @@ void FSPoseState::resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotio
if (it->captureOrder != captureOrder)
continue;
LL_WARNS("Posing") << "Resetting priority for: " << it->jointNamesAnimated << LL_ENDL;
posingMotion->resetBonePriority(it->jointNamesAnimated);
}
}
bool FSPoseState::avatarCanUsePose(LLVOAvatar* avatar, LLUUID motionId)
bool FSPoseState::canSaveMotionId(LLVOAvatar* avatar, LLAssetID motionId)
{
if (!avatar)
return true;
if (!motionId.notNull())
return true;
if (avatar != gAgentAvatarp)
return true;
if (!gAgentAvatarp || gAgentAvatarp.isNull())
return false;
// does the animation exist in inventory
LLInventoryItem* item = gInventory.getItem(motionId);
if (!item)
if (item && item->getPermissions().getOwner() == avatar->getID())
return true;
return item->getPermissions().getOwner() == avatar->getID();
for (const auto& [anim_object_id, anim_anim_id] : gAgentAvatarp->mAnimationSources)
{
if (anim_anim_id != motionId)
continue;
// is the item that started the anim in inventory
item = gInventory.getItem(anim_object_id);
if (item && item->getPermissions().getOwner() == avatar->getID())
return true;
// is the item that start the animation in-world
LLViewerObject* object = gObjectList.findObject(anim_object_id);
if (object && object->permYouOwner())
return true;
return false;
}
return false;
}

View File

@ -91,8 +91,6 @@ public:
/// </remarks>
bool applyMotionStatesToPosingMotion(LLVOAvatar* avatar, FSPosingMotion* posingMotion);
void resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotion* posingMotion, int captureOrder);
private:
/// <summary>
/// A class documenting the state of an animation for an avatar.
@ -120,9 +118,14 @@ private:
/// </summary>
bool motionApplied = false;
/// <summary>
/// Whether the avatar owns the pose, or the pose was loaded.
/// </summary>
bool avatarOwnsPose = false;
/// <summary>
/// When reloading, larger numbers are loaded last, nesting order and priority.
/// Represents recaptures.
/// This is used to represent recaptures, where joints could be animated with different poses.
/// </summary>
int captureOrder = 0;
@ -133,12 +136,20 @@ private:
};
/// <summary>
/// Gets whether the supplied avatar has ownership of the supplied motion id.
/// Resets the priority for the named joints for the supplied posing motion at the supplied capture order.
/// </summary>
/// <param name="avatar">The avatar to query for ownership.</param>
/// <param name="motionId">The motion to query for ownership.</param>
/// <returns>True if the avatar has ownership of the motion, otherwise false.</returns>
bool avatarCanUsePose(LLVOAvatar* avatar, LLUUID motionId);
/// <param name="avatar">The avatar being posed by the motion.</param>
/// <param name="posingMotion">The posing motion.</param>
/// <param name="captureOrder">The order of the capture.</param>
void resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotion* posingMotion, int captureOrder);
/// <summary>
/// Gets whether the supplied avatar owns, and thus can save information about the supplied asset ID.
/// </summary>
/// <param name="avatar">The avatar to query ownership for.</param>
/// <param name="motionId">The asset ID of the object.</param>
/// <returns>True if the avatar owns the asset, otherwise false.</returns>
bool canSaveMotionId(LLVOAvatar* avatar, LLAssetID motionId);
struct compareByCaptureOrder
{
@ -152,7 +163,7 @@ private:
};
static std::map <LLUUID, std::vector<fsMotionState>> sMotionStates;
static std::map<LLUUID, int> sCaptureOrder;
static std::map<LLUUID, int> sCaptureOrder;
};
#endif // LL_FSPoseState_H