|
|
@@ -164,38 +164,50 @@ public class DocumentRenderer : IPreviewRenderable, IDisposable
|
|
|
|
|
|
fullGraph.OutputNode.TraverseBackwards((node, input) =>
|
|
|
{
|
|
|
- if (node is StructureNode structureNode && membersToCombine != null &&
|
|
|
- !membersToCombine.Contains(structureNode.Id))
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
+ return CloneElement(membersToCombine, fullGraph, node, membersOnlyGraph, input, nodeMapping);
|
|
|
+ });
|
|
|
|
|
|
- if (node is LayerNode layer)
|
|
|
- {
|
|
|
- LayerNode clone = (LayerNode)layer.Clone();
|
|
|
- membersOnlyGraph.AddNode(clone);
|
|
|
+ return membersOnlyGraph;
|
|
|
+ }
|
|
|
|
|
|
+ private static bool CloneElement(HashSet<Guid>? membersToCombine, IReadOnlyNodeGraph fullGraph, IReadOnlyNode node,
|
|
|
+ NodeGraph membersOnlyGraph, IInputProperty input, Dictionary<Guid, Guid> nodeMapping,
|
|
|
+ IInputProperty? fallback = null)
|
|
|
+ {
|
|
|
+ if (node is StructureNode structureNode && membersToCombine != null &&
|
|
|
+ !membersToCombine.Contains(structureNode.Id))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- IInputProperty targetInput = GetTargetInput(input, fullGraph, membersOnlyGraph, nodeMapping);
|
|
|
+ if (node is LayerNode layer)
|
|
|
+ {
|
|
|
+ LayerNode clone = (LayerNode)layer.Clone();
|
|
|
+ membersOnlyGraph.AddNode(clone);
|
|
|
|
|
|
- clone.Output.ConnectTo(targetInput);
|
|
|
- nodeMapping[layer.Id] = clone.Id;
|
|
|
- }
|
|
|
- else if (node is FolderNode folder)
|
|
|
- {
|
|
|
- FolderNode clone = (FolderNode)folder.Clone();
|
|
|
- membersOnlyGraph.AddNode(clone);
|
|
|
+ IInputProperty targetInput = GetTargetInput(input, fullGraph, membersOnlyGraph, nodeMapping, fallback);
|
|
|
|
|
|
- var targetInput = GetTargetInput(input, fullGraph, membersOnlyGraph, nodeMapping);
|
|
|
+ clone.Output.ConnectTo(targetInput);
|
|
|
+ nodeMapping[layer.Id] = clone.Id;
|
|
|
+ }
|
|
|
+ else if (node is FolderNode folder)
|
|
|
+ {
|
|
|
+ FolderNode clone = (FolderNode)folder.Clone();
|
|
|
+ membersOnlyGraph.AddNode(clone);
|
|
|
|
|
|
- clone.Output.ConnectTo(targetInput);
|
|
|
- nodeMapping[folder.Id] = clone.Id;
|
|
|
- }
|
|
|
+ var targetInput = GetTargetInput(input, fullGraph, membersOnlyGraph, nodeMapping, fallback);
|
|
|
|
|
|
- return true;
|
|
|
- });
|
|
|
+ clone.Output.ConnectTo(targetInput);
|
|
|
+ nodeMapping[folder.Id] = clone.Id;
|
|
|
|
|
|
- return membersOnlyGraph;
|
|
|
+ folder.Content.Connection?.Node.TraverseBackwards((childNode, childInput) =>
|
|
|
+ {
|
|
|
+ return CloneElement(membersToCombine, fullGraph, childNode, membersOnlyGraph, childInput,
|
|
|
+ nodeMapping, clone.Content);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
RectD? IPreviewRenderable.GetPreviewBounds(int frame, string elementNameToRender = "") =>
|
|
|
@@ -324,9 +336,13 @@ public class DocumentRenderer : IPreviewRenderable, IDisposable
|
|
|
private static IInputProperty GetTargetInput(IInputProperty? input,
|
|
|
IReadOnlyNodeGraph sourceGraph,
|
|
|
NodeGraph membersOnlyGraph,
|
|
|
- Dictionary<Guid, Guid> nodeMapping)
|
|
|
+ Dictionary<Guid, Guid> nodeMapping, IInputProperty? fallback = null)
|
|
|
{
|
|
|
- if (input == null)
|
|
|
+ if (input == null && fallback != null)
|
|
|
+ {
|
|
|
+ return fallback;
|
|
|
+ }
|
|
|
+ else if (input == null)
|
|
|
{
|
|
|
if (membersOnlyGraph.OutputNode is IRenderInput inputNode) return inputNode.Background;
|
|
|
|