Browse Source

Improved lerp node and group keyframe preview

flabbet 1 year ago
parent
commit
343ad6d081

+ 13 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Context/FuncContext.cs

@@ -102,4 +102,17 @@ public class FuncContext
     {
         return getFrom.Connection.ValueType.IsAssignableTo(typeof(Delegate));
     }
+
+    public ShaderExpressionVariable GetValue(FuncInputProperty<Half4> getFrom)
+    {
+        if (getFrom.Connection == null || !IsFuncType(getFrom))
+        {
+            Half4 color = getFrom.Value(this);
+            color.VariableName = $"color_{Builder.GetUniqueNameNumber()}";
+            Builder.AddUniform(color.VariableName, color.ConstantValue);
+            return color;
+        }
+
+        return getFrom.Value(this);
+    }
 }

+ 3 - 3
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/LerpColorNode.cs

@@ -25,9 +25,9 @@ public class LerpColorNode : Node // TODO: ILerpable as inputs?
 
     private Half4 Lerp(FuncContext arg)
     {
-        var from = From.Value(arg);
-        var to = To.Value(arg);
-        var time = Time.Value(arg);
+        var from = arg.GetValue(From);
+        var to = arg.GetValue(To);
+        var time = arg.GetValue(Time);
         
         return arg.NewHalf4(ShaderMath.Lerp(from, to, time)); 
     }

+ 1 - 1
src/PixiEditor/Models/Rendering/MemberPreviewUpdater.cs

@@ -539,7 +539,7 @@ internal class MemberPreviewUpdater
         IReadOnlyStructureNode member, [DisallowNull] AffectedArea? affArea, VecI position, float scaling)
     {
         bool isEditingRootImage = !member.KeyFrames.Any(x => x.IsInFrame(doc.AnimationHandler.ActiveFrameBindable));
-        if (!isEditingRootImage)
+        if (!isEditingRootImage && keyFrame.PreviewSurface is not null)
             return;
 
         if (keyFrame.PreviewSurface == null ||