Hello
I have an MPxNode derived node that takes polygon mesh at input, moves vertives around, and outputs the mesh.
I also added an MFnMatrixAttribute attribute as a transformation space.
I connect locator1.worldMatrix[0] -> myNode.space and everything works as expected - vertives are moved in locators space.
However when I delete the locator, maya crashes. It seems that entire compute function is executed, and crash occurs after it.
Here are some code details:
Attribute creation:
MFnMatrixAttribute mtxAttr;
space = mtxAttr.create( "Space", "Space");
mtxAttr.setStorable(true);
mtxAttr.setWritable(true);
mtxAttr.setConnectable(true);
addAttribute( space );
attributeAffects( myNode::space, myNode::outMesh );
simplified compute function :
MMatrix space_mtx;
MMatrix space_mtx_inv;
MDataHandle spaceData = block.inputValue(space, &status );
if( !status.error() ) {
space_mtx = spaceData.asMatrix();
space_mtx_inv = space_mtx.inverse();
}
else {
MGlobal::displayError(status.errorString());
return MS::kFailure;
}
// Copy the inMesh to the outMesh, so you can
// perform operations directly on outMesh
// this is from devkit example plugin
outputData.set(inputData.asMesh());
MObject mesh = outputData.asMesh();
MFnMesh fnMesh(mesh);
MFloatPointArray verts;
fnMesh.getPoints(verts);
// ...
// move verts[] around using space_mtx and space_mtx_inv
// this works with and without connected locator
// write values back onto output using fast set method on iterator
fnMesh.setPoints(verts);
fnMesh.updateSurface(); // do I need to call that ?
outputData.setClean();
return status;
// after deleting locator - function completes up to this point, and maya crashes
// just disconnecting it works OK
HELP !!