graph: add adjust_height per request (resolves #388)

this command adjusts height (z-component) of all the graph nodes on map with specified height offset, negative height offset can be passed as parameter as well.
This commit is contained in:
jeefo 2022-12-22 21:32:45 +03:00
commit 0a45ea6ad7
No known key found for this signature in database
GPG key ID: D85B0637366787C3
2 changed files with 24 additions and 0 deletions

View file

@ -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 "";

View file

@ -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