Live patch: simplify node deletion code
This commit is contained in:
parent
2b6a7a4f78
commit
82c7302dd9
|
@ -110,42 +110,15 @@ class LivePatch extends iron.Trait {
|
|||
@:privateAccess node.inputs[socketIndex].set(value);
|
||||
}
|
||||
|
||||
public static function patchNodeDelete(treeName: String, nodeName: String, outputDatas: Array<Array<Dynamic>>) {
|
||||
public static function patchNodeDelete(treeName: String, nodeName: String) {
|
||||
var tree = LogicTree.nodeTrees[treeName];
|
||||
if (tree == null) return;
|
||||
|
||||
var node = tree.nodes[nodeName];
|
||||
if (node == null) return;
|
||||
|
||||
// Remove this node from the outputs of connected nodes
|
||||
for (input in node.inputs) {
|
||||
var inNodeOutputs = input.node.outputs;
|
||||
|
||||
// Default nodes don't have outputs when exported from Blender
|
||||
if (input.from < inNodeOutputs.length) {
|
||||
for (outNode in inNodeOutputs[input.from]) {
|
||||
if (outNode == node) {
|
||||
inNodeOutputs[input.from].remove(outNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Replace connected inputs of other nodes with default nodes
|
||||
for (outputNodes in node.outputs) {
|
||||
for (outNode in outputNodes) {
|
||||
for (outNodeInput in outNode.inputs) {
|
||||
if (outNodeInput.node == node) {
|
||||
var outputIndex = outNodeInput.from;
|
||||
var socketType = outputDatas[outputIndex][0];
|
||||
var socketValue = outputDatas[outputIndex][1];
|
||||
outNodeInput.node = createSocketDefaultNode(node.tree, socketType, socketValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node.clearOutputs();
|
||||
node.clearInputs();
|
||||
tree.nodes.remove(nodeName);
|
||||
}
|
||||
|
||||
|
|
|
@ -242,10 +242,7 @@ def send_event(event_id: str, opt_data: Any = None):
|
|||
tree_name = arm.node_utils.get_export_tree_name(node.get_tree())
|
||||
node_name = arm.node_utils.get_export_node_name(node)[1:]
|
||||
|
||||
out_data = [(out.arm_socket_type, out.get_default_value()) for out in node.outputs]
|
||||
out_data = arm.node_utils.haxe_format_socket_val(out_data)
|
||||
|
||||
js = f'LivePatch.patchNodeDelete("{tree_name}", "{node_name}", {out_data});'
|
||||
js = f'LivePatch.patchNodeDelete("{tree_name}", "{node_name}");'
|
||||
write_patch(js)
|
||||
|
||||
elif event_id == 'ln_copy':
|
||||
|
|
Loading…
Reference in a new issue