Skip to content

Commit

Permalink
Inline a few global functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 20, 2016
1 parent 40e426f commit b0faa99
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 78 deletions.
50 changes: 0 additions & 50 deletions radiant/selection/TransformationVisitors.cpp
Expand Up @@ -156,53 +156,3 @@ void ScaleComponentSelected::visit(const scene::INodePtr& node) const {
transform->setTranslation(parent_translation);
}
}

// ============ Scene Traversors ================================

// greebo: these could be implemented into the RadiantSelectionSystem class as well, if you ask me

/* greebo: This is called when a selected item is to be translated
* This basically cycles through all selected objects with a translation
* visitor class (which derives from SelectionSystem::Visitor)
*/
void Scene_Translate_Selected(scene::Graph& graph, const Vector3& translation) {
// Check if there is anything to do
if(GlobalSelectionSystem().countSelected() != 0) {
// Cycle through the selected items and apply the translation
GlobalSelectionSystem().foreachSelected(TranslateSelected(translation));
}
}

// The same as Scene_Translate_Selected, just that components are translated
void Scene_Translate_Component_Selected(scene::Graph& graph, const Vector3& translation) {
if(GlobalSelectionSystem().countSelected() != 0)
{
GlobalSelectionSystem().foreachSelectedComponent(TranslateComponentSelected(translation));
}
}

// The same as Scene_Rotate_Selected, just that components are rotated
void Scene_Rotate_Component_Selected(scene::Graph& graph, const Quaternion& rotation, const Vector3& world_pivot) {
if(GlobalSelectionSystem().countSelectedComponents() != 0)
{
GlobalSelectionSystem().foreachSelectedComponent(RotateComponentSelected(rotation, world_pivot));
}
}
/* greebo: This is called when a selected item is to be scaled
* This basically cycles through all selected objects with a scale
* visitor class (which derives from SelectionSystem::Visitor)
*/
void Scene_Scale_Selected(scene::Graph& graph, const Vector3& scaling, const Vector3& world_pivot) {
if(GlobalSelectionSystem().countSelected() != 0)
{
GlobalSelectionSystem().foreachSelected(ScaleSelected(scaling, world_pivot));
}
}

// The same as Scene_Scale_Selected, just that components are scaled
void Scene_Scale_Component_Selected(scene::Graph& graph, const Vector3& scaling, const Vector3& world_pivot) {
if(GlobalSelectionSystem().countSelectedComponents() != 0)
{
GlobalSelectionSystem().foreachSelectedComponent(ScaleComponentSelected(scaling, world_pivot));
}
}
14 changes: 0 additions & 14 deletions radiant/selection/TransformationVisitors.h
Expand Up @@ -133,17 +133,3 @@ class ScaleComponentSelected : public SelectionSystem::Visitor {
// This actually applies the change to the node
void visit(const scene::INodePtr& node) const;
};

// =============================================================================

/* greebo: This is called when a selected item is to be transformed
* This basically cycles through all selected objects passing the instance to the
* visitor class (which derives from SelectionSystem::Visitor)
*/
void Scene_Translate_Selected(scene::Graph& graph, const Vector3& translation);
void Scene_Translate_Component_Selected(scene::Graph& graph, const Vector3& translation);

void Scene_Rotate_Component_Selected(scene::Graph& graph, const Quaternion& rotation, const Vector3& world_pivot);

void Scene_Scale_Selected(scene::Graph& graph, const Vector3& scaling, const Vector3& world_pivot);
void Scene_Scale_Component_Selected(scene::Graph& graph, const Vector3& scaling, const Vector3& world_pivot);
17 changes: 9 additions & 8 deletions radiant/selection/algorithm/Transformation.cpp
Expand Up @@ -36,8 +36,8 @@ void rotateSelected(const Quaternion& rotation)
// Perform the rotation according to the current mode
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
{
Scene_Rotate_Component_Selected(GlobalSceneGraph(), rotation,
GlobalSelectionSystem().getPivot2World().t().getVector3());
GlobalSelectionSystem().foreachSelectedComponent(
RotateComponentSelected(rotation, GlobalSelectionSystem().getPivot2World().t().getVector3()));
}
else
{
Expand Down Expand Up @@ -76,13 +76,13 @@ void scaleSelected(const Vector3& scaleXYZ)
// Pass the scale to the according traversor
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
{
Scene_Scale_Component_Selected(GlobalSceneGraph(), scaleXYZ,
GlobalSelectionSystem().getPivot2World().t().getVector3());
GlobalSelectionSystem().foreachSelectedComponent(ScaleComponentSelected(scaleXYZ,
GlobalSelectionSystem().getPivot2World().t().getVector3()));
}
else
{
Scene_Scale_Selected(GlobalSceneGraph(), scaleXYZ,
GlobalSelectionSystem().getPivot2World().t().getVector3());
GlobalSelectionSystem().foreachSelected(ScaleSelected(scaleXYZ,
GlobalSelectionSystem().getPivot2World().t().getVector3()));
}

// Update the scene views
Expand Down Expand Up @@ -323,11 +323,12 @@ void translateSelected(const Vector3& translation)
// Apply the transformation and freeze the changes
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
{
Scene_Translate_Component_Selected(GlobalSceneGraph(), translation);
GlobalSelectionSystem().foreachSelectedComponent(TranslateComponentSelected(translation));
}
else
{
Scene_Translate_Selected(GlobalSceneGraph(), translation);
// Cycle through the selected items and apply the translation
GlobalSelectionSystem().foreachSelected(TranslateSelected(translation));
}

// Update the scene so that the changes are made visible
Expand Down
5 changes: 3 additions & 2 deletions radiant/selection/manipulators/ManipulatorComponents.cpp
Expand Up @@ -139,11 +139,12 @@ void SelectionTranslator::translate(const Vector3& translation)
{
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
{
Scene_Translate_Component_Selected(GlobalSceneGraph(), translation);
GlobalSelectionSystem().foreachSelectedComponent(TranslateComponentSelected(translation));
}
else
{
Scene_Translate_Selected(GlobalSceneGraph(), translation);
// Cycle through the selected items and apply the translation
GlobalSelectionSystem().foreachSelected(TranslateSelected(translation));
}

// Invoke the feedback function
Expand Down
2 changes: 1 addition & 1 deletion radiant/selection/manipulators/ManipulatorComponents.h
Expand Up @@ -138,7 +138,7 @@ class ResizeTranslatable :
{
void translate(const Vector3& translation) override
{
Scene_Translate_Component_Selected(GlobalSceneGraph(), translation);
GlobalSelectionSystem().foreachSelectedComponent(TranslateComponentSelected(translation));
}
};

Expand Down
3 changes: 2 additions & 1 deletion radiant/selection/manipulators/RotateManipulator.cpp
Expand Up @@ -273,7 +273,8 @@ void RotateManipulator::rotate(const Quaternion& rotation)
// Perform the rotation according to the current mode
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
{
Scene_Rotate_Component_Selected(GlobalSceneGraph(), rotation, _pivot.getVector3());
GlobalSelectionSystem().foreachSelectedComponent(
RotateComponentSelected(rotation, _pivot.getVector3()));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions radiant/selection/manipulators/ScaleManipulator.cpp
Expand Up @@ -129,11 +129,11 @@ 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());
GlobalSelectionSystem().foreachSelectedComponent(ScaleComponentSelected(scaling, _pivot.getVector3()));
}
else
{
Scene_Scale_Selected(GlobalSceneGraph(), scaling, _pivot.getVector3());
GlobalSelectionSystem().foreachSelected(ScaleSelected(scaling, _pivot.getVector3()));
}

// Update the scene views
Expand Down

0 comments on commit b0faa99

Please sign in to comment.