From 974e3e8769d456c5cdd8eb1767a7cf57ab4d52fc Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Thu, 3 Apr 2025 18:19:44 +0900 Subject: [PATCH] fix: Remove unnecessary vertex expansion --- Packages/src/Runtime/UIEffectContext.cs | 21 +++++++++---------- .../src/Runtime/Utilities/GraphicProxy.cs | 4 ++-- Packages/src/Runtime/Utilities/ImageProxy.cs | 13 +++++------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Packages/src/Runtime/UIEffectContext.cs b/Packages/src/Runtime/UIEffectContext.cs index a929ba0..c18a6f4 100644 --- a/Packages/src/Runtime/UIEffectContext.cs +++ b/Packages/src/Runtime/UIEffectContext.cs @@ -749,37 +749,36 @@ namespace Coffee.UIEffects UIVertexUtil.Flip(verts, flipHorizontal, flipVertical); } - private Vector2 GetExpandSize(bool canModifyShape) + private Vector4 GetExpandSize(bool canModifyShape) { - if (!canModifyShape) return Vector2.zero; + if (!canModifyShape) return Vector4.zero; - var expandSize = Vector2.zero; + var expandSize = Vector4.zero; switch (samplingFilter) { case SamplingFilter.BlurFast: - expandSize.x += 10; - expandSize.y += 10; + expandSize += Vector4.one * 10; break; case SamplingFilter.BlurMedium: - expandSize.x += 15; - expandSize.y += 15; + expandSize += Vector4.one * 15; break; case SamplingFilter.BlurDetail: - expandSize.x += 20; - expandSize.y += 20; + expandSize += Vector4.one * 20; break; case SamplingFilter.RgbShift: expandSize.x += 40; - expandSize.y += 40; + expandSize.z += 40; break; } switch (transitionFilter) { case TransitionFilter.Melt: - case TransitionFilter.Burn: expandSize.y += 40; break; + case TransitionFilter.Burn: + expandSize.w += 40; + break; } return expandSize; diff --git a/Packages/src/Runtime/Utilities/GraphicProxy.cs b/Packages/src/Runtime/Utilities/GraphicProxy.cs index b0be22f..9b45ea5 100644 --- a/Packages/src/Runtime/Utilities/GraphicProxy.cs +++ b/Packages/src/Runtime/Utilities/GraphicProxy.cs @@ -72,9 +72,9 @@ namespace Coffee.UIEffects { } - public virtual Vector4 ModifyExpandSize(Graphic graphic, Vector2 expandSize) + public virtual Vector4 ModifyExpandSize(Graphic graphic, Vector4 expandSize) { - return new Vector4(expandSize.x, expandSize.y, expandSize.x, expandSize.y); + return expandSize; } private static readonly Func s_OnLerpVertex = diff --git a/Packages/src/Runtime/Utilities/ImageProxy.cs b/Packages/src/Runtime/Utilities/ImageProxy.cs index 77a1227..0c938f4 100644 --- a/Packages/src/Runtime/Utilities/ImageProxy.cs +++ b/Packages/src/Runtime/Utilities/ImageProxy.cs @@ -33,25 +33,22 @@ namespace Coffee.UIEffects return false; } - public override Vector4 ModifyExpandSize(Graphic graphic, Vector2 expandSize) + public override Vector4 ModifyExpandSize(Graphic graphic, Vector4 expandSize) { - var image = graphic as Image; - var ret = new Vector4(expandSize.x, expandSize.y, expandSize.x, expandSize.y); - - if (image + if (graphic is Image image && image.type == Image.Type.Filled && image.fillMethod == Image.FillMethod.Radial360 && image.fillAmount <= 0.5f) { - ret[(image.fillOrigin + (image.fillClockwise ? 2 : 0)) % 4] = 0; + expandSize[(image.fillOrigin + (image.fillClockwise ? 2 : 0)) % 4] = 0; if (image.fillAmount <= 0.25f) { - ret[(image.fillOrigin + 3) % 4] = 0; + expandSize[(image.fillOrigin + 3) % 4] = 0; } } - return ret; + return expandSize; } } }