Skip to content

Commit

Permalink
SelectionSystem is not a Scalable anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 19, 2016
1 parent 6080bf1 commit cd0e1c6
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 67 deletions.
43 changes: 17 additions & 26 deletions radiant/selection/RadiantSelectionSystem.cpp
Expand Up @@ -742,26 +742,6 @@ void RadiantSelectionSystem::SelectArea(const render::View& view,
}
}

// Applies the scaling vector <scaling> to the current selection, this is called by the according ManipulatorComponents
void RadiantSelectionSystem::scale(const Vector3& scaling) {
// Check if anything is selected
if (!nothingSelected()) {
// Store the scaling vector internally
_scale = scaling;

// Pass the scale to the according traversor
if (Mode() == eComponent) {
Scene_Scale_Component_Selected(GlobalSceneGraph(), _scale, _pivot2world.t().getVector3());
}
else {
Scene_Scale_Selected(GlobalSceneGraph(), _scale, _pivot2world.t().getVector3());
}

// Update the scene views
SceneChangeNotify();
}
}

void RadiantSelectionSystem::onManipulationStart()
{
_pivotMoving = true;
Expand Down Expand Up @@ -833,10 +813,21 @@ void RadiantSelectionSystem::translateSelected(const Vector3& translation)
}

// Shortcut call for an instantly applied scaling of the current selection
void RadiantSelectionSystem::scaleSelected(const Vector3& scaling) {
// Apply the transformation and freeze the changes
startMove();
scale(scaling);
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());
}
else
{
Scene_Scale_Selected(GlobalSceneGraph(), scaling, _pivot2world.t().getVector3());
}

// Update the scene views
SceneChangeNotify();

freezeTransforms();
}

Expand Down Expand Up @@ -1010,15 +1001,15 @@ const StringSet& RadiantSelectionSystem::getDependencies() const

void RadiantSelectionSystem::initialiseModule(const ApplicationContext& ctx)
{
rMessage() << "RadiantSelectionSystem::initialiseModule called." << std::endl;
rMessage() << getName() << "::initialiseModule called." << std::endl;

constructStatic();

// Add manipulators
registerManipulator(std::make_shared<DragManipulator>(_pivot));
registerManipulator(std::make_shared<ClipManipulator>());
registerManipulator(std::make_shared<TranslateManipulator>(_pivot, 2, 64));
registerManipulator(std::make_shared<ScaleManipulator>(*this, 0, 64));
registerManipulator(std::make_shared<ScaleManipulator>(_pivot, 0, 64));
registerManipulator(std::make_shared<RotateManipulator>(_pivot, 8, 64));

_defaultManipulatorType = Manipulator::Drag;
Expand Down
9 changes: 0 additions & 9 deletions radiant/selection/RadiantSelectionSystem.h
Expand Up @@ -12,17 +12,13 @@
#include "wxutil/event/SingleIdleCallback.h"
#include "SelectedNodeList.h"

#include "Translatable.h"
#include "Scalable.h"
#include "Rotatable.h"
#include "ManipulationPivot.h"

namespace selection
{

class RadiantSelectionSystem :
public SelectionSystem,
public Scalable,
public Renderable,
protected wxutil::SingleIdleCallback
{
Expand All @@ -35,8 +31,6 @@ class RadiantSelectionSystem :
typedef std::list<Observer*> ObserverList;
ObserverList _observers;

Vector3 _scale;

// The 3D volume surrounding the most recent selection.
WorkZone _workZone;

Expand Down Expand Up @@ -156,9 +150,6 @@ class RadiantSelectionSystem :
void SelectPoint(const render::View& view, const Vector2& device_point, const Vector2& device_epsilon, EModifier modifier, bool face);
void SelectArea(const render::View& view, const Vector2& device_point, const Vector2& device_delta, EModifier modifier, bool face);

// These are the "callbacks" that are used by the Manipulatables
void scale(const Vector3& scaling);

void onManipulationStart() override;
void onManipulationChanged() override;
void onManipulationEnd() override;
Expand Down
5 changes: 3 additions & 2 deletions radiant/selection/manipulators/RotateManipulator.cpp
@@ -1,7 +1,8 @@
#include "RotateManipulator.h"

#include "../SelectionPool.h"
#include "../BestPoint.h"
#include "selection/SelectionPool.h"
#include "selection/BestPoint.h"
#include "selection/TransformationVisitors.h"
#include "render/View.h"

namespace selection
Expand Down
7 changes: 4 additions & 3 deletions radiant/selection/manipulators/RotateManipulator.h
@@ -1,10 +1,11 @@
#pragma once

#include "Rotatable.h"
#include "ManipulatorBase.h"
#include "ManipulatorComponents.h"
#include "../Renderables.h"
#include "../Pivot2World.h"
#include "../BasicSelectable.h"
#include "selection/Renderables.h"
#include "selection/Pivot2World.h"
#include "selection/BasicSelectable.h"
#include "selection/ManipulationPivot.h"

namespace selection
Expand Down
49 changes: 34 additions & 15 deletions radiant/selection/manipulators/ScaleManipulator.cpp
@@ -1,17 +1,19 @@
#include "ScaleManipulator.h"

#include "../Remap.h"
#include "../SelectionPool.h"
#include "../BestPoint.h"
#include "selection/Remap.h"
#include "selection/SelectionPool.h"
#include "selection/BestPoint.h"
#include "selection/TransformationVisitors.h"
#include "render/View.h"

namespace selection
{

// Constructor
ScaleManipulator::ScaleManipulator(Scalable& scalable, std::size_t segments, float length) :
_scaleFree(scalable),
_scaleAxis(scalable)
ScaleManipulator::ScaleManipulator(ManipulationPivot& pivot, std::size_t segments, float length) :
_pivot(pivot),
_scaleFree(*this),
_scaleAxis(*this)
{
draw_arrowline(length, &_arrowX.front(), 0);
draw_arrowline(length, &_arrowY.front(), 1);
Expand All @@ -27,27 +29,28 @@ void ScaleManipulator::UpdateColours() {
_quadScreen.setColour(colourSelected(ManipulatorBase::COLOUR_SCREEN(), _selectableScreen.isSelected()));
}

void ScaleManipulator::render(RenderableCollector& collector, const VolumeTest& volume, const Matrix4& pivot2world) {
_pivot.update(pivot2world, volume.GetModelview(), volume.GetProjection(), volume.GetViewport());
void ScaleManipulator::render(RenderableCollector& collector, const VolumeTest& volume, const Matrix4& pivot2world)
{
_pivot2World.update(_pivot.getMatrix4(), volume.GetModelview(), volume.GetProjection(), volume.GetViewport());

// temp hack
UpdateColours();

collector.addRenderable(_arrowX, _pivot._worldSpace);
collector.addRenderable(_arrowY, _pivot._worldSpace);
collector.addRenderable(_arrowZ, _pivot._worldSpace);
collector.addRenderable(_arrowX, _pivot2World._worldSpace);
collector.addRenderable(_arrowY, _pivot2World._worldSpace);
collector.addRenderable(_arrowZ, _pivot2World._worldSpace);

collector.addRenderable(_quadScreen, _pivot._viewpointSpace);
collector.addRenderable(_quadScreen, _pivot2World._viewpointSpace);
}

void ScaleManipulator::testSelect(const render::View& view, const Matrix4& pivot2world)
{
_pivot.update(pivot2world, view.GetModelview(), view.GetProjection(), view.GetViewport());
_pivot2World.update(_pivot.getMatrix4(), view.GetModelview(), view.GetProjection(), view.GetViewport());

SelectionPool selector;

{
Matrix4 local2view(view.GetViewMatrix().getMultipliedBy(_pivot._worldSpace));
Matrix4 local2view(view.GetViewMatrix().getMultipliedBy(_pivot2World._worldSpace));

{
SelectionIntersection best;
Expand All @@ -69,7 +72,7 @@ void ScaleManipulator::testSelect(const render::View& view, const Matrix4& pivot
}

{
Matrix4 local2view(view.GetViewMatrix().getMultipliedBy(_pivot._viewpointSpace));
Matrix4 local2view(view.GetViewMatrix().getMultipliedBy(_pivot2World._viewpointSpace));

{
SelectionIntersection best;
Expand Down Expand Up @@ -121,4 +124,20 @@ bool ScaleManipulator::isSelected() const
| _selectableScreen.isSelected();
}

void ScaleManipulator::scale(const Vector3& scaling)
{
// Pass the scale to the according traversor
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
{
Scene_Scale_Component_Selected(GlobalSceneGraph(), scaling, _pivot.getVector3());
}
else
{
Scene_Scale_Selected(GlobalSceneGraph(), scaling, _pivot.getVector3());
}

// Update the scene views
SceneChangeNotify();
}

}
25 changes: 13 additions & 12 deletions radiant/selection/manipulators/ScaleManipulator.h
@@ -1,11 +1,12 @@
#pragma once

#include "Scalable.h"
#include "ManipulatorBase.h"
#include "ManipulatorComponents.h"
#include "../Renderables.h"
#include "../Pivot2World.h"

#include "../BasicSelectable.h"
#include "selection/Renderables.h"
#include "selection/Pivot2World.h"
#include "selection/ManipulationPivot.h"
#include "selection/BasicSelectable.h"

namespace selection
{
Expand All @@ -14,9 +15,12 @@ namespace selection
* The Manipulator for scale operations
*/
class ScaleManipulator :
public ManipulatorBase
public ManipulatorBase,
public Scalable
{
private:
ManipulationPivot& _pivot;

ScaleFree _scaleFree;
ScaleAxis _scaleAxis;
RenderableArrowLine _arrowX;
Expand All @@ -27,22 +31,17 @@ class ScaleManipulator :
selection::BasicSelectable _selectableY;
selection::BasicSelectable _selectableZ;
selection::BasicSelectable _selectableScreen;
Pivot2World _pivot;
Pivot2World _pivot2World;

public:
// Constructor
ScaleManipulator(Scalable& scalable, std::size_t segments, float length);
ScaleManipulator(ManipulationPivot& pivot, std::size_t segments, float length);

Type getType() const override
{
return Scale;
}

Pivot2World& getPivot()
{
return _pivot;
}

void UpdateColours();

void render(RenderableCollector& collector, const VolumeTest& volume, const Matrix4& pivot2world) override;
Expand All @@ -52,6 +51,8 @@ class ScaleManipulator :
void setSelected(bool select) override;
bool isSelected() const override;

void scale(const Vector3& scaling) override;

}; // class ScaleManipulator

}

0 comments on commit cd0e1c6

Please sign in to comment.