Skip to content

Commit

Permalink
#5746: Refactor method for readability, private the fields again
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 16, 2021
1 parent 962b373 commit b8b2092
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
53 changes: 24 additions & 29 deletions radiant/selection/ManipulateMouseTool.cpp
Expand Up @@ -22,7 +22,6 @@ namespace

ManipulateMouseTool::ManipulateMouseTool() :
_selectEpsilon(registry::getValue<float>(RKEY_SELECT_EPSILON)),
_manipulationActive(false),
_undoBegun(false)
{}

Expand Down Expand Up @@ -85,40 +84,40 @@ bool ManipulateMouseTool::selectManipulator(const render::View& view, const Vect
auto activeManipulator = getActiveManipulator();
assert(activeManipulator);

if (manipulationIsPossible())
// Check if the scene selection is ready for manipulation
if (!manipulationIsPossible())
{
// Unselect any currently selected manipulators to be sure
activeManipulator->setSelected(false);
return false;
}

auto pivot2World = getPivot2World();
// Unselect all components to be sure
activeManipulator->setSelected(false);

// Perform a selection test on this manipulator's components
render::View scissored(view);
ConstructSelectionTest(scissored, selection::Rectangle::ConstructFromPoint(devicePoint, deviceEpsilon));
// Perform a selection test on this manipulator's components
render::View scissored(view);
ConstructSelectionTest(scissored, selection::Rectangle::ConstructFromPoint(devicePoint, deviceEpsilon));

SelectionVolume test(scissored);
activeManipulator->testSelect(test, pivot2World);
auto pivot2World = getPivot2World();
SelectionVolume test(scissored);
activeManipulator->testSelect(test, pivot2World);

// Save the pivot2world matrix
_pivot2worldStart = pivot2World;
// Save the pivot2world matrix
_pivot2worldStart = pivot2World;

onManipulationStart();
// We can start the manipulation if we successfully selected a component
if (!activeManipulator->isSelected())
{
return false;
}

// This is true, if a manipulator could be selected
_manipulationActive = activeManipulator->isSelected();
onManipulationStart();

// is a manipulator selected / the pivot moving?
if (_manipulationActive)
{
activeManipulator->getActiveComponent()->beginTransformation(_pivot2worldStart, view, devicePoint);
activeManipulator->getActiveComponent()->beginTransformation(_pivot2worldStart, view, devicePoint);

_deviceStart = devicePoint;
_deviceStart = devicePoint;
_undoBegun = false;

_undoBegun = false;
}
}

return _manipulationActive;
return true;
}

void ManipulateMouseTool::handleMouseMove(const render::View& view, const Vector2& devicePoint)
Expand Down Expand Up @@ -179,8 +178,6 @@ void ManipulateMouseTool::endMove()
auto activeManipulator = getActiveManipulator();
assert(activeManipulator);

_manipulationActive = false;

// Update the views
SceneChangeNotify();

Expand Down Expand Up @@ -222,8 +219,6 @@ void ManipulateMouseTool::cancelMove()
auto activeManipulator = getActiveManipulator();
assert(activeManipulator);

_manipulationActive = false;

onManipulationCancelled();

if (_undoBegun)
Expand Down
4 changes: 1 addition & 3 deletions radiant/selection/ManipulateMouseTool.h
Expand Up @@ -22,11 +22,9 @@ class ManipulateMouseTool :
private:
float _selectEpsilon;

protected:
Matrix4 _pivot2worldStart;
bool _manipulationActive;

Vector2 _deviceStart;

bool _undoBegun;

#ifdef _DEBUG
Expand Down

0 comments on commit b8b2092

Please sign in to comment.