Skip to content

Commit 02223d7

Browse files
Add MMSOLVER_CHECK_MSTATUS* macros assert_utils.h
These macros replace the inbuilt Maya macros; CHECK_MSTATUS CHECK_MSTATUS_AND_RETURN CHECK_MSTATUS_AND_RETURN_IT ... and offer *almost* the same functionallity, but we print out more detailed information when a check fails. The minor difference between these macros and Maya's macros is that we do not allow using MStatus::kFailure (and friends) error codes in the macro. Adding this limitation allows us to avoid a temporary MStatus variable from being created.
1 parent eb83cd2 commit 02223d7

File tree

88 files changed

+2883
-2734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2883
-2734
lines changed

src/mmSolver/adjust/adjust_base.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ bool get_initial_parameters(
311311

312312
double value = 0.0;
313313
status = attr->getValue(value, frame, timeEvalMode);
314-
CHECK_MSTATUS(status);
314+
MMSOLVER_CHECK_MSTATUS(status);
315315
if (status != MS::kSuccess) {
316316
out_solverResult.success = false;
317317
return false;
@@ -365,7 +365,7 @@ bool set_maya_attribute_values(
365365
}
366366

367367
status = attr->setValue(real_value, frame, dgmod, curveChange);
368-
CHECK_MSTATUS(status);
368+
MMSOLVER_CHECK_MSTATUS(status);
369369

370370
if (status != MS::kSuccess) {
371371
MString attr_name = attr->getName();
@@ -727,7 +727,7 @@ MStatus validateSolveFrames(
727727
"failed; out_numberOfErrors="
728728
<< out_numberOfErrors);
729729
out_solve_is_valid = false;
730-
CHECK_MSTATUS(status);
730+
MMSOLVER_CHECK_MSTATUS(status);
731731
return status;
732732
}
733733
MMSOLVER_ASSERT(out_numberOfErrors == (out_numberOfMarkerErrors +
@@ -754,7 +754,7 @@ MStatus validateSolveFrames(
754754
"out_numberOfParameters="
755755
<< out_numberOfParameters);
756756
out_solve_is_valid = false;
757-
CHECK_MSTATUS(status);
757+
MMSOLVER_CHECK_MSTATUS(status);
758758
return status;
759759
}
760760

@@ -800,7 +800,7 @@ MStatus validateSolveFrames(
800800
if (status != MS::kSuccess) {
801801
MMSOLVER_MAYA_VRB("validateSolveFrames: mapErrorsToParameters failed.");
802802
out_solve_is_valid = false;
803-
CHECK_MSTATUS(status);
803+
MMSOLVER_CHECK_MSTATUS(status);
804804
return status;
805805
}
806806

@@ -817,7 +817,7 @@ MStatus validateSolveFrames(
817817
MMSOLVER_MAYA_VRB(
818818
"validateSolveFrames: logResultsObjectCounts failed.");
819819
out_solve_is_valid = false;
820-
CHECK_MSTATUS(status);
820+
MMSOLVER_CHECK_MSTATUS(status);
821821
return status;
822822
}
823823
}
@@ -832,7 +832,7 @@ MStatus validateSolveFrames(
832832
MMSOLVER_MAYA_VRB(
833833
"validateSolveFrames: logResultsSolveObjectUsage failed.");
834834
out_solve_is_valid = false;
835-
CHECK_MSTATUS(status);
835+
MMSOLVER_CHECK_MSTATUS(status);
836836
return status;
837837
}
838838
}
@@ -848,7 +848,7 @@ MStatus validateSolveFrames(
848848
"validateSolveFrames: logResultsMarkerAffectsAttribute "
849849
"failed.");
850850
out_solve_is_valid = false;
851-
CHECK_MSTATUS(status);
851+
MMSOLVER_CHECK_MSTATUS(status);
852852
return status;
853853
}
854854
}
@@ -884,7 +884,7 @@ MStatus validateSolveFrames(
884884
if (status != MS::kSuccess) {
885885
MMSOLVER_MAYA_VRB(
886886
"validateSolveFrames: calculateMarkerAndParameterCount failed.");
887-
CHECK_MSTATUS(status);
887+
MMSOLVER_CHECK_MSTATUS(status);
888888
out_solve_is_valid = false;
889889
return status;
890890
}
@@ -898,7 +898,7 @@ MStatus validateSolveFrames(
898898
MMSOLVER_MAYA_VRB(
899899
"validateSolveFrames: logResultsSolverFrames failed.");
900900
out_solve_is_valid = false;
901-
CHECK_MSTATUS(status);
901+
MMSOLVER_CHECK_MSTATUS(status);
902902
return status;
903903
}
904904

@@ -1273,7 +1273,7 @@ MStatus solveFrames(
12731273
// per-frame, it's not possible to easily fall back. See
12741274
// the use of the 'FrameSolveMode' enum type for more
12751275
// details.
1276-
CHECK_MSTATUS(status);
1276+
MMSOLVER_CHECK_MSTATUS(status);
12771277
MMSOLVER_MAYA_ERR(
12781278
"Maya DAG is invalid for use with MM Scene Graph, "
12791279
<< "please switch to Maya DAG and solve again.");
@@ -1299,7 +1299,7 @@ MStatus solveFrames(
12991299
status = constructLensModelList(cameraList, markerList, attrList, frameList,
13001300
markerFrameToLensModelList,
13011301
attrFrameToLensModelList, lensModelList);
1302-
CHECK_MSTATUS_AND_RETURN_IT(status);
1302+
MMSOLVER_CHECK_MSTATUS_AND_RETURN_IT(status);
13031303
#endif
13041304

13051305
// Solving Objects.
@@ -1385,7 +1385,7 @@ MStatus solveFrames(
13851385
solverOptions.imageWidth, &out_errorList[0], &userData,
13861386
initialErrorAvg, initialErrorMax, initialErrorMin,
13871387
status);
1388-
CHECK_MSTATUS_AND_RETURN_IT(status);
1388+
MMSOLVER_CHECK_MSTATUS_AND_RETURN_IT(status);
13891389

13901390
initialErrorAvg = 0;
13911391
initialErrorMin = 0;
@@ -1595,7 +1595,7 @@ MStatus solveFrames(
15951595
numberOfAttrStiffnessErrors, numberOfAttrSmoothnessErrors,
15961596
logLevel, out_paramList);
15971597

1598-
CHECK_MSTATUS(status);
1598+
MMSOLVER_CHECK_MSTATUS(status);
15991599

16001600
MMSOLVER_MAYA_VRB("solveFrames: Z");
16011601

@@ -1652,14 +1652,14 @@ MStatus generateMarkerAndBundleRelationships(
16521652
// Outputs
16531653
out_relationshipAttrsExistCount,
16541654
out_markerToAttrToFrameMatrix, status);
1655-
CHECK_MSTATUS_AND_RETURN_IT(status);
1655+
MMSOLVER_CHECK_MSTATUS_AND_RETURN_IT(status);
16561656

16571657
// Create 'valid' lists.
16581658
generateValidMarkerAttrFrameLists(
16591659
markerList, attrList, frameList, out_markerToAttrToFrameMatrix,
16601660

16611661
out_validMarkerList, out_validAttrList, out_validFrameList, status);
1662-
CHECK_MSTATUS_AND_RETURN_IT(status);
1662+
MMSOLVER_CHECK_MSTATUS_AND_RETURN_IT(status);
16631663

16641664
// Print warnings about unused solve objects.
16651665
if ((out_validMarkerList.count_disabled() > 0) && removeUnusedMarkers) {
@@ -1816,7 +1816,7 @@ bool solve_v1(SolverOptions &solverOptions, CameraPtrList &cameraList,
18161816
// Outputs
18171817
relationshipAttrsExistCount, validMarkerList, validAttrList,
18181818
validFrameList, markerToAttrToFrameMatrix);
1819-
CHECK_MSTATUS(status);
1819+
MMSOLVER_CHECK_MSTATUS(status);
18201820

18211821
const Count32 validMarkerEnabledCount = validMarkerList.count_enabled();
18221822
const Count32 validAttrEnabledCount = validAttrList.count_enabled();
@@ -1856,7 +1856,7 @@ bool solve_v1(SolverOptions &solverOptions, CameraPtrList &cameraList,
18561856
auto jacobianList = std::vector<double>();
18571857

18581858
MGlobal::MMayaState mayaSessionState = MGlobal::mayaState(&status);
1859-
CHECK_MSTATUS_AND_RETURN_IT(status);
1859+
MMSOLVER_CHECK_MSTATUS_AND_RETURN_IT(status);
18601860

18611861
auto frameSolveMode = solverOptions.frameSolveMode;
18621862
MMSOLVER_MAYA_VRB(
@@ -1898,7 +1898,7 @@ bool solve_v1(SolverOptions &solverOptions, CameraPtrList &cameraList,
18981898
paramWeightList,
18991899
//
19001900
logLevel, verbose, solve_is_valid, cmdResult);
1901-
CHECK_MSTATUS(status);
1901+
MMSOLVER_CHECK_MSTATUS(status);
19021902

19031903
if (solve_is_valid) {
19041904
status = solveFrames(
@@ -2002,7 +2002,7 @@ bool solve_v1(SolverOptions &solverOptions, CameraPtrList &cameraList,
20022002
paramWeightList,
20032003
//
20042004
logLevel, verbose, solve_is_valid, perFrameCmdResult);
2005-
CHECK_MSTATUS(status);
2005+
MMSOLVER_CHECK_MSTATUS(status);
20062006

20072007
if (solve_is_valid) {
20082008
status = solveFrames(
@@ -2112,7 +2112,7 @@ bool solve_v2(SolverOptions &solverOptions, CameraPtrList &cameraList,
21122112
// Outputs
21132113
relationshipAttrsExistCount, validMarkerList, validAttrList,
21142114
validFrameList, markerToAttrToFrameMatrix);
2115-
CHECK_MSTATUS(status);
2115+
MMSOLVER_CHECK_MSTATUS(status);
21162116

21172117
const Count32 markerEnabledCount = markerList.count_enabled();
21182118
const Count32 frameEnabledCount = frameList.count_enabled();
@@ -2139,7 +2139,7 @@ bool solve_v2(SolverOptions &solverOptions, CameraPtrList &cameraList,
21392139
auto jacobianList = std::vector<double>();
21402140

21412141
MGlobal::MMayaState mayaSessionState = MGlobal::mayaState(&status);
2142-
CHECK_MSTATUS_AND_RETURN_IT(status);
2142+
MMSOLVER_CHECK_MSTATUS_AND_RETURN_IT(status);
21432143

21442144
auto frameSolveMode = solverOptions.frameSolveMode;
21452145
MMSOLVER_MAYA_VRB(
@@ -2181,7 +2181,7 @@ bool solve_v2(SolverOptions &solverOptions, CameraPtrList &cameraList,
21812181
paramWeightList,
21822182
//
21832183
logLevel, verbose, solve_is_valid, out_cmdResult);
2184-
CHECK_MSTATUS(status);
2184+
MMSOLVER_CHECK_MSTATUS(status);
21852185

21862186
if (solve_is_valid) {
21872187
status = solveFrames(
@@ -2282,7 +2282,7 @@ bool solve_v2(SolverOptions &solverOptions, CameraPtrList &cameraList,
22822282
paramWeightList,
22832283
//
22842284
perFrameLogLevel, verbose, solve_is_valid, perFrameCmdResult);
2285-
CHECK_MSTATUS(status);
2285+
MMSOLVER_CHECK_MSTATUS(status);
22862286

22872287
if (solve_is_valid) {
22882288
status = solveFrames(

src/mmSolver/adjust/adjust_measureErrors.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void measureErrors_mayaDag(const int numberOfErrors,
141141
MarkerPtr marker = ud->markerList[markerPair.first];
142142
MTime frame = ud->frameList[markerPair.second];
143143
status = marker->getPos(pos, frame + 1, TIME_EVAL_MODE_DG_CONTEXT);
144-
CHECK_MSTATUS(status);
144+
MMSOLVER_CHECK_MSTATUS(status);
145145
}
146146
#endif
147147

@@ -190,7 +190,7 @@ void measureErrors_mayaDag(const int numberOfErrors,
190190
CameraPtr camera = marker->getCamera();
191191
status = camera->getWorldProjMatrix(cameraWorldProjectionMatrix, frame,
192192
timeEvalMode);
193-
CHECK_MSTATUS(status);
193+
MMSOLVER_CHECK_MSTATUS(status);
194194

195195
MVector cam_dir;
196196
MPoint cam_pos;
@@ -209,7 +209,7 @@ void measureErrors_mayaDag(const int numberOfErrors,
209209
bool applyOverscan = true;
210210
status =
211211
marker->getPosXY(mkr_x, mkr_y, frame, timeEvalMode, applyOverscan);
212-
CHECK_MSTATUS(status);
212+
MMSOLVER_CHECK_MSTATUS(status);
213213
#endif
214214

215215
const int16_t filmFit = camera->getFilmFitValue();
@@ -243,7 +243,7 @@ void measureErrors_mayaDag(const int numberOfErrors,
243243
// Re-project Bundle into screen-space.
244244
MVector bnd_dir;
245245
status = bnd->getPos(bnd_mpos, frame, timeEvalMode);
246-
CHECK_MSTATUS(status);
246+
MMSOLVER_CHECK_MSTATUS(status);
247247
MPoint bnd_mpos_tmp(bnd_mpos);
248248
bnd_dir = bnd_mpos_tmp - cam_pos;
249249
bnd_dir.normalize();

src/mmSolver/adjust/adjust_relationships.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Count32 countUpNumberOfErrors(
202202
bool applyOverscan = true;
203203
status = marker->getPosXY(px, py, frame, timeEvalMode,
204204
applyOverscan);
205-
CHECK_MSTATUS(status);
205+
MMSOLVER_CHECK_MSTATUS(status);
206206
MPoint marker_pos(px, py, 0.0);
207207
out_markerPosList.push_back(marker_pos);
208208
}
@@ -663,7 +663,7 @@ void markFrameAffectedByAttribute(
663663
out_splitFrameStrings.append(out_affectedFramesString);
664664
} else {
665665
out_status = out_affectedFramesString.split(',', out_splitFrameStrings);
666-
CHECK_MSTATUS(out_status);
666+
MMSOLVER_CHECK_MSTATUS(out_status);
667667
MMSOLVER_ASSERT(out_status == MS::kSuccess,
668668
"Comma character is expected to exist in string; "
669669
"out_affectedFramesString='"
@@ -796,7 +796,7 @@ void parseMarkerAttributeRelationships(
796796
splitFrameStrings, out_markerToAttrToFrameMatrix,
797797
out_status);
798798
if (out_status != MS::kSuccess) {
799-
CHECK_MSTATUS(out_status);
799+
MMSOLVER_CHECK_MSTATUS(out_status);
800800
return;
801801
}
802802

@@ -842,7 +842,7 @@ void parseMarkerAttributeRelationships(
842842
splitFrameStrings, out_markerToAttrToFrameMatrix,
843843
out_status);
844844
if (out_status != MS::kSuccess) {
845-
CHECK_MSTATUS(out_status);
845+
MMSOLVER_CHECK_MSTATUS(out_status);
846846
return;
847847
}
848848

@@ -970,7 +970,7 @@ void analyseDependencyGraphRelationships(
970970
cmd);
971971
out_status = MGlobal::executePythonCommand(cmd, bundleAffectsResult,
972972
display, undoable);
973-
CHECK_MSTATUS(out_status);
973+
MMSOLVER_CHECK_MSTATUS(out_status);
974974

975975
// Find list of plug names that are affected by the marker
976976
// (and camera projection matrix).
@@ -994,7 +994,7 @@ void analyseDependencyGraphRelationships(
994994
cmd);
995995
out_status = MGlobal::executePythonCommand(cmd, markerAffectsResult,
996996
display, undoable);
997-
CHECK_MSTATUS(out_status);
997+
MMSOLVER_CHECK_MSTATUS(out_status);
998998

999999
parseMarkerAttributeRelationships(
10001000
markerIndex, attrList, frameList, bundleAffectsResult,
@@ -1003,7 +1003,7 @@ void analyseDependencyGraphRelationships(
10031003
// Outputs
10041004
out_markerToAttrToFrameMatrix, out_status);
10051005
if (out_status != MS::kSuccess) {
1006-
CHECK_MSTATUS(out_status);
1006+
MMSOLVER_CHECK_MSTATUS(out_status);
10071007
return;
10081008
}
10091009
}
@@ -1207,7 +1207,7 @@ void readStoredRelationships(const MarkerList &markerList,
12071207
MFnDependencyNode attrNodeFn(attrNodeObject);
12081208
MObject attrObject = attr->getAttribute();
12091209
MUuid attrUuid = attrNodeFn.uuid(&out_status);
1210-
CHECK_MSTATUS(out_status);
1210+
MMSOLVER_CHECK_MSTATUS(out_status);
12111211
MString attrUuidStr = attrUuid.asString();
12121212

12131213
// Get Attribute's Name.
@@ -1219,15 +1219,15 @@ void readStoredRelationships(const MarkerList &markerList,
12191219
MString attrName = "";
12201220
out_status =
12211221
constructAttrAffectsName(nodeAttrName, attrUuidStr, attrName);
1222-
CHECK_MSTATUS(out_status);
1222+
MMSOLVER_CHECK_MSTATUS(out_status);
12231223

12241224
// Get plug value
12251225
bool value = defaultValue;
12261226
MPlug plug = markerNodeFn.findPlug(
12271227
attrName, /*wantNetworkedPlug=*/true, &out_status);
12281228
if (out_status != MS::kSuccess) {
12291229
if (verbose) {
1230-
CHECK_MSTATUS(out_status);
1230+
MMSOLVER_CHECK_MSTATUS(out_status);
12311231
const MString markerNodeName = marker->getNodeName();
12321232
MMSOLVER_MAYA_VRB(
12331233
"readStoredRelationships: "
@@ -1272,7 +1272,7 @@ void readStoredRelationships(const MarkerList &markerList,
12721272
double curveValue = 0;
12731273
out_status = curveFn.evaluate(frame, curveValue);
12741274
if (out_status != MS::kSuccess) {
1275-
CHECK_MSTATUS(out_status);
1275+
MMSOLVER_CHECK_MSTATUS(out_status);
12761276
return;
12771277
}
12781278

@@ -1832,14 +1832,14 @@ void calculateMarkerAndParameterCount(
18321832
markerList, attrList, frameList, numParameters, numMarkerErrors,
18331833
paramToAttrList, errorToMarkerList, markerToAttrToFrameMatrix,
18341834
out_validFrameList, out_status);
1835-
CHECK_MSTATUS(out_status);
1835+
MMSOLVER_CHECK_MSTATUS(out_status);
18361836
} else if (frameSolveMode == FrameSolveMode::kPerFrame) {
18371837
MMSOLVER_MAYA_VRB("calculateMarkerAndParameterCount: D0");
18381838
calculateMarkerAndParameterCountPerFrame(
18391839
markerList, attrList, frameList, numParameters, numMarkerErrors,
18401840
paramToAttrList, errorToMarkerList, markerToAttrToFrameMatrix,
18411841
out_validFrameList, out_status);
1842-
CHECK_MSTATUS(out_status);
1842+
MMSOLVER_CHECK_MSTATUS(out_status);
18431843
} else {
18441844
const auto frameSolveModeValue = static_cast<int32_t>(frameSolveMode);
18451845
MMSOLVER_MAYA_ERR(

0 commit comments

Comments
 (0)