2025-01-13 18:11:12 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
[Tool]
|
|
|
|
[GlobalClass]
|
|
|
|
public partial class FrameSmoothing: Smoothing
|
|
|
|
{
|
|
|
|
[Export( PropertyHint.Range, "0,600")]
|
|
|
|
public int frames = 10;
|
2025-01-16 07:20:32 +00:00
|
|
|
|
2025-01-13 18:11:12 +00:00
|
|
|
protected override float _ComputeInterpolationAmount( float delta )
|
|
|
|
{
|
2025-01-16 07:20:32 +00:00
|
|
|
frames = Mathf.Clamp( frames, 0, 600 );
|
|
|
|
|
2025-01-13 18:11:12 +00:00
|
|
|
if ( frames <= 0 )
|
|
|
|
{
|
|
|
|
return 1;
|
2025-01-16 07:20:32 +00:00
|
|
|
}
|
2025-01-13 18:11:12 +00:00
|
|
|
|
|
|
|
var coefficient = GetCoefficientForFrames( frames );
|
|
|
|
return 1f - Mathf.Exp( -coefficient * delta );
|
|
|
|
}
|
|
|
|
|
2025-01-16 07:20:32 +00:00
|
|
|
public static float GetCoefficientForFrames( int frames )
|
2025-01-13 18:11:12 +00:00
|
|
|
{
|
2025-01-16 07:20:32 +00:00
|
|
|
return FrameSmoothingTable.Get( frames );
|
2025-01-13 18:11:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|