perf: improved garbage created by tweens slightly
They still do generate a lot of garbage but with boxed value pools I made the boxes reusable, it still does generate garbage through the delegate creation, gotta find a solution for them later
This commit is contained in:
@@ -5,40 +5,23 @@ namespace Engine.Systems.Tween;
|
||||
public static class TweenTransform2DExtensions
|
||||
{
|
||||
public static ITween TweenPosition(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetPosition)
|
||||
{
|
||||
Vector2D initialPosition = transform2D.Position;
|
||||
return tweenManager.StartTween(duration, t => transform2D.Position = initialPosition.Lerp(targetPosition, t));
|
||||
}
|
||||
=> transform2D.Position.TweenVector2D(tweenManager, duration, targetPosition, x => transform2D.Position = x);
|
||||
|
||||
public static ITween TweenScale(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetScale)
|
||||
{
|
||||
Vector2D initialScale = transform2D.Scale;
|
||||
return tweenManager.StartTween(duration, t => transform2D.Scale = initialScale.Lerp(targetScale, t));
|
||||
}
|
||||
=> transform2D.Scale.TweenVector2D(tweenManager, duration, targetScale, x => transform2D.Scale = x);
|
||||
|
||||
public static ITween TweenRotation(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float targetRotation)
|
||||
{
|
||||
float initialRotation = transform2D.Rotation;
|
||||
return tweenManager.StartTween(duration, t => transform2D.Rotation = initialRotation.Lerp(targetRotation, t));
|
||||
}
|
||||
=> transform2D.Rotation.TweenFloat(tweenManager, duration, targetRotation, x => transform2D.Rotation = x);
|
||||
|
||||
public static ITween TweenLocalPosition(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetLocalPosition)
|
||||
{
|
||||
Vector2D initialLocalPosition = transform2D.LocalPosition;
|
||||
return tweenManager.StartTween(duration, t => transform2D.LocalPosition = initialLocalPosition.Lerp(targetLocalPosition, t));
|
||||
}
|
||||
=> transform2D.LocalPosition.TweenVector2D(tweenManager, duration, targetLocalPosition, x => transform2D.LocalPosition = x);
|
||||
|
||||
public static ITween TweenLocalScale(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetLocalScale)
|
||||
{
|
||||
Vector2D initialLocalScale = transform2D.LocalScale;
|
||||
return tweenManager.StartTween(duration, t => transform2D.LocalScale = initialLocalScale.Lerp(targetLocalScale, t));
|
||||
}
|
||||
=> transform2D.LocalScale.TweenVector2D(tweenManager, duration, targetLocalScale, x => transform2D.LocalScale = x);
|
||||
|
||||
public static ITween TweenLocalRotation(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float targetLocalRotation)
|
||||
{
|
||||
float initialLocalRotation = transform2D.LocalRotation;
|
||||
return tweenManager.StartTween(duration, t => transform2D.LocalRotation = initialLocalRotation.Lerp(targetLocalRotation, t));
|
||||
}
|
||||
=> transform2D.LocalRotation.TweenFloat(tweenManager, duration, targetLocalRotation, x => transform2D.LocalRotation = x);
|
||||
|
||||
public static ITween TweenPositionAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D additivePosition)
|
||||
{
|
||||
Vector2D progressedPosition = Vector2D.Zero;
|
||||
|
Reference in New Issue
Block a user