diff --git a/Runtime/Animation/Smoothing/FrameSmoothing.cs b/Runtime/Animation/Smoothing/FrameSmoothing.cs index 4b71df3..0725537 100644 --- a/Runtime/Animation/Smoothing/FrameSmoothing.cs +++ b/Runtime/Animation/Smoothing/FrameSmoothing.cs @@ -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 ); diff --git a/Runtime/Animation/Smoothing/Smoothing.cs b/Runtime/Animation/Smoothing/Smoothing.cs index f04a69a..5d80a3b 100644 --- a/Runtime/Animation/Smoothing/Smoothing.cs +++ b/Runtime/Animation/Smoothing/Smoothing.cs @@ -4,6 +4,8 @@ using Godot; namespace Rokojori { + [Tool] + [GlobalClass] public partial class Smoothing: Resource { float _currentFloat = 0; diff --git a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs b/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs index 2396dac..51da007 100644 --- a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs +++ b/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs @@ -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;