diff --git a/.gitmodules b/.gitmodules index f6170fc..998206a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "cgcmake"] path = cgcmake - url = git@github.com:chadmv/cgcmake.git + url = https://github.com/chadmv/cgcmake.git diff --git a/cgcmake b/cgcmake index f896a28..a1ca40f 160000 --- a/cgcmake +++ b/cgcmake @@ -1 +1 @@ -Subproject commit f896a28b174969d3e77faecdbc30c2bccbff3595 +Subproject commit a1ca40f87cf30c4e6e57505616258cc4e4a0eced diff --git a/scripts/cvwrap/bindui.py b/scripts/cvwrap/bindui.py index 721919e..4b49873 100644 --- a/scripts/cvwrap/bindui.py +++ b/scripts/cvwrap/bindui.py @@ -1,4 +1,9 @@ +from __future__ import absolute_import +from __future__ import print_function + import maya.cmds as cmds + + if cmds.about(api=True) >= 201700: from PySide2 import QtWidgets as QtGui else: @@ -7,6 +12,8 @@ from maya.app.general.mayaMixin import MayaQWidgetBaseMixin _win = None + + def show(): global _win if _win == None: @@ -27,34 +34,40 @@ def __init__(self, parent=None): hbox = QtGui.QHBoxLayout() vbox.addLayout(hbox) label = QtGui.QLabel('Components to rebind:') - label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + label.setSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.Fixed) label.setMinimumWidth(label_width) label.setMaximumWidth(label_width) hbox.addWidget(label) self.components_to_rebind = QtGui.QLineEdit() - self.components_to_rebind.textChanged.connect(self.populate_cvwrap_dropdown) + self.components_to_rebind.textChanged.connect( + self.populate_cvwrap_dropdown) hbox.addWidget(self.components_to_rebind) button = QtGui.QPushButton('Set Components') - button.released.connect(partial(self.set_selected_text, widget=self.components_to_rebind)) + button.released.connect( + partial(self.set_selected_text, widget=self.components_to_rebind)) hbox.addWidget(button) hbox = QtGui.QHBoxLayout() vbox.addLayout(hbox) label = QtGui.QLabel('Faces to rebind to:') - label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + label.setSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.Fixed) label.setMinimumWidth(label_width) label.setMaximumWidth(label_width) hbox.addWidget(label) self.target_faces = QtGui.QLineEdit() hbox.addWidget(self.target_faces) button = QtGui.QPushButton('Set Faces') - button.released.connect(partial(self.set_selected_text, widget=self.target_faces)) + button.released.connect(partial(self.set_selected_text, + widget=self.target_faces)) hbox.addWidget(button) hbox = QtGui.QHBoxLayout() vbox.addLayout(hbox) label = QtGui.QLabel('cvWrap node:') - label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + label.setSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.Fixed) label.setMinimumWidth(label_width) label.setMaximumWidth(label_width) hbox.addWidget(label) @@ -64,7 +77,8 @@ def __init__(self, parent=None): hbox = QtGui.QHBoxLayout() vbox.addLayout(hbox) label = QtGui.QLabel('Sample radius:') - label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + label.setSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.Fixed) label.setMinimumWidth(label_width) label.setMaximumWidth(label_width) hbox.addWidget(label) @@ -106,7 +120,8 @@ def rebind(self): faces = self.target_faces.text().split() wrap_node = self.cvwrap_combo.currentText() radius = self.sample_radius.value() - # Make sure the faces are actual faces. If they are not, convert to faces. + # Make sure the faces are actual faces. + # If they are not, convert to faces. cmds.select(faces) cmds.ConvertSelectionToFaces() faces = cmds.ls(sl=True) @@ -115,5 +130,4 @@ def rebind(self): cmds.ConvertSelectionToVertices() cmds.select(faces, add=True) cmds.cvWrap(rb=wrap_node, radius=radius) - print 'Rebounded vertices' - + print('Rebounded vertices') diff --git a/scripts/cvwrap/menu.py b/scripts/cvwrap/menu.py index fa0ee37..4395ead 100644 --- a/scripts/cvwrap/menu.py +++ b/scripts/cvwrap/menu.py @@ -1,7 +1,12 @@ -import maya.cmds as cmds -import maya.mel as mel -import maya.OpenMayaUI as OpenMayaUI +from __future__ import absolute_import +from __future__ import print_function + import os + +import maya.mel as mel +import maya.cmds as cmds +# import maya.OpenMayaUI as OpenMayaUI + if cmds.about(api=True) >= 201700: from PySide2 import QtGui else: @@ -54,9 +59,9 @@ def create_menuitems(): sourceType='python', parent=submenu) MENU_ITEMS.append(item) elif menu_label == 'Cluster' and section == 'Paint Weights': - item = cmds.menuItem(label="cvWrap", command=paint_cvwrap_weights, - sourceType='python', insertAfter=item, parent=menu) - MENU_ITEMS.append(item) + item = cmds.menuItem(label="cvWrap", command=paint_cvwrap_weights, + sourceType='python', insertAfter=item, parent=menu) + MENU_ITEMS.append(item) def create_cvwrap(*args, **kwargs): @@ -65,9 +70,10 @@ def create_cvwrap(*args, **kwargs): if len(sel) >= 2: kwargs = get_create_command_kwargs() result = cmds.cvWrap(**kwargs) - print result + print(result) else: - raise RuntimeError("Select at least one surface and one influence object.") + raise RuntimeError( + "Select at least one surface and one influence object.") def get_create_command_kwargs(): @@ -98,7 +104,8 @@ def get_create_command_kwargs(): args['newBindMesh'] = True if cmds.textFieldButtonGrp(BIND_FILE_WIDGET, exists=True): - bind_file = cmds.textFieldButtonGrp(BIND_FILE_WIDGET, q=True, text=True) + bind_file = cmds.textFieldButtonGrp( + BIND_FILE_WIDGET, q=True, text=True) bind_file = os.path.expandvars(bind_file.strip()) if bind_file: if os.path.exists(bind_file): @@ -162,7 +169,9 @@ def close_option_box(*args, **kwargs): def display_bind_file_dialog(*args, **kwargs): - """Displays the dialog to choose the binding file with which to create the cvWrap deformer.""" + """Displays the dialog to choose the binding file with + which to create the cvWrap deformer. + """ root_dir = cmds.workspace(q=True, rootDirectory=True) start_directory = os.path.join(root_dir, 'data') file_path = cmds.fileDialog2(fileFilter='*.wrap', dialogStyle=2, fileMode=1, @@ -221,8 +230,8 @@ def get_wrap_node_from_selected(): if len(wrap_nodes) == 1: return wrap_nodes[0] else: - # Multiple wrap nodes are deforming the mesh. Let the user choose which one - # to use. + # Multiple wrap nodes are deforming the mesh. + # Let the user choose which one to use. return QtGui.QInputDialog.getItem(None, 'Select cvWrap node', 'cvWrap node:', wrap_nodes) diff --git a/src/bindingio.cpp b/src/bindingio.cpp index c353eec..68a4dda 100644 --- a/src/bindingio.cpp +++ b/src/bindingio.cpp @@ -35,21 +35,21 @@ void ReadAttribute(std::ifstream &in, MMatrix &matrix) { MStatus BindingIO::ExportBinding(std::ofstream& out, MObject& oWrapNode) { MStatus status; MFnWeightGeometryFilter fnWrapNode(oWrapNode, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (fnWrapNode.typeId() != CVWrap::id) { MGlobal::displayError(fnWrapNode.name() + " is not a cvWrap node."); - CHECK_MSTATUS_AND_RETURN_IT(MS::kFailure); + CHECK_STATUS_AND_RETURN_IT(MS::kFailure); } out.write((char *)&kWrapFileVersion, sizeof(float)); MPlug plugBindData = fnWrapNode.findPlug(CVWrap::aBindData, false, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Get the input geometry so we can get the geometry indices MObjectArray outputGeometry; status = fnWrapNode.getOutputGeometry(outputGeometry); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Write the number of geometry unsigned int geometryCount = outputGeometry.length(); out.write((char *)(&geometryCount), sizeof(geometryCount)); @@ -60,17 +60,17 @@ MStatus BindingIO::ExportBinding(std::ofstream& out, MObject& oWrapNode) { unsigned int geomIndex = fnWrapNode.indexForOutputShape(outputGeometry[i], &status); // Get the plugs to the binding attributes for this geometry MPlug plugBind = plugBindData.elementByLogicalIndex(geomIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleWeights = plugBind.child(CVWrap::aSampleWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleVerts = plugBind.child(CVWrap::aSampleComponents, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleBindMatrix = plugBind.child(CVWrap::aBindMatrix, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugTriangleVerts = plugBind.child(CVWrap::aTriangleVerts, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBarycentricWeights = plugBind.child(CVWrap::aBarycentricWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); unsigned int numElements = plugSampleWeights.numElements(); out.write((char *)(&numElements), sizeof(numElements)); @@ -78,45 +78,45 @@ MStatus BindingIO::ExportBinding(std::ofstream& out, MObject& oWrapNode) { for (unsigned int j = 0; j < numElements; ++j) { // Write the logical index MPlug plugSampleVertElement = plugSampleVerts.elementByPhysicalIndex(j, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); unsigned int logicalIndex = plugSampleVertElement.logicalIndex(); out.write((char *)(&logicalIndex), sizeof(logicalIndex)); // Export sample vertex ids MObject oSampleIds = plugSampleVertElement.asMObject(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnIntArrayData fnIntData(oSampleIds, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MIntArray sampleIds = fnIntData.array(); WriteAttribute(out, sampleIds); // Export sample weights MObject oWeightData = plugSampleWeights.elementByPhysicalIndex(j, &status).asMObject(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnDoubleArrayData fnDoubleData(oWeightData); MDoubleArray weights = fnDoubleData.array(); WriteAttribute(out, weights); // Export bind matrix MObject oBindMatrix = plugSampleBindMatrix.elementByPhysicalIndex(j, &status).asMObject(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnMatrixData fnMatrixData(oBindMatrix, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); WriteAttribute(out, fnMatrixData.matrix()); // Export triangle vertices MObject oTriangleVerts = plugTriangleVerts.elementByPhysicalIndex(j, &status).asMObject(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnNumericData fnNumericData(oTriangleVerts, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); fnNumericData.getData3Int(triangleVerts[0], triangleVerts[1], triangleVerts[2]); WriteAttribute(out, triangleVerts); // Export the barycentric weights MObject oBaryWeights = plugBarycentricWeights.elementByPhysicalIndex(j, &status).asMObject(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnNumericData fnBaryData(oBaryWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); fnBaryData.getData3Float(baryCoords[0], baryCoords[1], baryCoords[2]); WriteAttribute(out, baryCoords); } @@ -133,9 +133,9 @@ MStatus BindingIO::ImportBinding(std::ifstream& in, MObject& oWrapNode) { MStatus status; MFnWeightGeometryFilter fnWrapNode(oWrapNode, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBindData = fnWrapNode.findPlug(CVWrap::aBindData, false, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); float version; in.read((char *)(&version), sizeof(float)); @@ -152,17 +152,17 @@ MStatus BindingIO::ImportBinding(std::ifstream& in, MObject& oWrapNode) { for (unsigned int geomIndex = 0; geomIndex < geometryCount; ++geomIndex) { // Get the plugs to the binding attributes for this geometry MPlug plugBind = plugBindData.elementByLogicalIndex(geomIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleWeights = plugBind.child(CVWrap::aSampleWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleVerts = plugBind.child(CVWrap::aSampleComponents, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleBindMatrix = plugBind.child(CVWrap::aBindMatrix, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugTriangleVerts = plugBind.child(CVWrap::aTriangleVerts, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBarycentricWeights = plugBind.child(CVWrap::aBarycentricWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); unsigned int numElements = plugSampleWeights.numElements(); in.read((char *)(&numElements), sizeof(numElements)); @@ -174,46 +174,46 @@ MStatus BindingIO::ImportBinding(std::ifstream& in, MObject& oWrapNode) { MIntArray sampleIds; ReadAttribute(in, sampleIds); MObject oIntData = fnIntData.create(sampleIds, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); plugSampleVerts.elementByLogicalIndex(logicalIndex, &status).setMObject(oIntData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Sample weights MDoubleArray weights; ReadAttribute(in, weights); MObject oDoubleData = fnDoubleData.create(weights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); plugSampleWeights.elementByLogicalIndex(logicalIndex, &status).setMObject(oDoubleData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Bind matrix MMatrix bindMatrix; ReadAttribute(in, bindMatrix); MObject oMatrixData = fnMatrixData.create(bindMatrix, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); plugSampleBindMatrix.elementByLogicalIndex(logicalIndex, &status).setMObject(oMatrixData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Triangle vertices MIntArray triangleVertices; ReadAttribute(in, triangleVertices); MObject oNumericData = fnNumericData.create(MFnNumericData::k3Int, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = fnNumericData.setData3Int(triangleVertices[0], triangleVertices[1], triangleVertices[2]); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); plugTriangleVerts.elementByLogicalIndex(logicalIndex, &status).setMObject(oNumericData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Barycentric coordinates MFloatArray coords; ReadAttribute(in, coords); oNumericData = fnNumericData.create(MFnNumericData::k3Float, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = fnNumericData.setData3Float(coords[0], coords[1], coords[2]); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); plugBarycentricWeights.elementByLogicalIndex(logicalIndex, &status).setMObject(oNumericData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } } MGlobal::displayInfo("Wrap binding imported."); diff --git a/src/common.cpp b/src/common.cpp index 72c59d0..ee42c5e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -73,14 +73,14 @@ MStatus GetShapeNode(MDagPath& path, bool intermediate) { for (unsigned int i = 0; i < shapeCount; ++i) { status = path.push(path.child(i)); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (!IsShapeNode(path)) { path.pop(); continue; } MFnDagNode fnNode(path, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if ((!fnNode.isIntermediateObject() && !intermediate) || (fnNode.isIntermediateObject() && intermediate)) { return MS::kSuccess; @@ -99,9 +99,9 @@ MStatus GetDagPath(MString& name, MDagPath& path) { MStatus status; MSelectionList list; status = MGlobal::getSelectionListByName(name, list); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = list.getDagPath(0, path); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -110,7 +110,7 @@ MStatus DeleteIntermediateObjects(MDagPath& path) { MDagPath pathMesh(path); while (GetShapeNode(pathMesh, true) == MS::kSuccess) { status = MGlobal::executeCommand("delete " + pathMesh.partialPathName()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); pathMesh = MDagPath(path); } return MS::kSuccess; @@ -150,14 +150,14 @@ MStatus GetAdjacency(MDagPath& pathMesh, std::vector >& adjacency) MStatus status; // Get mesh adjacency. The adjacency will be all vertex ids on the connected faces. MItMeshVertex itVert(pathMesh, MObject::kNullObj, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnMesh fnMesh(pathMesh, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); adjacency.resize(itVert.count()); for (; !itVert.isDone(); itVert.next()) { MIntArray faces; status = itVert.getConnectedFaces(faces); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); adjacency[itVert.index()].clear(); // Put the vertex ids in a set to avoid duplicates for (unsigned int j = 0; j < faces.length(); ++j) { @@ -189,7 +189,7 @@ MStatus CrawlSurface(const MPoint& startPoint, const MIntArray& vertexIndices, M MStatus status; distances[NORMALIZATION_INDEX] = 0.0; // -1 will represent our hit point. double minStartDistance = 999999.0; - unsigned int minStartIndex = 0; + int minStartIndex = 0; // Instead of a recursive function, which can get pretty slow, we'll use a queue to keep // track of where we are going and where we are coming from. @@ -315,6 +315,7 @@ void CreateMatrix(const MPoint& origin, const MVector& normal, const MVector& up matrix[3][0] = t.x; matrix[3][1] = t.y; matrix[3][2] = t.z; matrix[3][3] = 1.0; } +#ifdef __AVX__ void CalculateBasisComponents(const MDoubleArray& weights, const BaryCoords& coords, const MIntArray& triangleVertices, const MPointArray& points, @@ -323,7 +324,7 @@ void CalculateBasisComponents(const MDoubleArray& weights, const BaryCoords& coo MPoint& origin, MVector& up, MVector& normal) { // Start with the recreated point and normal using the barycentric coordinates of the hit point. unsigned int hitIndex = weights.length()-1; -#ifdef __AVX__ + __m256d originV = Dot4(coords[0], coords[1], coords[2], 0.0, points[triangleVertices[0]], points[triangleVertices[1]], points[triangleVertices[2]], MPoint::origin); @@ -363,7 +364,21 @@ void CalculateBasisComponents(const MDoubleArray& weights, const BaryCoords& coo up.x = alignedStorage[0]; up.y = alignedStorage[1]; up.z = alignedStorage[2]; + + normal.normalize(); + GetValidUp(weights, points, sampleIds, origin, normal, up); +} + #else + +void CalculateBasisComponents(const MDoubleArray& weights, const BaryCoords& coords, + const MIntArray& triangleVertices, const MPointArray& points, + const MFloatVectorArray& normals, const MIntArray& sampleIds, + double* , + MPoint& origin, MVector& up, MVector& normal) { + // Start with the recreated point and normal using the barycentric coordinates of the hit point. + unsigned int hitIndex = weights.length()-1; + MVector hitNormal; // Create the barycentric point and normal. for (int i = 0; i < 3; ++i) { @@ -380,11 +395,12 @@ void CalculateBasisComponents(const MDoubleArray& weights, const BaryCoords& coo // The triangle vertices are sorted by decreasing barycentric coordinates so the first two are // the two closest vertices in the triangle. up = ((points[triangleVertices[0]] + points[triangleVertices[1]]) * 0.5) - origin; -#endif + normal.normalize(); GetValidUp(weights, points, sampleIds, origin, normal, up); } +#endif void GetValidUp(const MDoubleArray& weights, const MPointArray& points, const MIntArray& sampleIds, const MPoint& origin, const MVector& normal, diff --git a/src/common.h b/src/common.h index 0190b45..3cb77f3 100644 --- a/src/common.h +++ b/src/common.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -22,6 +24,18 @@ #include #endif +#define CHECK_STATUS_AND_RETURN_IT(_status) \ +{ \ + MStatus _maya_status = (_status); \ + if ( MStatus::kSuccess != _maya_status ) \ + { \ + std::cerr << "\nAPI error detected in " << __FILE__ \ + << " at line " << __LINE__ << std::endl; \ + _maya_status.perror ( "" ); \ + return (_status); \ + } \ +} + /** Helper function to start a new progress bar. @param[in] title Status title. @@ -210,12 +224,15 @@ struct ThreadData { @param[out] threadData The array of ThreadData objects. It is assumed the array is of size taskCount. */ template -void CreateThreadData(int taskCount, unsigned int elementCount, T* taskData, ThreadData* threadData) { +void CreateThreadData(unsigned int taskCount, unsigned int elementCount, T* taskData, ThreadData* threadData) { + if (taskCount == 0) { + return; + } unsigned int taskLength = (elementCount + taskCount - 1) / taskCount; unsigned int start = 0; unsigned int end = taskLength; - int lastTask = taskCount - 1; - for(int i = 0; i < taskCount; i++) { + unsigned int lastTask = taskCount - 1; + for(unsigned int i = 0; i < taskCount; i++) { if (i == lastTask) { end = elementCount; } diff --git a/src/cvWrapCmd.cpp b/src/cvWrapCmd.cpp index 031c14e..18461d1 100644 --- a/src/cvWrapCmd.cpp +++ b/src/cvWrapCmd.cpp @@ -103,13 +103,13 @@ MStatus CVWrapCmd::doIt(const MArgList& args) { MStatus status; status = GatherCommandArguments(args); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (command_ == kCommandImport || command_ == kCommandExport) { // In import/export mode, get the selected wrap deformer node so we can read/write // data from it. status = selectionList_.getDependNode(0, oWrapNode_); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnDependencyNode fnNode(oWrapNode_); if (fnNode.typeId() != CVWrap::id) { MGlobal::displayError("No wrap node specified."); @@ -117,13 +117,13 @@ MStatus CVWrapCmd::doIt(const MArgList& args) { } } else if (command_ == kCommandRebind) { status = GetGeometryPaths(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = Rebind(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } else { // Otherwise get the driver and driven geometry paths. status = GetGeometryPaths(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Add the cvWrap creation command to the modifier. MString command = "deformer -type cvWrap -n \"" + name_ + "\""; @@ -132,7 +132,7 @@ MStatus CVWrapCmd::doIt(const MArgList& args) { command += " " + fnDriven.partialPathName(); } status = dgMod_.commandToExecute(command); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } return redoIt(); @@ -150,16 +150,16 @@ MStatus CVWrapCmd::GatherCommandArguments(const MArgList& args) { } else if (argData.isFlagSet(kExportFlagShort)) { command_ = kCommandExport; filePath_ = argData.flagArgumentString(kExportFlagShort, 0, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } else if (argData.isFlagSet(kImportFlagShort)) { command_ = kCommandImport; filePath_ = argData.flagArgumentString(kImportFlagShort, 0, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } newBindMesh_ = argData.isFlagSet(kNewBindMeshFlagShort); if (argData.isFlagSet(kRadiusFlagShort)) { radius_ = argData.flagArgumentDouble(kRadiusFlagShort, 0, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Make sure radius is positive if (radius_ <= 0.0) { radius_ = 0.001; @@ -167,12 +167,12 @@ MStatus CVWrapCmd::GatherCommandArguments(const MArgList& args) { } if (argData.isFlagSet(kNameFlagShort)) { name_ = argData.flagArgumentString(kNameFlagShort, 0, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } if (argData.isFlagSet(kBindingFlagShort)) { useBinding_ = true; filePath_ = argData.flagArgumentString(kBindingFlagShort, 0, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } if (argData.isFlagSet(kRebindFlagShort)) { command_ = kCommandRebind; @@ -180,11 +180,11 @@ MStatus CVWrapCmd::GatherCommandArguments(const MArgList& args) { MString wrapNode = argData.flagArgumentString(kRebindFlagShort, 0, &status); MSelectionList slist; status = slist.add(wrapNode); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = slist.getDependNode(0, oWrapNode_); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnDependencyNode fnNode(oWrapNode_, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (fnNode.typeId() != CVWrap::id) { MGlobal::displayError(fnNode.name() + " is not a cvWrap node."); return MS::kFailure; @@ -198,7 +198,7 @@ MStatus CVWrapCmd::GetGeometryPaths() { MStatus status; // The driver is selected last status = selectionList_.getDagPath(selectionList_.length() - 1, pathDriver_, driverComponents_); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = GetShapeNode(pathDriver_); // The driver must be a mesh for this specific algorithm. if (!pathDriver_.hasFn(MFn::kMesh)) { @@ -207,7 +207,7 @@ MStatus CVWrapCmd::GetGeometryPaths() { } MItSelectionList iter(selectionList_); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); pathDriven_.clear(); drivenComponents_.clear(); for (unsigned int i = 0; i < selectionList_.length() - 1; ++i, iter.next()) { @@ -215,7 +215,7 @@ MStatus CVWrapCmd::GetGeometryPaths() { MObject component; iter.getDagPath(path, component); status = GetShapeNode(path); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); pathDriven_.append(path); drivenComponents_.append(component); } @@ -230,12 +230,12 @@ MStatus CVWrapCmd::redoIt() { std::ifstream in(filePath_.asChar(), ios::binary); if (!in.is_open()) { MGlobal::displayInfo("Unable to open file for importing."); - CHECK_MSTATUS_AND_RETURN_IT(MS::kFailure); + CHECK_STATUS_AND_RETURN_IT(MS::kFailure); } BindingIO exporter; status = exporter.ImportBinding(in, oWrapNode_); in.close(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } else if (command_ == kCommandExport) { std::ofstream out(filePath_.asChar(), ios::binary); @@ -246,15 +246,15 @@ MStatus CVWrapCmd::redoIt() { BindingIO exporter; status = exporter.ExportBinding(out, oWrapNode_); out.close(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } else if (command_ == kCommandRebind) { status = dgMod_.doIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } else if (command_ == kCommandCreate) { status = CreateWrapDeformer(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } return MS::kFailure; @@ -265,17 +265,17 @@ MStatus CVWrapCmd::CreateWrapDeformer() { MStatus status; // Create the deformer status = dgMod_.doIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Reacquire the paths because on referenced geo, a new driven path is created (the ShapeDeformed). status = GetGeometryPaths(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Get the created wrap deformer node. status = GetLatestWrapNode(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnDependencyNode fnNode(oWrapNode_, &status); setResult(fnNode.name()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Create a bind mesh so we can run rebind commands. We need a mesh at the state of the // initial binding in order to properly calculate rebinding information. We can't use @@ -283,46 +283,46 @@ MStatus CVWrapCmd::CreateWrapDeformer() { // Check if this driver already has a bind mesh. MDagPath pathBindMesh; status = GetExistingBindMesh(pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (newBindMesh_ || !pathBindMesh.isValid()) { // No bind mesh exists or the user wants to force create a new one. status = CreateBindMesh(pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } status = ConnectBindMesh(pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (useBinding_) { // Import a pre-existing binding. std::ifstream in(filePath_.asChar(), ios::binary); if (!in.is_open()) { MGlobal::displayInfo("Unable to open file for importing."); - CHECK_MSTATUS_AND_RETURN_IT(MS::kFailure); + CHECK_STATUS_AND_RETURN_IT(MS::kFailure); } BindingIO exporter; status = exporter.ImportBinding(in, oWrapNode_); in.close(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } else { MDGModifier dgMod; BindData bindData; status = CalculateBinding(pathBindMesh, bindData, dgMod); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = dgMod.doIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } // Connect the driver mesh to the wrap deformer. MFnDagNode fnDriver(pathDriver_); MPlug plugDriverMesh = fnDriver.findPlug("worldMesh", false, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = plugDriverMesh.selectAncestorLogicalIndex(0, plugDriverMesh.attribute()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugDriverGeo(oWrapNode_, CVWrap::aDriverGeo); MDGModifier dgMod; dgMod.connect(plugDriverMesh, plugDriverGeo); status = dgMod.doIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -340,12 +340,12 @@ MStatus CVWrapCmd::GetLatestWrapNode() { MItDependencyGraph::kDepthFirst, MItDependencyGraph::kNodeLevel, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MObject oDeformerNode; for (; !itDG.isDone(); itDG.next()) { oDeformerNode = itDG.currentItem(); MFnDependencyNode fnNode(oDeformerNode, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (fnNode.typeId() == CVWrap::id) { oWrapNode_ = oDeformerNode; return MS::kSuccess; @@ -359,7 +359,7 @@ MStatus CVWrapCmd::CreateBindMesh(MDagPath& pathBindMesh) { MStatus status; MStringArray duplicate; MFnDependencyNode fnWrap(oWrapNode_, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnDagNode fnDriver(pathDriver_); // Calling mesh.duplicate() can give incorrect results due to tweaks and such. @@ -367,18 +367,18 @@ MStatus CVWrapCmd::CreateBindMesh(MDagPath& pathBindMesh) { // of the duplicated geometry and it would not be reliable to do it from the modifier. MGlobal::executeCommand("duplicate -rr -n " + fnWrap.name() + "Base " + fnDriver.partialPathName(), duplicate); status = GetDagPath(duplicate[0], pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = DeleteIntermediateObjects(pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); bindMeshes_.append(duplicate[0]); // Hide the duplicate MFnDagNode fnBindMesh(pathBindMesh, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plug = fnBindMesh.findPlug("visibility", &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = plug.setBool(false); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -388,16 +388,16 @@ MStatus CVWrapCmd::ConnectBindMesh(MDagPath& pathBindMesh) { MStatus status; // Connect the bind mesh to the wrap node status = GetShapeNode(pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnDagNode fnBindMeshShape(pathBindMesh, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBindMessage = fnBindMeshShape.findPlug("message", false, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBindMesh(oWrapNode_, CVWrap::aBindDriverGeo); MDGModifier dgMod; dgMod.connect(plugBindMessage, plugBindMesh); status = dgMod.doIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -412,21 +412,21 @@ MStatus CVWrapCmd::CalculateBinding(MDagPath& pathBindMesh, BindData& bindData, bindData.driverMatrix = pathBindMesh.inclusiveMatrix(); MObject oBindMesh = pathBindMesh.node(); status = bindData.intersector.create(oBindMesh, bindData.driverMatrix); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // We need the adjacency of each vertex in order to crawl the mesh. status = GetAdjacency(pathBindMesh, bindData.adjacency); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnMesh fnBindMesh(pathBindMesh, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); fnBindMesh.getPoints(bindData.driverPoints, MSpace::kWorld); fnBindMesh.getVertexNormals(false, bindData.driverNormals, MSpace::kWorld); bindData.perFaceVertices.resize(fnBindMesh.numPolygons()); bindData.perFaceTriangleVertices.resize(fnBindMesh.numPolygons()); MIntArray vertexCount, vertexList, triangleCounts, triangleVertices; status = fnBindMesh.getVertices(vertexCount, vertexList); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = fnBindMesh.getTriangles(triangleCounts, triangleVertices); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); for (unsigned int faceId = 0, iter = 0, triIter = 0; faceId < vertexCount.length(); ++faceId) { bindData.perFaceVertices[faceId].clear(); for (int i = 0; i < vertexCount[faceId]; ++i, ++iter) { @@ -447,17 +447,17 @@ MStatus CVWrapCmd::CalculateBinding(MDagPath& pathBindMesh, BindData& bindData, for (unsigned int geomIndex = 0; geomIndex < pathDriven_.length(); ++geomIndex) { // Get the plugs to the binding attributes for this geometry MPlug plugBind = plugBindData.elementByLogicalIndex(geomIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleWeights = plugBind.child(CVWrap::aSampleWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleVerts = plugBind.child(CVWrap::aSampleComponents, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleBindMatrix = plugBind.child(CVWrap::aBindMatrix, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugTriangleVerts = plugBind.child(CVWrap::aTriangleVerts, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBarycentricWeights = plugBind.child(CVWrap::aBarycentricWeights, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Use the intermediate object for the binding. This assumes the intermediate object // has the same component count as the displayed shape. @@ -467,20 +467,20 @@ MStatus CVWrapCmd::CalculateBinding(MDagPath& pathBindMesh, BindData& bindData, pathDriven = pathDriven_[geomIndex]; } MItGeometry itGeo(pathDriven, drivenComponents_[geomIndex], &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); int geoCount = itGeo.count(); status = itGeo.allPositions(bindData.inputPoints, MSpace::kWorld); - CHECK_MSTATUS_AND_RETURN_IT(status); - bindData.sampleIds.resize(itGeo.count()); - bindData.weights.resize(itGeo.count()); - bindData.bindMatrices.setLength(itGeo.count()); - bindData.coords.resize(itGeo.count()); - bindData.triangleVertices.resize(itGeo.count()); + CHECK_STATUS_AND_RETURN_IT(status); + bindData.sampleIds.resize(geoCount); + bindData.weights.resize(geoCount); + bindData.bindMatrices.setLength(geoCount); + bindData.coords.resize(geoCount); + bindData.triangleVertices.resize(geoCount); // Send off the threads to calculate the binding. ThreadData threadData[TASK_COUNT]; - CreateThreadData(TASK_COUNT, itGeo.count(), &bindData, threadData); + CreateThreadData(TASK_COUNT, geoCount, &bindData, threadData); MThreadPool::init(); MThreadPool::newParallelRegion(CreateTasks, (void *)threadData); MThreadPool::release(); @@ -492,57 +492,57 @@ MStatus CVWrapCmd::CalculateBinding(MDagPath& pathBindMesh, BindData& bindData, // Store sample vert ids. MFnIntArrayData fnIntData; MObject oIntData = fnIntData.create(bindData.sampleIds[ii], &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleVertsElement = plugSampleVerts.elementByLogicalIndex(logicalIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = dgMod.newPlugValue(plugSampleVertsElement, oIntData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Store sample weights MFnDoubleArrayData fnDoubleData; MObject oDoubleData = fnDoubleData.create(bindData.weights[ii], &status); assert(bindData.weights[ii].length() > 0); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleWeightsElement = plugSampleWeights.elementByLogicalIndex(logicalIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = dgMod.newPlugValue(plugSampleWeightsElement, oDoubleData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Store bind matrix MObject oMatrixData = fnMatrixData.create(bindData.bindMatrices[ii], &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugSampleBindMatrixElement = plugSampleBindMatrix.elementByLogicalIndex(logicalIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = dgMod.newPlugValue(plugSampleBindMatrixElement, oMatrixData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Store triangle vertices MFnNumericData fnNumericData; MObject oNumericData = fnNumericData.create(MFnNumericData::k3Int, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = fnNumericData.setData3Int(bindData.triangleVertices[ii][0], bindData.triangleVertices[ii][1], bindData.triangleVertices[ii][2]); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugTriangleVertsElement = plugTriangleVerts.elementByLogicalIndex(logicalIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = dgMod.newPlugValue(plugTriangleVertsElement, oNumericData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Store barycentric coordinates oNumericData = fnNumericData.create(MFnNumericData::k3Float, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = fnNumericData.setData3Float(bindData.coords[ii][0], bindData.coords[ii][1], bindData.coords[ii][2]); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlug plugBarycentricWeightsElement = plugBarycentricWeights.elementByLogicalIndex( logicalIndex, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = dgMod.newPlugValue(plugBarycentricWeightsElement, oNumericData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } } return MS::kSuccess; @@ -662,14 +662,14 @@ MStatus CVWrapCmd::GetExistingBindMesh(MDagPath &pathBindMesh) { MStatus status; MObject oDriver = pathDriver_.node(); MFnDependencyNode fnDriver(oDriver, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // We'll find the bind mesh associated with the driver mesh by traversing the mesh connections // through the cvWrap node. MPlug plugOutGeom = fnDriver.findPlug("worldMesh", false, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = plugOutGeom.selectAncestorLogicalIndex(0, plugOutGeom.attribute()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MPlugArray geomPlugs; plugOutGeom.connectedTo(geomPlugs, false, true); for (unsigned int i = 0; i < geomPlugs.length(); i++) { @@ -678,7 +678,7 @@ MStatus CVWrapCmd::GetExistingBindMesh(MDagPath &pathBindMesh) { MFnDependencyNode fnNode(oThisNode); if (fnNode.typeId() == CVWrap::id) { status = GetBindMesh(oThisNode, pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } } @@ -692,25 +692,25 @@ MStatus CVWrapCmd::Rebind() { // Create bind mesh based off of specified faces MDagPath pathDriverSubset; status = CreateRebindSubsetMesh(pathDriverSubset); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Initialize the subset intersector to enable the rebind during the threaded calculation. BindData bindData; MObject oBindSubsetMesh = pathDriverSubset.node(); status = bindData.subsetIntersector.create(oBindSubsetMesh, pathDriverSubset.inclusiveMatrix()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MDagPath pathBindMesh; status = GetBindMesh(oWrapNode_, pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = CalculateBinding(pathBindMesh, bindData, dgMod_); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Delete the subset mesh since we don't need it anymore pathDriverSubset.pop(); status = MGlobal::executeCommand("delete " + pathDriverSubset.partialPathName()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -722,14 +722,14 @@ MStatus CVWrapCmd::GetBindMesh(MObject& oWrapNode, MDagPath& pathBindMesh) { MPlug plugBindMesh(oWrapNode, CVWrap::aBindDriverGeo); MPlugArray plugs; plugBindMesh.connectedTo(plugs, true, false, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (plugs.length() == 0) { MGlobal::displayError("Unable to rebind. No bind mesh is connected."); return MS::kFailure; } MObject oBindMesh = plugs[0].node(); status = MDagPath::getAPathTo(oBindMesh, pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -741,25 +741,25 @@ MStatus CVWrapCmd::CreateRebindSubsetMesh(MDagPath& pathDriverSubset) { MDagPath pathBindMesh; status = GetBindMesh(oWrapNode_, pathBindMesh); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnMesh fnBindMesh(pathBindMesh); // Duplicate the bind mesh to create subset MStringArray duplicate; // Calling mesh.duplicate() gave jacked results. status = MGlobal::executeCommand("duplicate -rr " + fnBindMesh.partialPathName(), duplicate); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = GetDagPath(duplicate[0], pathDriverSubset); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = DeleteIntermediateObjects(pathDriverSubset); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Get selected driver faces MFnSingleIndexedComponent fnDriverComp(driverComponents_, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MIntArray driverFaces; status = fnDriverComp.getElements(driverFaces); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); int numFacesToDelete = fnBindMesh.numPolygons() - driverFaces.length(); if (numFacesToDelete) { @@ -776,21 +776,21 @@ MStatus CVWrapCmd::CreateRebindSubsetMesh(MDagPath& pathDriverSubset) { MFnSingleIndexedComponent fnDeleteComp; MObject oFacesToDelete = fnDeleteComp.create(MFn::kMeshPolygonComponent, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = fnDeleteComp.addElements(facesToDelete); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MSelectionList deleteList; status = deleteList.add(pathDriverSubset, oFacesToDelete); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = MGlobal::setActiveSelectionList(deleteList); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = MGlobal::executeCommand("delete;"); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Reacquire the the dag path since it is invalid now after deleting the faces. status = GetDagPath(duplicate[0], pathDriverSubset); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = GetShapeNode(pathDriverSubset); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } return MS::kSuccess; } @@ -799,17 +799,17 @@ MStatus CVWrapCmd::CreateRebindSubsetMesh(MDagPath& pathDriverSubset) { MStatus CVWrapCmd::undoIt() { MStatus status; status = dgMod_.undoIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (bindMeshes_.length()) { // Delete any created bind meshes. MDGModifier mod; for (unsigned int i = 0; i < bindMeshes_.length(); i++) { status = mod.commandToExecute("delete " + bindMeshes_[i]); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } status = mod.doIt(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); bindMeshes_.clear(); } diff --git a/src/cvWrapDeformer.cpp b/src/cvWrapDeformer.cpp index 5733ff4..d84a94c 100644 --- a/src/cvWrapDeformer.cpp +++ b/src/cvWrapDeformer.cpp @@ -110,7 +110,7 @@ MStatus GetBindInfo(MDataBlock& data, unsigned int geomIndex, TaskData& taskData MStatus status; MArrayDataHandle hBindDataArray = data.inputArrayValue(CVWrap::aBindData); status = hBindDataArray.jumpToElement(geomIndex); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MDataHandle hBindData = hBindDataArray.inputValue(); MArrayDataHandle hSampleWeights = hBindData.child(CVWrap::aSampleWeights); @@ -152,13 +152,13 @@ MStatus GetBindInfo(MDataBlock& data, unsigned int geomIndex, TaskData& taskData // Get sample ids MObject oIndexData = hComponents.inputValue().data(); MFnIntArrayData fnIntData(oIndexData, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); taskData.sampleIds[logicalIndex] = fnIntData.array(); // Get sample weights MObject oWeightData = hSampleWeights.inputValue().data(); MFnDoubleArrayData fnDoubleData(oWeightData, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); taskData.sampleWeights[logicalIndex] = fnDoubleData.array(); assert(taskData.sampleWeights[logicalIndex].length() == taskData.sampleIds[logicalIndex].length()); @@ -167,7 +167,7 @@ MStatus GetBindInfo(MDataBlock& data, unsigned int geomIndex, TaskData& taskData // Get triangle vertex binding int3& verts = hTriangleVerts.inputValue(&status).asInt3(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MIntArray& triangleVerts = taskData.triangleVerts[logicalIndex]; triangleVerts.setLength(3); triangleVerts[0] = verts[0]; @@ -176,7 +176,7 @@ MStatus GetBindInfo(MDataBlock& data, unsigned int geomIndex, TaskData& taskData // Get barycentric weights float3& baryWeights = hBarycentricWeights.inputValue(&status).asFloat3(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); BaryCoords& coords = taskData.baryCoords[logicalIndex]; coords[0] = baryWeights[0]; coords[1] = baryWeights[1]; @@ -195,14 +195,14 @@ MStatus GetDriverData(MDataBlock& data, TaskData& taskData) { MStatus status; // Get driver geo MDataHandle hDriverGeo = data.inputValue(CVWrap::aDriverGeo, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MObject oDriverGeo = hDriverGeo.asMesh(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MFnMesh fnDriver(oDriverGeo, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Get the driver point positions status = fnDriver.getPoints(taskData.driverPoints, MSpace::kWorld); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); unsigned int numDriverPoints = taskData.driverPoints.length(); // Get the driver normals taskData.driverNormals.setLength(numDriverPoints); @@ -241,7 +241,7 @@ void CVWrap::postConstructor() onDeleteCallbackId = MNodeMessage::addNodeAboutToDeleteCallback(obj, aboutToDeleteCB, NULL, &status); } -void CVWrap::aboutToDeleteCB(MObject &node, MDGModifier &modifier, void *clientData) +void CVWrap::aboutToDeleteCB(MObject &node, MDGModifier &modifier, void *) { // Find any node connected to .bindMesh and delete it with the deformer, for compatibility with wrap. MPlug bindPlug(node, aBindDriverGeo); @@ -254,7 +254,7 @@ void CVWrap::aboutToDeleteCB(MObject &node, MDGModifier &modifier, void *clientD } -MStatus CVWrap::setDependentsDirty(const MPlug& plugBeingDirtied, MPlugArray& affectedPlugs) { +MStatus CVWrap::setDependentsDirty(const MPlug& plugBeingDirtied, MPlugArray& ) { // Extract the geom index from the dirty plug and set the dirty flag so we know that we need to // re-read the binding data. if (plugBeingDirtied.isElement()) { @@ -278,9 +278,9 @@ MStatus CVWrap::deform(MDataBlock& data, MItGeometry& itGeo, const MMatrix& loca // Get driver geo MDataHandle hDriverGeo = data.inputValue(aDriverGeo, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MObject oDriverGeo = hDriverGeo.asMesh(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (oDriverGeo.isNull()) { // Without a driver mesh, we can't do anything return MS::kSuccess; @@ -294,16 +294,16 @@ MStatus CVWrap::deform(MDataBlock& data, MItGeometry& itGeo, const MMatrix& loca // If no bind information is stored yet, don't do anything. return MS::kSuccess; } else if (MFAIL(status)) { - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); } } // Get driver geo information MFnMesh fnDriver(oDriverGeo, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Get the driver point positions status = fnDriver.getPoints(taskData.driverPoints, MSpace::kWorld); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); unsigned int numDriverPoints = taskData.driverPoints.length(); // Get the driver normals taskData.driverNormals.setLength(numDriverPoints); @@ -314,7 +314,7 @@ MStatus CVWrap::deform(MDataBlock& data, MItGeometry& itGeo, const MMatrix& loca taskData.membership.setLength(membershipCount); taskData.paintWeights.setLength(membershipCount); status = itGeo.allPositions(taskData.points); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); for (int i = 0; !itGeo.isDone(); itGeo.next(), i++) { taskData.membership[i] = itGeo.index(); taskData.paintWeights[i] = weightValue(data, geomIndex, itGeo.index()); @@ -326,10 +326,11 @@ MStatus CVWrap::deform(MDataBlock& data, MItGeometry& itGeo, const MMatrix& loca // See if we even need to calculate anything. taskData.scale = data.inputValue(aScale).asFloat(); taskData.envelope = data.inputValue(envelope).asFloat(); - int taskCount = data.inputValue(aNumTasks).asInt(); - if (taskData.envelope == 0.0f || taskCount <= 0) { + int tc = data.inputValue(aNumTasks).asInt(); + if (taskData.envelope == 0.0f || tc <= 0) { return MS::kSuccess; } + unsigned int taskCount = (unsigned int)tc; if (geomIndex >= threadData_.size()) { // Make sure a ThreadData objects exist for this geomIndex. @@ -351,7 +352,7 @@ MStatus CVWrap::deform(MDataBlock& data, MItGeometry& itGeo, const MMatrix& loca MThreadPool::newParallelRegion(CreateTasks, (void *)threadData_[geomIndex]); status = itGeo.setAllPositions(taskData.points); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); return MS::kSuccess; } @@ -627,7 +628,7 @@ MStatus CVWrapGPU::EnqueueBindData(MDataBlock& data, const MEvaluationNode& eval TaskData taskData; unsigned int geomIndex = plug.logicalIndex(); status = GetBindInfo(data, geomIndex, taskData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Flatten out bind matrices to float array size_t arraySize = taskData.bindMatrices.length() * 16; @@ -640,6 +641,7 @@ MStatus CVWrapGPU::EnqueueBindData(MDataBlock& data, const MEvaluationNode& eval } } cl_int err = EnqueueBuffer(bindMatrices_, arraySize * sizeof(float), (void*)bindMatrices); + MOpenCLInfo::checkCLErrorStatus(err); delete [] bindMatrices; // Store samples per vertex @@ -653,7 +655,9 @@ MStatus CVWrapGPU::EnqueueBindData(MDataBlock& data, const MEvaluationNode& eval totalSamples += samplesPerVertex[i]; } err = EnqueueBuffer(sampleCounts_, arraySize * sizeof(int), (void*)samplesPerVertex); + MOpenCLInfo::checkCLErrorStatus(err); err = EnqueueBuffer(sampleOffsets_, arraySize * sizeof(int), (void*)sampleOffsets); + MOpenCLInfo::checkCLErrorStatus(err); delete [] samplesPerVertex; delete [] sampleOffsets; @@ -669,7 +673,9 @@ MStatus CVWrapGPU::EnqueueBindData(MDataBlock& data, const MEvaluationNode& eval } } err = EnqueueBuffer(sampleIds_, totalSamples * sizeof(int), (void*)sampleIds); + MOpenCLInfo::checkCLErrorStatus(err); err = EnqueueBuffer(sampleWeights_, totalSamples * sizeof(float), (void*)sampleWeights); + MOpenCLInfo::checkCLErrorStatus(err); delete [] sampleIds; delete [] sampleWeights; @@ -686,18 +692,20 @@ MStatus CVWrapGPU::EnqueueBindData(MDataBlock& data, const MEvaluationNode& eval } } err = EnqueueBuffer(triangleVerts_, arraySize * sizeof(int), (void*)triangleVerts); + MOpenCLInfo::checkCLErrorStatus(err); err = EnqueueBuffer(baryCoords_, arraySize * sizeof(float), (void*)baryCoords); + MOpenCLInfo::checkCLErrorStatus(err); delete [] triangleVerts; delete [] baryCoords; return MS::kSuccess; } -MStatus CVWrapGPU::EnqueueDriverData(MDataBlock& data, const MEvaluationNode& evaluationNode, const MPlug& plug) { +MStatus CVWrapGPU::EnqueueDriverData(MDataBlock& data, const MEvaluationNode&, const MPlug& plug) { MStatus status; TaskData taskData; status = GetDriverData(data, taskData); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); cl_int err = CL_SUCCESS; // Store world space driver points and normals into float arrays. // Reuse the same array for points and normals so we're not dynamically allocating double @@ -712,7 +720,8 @@ MStatus CVWrapGPU::EnqueueDriverData(MDataBlock& data, const MEvaluationNode& ev driverData[iter++] = (float)taskData.driverPoints[i].z; } err = EnqueueBuffer(driverPoints_, pointCount * 3 * sizeof(float), (void*)driverData); - + MOpenCLInfo::checkCLErrorStatus(err); + // Store the driver normals on the gpu. for (unsigned int i = 0, iter = 0; i < pointCount; ++i) { driverData[iter++] = taskData.driverNormals[i].x; @@ -720,6 +729,7 @@ MStatus CVWrapGPU::EnqueueDriverData(MDataBlock& data, const MEvaluationNode& ev driverData[iter++] = taskData.driverNormals[i].z; } err = EnqueueBuffer(driverNormals_, pointCount * 3 * sizeof(float), (void*)driverData); + MOpenCLInfo::checkCLErrorStatus(err); delete [] driverData; int idx = 0; @@ -728,9 +738,9 @@ MStatus CVWrapGPU::EnqueueDriverData(MDataBlock& data, const MEvaluationNode& ev MArrayDataHandle hInputs = data.inputValue(CVWrap::input, &status); unsigned int geomIndex = plug.logicalIndex(); status = hInputs.jumpToElement(geomIndex); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MDataHandle hInput = hInputs.inputValue(&status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MDataHandle hGeom = hInput.child(CVWrap::inputGeom); MMatrix localToWorldMatrix = hGeom.geometryTransformMatrix(); MMatrix worldToLocalMatrix = localToWorldMatrix.inverse(); @@ -752,7 +762,7 @@ MStatus CVWrapGPU::EnqueueDriverData(MDataBlock& data, const MEvaluationNode& ev #endif // Scale matrix is stored row major float scale = data.inputValue(CVWrap::aScale, &status).asFloat(); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MMatrix scaleMatrix; scaleMatrix[0][0] = scale; scaleMatrix[1][1] = scale; @@ -788,7 +798,7 @@ MStatus CVWrapGPU::EnqueuePaintMapData(MDataBlock& data, // Since we can't call MPxDeformerNode::weightValue, get the paint weights from the data block. float* paintWeights = new float[numElements]; MArrayDataHandle weightList = data.outputArrayValue(MPxDeformerNode::weightList, &status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); unsigned int geomIndex = plug.logicalIndex(); status = weightList.jumpToElement(geomIndex); // it is possible that the jumpToElement fails. In that case all weights are 1. @@ -802,12 +812,12 @@ MStatus CVWrapGPU::EnqueuePaintMapData(MDataBlock& data, paintWeights[i] = 1.0f; } MDataHandle weightsStructure = weightList.inputValue(&status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); MArrayDataHandle weights = weightsStructure.child(MPxDeformerNode::weights); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Gather all the non-zero weights unsigned int numWeights = weights.elementCount(&status); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); for (unsigned int i = 0; i < numWeights; i++, weights.next()) { unsigned int weightsElementIndex = weights.elementIndex(&status); MDataHandle value = weights.inputValue(&status); @@ -816,6 +826,7 @@ MStatus CVWrapGPU::EnqueuePaintMapData(MDataBlock& data, } } err = EnqueueBuffer(paintWeights_, numElements * sizeof(float), (void*)paintWeights); + MOpenCLInfo::checkCLErrorStatus(err); delete [] paintWeights; return MS::kSuccess; } diff --git a/src/cvWrapDeformer.h b/src/cvWrapDeformer.h index 7e47b24..572617a 100644 --- a/src/cvWrapDeformer.h +++ b/src/cvWrapDeformer.h @@ -158,18 +158,18 @@ class CVWrapGPUDeformerInfo : public MGPUDeformerRegistrationInfo { #if MAYA_API_VERSION >= 201650 - virtual bool validateNodeInGraph(MDataBlock& block, const MEvaluationNode& evaluationNode, - const MPlug& plug, MStringArray* messages) { + virtual bool validateNodeInGraph(MDataBlock&, const MEvaluationNode&, + const MPlug&, MStringArray*) { return true; } - virtual bool validateNodeValues(MDataBlock& block, const MEvaluationNode& evaluationNode, - const MPlug& plug, MStringArray* messages) { + virtual bool validateNodeValues(MDataBlock&, const MEvaluationNode&, + const MPlug&, MStringArray*) { return true; } #else - virtual bool validateNode(MDataBlock& block, const MEvaluationNode& evaluationNode, - const MPlug& plug, MStringArray* messages) { + virtual bool validateNode(MDataBlock&, const MEvaluationNode&, + const MPlug&, MStringArray*) { return true; } #endif diff --git a/src/pluginMain.cpp b/src/pluginMain.cpp index a07250d..a7e7def 100644 --- a/src/pluginMain.cpp +++ b/src/pluginMain.cpp @@ -4,18 +4,18 @@ #include #include -MStatus initializePlugin(MObject obj) { +PLUGIN_EXPORT MStatus initializePlugin(MObject obj) { MStatus status; MFnPlugin plugin(obj, "Chad Vernon", "1.0", "Any"); status = plugin.registerNode(CVWrap::kName, CVWrap::id, CVWrap::creator, CVWrap::initialize, MPxNode::kDeformerNode); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = plugin.registerCommand(CVWrapCmd::kName, CVWrapCmd::creator, CVWrapCmd::newSyntax); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); #if MAYA_API_VERSION >= 201600 status = MGPUDeformerRegistry::registerGPUDeformerCreator(CVWrap::kName, "cvWrapOverride", CVWrapGPU::GetGPUDeformerInfo()); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); // Set the load path so we can find the cl kernel. CVWrapGPU::pluginLoadPath = plugin.loadPath(); #endif @@ -29,18 +29,18 @@ MStatus initializePlugin(MObject obj) { return status; } -MStatus uninitializePlugin( MObject obj) { +PLUGIN_EXPORT MStatus uninitializePlugin( MObject obj) { MStatus status; MFnPlugin plugin(obj); #if MAYA_API_VERSION >= 201600 status = MGPUDeformerRegistry::deregisterGPUDeformerCreator(CVWrap::kName, "cvWrapOverride"); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); #endif status = plugin.deregisterCommand(CVWrapCmd::kName); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); status = plugin.deregisterNode(CVWrap::id); - CHECK_MSTATUS_AND_RETURN_IT(status); + CHECK_STATUS_AND_RETURN_IT(status); if (MGlobal::mayaState() == MGlobal::kInteractive) { MGlobal::executePythonCommandOnIdle("import cvwrap.menu");