From 8061cdd5b12f4213acb3a9d5e6a30506d6a228a8 Mon Sep 17 00:00:00 2001 From: codereader Date: Mon, 24 Jan 2022 12:52:07 +0100 Subject: [PATCH] #5584: Remove deactivated patch renderables --- radiantcore/patch/Patch.cpp | 2 - radiantcore/patch/Patch.h | 2 - radiantcore/patch/PatchRenderables.cpp | 130 +------------------------ radiantcore/patch/PatchRenderables.h | 53 ---------- 4 files changed, 5 insertions(+), 182 deletions(-) diff --git a/radiantcore/patch/Patch.cpp b/radiantcore/patch/Patch.cpp index 83654a2d57..56c5f79044 100644 --- a/radiantcore/patch/Patch.cpp +++ b/radiantcore/patch/Patch.cpp @@ -48,7 +48,6 @@ inline bool double_valid(double f) { Patch::Patch(PatchNode& node) : _node(node), _undoStateSaver(nullptr), - _renderableNTBVectors(_mesh), _transformChanged(false), _tesselationChanged(true), _shader(texdef_name_default()) @@ -64,7 +63,6 @@ Patch::Patch(const Patch& other, PatchNode& node) : IUndoable(other), _node(node), _undoStateSaver(nullptr), - _renderableNTBVectors(_mesh), _transformChanged(false), _tesselationChanged(true), _shader(other._shader.getMaterialName()) diff --git a/radiantcore/patch/Patch.h b/radiantcore/patch/Patch.h index 80dc3215ca..408f4b9152 100644 --- a/radiantcore/patch/Patch.h +++ b/radiantcore/patch/Patch.h @@ -56,8 +56,6 @@ class Patch : // The tesselation for this patch PatchTesselation _mesh; - RenderablePatchVectorsNTB _renderableNTBVectors; - bool _transformChanged; // TRUE if the patch tesselation needs an update diff --git a/radiantcore/patch/PatchRenderables.cpp b/radiantcore/patch/PatchRenderables.cpp index 7cf0c64bc0..a1f8ef13e1 100644 --- a/radiantcore/patch/PatchRenderables.cpp +++ b/radiantcore/patch/PatchRenderables.cpp @@ -1,123 +1,16 @@ #include "PatchRenderables.h" -#if 0 -RenderablePatchSolid::RenderablePatchSolid(PatchTesselation& tess) : - _tess(tess), - _needsUpdate(true) -{} - -void RenderablePatchSolid::render(const RenderInfo& info) const -{ - if (_tess.vertices.empty() || _tess.indices.empty()) return; - - if (!info.checkFlag(RENDER_BUMP)) - { - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - } - - // No colour changing - glDisableClientState(GL_COLOR_ARRAY); - - if (info.checkFlag(RENDER_VERTEX_COLOUR)) - { - glColor3f(1, 1, 1); - } - - if (_needsUpdate) - { - _needsUpdate = false; - - // Add vertex geometry to vertex buffer - VertexBuffer_T currentVBuf; - currentVBuf.addVertices(_tess.vertices.begin(), _tess.vertices.end()); - - // Submit indices - const RenderIndex* strip_indices = &_tess.indices.front(); - for (std::size_t i = 0; - i < _tess.numStrips; - i++, strip_indices += _tess.lenStrips) - { - currentVBuf.addIndexBatch(strip_indices, _tess.lenStrips); - } - - // Render all batches - _vertexBuf.replaceData(currentVBuf); - } - - _vertexBuf.renderAllBatches(GL_QUAD_STRIP, info.checkFlag(RENDER_BUMP)); - - if (!info.checkFlag(RENDER_BUMP)) - { - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } -} - -void RenderablePatchSolid::queueUpdate() -{ - _needsUpdate = true; -} -#endif - -const ShaderPtr& RenderablePatchVectorsNTB::getShader() const -{ - return _shader; -} - -RenderablePatchVectorsNTB::RenderablePatchVectorsNTB(const PatchTesselation& tess) : - _tess(tess) -{} - -void RenderablePatchVectorsNTB::setRenderSystem(const RenderSystemPtr& renderSystem) +namespace detail { - if (renderSystem) - { - _shader = renderSystem->capture("$PIVOT"); - } - else - { - _shader.reset(); - } -} - -#define VectorMA( v, s, b, o ) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) -void RenderablePatchVectorsNTB::render(const RenderInfo& info) const +inline Vector4 getControlPointVertexColour(std::size_t i, std::size_t width) { - if (_tess.vertices.empty()) return; - - glBegin(GL_LINES); - - for (const ArbitraryMeshVertex& v : _tess.vertices) - { - Vector3 end; - - glColor3f(0, 0, 1); - glVertex3dv(v.vertex); - VectorMA(v.vertex, 5, v.normal, end); - glVertex3dv(end); - - glColor3f(1, 0, 0); - glVertex3dv(v.vertex); - VectorMA(v.vertex, 5, v.tangent, end); - glVertex3dv(end); - - glColor3f(0, 1, 0); - glVertex3dv(v.vertex); - VectorMA(v.vertex, 5, v.bitangent, end); - glVertex3dv(end); - - glColor3f(1, 1, 1); - glVertex3dv(v.vertex); - glVertex3dv(v.vertex); - } + static const Vector3& cornerColourVec = GlobalPatchModule().getSettings().getVertexColour(patch::PatchEditVertexType::Corners); + static const Vector3& insideColourVec = GlobalPatchModule().getSettings().getVertexColour(patch::PatchEditVertexType::Inside); - glEnd(); + return (i % 2 || (i / width) % 2) ? cornerColourVec : insideColourVec; } -void RenderablePatchVectorsNTB::render(IRenderableCollector& collector, const VolumeTest& volume, const Matrix4& localToWorld) const -{ - collector.setHighlightFlag(IRenderableCollector::Highlight::Primitives, false); - collector.addRenderable(*_shader, *this, localToWorld); } RenderablePatchControlPoints::RenderablePatchControlPoints(const IPatch& patch, @@ -127,19 +20,6 @@ RenderablePatchControlPoints::RenderablePatchControlPoints(const IPatch& patch, _needsUpdate(true) {} -namespace detail -{ - -inline Vector4 getControlPointVertexColour(std::size_t i, std::size_t width) -{ - static const Vector3& cornerColourVec = GlobalPatchModule().getSettings().getVertexColour(patch::PatchEditVertexType::Corners); - static const Vector3& insideColourVec = GlobalPatchModule().getSettings().getVertexColour(patch::PatchEditVertexType::Inside); - - return (i % 2 || (i / width) % 2) ? cornerColourVec : insideColourVec; -} - -} - void RenderablePatchControlPoints::updateGeometry() { if (!_needsUpdate) return; diff --git a/radiantcore/patch/PatchRenderables.h b/radiantcore/patch/PatchRenderables.h index e9d6c6c597..94d1111bd0 100644 --- a/radiantcore/patch/PatchRenderables.h +++ b/radiantcore/patch/PatchRenderables.h @@ -6,64 +6,11 @@ #pragma once #include -#include "igl.h" -#include "imodelsurface.h" - #include "PatchTesselation.h" #include "PatchControlInstance.h" -#include "render/VertexBuffer.h" -#include "render/IndexedVertexBuffer.h" #include "render/RenderableGeometry.h" -#if 0 -/// Helper class to render a PatchTesselation in solid mode -class RenderablePatchSolid : - public OpenGLRenderable -{ - // Geometry source - PatchTesselation& _tess; - - // VertexBuffer for rendering - typedef render::IndexedVertexBuffer VertexBuffer_T; - mutable VertexBuffer_T _vertexBuf; - - mutable bool _needsUpdate; - - // The render indices to render the mesh vertices as QUADS - std::vector _indices; - -public: - RenderablePatchSolid(PatchTesselation& tess); - - void render(const RenderInfo& info) const; - - void queueUpdate(); -}; -#endif - -// Renders a vertex' normal/tangent/bitangent vector (for debugging purposes) -class RenderablePatchVectorsNTB : - public OpenGLRenderable -{ -private: - std::vector _vertices; - const PatchTesselation& _tess; - - ShaderPtr _shader; - -public: - const ShaderPtr& getShader() const; - - RenderablePatchVectorsNTB(const PatchTesselation& tess); - - void setRenderSystem(const RenderSystemPtr& renderSystem); - - void render(const RenderInfo& info) const; - - void render(IRenderableCollector& collector, const VolumeTest& volume, const Matrix4& localToWorld) const; -}; - class ITesselationIndexer { public: