Skip to content

Commit 1157541

Browse files
committed
Core: UPV Visualizer: Replace subtract nodes with plusMinusAverage Closes #617
Replace Maya 2024.2+ subtract/sum/multiply nodes with backwards- compatible plusMinusAverage and multiplyDivide nodes for Maya 2022+. Use core.node helpers (createDecomposeMatrixNode, createMulNode, createPlusMinusAverage1D) instead of raw pm.createNode calls. Add createPlusMinusAverage3D to core.node for 3D vector operations.
1 parent 95e9a83 commit 1157541

2 files changed

Lines changed: 342 additions & 400 deletions

File tree

release/scripts/mgear/core/node.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,44 @@ def createPlusMinusAverage1D(input, operation=1, output=None):
675675
return node
676676

677677

678+
def createPlusMinusAverage3D(input, operation=1, output=None):
679+
"""Create a plusMinusAverage node with 3D inputs.
680+
681+
Args:
682+
input (attr or list): The input 3D attributes. Each element
683+
is connected to input3D[i].
684+
operation (int): Node operation. 0=None, 1=sum, 2=subtract,
685+
3=average.
686+
output (attr): The attribute to connect output3D to.
687+
688+
Returns:
689+
pyNode: the newly created node.
690+
"""
691+
if not isinstance(input, list):
692+
input = [input]
693+
694+
node = pm.createNode("plusMinusAverage")
695+
node.attr("operation").set(operation)
696+
697+
for i, x in enumerate(input):
698+
try:
699+
pm.connectAttr(x, f"{node}.input3D[{i}]")
700+
except RuntimeError:
701+
if isinstance(x, (list, tuple)) and len(x) == 3:
702+
pm.setAttr(
703+
f"{node}.input3D[{i}]", *x, type="double3"
704+
)
705+
else:
706+
pm.setAttr(
707+
f"{node}.input3D[{i}]", x, x, x, type="double3"
708+
)
709+
710+
if output:
711+
pm.connectAttr(f"{node}.output3D", output)
712+
713+
return node
714+
715+
678716
def createVertexPositionNode(
679717
inShape, vId=0, output=None, name="mgear_vertexPosition"
680718
):

0 commit comments

Comments
 (0)