Merge branch 'main' of community.rokojori.com:Rokojori/rj-action-library

This commit is contained in:
Josef 2025-04-25 13:51:58 +02:00
commit a68e052957
3 changed files with 22 additions and 4 deletions

View File

@ -9,7 +9,7 @@ namespace Rokojori
public partial class FrameSmoothing: Smoothing
{
[Export( PropertyHint.Range, "0,600")]
public int frames = 10;
public float frames = 10;
protected override float _ComputeInterpolationAmount( float delta )
{
@ -20,11 +20,10 @@ namespace Rokojori
return 1;
}
var coefficient = GetCoefficientForFrames( frames );
var coefficient = GetLerpedCoefficientForFrames( frames );
return 1f - Mathf.Exp( -coefficient * delta );
}
public static float ComputeCoefficient( float delta, float frames )
{
int floored = Mathf.FloorToInt( frames );
@ -48,6 +47,16 @@ namespace Rokojori
return 1f - Mathf.Exp( -coefficient * delta );
}
public static float GetLerpedCoefficientForFrames( float frames )
{
int floored = Mathf.FloorToInt( frames );
float low = GetCoefficientForFrames( floored );
float high = GetCoefficientForFrames( floored + 1 );
return Mathf.Lerp( low, high, frames - floored );
}
public static float GetCoefficientForFrames( int frames )
{
return FrameSmoothingTable.Get( frames );

View File

@ -4,6 +4,8 @@ using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class Smoothing: Resource
{
float _currentFloat = 0;

View File

@ -42,6 +42,9 @@ namespace Rokojori
public float zoomSmoothingCoefficient = 0.1f;
Smoother smoother = new Smoother();
[Export( PropertyHint.Range, "0,600")]
public Smoothing zoomSmoothing = new Smoothing();
public Vector3 moveDirection = Vector3.Zero;
[Export]
@ -244,7 +247,11 @@ namespace Rokojori
void Apply( float delta )
{
_smoothDistance = smoother.SmoothWithCoefficient( _smoothDistance, distance, zoomSmoothingCoefficient, delta );
// _smoothDistance = smoother.SmoothWithCoefficient( _smoothDistance, distance, zoomSmoothingCoefficient, delta );
// _smoothDistance = FrameSmoothing.ComputeCoefficient
_smoothDistance = Smoothing.Apply( zoomSmoothing, distance, delta );
GlobalRotation = new Vector3( Mathf.DegToRad( pitch ), Mathf.DegToRad( yaw ), 0 );
var forward = Math3D.GetGlobalForward( this ) * _smoothDistance;