Skip to content

Commit

Permalink
core: applyop: add arg maintainRotOffset to gear_matrix_cns
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcampos committed Oct 16, 2024
1 parent 4e1afb2 commit 91b7304
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions release/scripts/mgear/core/applyop.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def gear_matrix_cns(
rot_off=[0, 0, 0],
rot_mult=[1, 1, 1],
scl_mult=[1, 1, 1],
maintainRotOffset=True,
):
"""Create and connect matrix constraint node
Expand Down Expand Up @@ -387,13 +388,14 @@ def gear_matrix_cns(
force=True,
)

# calculate rest pose
# we use the outputDriverOffsetMatrix to have in account the offset
# rotation when the rest pose is calculated
driver_m = om.MMatrix(pm.getAttr(node + ".outputDriverOffsetMatrix"))
driven_m = om.MMatrix(pm.getAttr(out_obj + ".parentInverseMatrix[0]"))
mult = driver_m * driven_m
pm.setAttr(node + ".drivenRestMatrix", mult, type="matrix")
if maintainRotOffset:
# calculate rotation rest pose
# we use the outputDriverOffsetMatrix to have in account the offset
# rotation when the rest pose is calculated
driver_m = om.MMatrix(pm.getAttr(node + ".outputDriverOffsetMatrix"))
driven_m = om.MMatrix(pm.getAttr(out_obj + ".parentInverseMatrix[0]"))
mult = driver_m * driven_m
pm.setAttr(node + ".drivenRestMatrix", mult, type="matrix")

# connect srt (scale, rotation, translation)
if "t" in connect_srt:
Expand Down

0 comments on commit 91b7304

Please sign in to comment.