MStatus polyModifierCmd::undoModifyPoly() { MStatus status = MS::kSuccess; if( !fHasHistory && !fHasRecordHistory ) { status = undoDirectModifier(); } else { fDGModifier.undoIt(); // undoCachedMesh must be called before undoTweakProcessing because // undoCachedMesh copies the original mesh *without* tweaks back onto // the existing mesh. Any changes done before the copy will be lost. // if( !fHasHistory ) { status = undoCachedMesh(); MCheckStatus( status, "undoCachedMesh" ); fDagModifier.undoIt(); } status = undoTweakProcessing(); MCheckStatus( status, "undoTweakProcessing" ); } return status; }
// -------------------------------------------------------------------------------------------- MStatus polyModifierCmd::undoModifyPoly() // -------------------------------------------------------------------------------------------- { MStatus status = MS::kSuccess; if( !fHasHistory && !fHasRecordHistory ) { status = undoDirectModifier(); } else { // Merke: Das MObject zur ModifierNode sollte jetzt zerstrt werden, da es ungueltig wird, wenn der modifier rueckgngig gemacht wird. // Ansonsten gibts nen absturz myModifierNode = MObject::kNullObj; if(createAnimCurves) { createSlideAnim.undoIt(); } fDGModifier.undoIt(); // undoCachedMesh must be called before undoTweakProcessing because // undoCachedMesh copies the original mesh *without* tweaks back onto // the existing mesh. Any changes done before the copy will be lost. // if( !fHasHistory ) { status = undoCachedMesh(); MCheckStatus( status, "undoCachedMesh" ); //fDagModifier.undoIt(); deleteDuplicate.undoIt(); reparentDuplicate.undoIt(); createDuplicate.undoIt(); } status = undoTweakProcessing(); MCheckStatus( status, "undoTweakProcessing" ); } return status; }
MStatus polyModifierCmd::undoModifyPoly() { MStatus status = MS::kSuccess; if( !fHasHistory && !fHasRecordHistory ) { status = undoDirectModifier(); } else { fDGModifier.undoIt(); // undoCachedMesh must be called before undoTweakProcessing because // undoCachedMesh copies the original mesh *without* tweaks back onto // the existing mesh. Any changes done before the copy will be lost. // if( !fHasHistory ) { status = undoCachedMesh(); MCheckStatus( status, "undoCachedMesh" ); //by_tima: fDagModifier.undoIt(); //########################################################################### tima/ MFnDagNode tmpDagNodeFn( fDuplicateDagPath); tima_tempForUndoDeleteDuplicate_modifier.deleteNode(tmpDagNodeFn.object()); status = tima_tempForUndoDeleteDuplicate_modifier.doIt(); /*#ifdef _DEBUG MGlobal::displayInfo( "tima_upstreamNodeTransform_name = " + tmpDagNodeFn.name()); if(status)cout<<endl<<"tima_tempForUndoDeleteDuplicate_modifier.doIt - success"<<endl; else cout<<endl<<"tima_tempForUndoDeleteDuplicate_modifier.doIt - failed"<<endl; #endif*/ MCheckStatus( status, "tima_tempForUndoDeleteDuplicate_modifier.doIt" ); //########################################################################### /tima } status = undoTweakProcessing(); MCheckStatus( status, "undoTweakProcessing" ); } return status; }
// -------------------------------------------------------------------------------------------- MStatus polyModifierCmd::undoDirectModifier() // -------------------------------------------------------------------------------------------- { MStatus status; MFnDependencyNode depNodeFn; MFnDagNode dagNodeFn; MObject meshNode = fDagPath.node(); depNodeFn.setObject( meshNode ); // For the case with tweaks, we cannot write the mesh directly back onto // the cachedInMesh, since the shape can have out of date information from the // cachedInMesh. Thus we temporarily create an duplicate mesh, place our // old mesh on the outMesh attribute of our duplicate mesh, connect the // duplicate mesh shape to the mesh shape, and force a DG evaluation. // // For the case without tweaks, we can simply write onto the outMesh, since // the shape relies solely on an outMesh when there is no history nor tweaks. // if( fHasTweaks ) { // Retrieve the inMesh and name of our mesh node (for the DG eval) // depNodeFn.setObject( meshNode ); MPlug meshNodeInMeshPlug = depNodeFn.findPlug( "inMesh", &status ); MCheckStatus( status, "Could not retrieve inMesh" ); MString meshNodeName = depNodeFn.name(); // Duplicate our current mesh // dagNodeFn.setObject( meshNode ); MObject dupMeshNode = dagNodeFn.duplicate(); // The dagNodeFn::duplicate() returns a transform, but we need a shape // so retrieve the DAG path and extend it to the shape. // MDagPath dupMeshDagPath; MDagPath::getAPathTo( dupMeshNode, dupMeshDagPath ); dupMeshDagPath.extendToShape(); // Retrieve the outMesh of the duplicate mesh and set our mesh data back // on it. // depNodeFn.setObject( dupMeshDagPath.node() ); MPlug dupMeshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status ); MCheckStatus( status, "Could not retrieve outMesh" ); status = dupMeshNodeOutMeshPlug.setValue( fMeshData ); // Temporarily connect the duplicate mesh node to our mesh node // MDGModifier dgModifier; dgModifier.connect( dupMeshNodeOutMeshPlug, meshNodeInMeshPlug ); status = dgModifier.doIt(); MCheckStatus( status, "Could not connect dupMeshNode -> meshNode" ); // Need to force a DG evaluation now that the input has been changed. // MString cmd("dgeval -src "); cmd += meshNodeName; cmd += ".inMesh"; status = MGlobal::executeCommand( cmd, false, false ); MCheckStatus( status, "Could not force DG eval" ); // Disconnect and delete the duplicate mesh node now // dgModifier.undoIt(); MGlobal::deleteNode( dupMeshNode ); // Restore the tweaks on the mesh // status = undoTweakProcessing(); } else { // Restore the original mesh by writing the old mesh data (fMeshData) back // onto the outMesh of our meshNode // depNodeFn.setObject( meshNode ); MPlug meshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status ); MCheckStatus( status, "Could not retrieve outMesh" ); status = meshNodeOutMeshPlug.setValue( fMeshData ); MCheckStatus( status, "Could not set meshData" ); } return status; }