diff --git a/inc/control.h b/inc/control.h index b225ca3..2dcd7cd 100644 --- a/inc/control.h +++ b/inc/control.h @@ -124,6 +124,7 @@ private: int cmdNodeIterateCamp (); int cmdNodeShowStats (); int cmdNodeFileInfo (); + int cmdAdjustHeight (); private: int menuMain (int item); @@ -187,6 +188,13 @@ public: return m_args[arg].int_ (); } + float floatValue (size_t arg) const { + if (!hasArg (arg)) { + return 0.0f; + } + return m_args[arg].float_ (); + } + StringRef strValue (size_t arg) { if (!hasArg (arg)) { return ""; diff --git a/src/control.cpp b/src/control.cpp index 74f982b..6943bf4 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -333,6 +333,7 @@ int BotControl::cmdNode () { addGraphCmd ("upload", "upload", "Uploads created graph to graph database.", &BotControl::cmdNodeUpload); addGraphCmd ("stats", "stats [noarguments]", "Shows the stats about node types on the map.", &BotControl::cmdNodeShowStats); addGraphCmd ("fileinfo", "fileinfo [noarguments]", "Shows basic information about graph file.", &BotControl::cmdNodeFileInfo); + addGraphCmd ("adjust_height", "adjust_height [height offset]", "Modifies all the graph nodes height (z-component) with specified offset.", &BotControl::cmdAdjustHeight); // add path commands addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate); @@ -867,6 +868,21 @@ int BotControl::cmdNodeFileInfo () { return BotCommandResult::Handled; } +int BotControl::cmdAdjustHeight() { + enum args { graph_cmd = 1, cmd, offset }; + + if (!hasArg (offset)) { + return BotCommandResult::BadFormat; + } + auto heightOffset = floatValue (offset); + + // adjust the height for all the nodes (negative values possible) + for (int i = 0; i < graph.length (); ++i) { + graph[i].origin.z += heightOffset; + } + return BotCommandResult::Handled; +} + int BotControl::menuMain (int item) { closeMenu (); // reset menu display