Skip to content

Commit

Permalink
#6009: Move renderHighlights to base class
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 29, 2022
1 parent 485dbb1 commit 9beffa7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
9 changes: 9 additions & 0 deletions radiantcore/model/ModelNodeBase.cpp
Expand Up @@ -3,5 +3,14 @@
namespace model
{

void ModelNodeBase::renderHighlights(IRenderableCollector& collector, const VolumeTest& volume)
{
auto identity = Matrix4::getIdentity();

for (const auto& surface : _renderableSurfaces)
{
collector.addHighlightRenderable(*surface, identity);
}
}

}
16 changes: 15 additions & 1 deletion radiantcore/model/ModelNodeBase.h
@@ -1,14 +1,28 @@
#pragma once

#include <vector>
#include "scene/Node.h"
#include "RenderableModelSurface.h"

namespace model
{

/**
* Common ModelNode implementation used by various model types,
* e.g. StaticModelNode and MD5ModelNode
*/
class ModelNodeBase :
public scene::Node
{
protected:
// The renderable surfaces attached to the shaders
std::vector<RenderableModelSurface::Ptr> _renderableSurfaces;

protected:
ModelNodeBase()
{}

public:
void renderHighlights(IRenderableCollector& collector, const VolumeTest& volume) override;
};

}
10 changes: 0 additions & 10 deletions radiantcore/model/StaticModelNode.cpp
Expand Up @@ -112,16 +112,6 @@ void StaticModelNode::onPreRender(const VolumeTest& volume)
attachToShaders();
}

void StaticModelNode::renderHighlights(IRenderableCollector& collector, const VolumeTest& volume)
{
auto identity = Matrix4::getIdentity();

for (const auto& surface : _renderableSurfaces)
{
collector.addHighlightRenderable(*surface, identity);
}
}

void StaticModelNode::setRenderSystem(const RenderSystemPtr& renderSystem)
{
Node::setRenderSystem(renderSystem);
Expand Down
1 change: 0 additions & 1 deletion radiantcore/model/StaticModelNode.h
Expand Up @@ -79,7 +79,6 @@ class StaticModelNode final :

// Renderable implementation
void onPreRender(const VolumeTest& volume) override;
void renderHighlights(IRenderableCollector& collector, const VolumeTest& volume) override;
void setRenderSystem(const RenderSystemPtr& renderSystem) override;

std::size_t getHighlightFlags() override
Expand Down
10 changes: 0 additions & 10 deletions radiantcore/model/md5/MD5ModelNode.cpp
Expand Up @@ -133,16 +133,6 @@ void MD5ModelNode::onPreRender(const VolumeTest& volume)
}
}

void MD5ModelNode::renderHighlights(IRenderableCollector& collector, const VolumeTest& volume)
{
auto identity = Matrix4::getIdentity();

for (const auto& surface : _renderableSurfaces)
{
collector.addHighlightRenderable(*surface, identity);
}
}

void MD5ModelNode::detachFromShaders()
{
// Detach any existing surfaces. In case we need them again,
Expand Down
1 change: 0 additions & 1 deletion radiantcore/model/md5/MD5ModelNode.h
Expand Up @@ -71,7 +71,6 @@ class MD5ModelNode :

// Renderable implementation
void onPreRender(const VolumeTest& volume) override;
void renderHighlights(IRenderableCollector& collector, const VolumeTest& volume) override;

std::size_t getHighlightFlags() override
{
Expand Down

0 comments on commit 9beffa7

Please sign in to comment.