SL-14183, SL-14142 - impostor management improvements, animesh attachments update on frames when their parent does

master
Brad Payne (Vir Linden) 2020-10-27 16:04:19 +01:00
parent 263c4c341f
commit 8b9ed94a35
6 changed files with 80 additions and 25 deletions

View File

@ -360,7 +360,38 @@ void LLControlAvatar::idleUpdate(LLAgent &agent, const F64 &time)
}
}
BOOL LLControlAvatar::updateCharacter(LLAgent &agent)
bool LLControlAvatar::computeNeedsUpdate()
{
computeUpdatePeriod();
// Animesh attachments are a special case. Should have the same update cadence as their attached parent avatar.
bool is_attachment = mRootVolp && mRootVolp->isAttachment(); // For attached animated objects
if (is_attachment)
{
LLVOAvatar *attached_av = mRootVolp->getAvatarAncestor();
if (attached_av)
{
// Have to run computeNeedsUpdate() for attached av in
// case it hasn't run updateCharacter() already this
// frame. Note this means that the attached av will
// run computeNeedsUpdate() multiple times per frame
// if it has animesh attachments. Results will be
// consistent except for the corner case of exceeding
// MAX_IMPOSTOR_INTERVAL in one call but not another,
// which should be rare.
attached_av->computeNeedsUpdate();
mNeedsImpostorUpdate = attached_av->mNeedsImpostorUpdate;
if (mNeedsImpostorUpdate)
{
mLastImpostorUpdateReason = 12;
}
return mNeedsImpostorUpdate;
}
}
return LLVOAvatar::computeNeedsUpdate();
}
bool LLControlAvatar::updateCharacter(LLAgent &agent)
{
return LLVOAvatar::updateCharacter(agent);
}

View File

@ -53,7 +53,8 @@ public:
void markForDeath();
virtual void idleUpdate(LLAgent &agent, const F64 &time);
virtual BOOL updateCharacter(LLAgent &agent);
virtual bool computeNeedsUpdate();
virtual bool updateCharacter(LLAgent &agent);
void getAnimatedVolumes(std::vector<LLVOVolume*>& volumes);
void updateAnimations();

View File

@ -2139,7 +2139,15 @@ void LLVOAvatar::resetSkeleton(bool reset_animations)
}
else
{
// Stripped down approximation of
// applyParsedAppearanceMessage, but with alternative default
// (jellydoll) params
setCompositeUpdatesEnabled( FALSE );
gPipeline.markGLRebuild(this);
applyDefaultParams();
setCompositeUpdatesEnabled( TRUE );
updateMeshTextures();
updateMeshVisibility();
}
updateVisualParams();
@ -4418,6 +4426,37 @@ void LLVOAvatar::updateRootPositionAndRotation(LLAgent& agent, F32 speed, bool w
}
//------------------------------------------------------------------------
// LLVOAvatar::computeNeedsUpdate()
//
// Most of the logic here is to figure out when to periodically update impostors.
// Non-impostors have mUpdatePeriod == 1 and will need update every frame.
//------------------------------------------------------------------------
bool LLVOAvatar::computeNeedsUpdate()
{
const F32 MAX_IMPOSTOR_INTERVAL = 4.0f;
computeUpdatePeriod();
bool needs_update_by_frame_count = ((LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0);
bool needs_update_by_max_time = ((gFrameTimeSeconds-mLastImpostorUpdateFrameTime)> MAX_IMPOSTOR_INTERVAL);
bool needs_update = needs_update_by_frame_count || needs_update_by_max_time;
if (needs_update && !isSelf())
{
if (needs_update_by_max_time)
{
mNeedsImpostorUpdate = TRUE;
mLastImpostorUpdateReason = 11;
}
else
{
//mNeedsImpostorUpdate = TRUE;
//mLastImpostorUpdateReason = 10;
}
}
return needs_update;
}
// updateCharacter()
//
// This is called for all avatars, so there are 4 possible situations:
@ -4440,7 +4479,7 @@ void LLVOAvatar::updateRootPositionAndRotation(LLAgent& agent, F32 speed, bool w
// simulator.
//
//------------------------------------------------------------------------
BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
bool LLVOAvatar::updateCharacter(LLAgent &agent)
{
updateDebugText();
@ -4452,6 +4491,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
BOOL visible = isVisible();
bool is_control_avatar = isControlAvatar(); // capture state to simplify tracing
bool is_attachment = false;
if (is_control_avatar)
{
LLControlAvatar *cav = dynamic_cast<LLControlAvatar*>(this);
@ -4474,25 +4514,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
// Set mUpdatePeriod and visible based on distance and other criteria,
// and flag for impostor update if needed.
//--------------------------------------------------------------------
const F32 MAX_IMPOSTOR_INTERVAL = 4.0f;
computeUpdatePeriod();
bool needs_update_by_frame_count = ((LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0);
bool needs_update_by_max_time = ((mLastImpostorUpdateFrameTime-gFrameTimeSeconds)> MAX_IMPOSTOR_INTERVAL);
bool needs_update = needs_update_by_frame_count || needs_update_by_max_time;
if (needs_update && !isSelf())
{
if (needs_update_by_max_time)
{
mNeedsImpostorUpdate = TRUE;
mLastImpostorUpdateReason = 11;
}
else
{
mNeedsImpostorUpdate = TRUE;
mLastImpostorUpdateReason = 10;
}
}
bool needs_update = computeNeedsUpdate();
//--------------------------------------------------------------------
// Early out if does not need update and not self

View File

@ -263,7 +263,8 @@ public:
void updateAppearanceMessageDebugText();
void updateAnimationDebugText();
virtual void updateDebugText();
virtual BOOL updateCharacter(LLAgent &agent);
virtual bool computeNeedsUpdate();
virtual bool updateCharacter(LLAgent &agent);
void updateFootstepSounds();
void computeUpdatePeriod();
void updateOrientation(LLAgent &agent, F32 speed, F32 delta_time);

View File

@ -668,7 +668,7 @@ LLVOAvatarSelf::~LLVOAvatarSelf()
*********************************************************************************/
// virtual
BOOL LLVOAvatarSelf::updateCharacter(LLAgent &agent)
bool LLVOAvatarSelf::updateCharacter(LLAgent &agent)
{
// update screen joint size
if (mScreenp)

View File

@ -116,7 +116,7 @@ public:
// Updates
//--------------------------------------------------------------------
public:
/*virtual*/ BOOL updateCharacter(LLAgent &agent);
/*virtual*/ bool updateCharacter(LLAgent &agent);
/*virtual*/ void idleUpdateTractorBeam();
bool checkStuckAppearance();