Skip to content

Commit

Permalink
#5128: Add TextureToolRotateManipulator stub
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 12, 2021
1 parent 80473fb commit 7057b97
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 15 deletions.
6 changes: 3 additions & 3 deletions include/imanipulator.h
Expand Up @@ -102,9 +102,6 @@ class IManipulator

virtual void setSelected(bool select) = 0;
virtual bool isSelected() const = 0;

// Manipulators should indicate whether component editing is supported or not
virtual bool supportsComponentManipulation() const = 0;
};

/**
Expand All @@ -121,6 +118,9 @@ class ISceneManipulator :

// Renders the manipulator's visual representation to the scene
virtual void render(RenderableCollector& collector, const VolumeTest& volume) = 0;

// Manipulators should indicate whether component editing is supported or not
virtual bool supportsComponentManipulation() const = 0;
};

// Factory interface instantiating new IManipulator instances for a given purpose
Expand Down
6 changes: 3 additions & 3 deletions radiant/textool/TexTool.cpp
Expand Up @@ -77,9 +77,9 @@ TexTool::TexTool() :
std::bind(&TexTool::onMouseDown, this, std::placeholders::_1),
std::bind(&TexTool::onMouseUp, this, std::placeholders::_1));

#if 0
registerManipulator(std::make_shared<RotateManipulator>(_pivot, 8, 64.0f));
#endif
registerManipulator(GlobalManipulatorManager().createManipulator(
selection::IManipulator::Context::TextureTool, selection::IManipulator::Rotate));

_defaultManipulatorType = selection::IManipulator::Rotate;
setActiveManipulator(_defaultManipulatorType);
}
Expand Down
4 changes: 2 additions & 2 deletions radiant/textool/tools/TextureToolManipulateMouseTool.cpp
Expand Up @@ -103,15 +103,15 @@ bool TextureToolManipulateMouseTool::selectManipulator(const render::View& view,
bool dragComponentMode = activeManipulator->getType() == selection::Manipulator::Drag &&
GlobalSelectionSystem().Mode() == SelectionSystem::eComponent;
#endif
if (!nothingSelected()/* || dragComponentMode*/)
if (true/*!nothingSelected()/* || dragComponentMode*/)
{
// Unselect any currently selected manipulators to be sure
activeManipulator->setSelected(false);

const Matrix4& pivot2World = TexTool::Instance().getPivot2World();

// Test, if the current manipulator can be selected
if (!nothingSelected()/* || dragComponentMode*/)
if (true/*!nothingSelected()/* || dragComponentMode*/)
{
render::View scissored(view);
ConstructSelectionTest(scissored, selection::Rectangle::ConstructFromPoint(devicePoint, deviceEpsilon));
Expand Down
1 change: 1 addition & 0 deletions radiantcore/CMakeLists.txt
Expand Up @@ -248,6 +248,7 @@ add_library(radiantcore MODULE
selection/manipulators/ModelScaleManipulator.cpp
selection/manipulators/RotateManipulator.cpp
selection/manipulators/ScaleManipulator.cpp
selection/manipulators/TextureToolRotateManipulator.cpp
selection/manipulators/TranslateManipulator.cpp
selection/RadiantSelectionSystem.cpp
selection/SelectedNodeList.cpp
Expand Down
6 changes: 0 additions & 6 deletions radiantcore/selection/manipulators/ManipulatorBase.h
Expand Up @@ -6,12 +6,6 @@
namespace selection
{

/**
* A Manipulator is a renderable object which contains one or more
* ManipulatorComponents, each of which can be manipulated by the user. For
* example, the rotation Manipulator draws several circles which cause rotations
* around specific axes.
*/
class ManipulatorBase :
public ISceneManipulator
{
Expand Down
4 changes: 3 additions & 1 deletion radiantcore/selection/manipulators/ManipulatorManager.cpp
Expand Up @@ -3,6 +3,7 @@
#include <map>
#include "module/StaticModule.h"
#include "string/convert.h"
#include "TextureToolRotateManipulator.h"

namespace selection
{
Expand Down Expand Up @@ -52,7 +53,8 @@ class ManipulatorManager :
_manipulatorsByContext.emplace(IManipulator::Context::Scene, ManipulatorsByType());
_manipulatorsByContext.emplace(IManipulator::Context::TextureTool, ManipulatorsByType());

// TODO
_manipulatorsByContext[IManipulator::Context::TextureTool].emplace(
IManipulator::Rotate, [] { return std::make_shared<TextureToolRotateManipulator>(); });
}

void shutdownModule()
Expand Down
@@ -0,0 +1,41 @@
#include "TextureToolRotateManipulator.h"

namespace selection
{

std::size_t TextureToolRotateManipulator::getId() const
{
return _id;
}

void TextureToolRotateManipulator::setId(std::size_t id)
{
_id = id;
}

IManipulator::Type TextureToolRotateManipulator::getType() const
{
return IManipulator::Rotate;
}

IManipulator::Component* TextureToolRotateManipulator::getActiveComponent()
{
return nullptr;
}

void TextureToolRotateManipulator::setSelected(bool select)
{
_isSelected = select;
}

bool TextureToolRotateManipulator::isSelected() const
{
return _isSelected;
}

void TextureToolRotateManipulator::testSelect(SelectionTest& test, const Matrix4& pivot2world)
{
// TODO
}

}
27 changes: 27 additions & 0 deletions radiantcore/selection/manipulators/TextureToolRotateManipulator.h
@@ -0,0 +1,27 @@
#pragma once

#include "imanipulator.h"

namespace selection
{

class TextureToolRotateManipulator :
public IManipulator
{
private:
std::size_t _id;
bool _isSelected;

public:
virtual std::size_t getId() const override;
virtual void setId(std::size_t id) override;
virtual Type getType() const override;

virtual Component* getActiveComponent() override;

virtual void setSelected(bool select) override;
virtual bool isSelected() const override;
virtual void testSelect(SelectionTest& test, const Matrix4& pivot2world) override;
};

}
2 changes: 2 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -661,6 +661,7 @@
<ClCompile Include="..\..\radiantcore\selection\manipulators\ModelScaleManipulator.cpp" />
<ClCompile Include="..\..\radiantcore\selection\manipulators\RotateManipulator.cpp" />
<ClCompile Include="..\..\radiantcore\selection\manipulators\ScaleManipulator.cpp" />
<ClCompile Include="..\..\radiantcore\selection\manipulators\TextureToolRotateManipulator.cpp" />
<ClCompile Include="..\..\radiantcore\selection\manipulators\TranslateManipulator.cpp" />
<ClCompile Include="..\..\radiantcore\selection\RadiantSelectionSystem.cpp" />
<ClCompile Include="..\..\radiantcore\selection\SelectedNodeList.cpp" />
Expand Down Expand Up @@ -1009,6 +1010,7 @@
<ClInclude Include="..\..\radiantcore\selection\manipulators\ModelScaleManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\manipulators\RotateManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\manipulators\ScaleManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\manipulators\TextureToolRotateManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\manipulators\TranslateManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\RadiantSelectionSystem.h" />
<ClInclude Include="..\..\radiantcore\selection\Remap.h" />
Expand Down
6 changes: 6 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -1078,6 +1078,9 @@
<ClCompile Include="..\..\radiantcore\selection\manipulators\ManipulatorManager.cpp">
<Filter>src\selection\manipulators</Filter>
</ClCompile>
<ClCompile Include="..\..\radiantcore\selection\manipulators\TextureToolRotateManipulator.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiantcore\modulesystem\ModuleLoader.h">
Expand Down Expand Up @@ -2193,5 +2196,8 @@
<ClInclude Include="..\..\radiantcore\map\format\Quake3Utils.h">
<Filter>src\map\format</Filter>
</ClInclude>
<ClInclude Include="..\..\radiantcore\selection\manipulators\TextureToolRotateManipulator.h">
<Filter>src\selection\manipulators</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 7057b97

Please sign in to comment.