Skip to content

Commit

Permalink
#5608: Add MoveSelected console command, accepting any 3-component ve…
Browse files Browse the repository at this point in the history
…ctor as translation argument
  • Loading branch information
codereader committed May 22, 2021
1 parent ed5dc93 commit 13d07da
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion radiantcore/selection/algorithm/General.cpp
Expand Up @@ -983,7 +983,8 @@ void registerCommands()
GlobalCommandSystem().addCommand("FlipTextureX", flipTextureS);
GlobalCommandSystem().addCommand("FlipTextureY", flipTextureT);

GlobalCommandSystem().addCommand("MoveSelectionVertically", moveSelectedCmd, { cmd::ARGTYPE_STRING });
GlobalCommandSystem().addCommand("MoveSelectionVertically", moveSelectedVerticallyCmd, { cmd::ARGTYPE_STRING });
GlobalCommandSystem().addCommand("MoveSelection", moveSelectedCmd, { cmd::ARGTYPE_VECTOR3 });

GlobalCommandSystem().addCommand("CurveAppendControlPoint", appendCurveControlPoint);
GlobalCommandSystem().addCommand("CurveRemoveControlPoint", removeCurveControlPoints);
Expand Down
22 changes: 21 additions & 1 deletion radiantcore/selection/algorithm/Transformation.cpp
Expand Up @@ -448,7 +448,7 @@ void moveSelectedAlongZ(float amount)
nudgeByAxis(2, amount);
}

void moveSelectedCmd(const cmd::ArgumentList& args)
void moveSelectedVerticallyCmd(const cmd::ArgumentList& args)
{
if (args.size() != 1)
{
Expand Down Expand Up @@ -482,6 +482,26 @@ void moveSelectedCmd(const cmd::ArgumentList& args)
}
}

void moveSelectedCmd(const cmd::ArgumentList& args)
{
if (args.size() != 1)
{
rMessage() << "Usage: moveSelection <vector>" << std::endl;
return;
}

if (GlobalSelectionSystem().countSelected() == 0)
{
rMessage() << "Nothing selected." << std::endl;
return;
}

UndoableCommand undo("moveSelection");

auto translation = args[0].getVector3();
translateSelected(translation);
}

enum axis_t
{
eAxisX = 0,
Expand Down
8 changes: 7 additions & 1 deletion radiantcore/selection/algorithm/Transformation.h
Expand Up @@ -80,6 +80,12 @@ void nudgeSelected(ENudgeDirection direction, float amount, EViewType viewtype);
*/
void nudgeSelectedCmd(const cmd::ArgumentList& args);

/**
* Generic move command, always moves the selection in the given direction.
* args[0]: Vector defining the translation
*/
void moveSelectedCmd(const cmd::ArgumentList& args);

/**
* Moves the selection along the z axis by the given amount.
*/
Expand All @@ -90,7 +96,7 @@ void moveSelectedAlongZ(float amount);
* args[0]: String indicating the direction: "up" or "down".
* Each move command is using the current grid size as amount.
*/
void moveSelectedCmd(const cmd::ArgumentList& args);
void moveSelectedVerticallyCmd(const cmd::ArgumentList& args);

/**
* Rotates the current selection about one of the main axes.
Expand Down

0 comments on commit 13d07da

Please sign in to comment.