FIRE-21915: Make fix bogus avatar movement on region crossing optional via FSExperimentalRegionCrossingMovementFix debug setting (enabled by default for now)

Mon, 02 Apr 2018 20:53:24 +0200

author
Ansariel
date
Mon, 02 Apr 2018 20:53:24 +0200
changeset 55025
7cf19cd78336
parent 55024
8b4ad8e76ade
child 55026
27c857bfb47a

FIRE-21915: Make fix bogus avatar movement on region crossing optional via FSExperimentalRegionCrossingMovementFix debug setting (enabled by default for now)

indra/newview/app_settings/settings.xml file | annotate | diff | revisions
indra/newview/llviewerobject.cpp file | annotate | diff | revisions
indra/newview/llworld.cpp file | annotate | diff | revisions
     1.1 --- a/indra/newview/app_settings/settings.xml	Sat Mar 31 00:55:51 2018 +0200
     1.2 +++ b/indra/newview/app_settings/settings.xml	Mon Apr 02 20:53:24 2018 +0200
     1.3 @@ -24602,6 +24602,17 @@
     1.4        <key>Value</key>
     1.5        <integer>0</integer>
     1.6      </map>
     1.7 +    <key>FSExperimentalRegionCrossingMovementFix</key>
     1.8 +    <map>
     1.9 +      <key>Comment</key>
    1.10 +      <string>If enabled, use the experimental fix for region crossing movements being bogus due to false predictions by the viewer.</string>
    1.11 +      <key>Persist</key>
    1.12 +      <integer>1</integer>
    1.13 +      <key>Type</key>
    1.14 +      <string>Boolean</string>
    1.15 +      <key>Value</key>
    1.16 +      <integer>1</integer>
    1.17 +    </map>
    1.18    </map>
    1.19  </llsd>
    1.20  
     2.1 --- a/indra/newview/llviewerobject.cpp	Sat Mar 31 00:55:51 2018 +0200
     2.2 +++ b/indra/newview/llviewerobject.cpp	Mon Apr 02 20:53:24 2018 +0200
     2.3 @@ -2660,20 +2660,24 @@
     2.4  			// Extrapolation across region boundaries is almost always wrong, and if the region being
     2.5  			// entered is slow to respond, very wrong.
     2.6  			// Probably don't need edge of world check below any more since we are clipping the predictor to the region.
     2.7 -			bool clipped; // true if clipped at boundary
     2.8 -			LLVector3d clip_pos_global_region = LLWorld::getInstance()->clipToRegion(mRegionp,old_pos_global, new_pos_global, clipped);
     2.9 -			if (clipped)
    2.10 +			static LLCachedControl<bool> fsExperimentalRegionCrossingMovementFix(gSavedSettings, "FSExperimentalRegionCrossingMovementFix");
    2.11 +			if (fsExperimentalRegionCrossingMovementFix)
    2.12  			{
    2.13 -				// Was clipped, so we crossed a region boundary
    2.14 -				//LL_INFOS() << "Beyond region edge, clipped predicted position to " << mRegionp->getPosRegionFromGlobal(clip_pos_global_region)
    2.15 -				//	<< " from [" << getPositionRegion() << " .. " << new_pos << "]" << LL_ENDL;
    2.16 -				new_pos = mRegionp->getPosRegionFromGlobal(clip_pos_global_region);
    2.17 -				// Don't zero out velocity on the server. Telling the server affects scripts and audio.
    2.18 -				//new_v.clear();
    2.19 -				//setAcceleration(LLVector3::zero); // stop linear acceleration
    2.20 -				LLVector3 new_angv;
    2.21 -				new_angv.clear();
    2.22 -				setAngularVelocity(new_angv); // stop rotation
    2.23 +				bool clipped; // true if clipped at boundary
    2.24 +				LLVector3d clip_pos_global_region = LLWorld::getInstance()->clipToRegion(mRegionp, old_pos_global, new_pos_global, clipped);
    2.25 +				if (clipped)
    2.26 +				{
    2.27 +					// Was clipped, so we crossed a region boundary
    2.28 +					//LL_INFOS() << "Beyond region edge, clipped predicted position to " << mRegionp->getPosRegionFromGlobal(clip_pos_global_region)
    2.29 +					//	<< " from [" << getPositionRegion() << " .. " << new_pos << "]" << LL_ENDL;
    2.30 +					new_pos = mRegionp->getPosRegionFromGlobal(clip_pos_global_region);
    2.31 +					// Don't zero out velocity on the server. Telling the server affects scripts and audio.
    2.32 +					//new_v.clear();
    2.33 +					//setAcceleration(LLVector3::zero); // stop linear acceleration
    2.34 +					LLVector3 new_angv;
    2.35 +					new_angv.clear();
    2.36 +					setAngularVelocity(new_angv); // stop rotation
    2.37 +				}
    2.38  			}
    2.39  			// </FS>
    2.40  
     3.1 --- a/indra/newview/llworld.cpp	Sat Mar 31 00:55:51 2018 +0200
     3.2 +++ b/indra/newview/llworld.cpp	Mon Apr 02 20:53:24 2018 +0200
     3.3 @@ -787,6 +787,8 @@
     3.4  //  If start_pos is outside the region, use start_pos.
     3.5  LLVector3d	LLWorld::clipToRegion(const LLViewerRegion* regionp, const LLVector3d &start_pos, const LLVector3d &end_pos, bool &clipped)
     3.6  {
     3.7 +	static LLCachedControl<bool> fsExperimentalRegionCrossingMovementFix(gSavedSettings, "FSExperimentalRegionCrossingMovementFix");
     3.8 +
     3.9  	clipped = false;									// no clipping yet
    3.10  	if (!regionp)										// no region. We're lost
    3.11  	{
    3.12 @@ -808,8 +810,9 @@
    3.13  	// </FS>
    3.14  	F32 region_width = regionp->getWidth();
    3.15  	// <FS> FIRE-21915: Fix bogus avatar movement on region crossing
    3.16 -	if (region_coord_start.mV[VX] < 0.f || region_coord_start.mV[VX] > region_width
    3.17 -		|| region_coord_start.mV[VY] < 0.f || region_coord_start.mV[VY] > region_width)
    3.18 +	if (fsExperimentalRegionCrossingMovementFix &&
    3.19 +		(region_coord_start.mV[VX] < 0.f || region_coord_start.mV[VX] > region_width
    3.20 +		|| region_coord_start.mV[VY] < 0.f || region_coord_start.mV[VY] > region_width))
    3.21  	{
    3.22  		clip_factor = 1.0;								// start pos outside region, use start pos
    3.23  	}
    3.24 @@ -853,8 +856,14 @@
    3.25  		clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY];
    3.26  	}
    3.27  	// <FS> FIRE-21915: Fix bogus avatar movement on region crossing
    3.28 -		if (!std::isfinite(clip_factor)) { clip_factor = 0.0; }	// avoid NaN problems
    3.29 -		clip_factor = llclamp(clip_factor, 0.0, 1.0);			// avoid overflow problem
    3.30 +		if (!std::isfinite(clip_factor))
    3.31 +		{
    3.32 +			clip_factor = 0.0;								// avoid NaN problems
    3.33 +		}
    3.34 +		else
    3.35 +		{
    3.36 +			clip_factor = llclamp(clip_factor, 0.0, 1.0);	// avoid overflow problem
    3.37 +		}
    3.38  	}
    3.39  	// </FS>
    3.40  
    3.41 @@ -868,21 +877,36 @@
    3.42  	//final_region_pos.mdV[VZ] = llclamp(final_region_pos.mdV[VZ], 0.0,
    3.43  	//								   (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO));
    3.44  
    3.45 -	// True if clipped. Caller needs to know, because it will kill velocity if there's clipping
    3.46 -	// Don't do this by comparing floating point numbers for equality. That has roundoff problems.
    3.47 -	clipped = clip_factor > F_ALMOST_ZERO;						// clipped in X or Y
    3.48 -	LLVector3d final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor);
    3.49 -	clipped |= final_region_pos.mdV[VX] < -F_ALMOST_ZERO || final_region_pos.mdV[VX] > (F64)(region_width - F_ALMOST_ZERO);
    3.50 -	clipped |= final_region_pos.mdV[VY] < -F_ALMOST_ZERO || final_region_pos.mdV[VY] > (F64)(region_width - F_ALMOST_ZERO);
    3.51 -	clipped |= final_region_pos.mdV[VZ] < -F_ALMOST_ZERO || final_region_pos.mdV[VZ] > (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO); // if actually clipping
    3.52 -	// Final sanity check - don't allow positions more than clamp_range out of region.
    3.53 -	F64 clamp_range = region_width / 2.0; // half a region width
    3.54 -	final_region_pos.mdV[VX] = llclamp(final_region_pos.mdV[VX], -clamp_range,
    3.55 -									   (F64)(region_width + clamp_range));
    3.56 -	final_region_pos.mdV[VY] = llclamp(final_region_pos.mdV[VY], -clamp_range,
    3.57 -									   (F64)(region_width + clamp_range));
    3.58 -	final_region_pos.mdV[VZ] = llclamp(final_region_pos.mdV[VZ], 0.0,
    3.59 -									   (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO));
    3.60 +	LLVector3d final_region_pos;
    3.61 +	if (fsExperimentalRegionCrossingMovementFix)
    3.62 +	{
    3.63 +		// True if clipped. Caller needs to know, because it will kill velocity if there's clipping
    3.64 +		// Don't do this by comparing floating point numbers for equality. That has roundoff problems.
    3.65 +		clipped = clip_factor > F_ALMOST_ZERO;						// clipped in X or Y
    3.66 +		final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor);
    3.67 +		clipped |= final_region_pos.mdV[VX] < -F_ALMOST_ZERO || final_region_pos.mdV[VX] > (F64)(region_width - F_ALMOST_ZERO);
    3.68 +		clipped |= final_region_pos.mdV[VY] < -F_ALMOST_ZERO || final_region_pos.mdV[VY] > (F64)(region_width - F_ALMOST_ZERO);
    3.69 +		clipped |= final_region_pos.mdV[VZ] < -F_ALMOST_ZERO || final_region_pos.mdV[VZ] > (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO); // if actually clipping
    3.70 +		// Final sanity check - don't allow positions more than clamp_range out of region.
    3.71 +		F64 clamp_range = region_width / 2.0; // half a region width
    3.72 +		final_region_pos.mdV[VX] = llclamp(final_region_pos.mdV[VX], -clamp_range,
    3.73 +			(F64)(region_width + clamp_range));
    3.74 +		final_region_pos.mdV[VY] = llclamp(final_region_pos.mdV[VY], -clamp_range,
    3.75 +			(F64)(region_width + clamp_range));
    3.76 +		final_region_pos.mdV[VZ] = llclamp(final_region_pos.mdV[VZ], 0.0,
    3.77 +			(F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO));
    3.78 +	}
    3.79 +	else
    3.80 +	{
    3.81 +		// clamp to within region dimensions
    3.82 +		final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor);
    3.83 +		final_region_pos.mdV[VX] = llclamp(final_region_pos.mdV[VX], 0.0,
    3.84 +										   (F64)(region_width - F_ALMOST_ZERO));
    3.85 +		final_region_pos.mdV[VY] = llclamp(final_region_pos.mdV[VY], 0.0,
    3.86 +										   (F64)(region_width - F_ALMOST_ZERO));
    3.87 +		final_region_pos.mdV[VZ] = llclamp(final_region_pos.mdV[VZ], 0.0,
    3.88 +										   (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO));
    3.89 +	}
    3.90  	// </FS>
    3.91  	return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos));
    3.92  }

mercurial