Hi,
Great forum, lots of respect.
This is some stupid problem i am having with being new to the maya api. Something to do with poly mesh caching and tweaks, maybe.
I have a simple-as node (OpenMayaMPx.MPxNode derived) that takes a mesh in, copies it, does some modifications to CPVs, and spits out the mesh. No special business, this is the skeleton (also file is attached as an example node of this, and setup in he header to quickly see what im on about, if you’d be kind enough to look):
def compute(self, plug, data):
if plug == self.outMesh:
inputMesh_dHandle = data.inputValue(self.inMesh)
outMesh_dHandle = data.outputValue(self.outMesh)
if directCopy:
outMesh_dHandle.copy(inputMesh_dHandle)
outMesh_mFn = OpenMaya.MFnMesh(inputMesh_dHandle.asMesh())
# do CPV stuff
# outMesh_mFn.setVertexColors(colours, vertsToSet)
#outMesh_mFn.updateSurface()
data.setClean(plug)
else:
inputMesh_obj = inputMesh_dHandle.asMesh()
newDataCreator = OpenMaya.MFnMeshData()
outMesh_obj = newDataCreator.create()
outMesh_mFn = OpenMaya.MFnMesh(outMesh_obj)
outMesh_mFn.copy(inputMesh_obj, outMesh_obj)
# do CPV stuff
# outMesh_mFn.setVertexColors(colours, vertsToSet)
outMesh_dHandle.setMObject(outMesh_obj)
#outMesh_mFn.updateSurface()
data.setClean(plug)
… and it appears to work well (there is some not so nice viewport flickering, but other default maya ops working on CPV do the same thing), but for one thing - if you do a transform on an input mesh component, it allows one budge and then also selects the corresponding component on the output mesh, freezes further dragging interaction, and then drops them after mouse off. Subsequent modifications to the input poly dont have this problem. If you simply just select any component on the output mesh (just select, nothing else, no transform) before you do a tweak on the input, then the behavior is normal for that first tweak. This happens regardless of whether the input mesh or the output mesh had history or not, or tweaks, before sticking my node between them. Is this something to do with cachedMesh or tweaks, or similar, but i cant bloody see what to do. That you can ‘prevent’ this ‘problem’ by simply select an output mesh comp before hand makes me suspicious about the cache/tweaks though, as it surprising that a GUI style thing does this when no mesh mod has occurred (?) by simple selection? There other phenomena I could further add, but this is probably diagnostic enough for you folk, and ill try to reduce the noise.
Margh! Retard. I’ve read the api doc notes, but I’m not so sure i need to be doing any extra style things like the polyModifier examples. Save me.
Thanks,
C.