Skip to content

Commit

Permalink
#5584: Move point shader to BrushNode
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 8, 2022
1 parent 4948db1 commit 0626992
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
9 changes: 0 additions & 9 deletions radiantcore/brush/Brush.cpp
Expand Up @@ -386,15 +386,6 @@ FacePtr Brush::addPlane(const Vector3& p0, const Vector3& p1, const Vector3& p2,

void Brush::setRenderSystem(const RenderSystemPtr& renderSystem)
{
if (renderSystem)
{
m_state_point = renderSystem->capture("$POINT");
}
else
{
m_state_point.reset();
}

for (Faces::iterator i = m_faces.begin(); i != m_faces.end(); ++i)
{
(*i)->setRenderSystem(renderSystem);
Expand Down
4 changes: 0 additions & 4 deletions radiantcore/brush/Brush.h
Expand Up @@ -143,10 +143,6 @@ class Brush :
DetailFlag _detailFlag;
};

// static data
ShaderPtr m_state_point;
// ----

static double m_maxWorldCoord;

// Constructors
Expand Down
10 changes: 8 additions & 2 deletions radiantcore/brush/BrushNode.cpp
Expand Up @@ -371,7 +371,7 @@ void BrushNode::onPreRender(const VolumeTest& volume)
if (isSelected() && GlobalSelectionSystem().Mode() == selection::SelectionSystem::eComponent)
{
_renderableVertices.setComponentMode(GlobalSelectionSystem().ComponentMode());
_renderableVertices.update(m_brush.m_state_point);
_renderableVertices.update(_pointShader);
}
else
{
Expand All @@ -387,7 +387,7 @@ void BrushNode::renderComponents(IRenderableCollector& collector, const VolumeTe
if (volume.fill() && GlobalSelectionSystem().ComponentMode() == selection::ComponentSelectionMode::Face)
{
updateFaceCentroidPoints();
collector.addRenderable(*m_brush.m_state_point, _visibleFaceCentroidPoints, l2w);
collector.addRenderable(*_pointShader, _visibleFaceCentroidPoints, l2w);
}
#if 0
else
Expand Down Expand Up @@ -458,11 +458,17 @@ void BrushNode::setRenderSystem(const RenderSystemPtr& renderSystem)

if (renderSystem)
{
_pointShader = renderSystem->capture("$POINT");
m_state_selpoint = renderSystem->capture("$SELPOINT");

_renderableVertices.queueUpdate();
}
else
{
_pointShader.reset();
m_state_selpoint.reset();

_renderableVertices.clear();
}

m_brush.setRenderSystem(renderSystem);
Expand Down
1 change: 1 addition & 0 deletions radiantcore/brush/BrushNode.h
Expand Up @@ -56,6 +56,7 @@ class BrushNode :
BrushClipPlane m_clipPlane;

ShaderPtr m_state_selpoint;
ShaderPtr _pointShader;

// TRUE if any of the FaceInstance's component selection got changed or transformed
mutable bool _renderableComponentsNeedUpdate;
Expand Down
11 changes: 4 additions & 7 deletions radiantcore/brush/RenderableBrushVertices.cpp
@@ -1,5 +1,6 @@
#include "RenderableBrushVertices.h"

#include "ibrush.h"
#include "Brush.h"

namespace brush
Expand All @@ -20,17 +21,13 @@ void RenderableBrushVertices::updateGeometry()
vertices.reserve(brushVertices.size());
indices.reserve(brushVertices.size());

static const Vector3& vertexColour = GlobalBrushCreator().getSettings().getVertexColour();
const Vector4 colour(vertexColour, 1);

for (auto i = 0; i < brushVertices.size(); ++i)
{
const auto& vertex = brushVertices[i];

Vector4 colour(
vertex.colour.r / 255.0,
vertex.colour.g / 255.0,
vertex.colour.b / 255.0,
1.0
);

vertices.push_back(ArbitraryMeshVertex(vertex.vertex, { 0,0,0 }, { 0,0 }, colour));
indices.push_back(i);
}
Expand Down

0 comments on commit 0626992

Please sign in to comment.