Skip to content

Commit

Permalink
Some cleanup in RadiantSelectionSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 19, 2016
1 parent cd0e1c6 commit c9669b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
4 changes: 4 additions & 0 deletions radiant/selection/ManipulationPivot.h
Expand Up @@ -9,6 +9,8 @@ namespace selection
* Represents the anchor point for manipulation operations
* in the scene. Usually this is defined by the origin of the
* current selection AABB.
*
* Use the getMatrix4() method to acquire a pivot-to-world matrix.
*/
class ManipulationPivot
{
Expand All @@ -22,11 +24,13 @@ class ManipulationPivot
Matrix4 _pivot2WorldStart;

public:
// Returns the pivot-to-world transform
const Matrix4& getMatrix4() const
{
return _pivot2World;
}

// Returns the position of the pivot point relative to origin
const Vector3& getVector3() const
{
return _pivot2World.t().getVector3();
Expand Down
22 changes: 7 additions & 15 deletions radiant/selection/RadiantSelectionSystem.cpp
Expand Up @@ -521,11 +521,6 @@ void RadiantSelectionSystem::foreachPatch(const std::function<void(Patch&)>& fun
}
}

// Start a move, the current pivot point is saved as a start point
void RadiantSelectionSystem::startMove() {
_pivot2worldStart = getPivot2World();
}

// Hub function for "deselect all", this passes the deselect call to the according functions
void RadiantSelectionSystem::deselectAll() {
if (Mode() == eComponent) {
Expand Down Expand Up @@ -745,7 +740,6 @@ void RadiantSelectionSystem::SelectArea(const render::View& view,
void RadiantSelectionSystem::onManipulationStart()
{
_pivotMoving = true;
_pivot2worldStart = getPivot2World();

// Save the pivot state now that the transformation is starting
_pivot.beginOperation();
Expand Down Expand Up @@ -779,12 +773,12 @@ void RadiantSelectionSystem::rotateSelected(const Quaternion& rotation)
// Perform the rotation according to the current mode
if (Mode() == eComponent)
{
Scene_Rotate_Component_Selected(GlobalSceneGraph(), rotation, _pivot2world.t().getVector3());
Scene_Rotate_Component_Selected(GlobalSceneGraph(), rotation, _pivot.getVector3());
}
else
{
// Cycle through the selections and rotate them
foreachSelected(RotateSelected(rotation, _pivot2world.t().getVector3()));
foreachSelected(RotateSelected(rotation, _pivot.getVector3()));
}

// Update the views
Expand Down Expand Up @@ -818,11 +812,11 @@ void RadiantSelectionSystem::scaleSelected(const Vector3& scaling)
// Pass the scale to the according traversor
if (Mode() == eComponent)
{
Scene_Scale_Component_Selected(GlobalSceneGraph(), scaling, _pivot2world.t().getVector3());
Scene_Scale_Component_Selected(GlobalSceneGraph(), scaling, _pivot.getVector3());
}
else
{
Scene_Scale_Selected(GlobalSceneGraph(), scaling, _pivot2world.t().getVector3());
Scene_Scale_Selected(GlobalSceneGraph(), scaling, _pivot.getVector3());
}

// Update the scene views
Expand All @@ -842,7 +836,7 @@ const Matrix4& RadiantSelectionSystem::getPivot2World() const
// Questionable const design - almost everything needs to be declared const here...
const_cast<RadiantSelectionSystem*>(this)->recalculatePivot2World();

return _pivot2world;
return _pivot.getMatrix4();
}

void RadiantSelectionSystem::constructStatic() {
Expand Down Expand Up @@ -944,10 +938,8 @@ void RadiantSelectionSystem::recalculatePivot2World()
//vector3_snap(objectPivot, GlobalGrid().getGridSize());

// The pivot2world matrix is just a translation from the world origin (0,0,0) to the object pivot
_pivot2world = Matrix4::getTranslation(objectPivot);

// Save this to our ManipulationPivot
_pivot.setFromMatrix(_pivot2world);
// Save this to our ManipulationPivot class
_pivot.setFromMatrix(Matrix4::getTranslation(objectPivot));
}
}
/* greebo: Renders the currently active manipulator by setting the render state and
Expand Down
4 changes: 0 additions & 4 deletions radiant/selection/RadiantSelectionSystem.h
Expand Up @@ -24,8 +24,6 @@ class RadiantSelectionSystem :
{
ManipulationPivot _pivot;

mutable Matrix4 _pivot2world;
Matrix4 _pivot2worldStart;
Matrix4 _manip2pivotStart;

typedef std::list<Observer*> ObserverList;
Expand Down Expand Up @@ -143,8 +141,6 @@ class RadiantSelectionSystem :
void foreachFace(const std::function<void(Face&)>& functor);
void foreachPatch(const std::function<void(Patch&)>& functor);

void startMove();

void deselectAll();

void SelectPoint(const render::View& view, const Vector2& device_point, const Vector2& device_epsilon, EModifier modifier, bool face);
Expand Down

0 comments on commit c9669b4

Please sign in to comment.