Skip to content

Commit

Permalink
#5584: Some preparations to get manipulator rendering on the rails
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 22, 2022
1 parent 3a329a0 commit f006295
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/imanipulator.h
Expand Up @@ -13,6 +13,9 @@ class VolumeTest;
class SelectionTest;
class IRenderableCollector;

class RenderSystem;
typedef std::shared_ptr<RenderSystem> RenderSystemPtr;

namespace selection
{

Expand Down Expand Up @@ -117,9 +120,15 @@ class ISceneManipulator :

virtual ~ISceneManipulator() {}

// Prepares this manipulator for rendering
virtual void onPreRender(const RenderSystemPtr& renderSystem, const VolumeTest& volume) = 0;

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

// Removes / hides the renderables of this manipulator
virtual void clearRenderables() = 0;

// Manipulators should indicate whether component editing is supported or not
virtual bool supportsComponentManipulation() const = 0;
};
Expand Down
21 changes: 21 additions & 0 deletions radiantcore/selection/RadiantSelectionSystem.cpp
Expand Up @@ -924,6 +924,27 @@ Vector3 RadiantSelectionSystem::getCurrentSelectionCenter()
return algorithm::getCurrentSelectionCenter();
}

void RadiantSelectionSystem::onPreRender(const VolumeTest& volume)
{
if (!nothingSelected())
{
auto renderSystem = GlobalMapModule().getRoot()->getRenderSystem();

if (renderSystem)
{
_activeManipulator->onPreRender(renderSystem, volume);
}
else
{
_activeManipulator->clearRenderables();
}
}
else
{
_activeManipulator->clearRenderables();
}
}

/* greebo: Renders the currently active manipulator by setting the render state and
* calling the manipulator's render method
*/
Expand Down
1 change: 1 addition & 0 deletions radiantcore/selection/RadiantSelectionSystem.h
Expand Up @@ -152,6 +152,7 @@ class RadiantSelectionSystem :
const WorkZone& getWorkZone() override;
Vector3 getCurrentSelectionCenter() override;

void onPreRender(const VolumeTest& volume) override;
void renderSolid(IRenderableCollector& collector, const VolumeTest& volume) const override;
void renderWireframe(IRenderableCollector& collector, const VolumeTest& volume) const override;
void renderHighlights(IRenderableCollector& collector, const VolumeTest& volume) override
Expand Down
6 changes: 6 additions & 0 deletions radiantcore/selection/manipulators/ManipulatorBase.h
Expand Up @@ -24,10 +24,16 @@ class ManipulatorBase :
return true;
}

virtual void onPreRender(const RenderSystemPtr& renderSystem, const VolumeTest& volume) override
{}

// No visual representation by default
virtual void render(IRenderableCollector& collector, const VolumeTest& volume) override
{}

virtual void clearRenderables() override
{}

public:
std::size_t getId() const override
{
Expand Down

0 comments on commit f006295

Please sign in to comment.