Merge branch 'main' of community.rokojori.com:Rokojori/rj-action-library
This commit is contained in:
commit
a68e052957
|
@ -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 );
|
||||
|
|
|
@ -4,6 +4,8 @@ using Godot;
|
|||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class Smoothing: Resource
|
||||
{
|
||||
float _currentFloat = 0;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue