Skip to content

Commit

Permalink
fix reset verts with duplicate mesh name (#6)
Browse files Browse the repository at this point in the history
fix empty group meshes
fix multiWindow add meshes

Co-authored-by: Guillaume Babin <[email protected]>
  • Loading branch information
guibab and Guillaume Babin authored May 15, 2024
1 parent 6ee9bca commit 742c3eb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 26 deletions.
2 changes: 2 additions & 0 deletions scripts/blurdeform/blurAddPose.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ def __init__(self, parent=None):

self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint)
self.setWindowTitle("Add New Pose")

self.refreshWindow()
11 changes: 7 additions & 4 deletions scripts/blurdeform/blurDeformQueryMeshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class BlurDeformQueryMeshes(Dialog):
def __init__(self, parent=None):
def __init__(self, parent=None, lstMeshes=None, listToSelect=None, addComboMeshes=None):
super(BlurDeformQueryMeshes, self).__init__(parent)
self.btnClicked = None
self.listSelectedMeshes = []
Expand All @@ -28,10 +28,12 @@ def __init__(self, parent=None):
self.buttonBox.button(QtWidgets.QDialogButtonBox.Yes).setText("Add Selected")
self.buttonBox.button(QtWidgets.QDialogButtonBox.YesToAll).setText("Add All")

self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint)
# self.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint)
#self.setWindowModality
self.setWindowTitle("Pick meshes to Add")

self.addComboMeshes = None
self.refreshWindow(lstMeshes, listToSelect, addComboMeshes)

def closeEvent(self, event):
self.listSelectedMeshes = [] # same as rejected
Expand All @@ -56,12 +58,13 @@ def refreshWindow(self, lstMeshes, listToSelect, addComboMeshes):
self.listSelectedMeshes = []
self.uiMeshesLW.clear()
for ind, nm in enumerate(lstMeshes):
item = QtWidgets.QTreeWidgetItem()
print(nm)
item = QtWidgets.QTreeWidgetItem(self.uiMeshesLW)
item.setText(0, nm)
item.setFlags(
item.flags() | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsUserCheckable
)
self.uiMeshesLW.addTopLevelItem(item)
# self.uiMeshesLW.addTopLevelItem(item)

if self.addComboMeshes:
cb = QtWidgets.QComboBox(self)
Expand Down
59 changes: 39 additions & 20 deletions scripts/blurdeform/blurdeform.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def getVertsSelection():
continue
transform = dagPath.transform()
depNode = OpenMaya.MFnDependencyNode(transform)
depNode_name = depNode.name()
depNode_name = cmds.ls(depNode.uniqueName())[0]

if component.isNull():
iterSel.next()
Expand Down Expand Up @@ -149,10 +149,14 @@ def deltasPaste(self):
self.blurDeformQueryMeshesWin,
modal=True,
instanced=True,
lstMeshes=self.currentGeometries,
listToSelect=self.currentGeometries,
addComboMeshes=None

)
self.blurDeformQueryMeshesWin.refreshWindow(
self.currentGeometries, self.currentGeometries, None
)
# self.blurDeformQueryMeshesWin.refreshWindow(
# self.currentGeometries, self.currentGeometries, None
# )

selectedMeshes = self.blurDeformQueryMeshesWin.listSelectedMeshes
indicesMeshes = list(
Expand Down Expand Up @@ -351,6 +355,7 @@ def setSelectedVerticestoInBetweenFrame(self):
def removeSelectedVerticesFromFrame(self):
selectedVertices = getVertsSelection()
if not selectedVertices:
cmds.confirmDialog(t="remove verts", m="select some vertices\nFailed")
return
# get an easy array to deal with
indicesMeshes = sorted(
Expand Down Expand Up @@ -567,12 +572,15 @@ def addNewFrame(self):
self,
blurDeformQueryMeshes.BlurDeformQueryMeshes,
self.blurDeformQueryMeshesWin,
modal=True,
instanced=True,
)
self.blurDeformQueryMeshesWin.refreshWindow(
listResForDuplicate, objsWithAttributes, None
modal=False,
instanced=False,
lstMeshes=listResForDuplicate,
listToSelect=objsWithAttributes,
addComboMeshes=None
)
# self.blurDeformQueryMeshesWin.refreshWindow(
# listResForDuplicate, objsWithAttributes, None
# )
objsToAdd = self.blurDeformQueryMeshesWin.listSelectedMeshes
else:
objsToAdd = objsWithAttributes
Expand All @@ -592,10 +600,14 @@ def addNewFrame(self):
self.blurDeformQueryMeshesWin,
modal=True,
instanced=True,
lstMeshes=selection,
listToSelect=selection,
addComboMeshes=self.currentGeometries

)
self.blurDeformQueryMeshesWin.refreshWindow(
selection, selection, self.currentGeometries
)
# self.blurDeformQueryMeshesWin.refreshWindow(
# selection, selection, self.currentGeometries
# )
selectedMeshes = self.blurDeformQueryMeshesWin.listSelectedMeshes
for geo, sourceMesh in selectedMeshes:
self.doAddNewFrame(self.currentBlurNode, sourceMesh, geo)
Expand Down Expand Up @@ -631,10 +643,14 @@ def addNewFrame(self):
self.refresh(selectTime=True, selTime=cmds.currentTime(q=True))

def doAddNewFrame(self, blurNode, currentGeom, targetMesh):
prt ,= cmds.listRelatives(targetMesh, parent=True, path=True)
# print(blurNode, currentGeom, targetMesh)
prt ,= cmds.listRelatives(targetMesh, parent=True, path=True) or [None]
cmds.parent(targetMesh, currentGeom)
cmds.makeIdentity(targetMesh, apply=True, translate=False, rotate=True, scale=False, normal=0, preserveNormals=True)
cmds.parent(targetMesh, prt)
if prt is not None:
cmds.parent(targetMesh, prt)
else:
cmds.parent(targetMesh, w=True)

poseName = cmds.getAttr(self.currentPose + ".poseName")

Expand Down Expand Up @@ -2249,22 +2265,25 @@ def selectVertices(self):
indexToMesh = {}
for ind, msh in indicesMeshes:
indexToMesh[ind] = msh

toHilite=[]
for ind in storedVectorsIndices:
if ind in indexToMesh:
vertices = cmds.getAttr(
frameChannel
+ ".storedVectors[{}].multiVectorMovements".format(ind),
mi=True,
)
toSelect += [
"{}.vtx[{}]".format(indexToMesh[ind], el)
for el in orderMelList(vertices)
]
if vertices:
toSelect += [
"{}.vtx[{}]".format(indexToMesh[ind], el)
for el in orderMelList(vertices)
]
toHilite.append(indexToMesh[ind])

if toSelect:
with extraWidgets.WaitCursorCtxt():
cmds.select(toSelect)
cmds.hilite(toHilite)
else:
cmds.select(clear=True)

Expand All @@ -2286,7 +2305,7 @@ def callAddPose(self):
modal=False,
instanced=True,
)
self.addPoseWin.refreshWindow()
#self.addPoseWin.refreshWindow()

def callSaveXml(self):
self.toRestore = []
Expand Down
4 changes: 2 additions & 2 deletions scripts/blurdeform/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ def rootWindow():
return window


def launchDialog(parent, dialogClass, instance, modal=True, instanced=True):
def launchDialog(parent, dialogClass, instance, modal=True, instanced=True, **kwargs):
# if instanced:
# if instance is None:
# dlg = dialogClass(parent=parent)
# else:# fails
# dlg = instance
# else:
# dlg = dialogClass(parent=parent)
dlg = dialogClass(parent=parent)
dlg = dialogClass(parent=parent, **kwargs)

if modal:
dlg.exec_()
Expand Down

0 comments on commit 742c3eb

Please sign in to comment.