Skip to content

Commit

Permalink
fix retrieve xml, added vertices count to find match in name mismatch (
Browse files Browse the repository at this point in the history
…#8)

Co-authored-by: Guillaume Babin <guillaume@blur.com>
  • Loading branch information
guibab and Guillaume Babin authored Dec 9, 2024
1 parent 2ddb55e commit 8c13c98
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 6 additions & 2 deletions scripts/blurdeform/blurdeform.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,11 @@ def addNewFrame(self):
self.refresh(selectTime=True, selTime=cmds.currentTime(q=True))

def doAddNewFrame(self, blurNode, currentGeom, targetMesh):
# print(blurNode, currentGeom, targetMesh)
print(blurNode, currentGeom, targetMesh)
prt ,= cmds.listRelatives(targetMesh, parent=True, path=True) or [None]
cmds.parent(targetMesh, currentGeom)
[cmds.setAttr(targetMesh+"."+att+axis, l=False) for att in "trs" for axis in " xyz"]
if prt != currentGeom:
cmds.parent(targetMesh, currentGeom)
cmds.makeIdentity(targetMesh, apply=True, translate=False, rotate=True, scale=False, normal=0, preserveNormals=True)
if prt is not None:
cmds.parent(targetMesh, prt)
Expand Down Expand Up @@ -1633,6 +1635,8 @@ def storeInfoBlurSculpt(self, doc, blurNode, inputPoseFramesIndices=None):
geomIndices = " - ".join(map(str, geoIndices))
blurNode_tag.setAttribute("geom", geom)
blurNode_tag.setAttribute("geomIndices", geomIndices)
nbVertices = cmds.polyEvaluate(geom, v=True)
blurNode_tag.setAttribute("nbVertices", nbVertices)

listPoses = cmds.blurSculpt(blurNode, query=True, listPoses=True)
if not listPoses:
Expand Down
21 changes: 19 additions & 2 deletions scripts/blurdeform/storeXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,23 @@ def retrieveblurXml(self, dicFrames, listPoses, theBlurNode=None):
dicVal = {"blurNode": theBlurNode}

blurNodeMeshToIndex, geomSorted = self.blurInfo[theBlurNode]
fileIndexToMesh = self.blurFileInfo[geomSorted]
if geomSorted not in self.blurFileInfo:
# try the first element
currentNbVerts = cmds.polyEvaluate(geomSorted, v=True)
if currentNbVerts in self.vertsToName:
storedName = self.vertsToName[currentNbVerts]
fileIndexToMesh = self.blurFileInfo[storedName]
print("matching vertices found {}".format(currentNbVerts))
else:
storedName, fileIndexToMesh = next(iter(self.blurFileInfo.items()))

else:
fileIndexToMesh = self.blurFileInfo[geomSorted]
storedName = geomSorted

dicIndexFileToIndexNode = {}
for indexGeo, meshName in six.iteritems(blurNodeMeshToIndex):
indexFile = fileIndexToMesh[meshName]
indexFile = fileIndexToMesh[meshName if meshName in fileIndexToMesh else storedName]
dicIndexFileToIndexNode[indexFile] = indexGeo

pses = cmds.getAttr(theBlurNode + ".poses", mi=True)
Expand Down Expand Up @@ -438,6 +450,7 @@ def readXmlFile(self):
self.blurDic = {}
self.blurInfo = {}
self.blurFileInfo = {}
self.vertsToName = {}
for blurNode in selectedItems:
geos, geoIndices = self.parentWindow.getGeom(blurNode, transform=True)
geomSorted = " - ".join(sorted(geos))
Expand Down Expand Up @@ -489,6 +502,10 @@ def refreshTreeFromRoot(self, root):
self.blurFileInfo[geomSorted] = blurNodeIndexToMesh
# multi deal - with name END

if "nbVertices" in blurNode_tag.attrib:
nbVertices = blurNode_tag.get("nbVertices")
self.vertsToName[int(nbVertices)] = geomSorted

isGeomSelected = geomSorted in geomsSelected
for pose_tag in list(iter(blurNode_tag)):
poseName = pose_tag.get("poseName")
Expand Down

0 comments on commit 8c13c98

Please sign in to comment.