Fix for Jittery and Jerkiness on Gestures During Scenes #406

Open
opened 2024-10-23 21:35:21 +00:00 by epicplayer40 · 5 comments
epicplayer40 commented 2024-10-23 21:35:21 +00:00 (Migrated from gitlab.com)

In the HL2 leak and Leaknet, character models that are playing scene files with gestures in them will have gestures that glitch out after they finish playing and look bad. Here is how to fix it in cl_dll/animationlayer.h:

At line 31, replace
output.flCycle = LoopingLerp( flPercent, from.flCycle, to.flCycle );
with:

	if(to.flCycle > from.flCycle)
	{
		output.flCycle = LoopingLerp( flPercent, from.flCycle, to.flCycle );
		//Msg("Loop Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle);
	}
	else
	{
		output.flCycle = to.flCycle;
	}

At line 47, replace
output.flCycle = Lerp( flPercent, from.flCycle, to.flCycle );
with:

	if(to.flCycle > from.flCycle)
	{
		output.flCycle = Lerp( flPercent, from.flCycle, to.flCycle );
		//Msg("Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle);
	}
	else
	{
		output.flCycle = to.flCycle;
	}

At line 76, at the start of the
LoopingLerp_Hermite( float flPercent, AnimationLayer_t prev, AnimationLayer_t from, AnimationLayer_t to )
function, before the line that says
AnimationLayer_t output;
add in:
return LoopingLerp(flPercent, from, to);

After
output.nSequence = to.nSequence;
Change
output.flCycle = LoopingLerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle );
to:

	if(to.flCycle > from.flCycle)
	{
		output.flCycle = LoopingLerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle );
		//Msg("Loop Hermite Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle);
	}
	else
	{
		output.flCycle = to.flCycle;
	}

At the function
inline AnimationLayer_t Lerp_Hermite<AnimationLayer_t>( float flPercent, const AnimationLayer_t& prev, const AnimationLayer_t& from, const AnimationLayer_t& to )
Before the line that says AnimationLayer_t output;
add
return Lerp(flPercent, from, to);

And then after the line
output.nSequence = to.nSequence;
Change
output.flCycle = Lerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle );
to:

if(to.flCycle > from.flCycle)
	{
		output.flCycle = Lerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle );
		//Msg("Hermite Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle);
	}
	else
	{
		output.flCycle = to.flCycle;
	}

An example of the fixed animationlayer.h file has been attached: animationlayer.h

In the HL2 leak and Leaknet, character models that are playing scene files with gestures in them will have gestures that glitch out after they finish playing and look bad. Here is how to fix it in `cl_dll/animationlayer.h`: At line 31, replace `output.flCycle = LoopingLerp( flPercent, from.flCycle, to.flCycle );` with: ```cpp if(to.flCycle > from.flCycle) { output.flCycle = LoopingLerp( flPercent, from.flCycle, to.flCycle ); //Msg("Loop Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle); } else { output.flCycle = to.flCycle; } ``` At line 47, replace `output.flCycle = Lerp( flPercent, from.flCycle, to.flCycle );` with: ```cpp if(to.flCycle > from.flCycle) { output.flCycle = Lerp( flPercent, from.flCycle, to.flCycle ); //Msg("Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle); } else { output.flCycle = to.flCycle; } ``` At line 76, at the start of the `LoopingLerp_Hermite( float flPercent, AnimationLayer_t prev, AnimationLayer_t from, AnimationLayer_t to )` function, before the line that says `AnimationLayer_t output;` add in: `return LoopingLerp(flPercent, from, to);` After `output.nSequence = to.nSequence;` Change `output.flCycle = LoopingLerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle );` to: ```cpp if(to.flCycle > from.flCycle) { output.flCycle = LoopingLerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle ); //Msg("Loop Hermite Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle); } else { output.flCycle = to.flCycle; } ``` At the function `inline AnimationLayer_t Lerp_Hermite<AnimationLayer_t>( float flPercent, const AnimationLayer_t& prev, const AnimationLayer_t& from, const AnimationLayer_t& to )` Before the line that says `AnimationLayer_t output;` add `return Lerp(flPercent, from, to);` And then after the line `output.nSequence = to.nSequence;` Change `output.flCycle = Lerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle );` to: ```cpp if(to.flCycle > from.flCycle) { output.flCycle = Lerp_Hermite( flPercent, prev.flCycle, from.flCycle, to.flCycle ); //Msg("Hermite Lerping flCycle from %f to %f, result : %f\n", from.flCycle, to.flCycle, output.flCycle); } else { output.flCycle = to.flCycle; } ``` An example of the fixed animationlayer.h file has been attached: [animationlayer.h](/uploads/78026047d79ca04345198fbd2ce60dc4/animationlayer.h)
epicplayer40 commented 2024-10-23 21:35:38 +00:00 (Migrated from gitlab.com)

changed title from Fix{-Ing-} Jittery and Jerkiness on Gestures During Scenes to Fix{+ for+} Jittery and Jerkiness on Gestures During Scenes

changed title from **Fix{-Ing-} Jittery and Jerkiness on Gestures During Scenes** to **Fix{+ for+} Jittery and Jerkiness on Gestures During Scenes**
epicplayer40 commented 2024-10-23 21:36:22 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
UAVXP commented 2024-11-11 14:15:13 +00:00 (Migrated from gitlab.com)

You can actually make a merge request with those changes, if you will

You can actually make a merge request with those changes, if you will
UAVXP commented 2024-11-11 14:17:13 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
tyabus commented 2024-12-05 14:32:01 +00:00 (Migrated from gitlab.com)

mentioned in commit f416a9b1ae

mentioned in commit f416a9b1aeecb8e25e839bed9693eacd4d4bb02a
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Archive/LeakNet#406
No description provided.