Skip to content

Commit

Permalink
'mmSolver -sceneGraphMode' command flag; use Maya DAG or mmSceneGraph.
Browse files Browse the repository at this point in the history
Use '0' for Maya DAG (the default value for now), or use '1' for
mmSceneGraph.

The Maya DAG should be used for backwards compatibility and the full
feature set, but mmSceneGraph should provide improved performance
for simplier use-cases.

Issue #114.
  • Loading branch information
david-cattermole committed Jan 2, 2022
1 parent aa17b96 commit 42e6c16
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/source/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Flag Type Description
-attrStiffness (-asf) string, string, string, string Node attribute, weight plug name, variance plug name, value plug name. None
-attrSmoothness (-asm) string, string, string, string Node attribute, weight plug name, variance plug name, value plug name. None
-solverType (-st) unsigned int Type of solver to use. <auto detected>
-sceneGraphMode (-sgm) unsigned int The Scene Graph used; 0=Maya DAG, 1=MM Scene Graph 0 (Maya DAG)
-timeEvalMode (-tem) unsigned int How to evalulate values at different times, 0=DG Context 1=Set TIme 0 (DG Context)
-iterations (-it) unsigned int Maximum number of iterations 20
-tauFactor (-t) double Initial Damping Factor 1E-03
Expand Down
15 changes: 12 additions & 3 deletions src/MMSolverCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ void createSolveInfoSyntax(MSyntax &syntax) {
syntax.addFlag(REMOVE_UNUSED_ATTRIBUTES_FLAG, REMOVE_UNUSED_ATTRIBUTES_FLAG_LONG,
MSyntax::kBoolean);

syntax.addFlag(SCENE_GRAPH_MODE_FLAG, SCENE_GRAPH_MODE_FLAG_LONG,
MSyntax::kUnsigned);
syntax.addFlag(TIME_EVAL_MODE_FLAG, TIME_EVAL_MODE_FLAG_LONG,
MSyntax::kUnsigned);
}
Expand Down Expand Up @@ -187,6 +189,7 @@ MStatus parseSolveInfoArguments(const MArgDatabase &argData,
int &out_robustLossType,
double &out_robustLossScale,
int &out_solverType,
SceneGraphMode &out_sceneGraphMode,
int &out_timeEvalMode,
bool &out_acceptOnlyBetter,
bool &out_supportAutoDiffForward,
Expand All @@ -212,6 +215,14 @@ MStatus parseSolveInfoArguments(const MArgDatabase &argData,
CHECK_MSTATUS_AND_RETURN_IT(status);
}

// Get 'Scene Graph Mode'
uint32_t sceneGraphMode = SCENE_GRAPH_MODE_DEFAULT_VALUE;
if (argData.isFlagSet(SCENE_GRAPH_MODE_FLAG)) {
status = argData.getFlagArgument(SCENE_GRAPH_MODE_FLAG, 0, sceneGraphMode);
CHECK_MSTATUS_AND_RETURN_IT(status);
}
out_sceneGraphMode = static_cast<SceneGraphMode>(sceneGraphMode);

// Get 'Time Evaluation Mode'
out_timeEvalMode = TIME_EVAL_MODE_DEFAULT_VALUE;
if (argData.isFlagSet(TIME_EVAL_MODE_FLAG)) {
Expand Down Expand Up @@ -396,6 +407,7 @@ MStatus MMSolverCmd::parseArgs(const MArgList &args) {
m_robustLossType,
m_robustLossScale,
m_solverType,
m_sceneGraphMode,
m_timeEvalMode,
m_acceptOnlyBetter,
m_supportAutoDiffForward,
Expand Down Expand Up @@ -445,9 +457,6 @@ MStatus MMSolverCmd::doIt(const MArgList &args) {
// of edits.
m_curveChange.setInteractive(true);

// m_sceneGraphMode = SceneGraphMode::kMaya;
m_sceneGraphMode = SceneGraphMode::kMMSceneGraph;

SolverOptions solverOptions;
solverOptions.iterMax = m_iterations;
solverOptions.tau = m_tau;
Expand Down
4 changes: 4 additions & 0 deletions src/MMSolverCmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
#define SOLVER_TYPE_FLAG "-st"
#define SOLVER_TYPE_FLAG_LONG "-solverType"

// The Scene Graph used for evaluation.
#define SCENE_GRAPH_MODE_FLAG "-sgm"
#define SCENE_GRAPH_MODE_FLAG_LONG "-sceneGraphMode"

// Time Evaluation Mode
//
// How should the solver evaluate time? Should we use DG Context, or
Expand Down
2 changes: 1 addition & 1 deletion src/core/bundleAdjust_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ bool solve(SolverOptions &solverOptions,
auto mmsgBundleNodes = std::vector<mmsg::BundleNode>();
auto mmsgMarkerNodes = std::vector<mmsg::MarkerNode>();
auto mmsgAttrIdList = std::vector<mmsg::AttrId>();
if (solverOptions.sceneGraphMode == SceneGraphMode::kMaya) {
if (solverOptions.sceneGraphMode == SceneGraphMode::kMayaDag) {
} else if (solverOptions.sceneGraphMode == SceneGraphMode::kMMSceneGraph) {
status = construct_scene_graph(
cameraList,
Expand Down
4 changes: 2 additions & 2 deletions src/core/bundleAdjust_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ struct SolverTimer {

enum class SceneGraphMode
{
kMaya = 0,
kMMSceneGraph = 1,
kMayaDag = SCENE_GRAPH_MODE_MAYA_DAG,
kMMSceneGraph = SCENE_GRAPH_MODE_MM_SCENE_GRAPH,
kNumSceneGraphModes,
};

Expand Down
8 changes: 8 additions & 0 deletions src/core/bundleAdjust_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
#define TIME_EVAL_MODE_DG_CONTEXT (0)
#define TIME_EVAL_MODE_SET_TIME (1)

// What Scene Graph should we use for evaluation?
//
// These are the possible values:
#define SCENE_GRAPH_MODE_MAYA_DAG (0)
#define SCENE_GRAPH_MODE_MM_SCENE_GRAPH (1)
// The default value
#define SCENE_GRAPH_MODE_DEFAULT_VALUE SCENE_GRAPH_MODE_MAYA_DAG

// Print Statistics for mmSolver command.
//
// These are the possible values:
Expand Down
4 changes: 2 additions & 2 deletions src/core/bundleAdjust_solveFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void setParameters(
#endif

const SceneGraphMode sceneGraphMode = ud->solverOptions->sceneGraphMode;
if (sceneGraphMode == SceneGraphMode::kMaya) {
if (sceneGraphMode == SceneGraphMode::kMayaDag) {
setParameters_mayaDag(
numberOfParameters,
parameters,
Expand Down Expand Up @@ -731,7 +731,7 @@ void measureErrors(
assert(ud->frameList.length() > 0);

const SceneGraphMode sceneGraphMode = ud->solverOptions->sceneGraphMode;
if (sceneGraphMode == SceneGraphMode::kMaya) {
if (sceneGraphMode == SceneGraphMode::kMayaDag) {
measureErrors_mayaDag(
numberOfErrors,
numberOfMarkerErrors,
Expand Down

0 comments on commit 42e6c16

Please sign in to comment.