Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Deleting connection to MFnMatrixAttribute crashes Maya

Deleting connection to MFnMatrixAttribute crashes Maya

Anonymous
Not applicable
348 Views
1 Reply
Message 1 of 2

Deleting connection to MFnMatrixAttribute crashes Maya

Anonymous
Not applicable
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 -> 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
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


thanks !
-Michal
0 Likes
349 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
solved !

My node was MPxNode derived, but registered as MPxDeformerNode - blame Copy&Paste programming
0 Likes