Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix retrieve xml, added vertices count to find match in name mismatch #8

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading