Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance patch and containment fixes #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ConstantNodeViewModel()
Editor = ValueEditor,
Value = this.WhenAnyValue(vm => vm.ValueEditor.Value)
};
this.Outputs.Add(Output);
this.EditableOutputs().Add(Output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public DivisionNodeViewModel()
Name = "A",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input1);
EditableInputs().Add(Input1);

Input2 = new ValueNodeInputViewModel<int?>
{
Name = "B",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input2);
EditableInputs().Add(Input2);

var divide = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value)
.Select(_ => Input1.Value != null && Input2.Value != null && Input2.Value != 0 ? Input1.Value / Input2.Value : null);
Expand All @@ -45,7 +45,7 @@ public DivisionNodeViewModel()
Name = "A / B",
Value = divide
};
Outputs.Add(Output);
EditableOutputs().Add(Output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public OutputNodeViewModel()
Name = "Value",
Editor = new IntegerValueEditorViewModel()
};
this.Inputs.Add(ResultInput);
this.EditableInputs().Add(ResultInput);
}
}
}
6 changes: 3 additions & 3 deletions ExampleCalculatorApp/ViewModels/Nodes/ProductNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public ProductNodeViewModel()
Name = "A",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input1);
EditableInputs().Add(Input1);

Input2 = new ValueNodeInputViewModel<int?>
{
Name = "B",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input2);
EditableInputs().Add(Input2);

var product = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value)
.Select(_ => Input1.Value != null && Input2.Value != null ? Input1.Value * Input2.Value : null);
Expand All @@ -44,7 +44,7 @@ public ProductNodeViewModel()
Name = "A * B",
Value = product
};
Outputs.Add(Output);
EditableOutputs().Add(Output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public SubtractionNodeViewModel()
Name = "A",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input1);
EditableInputs().Add(Input1);

Input2 = new ValueNodeInputViewModel<int?>
{
Name = "B",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input2);
EditableInputs().Add(Input2);

var subtract = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value)
.Select(_ => Input1.Value != null && Input2.Value != null ? Input1.Value - Input2.Value : null);
Expand All @@ -44,7 +44,7 @@ public SubtractionNodeViewModel()
Name = "A - B",
Value = subtract
};
Outputs.Add(Output);
EditableOutputs().Add(Output);
}
}
}
6 changes: 3 additions & 3 deletions ExampleCalculatorApp/ViewModels/Nodes/SumNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public SumNodeViewModel()
Name = "A",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input1);
EditableInputs().Add(Input1);

Input2 = new ValueNodeInputViewModel<int?>
{
Name = "B",
Editor = new IntegerValueEditorViewModel()
};
Inputs.Add(Input2);
EditableInputs().Add(Input2);

var sum = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value)
.Select(_ => Input1.Value != null && Input2.Value != null ? Input1.Value + Input2.Value : null);
Expand All @@ -44,7 +44,7 @@ public SumNodeViewModel()
Name = "A + B",
Value = sum
};
Outputs.Add(Output);
EditableOutputs().Add(Output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public GroupEndpointEditorViewModel(CodeNodeGroupIOBinding nodeGroupBinding)
MoveUp = ReactiveCommand.Create(() =>
{
bool isInput = Parent is NodeInputViewModel;
IEnumerable<Endpoint> endpoints = isInput ? (IEnumerable<Endpoint>)Parent.Parent.Inputs.Items : Parent.Parent.Outputs.Items;
IEnumerable<Endpoint> endpoints = isInput ? (IEnumerable<Endpoint>)Parent.Parent.InputItems : Parent.Parent.OutputItems;

// Swap SortIndex of this endpoint with the SortIndex of the previous endpoint in the list, if any.
var prevElement = endpoints
Expand All @@ -62,7 +62,7 @@ public GroupEndpointEditorViewModel(CodeNodeGroupIOBinding nodeGroupBinding)
MoveDown = ReactiveCommand.Create(() =>
{
bool isInput = Parent is NodeInputViewModel;
IEnumerable<Endpoint> endpoints = isInput ? (IEnumerable<Endpoint>)Parent.Parent.Inputs.Items : Parent.Parent.Outputs.Items;
IEnumerable<Endpoint> endpoints = isInput ? (IEnumerable<Endpoint>)Parent.Parent.InputItems : Parent.Parent.OutputItems;

var nextElement = endpoints
.Where(e => e.SortIndex > Parent.SortIndex)
Expand Down
2 changes: 1 addition & 1 deletion ExampleCodeGenApp/ViewModels/Nodes/ButtonEventNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ButtonEventNode() : base(NodeType.EventNode)
Name = "On Click"
};

this.Inputs.Add(OnClickFlow);
this.EditableInputs().Add(OnClickFlow);
}
}
}
12 changes: 6 additions & 6 deletions ExampleCodeGenApp/ViewModels/Nodes/ForLoopNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,30 @@ public ForLoopNode() : base(NodeType.FlowControl)
Name = "Loop Body",
Group = controlFlowInputsGroup
};
this.Inputs.Add(LoopBodyFlow);
this.EditableInputs().Add(LoopBodyFlow);

LoopEndFlow = new CodeGenListInputViewModel<IStatement>(PortType.Execution)
{
Name = "Loop End",
Group = controlFlowInputsGroup
};
this.Inputs.Add(LoopEndFlow);
this.EditableInputs().Add(LoopEndFlow);


FirstIndex = new CodeGenInputViewModel<ITypedExpression<int>>(PortType.Integer)
{
Name = "First Index",
Group = boundsGroup
};
this.Inputs.Add(FirstIndex);
this.EditableInputs().Add(FirstIndex);

LastIndex = new CodeGenInputViewModel<ITypedExpression<int>>(PortType.Integer)
{
Name = "Last Index",
Group = boundsGroup

};
this.Inputs.Add(LastIndex);
this.EditableInputs().Add(LastIndex);

ForLoop value = new ForLoop();

Expand All @@ -90,14 +90,14 @@ public ForLoopNode() : base(NodeType.FlowControl)
}),
Group = controlFlowGroup
};
this.Outputs.Add(FlowIn);
this.EditableOutputs().Add(FlowIn);

CurrentIndex = new CodeGenOutputViewModel<ITypedExpression<int>>(PortType.Integer)
{
Name = "Current Index",
Value = Observable.Return(new VariableReference<int>{ LocalVariable = value.CurrentIndex })
};
this.Outputs.Add(CurrentIndex);
this.EditableOutputs().Add(CurrentIndex);
}
}
}
2 changes: 1 addition & 1 deletion ExampleCodeGenApp/ViewModels/Nodes/IntLiteralNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public IntLiteralNode() : base(NodeType.Literal)
Editor = ValueEditor,
Value = ValueEditor.ValueChanged.Select(v => new IntLiteral{Value = v ?? 0})
};
this.Outputs.Add(Output);
this.EditableOutputs().Add(Output);
}
}
}
4 changes: 2 additions & 2 deletions ExampleCodeGenApp/ViewModels/Nodes/PrintNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public PrintNode() : base(NodeType.Function)
{
Name = "Text"
};
this.Inputs.Add(Text);
this.EditableInputs().Add(Text);

Flow = new CodeGenOutputViewModel<IStatement>(PortType.Execution)
{
Expand All @@ -47,7 +47,7 @@ public PrintNode() : base(NodeType.Function)
}
})
};
this.Outputs.Add(Flow);
this.EditableOutputs().Add(Flow);
}
}
}
2 changes: 1 addition & 1 deletion ExampleCodeGenApp/ViewModels/Nodes/TextLiteralNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public TextLiteralNode() : base(NodeType.Literal)
Editor = ValueEditor,
Value = ValueEditor.ValueChanged.Select(v => new StringLiteral{ Value = v })
};
this.Outputs.Add(Output);
this.EditableOutputs().Add(Output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ColorNodeViewModel()
ColorOutput.Editor = editor;
ColorOutput.ReturnType = typeof(Vec3);
ColorOutput.Value = editor.ValueChanged;
this.Outputs.Add(ColorOutput);
this.EditableOutputs().Add(ColorOutput);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ public GeometryNodeViewModel()
VertexPositionOutput.ReturnType = typeof(Vec3);
VertexPositionOutput.Value = Observable.Return(new ShaderFunc(() => "pos"));
VertexPositionOutput.Editor = null;
this.Outputs.Add(VertexPositionOutput);
this.EditableOutputs().Add(VertexPositionOutput);

NormalOutput.Name = "Normal";
NormalOutput.ReturnType = typeof(Vec3);
NormalOutput.Value = Observable.Return(new ShaderFunc(() => "norm"));
NormalOutput.Editor = null;
this.Outputs.Add(NormalOutput);
this.EditableOutputs().Add(NormalOutput);

CameraOutput.Name = "Camera";
CameraOutput.ReturnType = typeof(Vec3);
CameraOutput.Value = Observable.Return(new ShaderFunc(() => "cam"));
CameraOutput.Editor = null;
this.Outputs.Add(CameraOutput);
this.EditableOutputs().Add(CameraOutput);
}
}
}
8 changes: 4 additions & 4 deletions ExampleShaderEditorApp/ViewModels/Nodes/Math2NodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public Math2NodeViewModel()

OperationInput.Editor = new EnumEditorViewModel(typeof(MathOperation));
OperationInput.Port.IsVisible = false;
Inputs.Add(OperationInput);
EditableInputs().Add(OperationInput);

InputA.Name = "A";
InputA.Editor = new FloatEditorViewModel();
Inputs.Add(InputA);
EditableInputs().Add(InputA);

InputB.Name = "B";
InputB.Editor = new FloatEditorViewModel();
Inputs.Add(InputB);
EditableInputs().Add(InputB);

Result.Name = "Result";
Result.ReturnType = typeof(float);
Expand All @@ -69,7 +69,7 @@ public Math2NodeViewModel()
}
return BuildMathOperation(t.Item1, t.Item2, (MathOperation) t.Item3);
});
Outputs.Add(Result);
EditableOutputs().Add(Result);
}

private ShaderFunc BuildMathOperation(ShaderFunc a, ShaderFunc b, MathOperation operation)
Expand Down
6 changes: 3 additions & 3 deletions ExampleShaderEditorApp/ViewModels/Nodes/MathNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ public MathNodeViewModel()

OperationInput.Editor = new EnumEditorViewModel(typeof(MathOperation));
OperationInput.Port.IsVisible = false;
Inputs.Add(OperationInput);
EditableInputs().Add(OperationInput);

Input.Name = "A";
Input.Editor = new FloatEditorViewModel();
Inputs.Add(Input);
EditableInputs().Add(Input);

Result.Name = "Result";
Result.ReturnType = typeof(float);
Result.Value = this.WhenAnyValue(vm => vm.Input.Value, vm => vm.OperationInput.Value)
.Select(t => (t.Item1 == null || t.Item2 == null) ? null : BuildMathOperation(t.Item1, (MathOperation)t.Item2));
Outputs.Add(Result);
EditableOutputs().Add(Result);
}

private ShaderFunc BuildMathOperation(ShaderFunc a, MathOperation operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ShaderOutputNodeViewModel()
this.CanBeRemovedByUser = false;

ColorInput.Name = "Color";
this.Inputs.Add(ColorInput);
this.EditableInputs().Add(ColorInput);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public TimeNodeViewModel()
Result.Name = "Seconds";
Result.ReturnType = typeof(float);
Result.Value = Observable.Return(new ShaderFunc(() => "seconds"));
Outputs.Add(Result);
EditableOutputs().Add(Result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public Vec2PackNodeViewModel()

XInput.Name = "X";
XInput.Editor = new FloatEditorViewModel();
Inputs.Add(XInput);
EditableInputs().Add(XInput);

YInput.Name = "Y";
YInput.Editor = new FloatEditorViewModel();
Inputs.Add(YInput);
EditableInputs().Add(YInput);

Result.Name = "Vec2";
Result.ReturnType = typeof(Vec2);
Expand All @@ -49,7 +49,7 @@ public Vec2PackNodeViewModel()
}
return new ShaderFunc(() => $"vec2(({t.Item1.Compile()}), ({t.Item2.Compile()}))");
});
Outputs.Add(Result);
EditableOutputs().Add(Result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public Vec2UnpackNodeViewModel()

VectorInput.Name = "Vec2";
VectorInput.Editor = null;
Inputs.Add(VectorInput);
EditableInputs().Add(VectorInput);

X.Name = "X";
X.ReturnType = typeof(float);
X.Value = this.WhenAnyValue(vm => vm.VectorInput.Value).Select(v => v == null ? null : new ShaderFunc(() => $"({v.Compile()}).x"));
Outputs.Add(X);
EditableOutputs().Add(X);

Y.Name = "Y";
Y.ReturnType = typeof(float);
Y.Value = this.WhenAnyValue(vm => vm.VectorInput.Value).Select(v => v == null ? null : new ShaderFunc(() => $"({v.Compile()}).y"));
Outputs.Add(Y);
EditableOutputs().Add(Y);
}
}
}
Loading