From 7506e0617c6e36d9fc5276affe4502886f0cbdea Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 23 Jan 2022 16:20:34 +0100 Subject: [PATCH] #5584: TranslateManipulator migrated, including RenderableQuad. --- libs/render.h | 7 --- libs/selection/BestPoint.h | 6 +- radiantcore/selection/Renderables.h | 51 ---------------- .../manipulators/ModelScaleManipulator.h | 1 - .../selection/manipulators/Renderables.h | 14 +++++ .../manipulators/RotateManipulator.h | 1 - .../manipulators/TranslateManipulator.cpp | 59 +++---------------- .../manipulators/TranslateManipulator.h | 2 - .../textool/TextureToolRotateManipulator.h | 1 - tools/msvc/DarkRadiantCore.vcxproj | 1 - tools/msvc/DarkRadiantCore.vcxproj.filters | 3 - 11 files changed, 24 insertions(+), 122 deletions(-) delete mode 100644 radiantcore/selection/Renderables.h diff --git a/libs/render.h b/libs/render.h index 3b7e3ac817..c03439f12e 100644 --- a/libs/render.h +++ b/libs/render.h @@ -474,10 +474,3 @@ inline void draw_circle(const std::size_t segments, const double radius, VertexA { draw_ellipse(segments, radius, radius, vertices, firstVertex); } - -inline void draw_quad(const float radius, VertexCb* quad) { - (*quad++).vertex = Vertex3f(-radius, radius, 0); - (*quad++).vertex = Vertex3f(radius, radius, 0); - (*quad++).vertex = Vertex3f(radius, -radius, 0); - (*quad++).vertex = Vertex3f(-radius, -radius, 0); -} diff --git a/libs/selection/BestPoint.h b/libs/selection/BestPoint.h index 6474878391..c1aca38019 100644 --- a/libs/selection/BestPoint.h +++ b/libs/selection/BestPoint.h @@ -525,15 +525,15 @@ inline void Circle_BestPoint(const Matrix4& local2view, clipcull_t cull, const V } } -inline void Quad_BestPoint(const Matrix4& local2view, clipcull_t cull, const VertexCb* vertices, SelectionIntersection& best) +inline void Quad_BestPoint(const Matrix4& local2view, clipcull_t cull, const Vertex3f* vertices, SelectionIntersection& best) { Vector4 clipped[9]; { - const std::size_t count = clipTriangle(local2view, vertices[0].vertex, vertices[1].vertex, vertices[3].vertex, clipped); + const std::size_t count = clipTriangle(local2view, vertices[0], vertices[1], vertices[3], clipped); BestPoint(count, clipped, best, cull); } { - const std::size_t count = clipTriangle(local2view, vertices[1].vertex, vertices[2].vertex, vertices[3].vertex, clipped); + const std::size_t count = clipTriangle(local2view, vertices[1], vertices[2], vertices[3], clipped); BestPoint(count, clipped, best, cull); } } diff --git a/radiantcore/selection/Renderables.h b/radiantcore/selection/Renderables.h deleted file mode 100644 index 78e871a6c9..0000000000 --- a/radiantcore/selection/Renderables.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "render.h" -#include "render/VertexNCb.h" - -/* greebo: This contains the renderables (rectangles, arrows) to represent - * the manipulators of the selected items - */ - -// Helper class for rendering an arrow (only the head part) -class RenderableArrowHead : - public OpenGLRenderable -{ -public: - typedef std::vector FlatShadedVertices; - FlatShadedVertices _vertices; - - RenderableArrowHead(std::size_t size) : - _vertices(size) - {} - - void render(const RenderInfo& info) const - { - glEnableClientState(GL_COLOR_ARRAY); - - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexNCb), &_vertices.front().colour); - glVertexPointer(3, GL_DOUBLE, sizeof(VertexNCb), &_vertices.front().vertex); - glNormalPointer(GL_DOUBLE, sizeof(VertexNCb), &_vertices.front().normal); - glDrawArrays(GL_TRIANGLES, 0, GLsizei(_vertices.size())); - - glDisableClientState(GL_COLOR_ARRAY); - } - - void setColour(const Colour4b& colour) - { - for (FlatShadedVertices::iterator i = _vertices.begin(); i != _vertices.end(); ++i) - { - i->colour = colour; - } - } -}; - -// Helper class for rendering a quadratic -class RenderableQuad : - public RenderablePointVector -{ -public: - RenderableQuad() : - RenderablePointVector(GL_LINE_LOOP, 4) - {} -}; diff --git a/radiantcore/selection/manipulators/ModelScaleManipulator.h b/radiantcore/selection/manipulators/ModelScaleManipulator.h index e22cd2bee8..abfce5de47 100644 --- a/radiantcore/selection/manipulators/ModelScaleManipulator.h +++ b/radiantcore/selection/manipulators/ModelScaleManipulator.h @@ -4,7 +4,6 @@ #include "ManipulatorBase.h" #include "ManipulatorComponents.h" -#include "selection/Renderables.h" #include "selection/ManipulationPivot.h" #include "selection/Pivot2World.h" #include "selection/BasicSelectable.h" diff --git a/radiantcore/selection/manipulators/Renderables.h b/radiantcore/selection/manipulators/Renderables.h index 30aad27fae..d207b6c802 100644 --- a/radiantcore/selection/manipulators/Renderables.h +++ b/radiantcore/selection/manipulators/Renderables.h @@ -265,6 +265,20 @@ class RenderableArrowLine : } }; +class RenderableQuad : + public RenderableLineStrip +{ +public: + RenderableQuad(double edgeLength, const Matrix4& localToWorld) : + RenderableLineStrip(4, localToWorld) + { + _rawPoints[0] = Vector3(edgeLength, edgeLength, 0); + _rawPoints[1] = Vector3(edgeLength, -edgeLength, 0); + _rawPoints[2] = Vector3(-edgeLength, -edgeLength, 0); + _rawPoints[3] = Vector3(-edgeLength, edgeLength, 0); + } +}; + // Renders a few flat-shaded triangles as arrow head, offset by a given amount class RenderableArrowHead : public render::RenderableGeometry diff --git a/radiantcore/selection/manipulators/RotateManipulator.h b/radiantcore/selection/manipulators/RotateManipulator.h index b8a0d88085..f17e7aeadf 100644 --- a/radiantcore/selection/manipulators/RotateManipulator.h +++ b/radiantcore/selection/manipulators/RotateManipulator.h @@ -4,7 +4,6 @@ #include "Rotatable.h" #include "ManipulatorBase.h" #include "ManipulatorComponents.h" -#include "selection/Renderables.h" #include "selection/Pivot2World.h" #include "selection/BasicSelectable.h" #include "selection/ManipulationPivot.h" diff --git a/radiantcore/selection/manipulators/TranslateManipulator.cpp b/radiantcore/selection/manipulators/TranslateManipulator.cpp index b5c3fb8c47..cfaf796509 100644 --- a/radiantcore/selection/manipulators/TranslateManipulator.cpp +++ b/radiantcore/selection/manipulators/TranslateManipulator.cpp @@ -20,10 +20,9 @@ TranslateManipulator::TranslateManipulator(ManipulationPivot& pivot, std::size_t _arrowZ({ 0,0,length }, _pivot2World._worldSpace), _arrowHeadX({ length,0,0 }, _pivot2World._axisScreen, length / 8, length / 3, _pivot2World._worldSpace), _arrowHeadY({ 0,length,0 }, _pivot2World._axisScreen, length / 8, length / 3, _pivot2World._worldSpace), - _arrowHeadZ({ 0,0,length }, _pivot2World._axisScreen, length / 8, length / 3, _pivot2World._worldSpace) -{ - draw_quad(16, &_quadScreen.front()); -} + _arrowHeadZ({ 0,0,length }, _pivot2World._axisScreen, length / 8, length / 3, _pivot2World._worldSpace), + _quadScreen(16, _pivot2World._viewplaneSpace) +{} void TranslateManipulator::updateColours() { @@ -99,6 +98,8 @@ void TranslateManipulator::onPreRender(const RenderSystemPtr& renderSystem, cons _arrowZ.clear(); _arrowHeadZ.clear(); } + + _quadScreen.update(_lineShader); } void TranslateManipulator::clearRenderables() @@ -109,58 +110,12 @@ void TranslateManipulator::clearRenderables() _arrowHeadX.clear(); _arrowHeadY.clear(); _arrowHeadZ.clear(); + _quadScreen.clear(); _lineShader.reset(); _arrowHeadShader.reset(); } -void TranslateManipulator::render(IRenderableCollector& collector, const VolumeTest& volume) -{ -#if 0 - _pivot2World.update(_pivot.getMatrix4(), volume.GetModelview(), volume.GetProjection(), volume.GetViewport()); - - // temp hack - updateColours(); - - Vector3 x = _pivot2World._worldSpace.xCol3().getNormalised(); - bool show_x = manipulator_show_axis(_pivot2World, x); - - Vector3 y = _pivot2World._worldSpace.yCol3().getNormalised(); - bool show_y = manipulator_show_axis(_pivot2World, y); - - Vector3 z = _pivot2World._worldSpace.zCol3().getNormalised(); - bool show_z = manipulator_show_axis(_pivot2World, z); - - if(show_x) - { - collector.addRenderable(*_stateWire, _arrowX, _pivot2World._worldSpace); - } - if(show_y) - { - collector.addRenderable(*_stateWire, _arrowY, _pivot2World._worldSpace); - } - if(show_z) - { - collector.addRenderable(*_stateWire, _arrowZ, _pivot2World._worldSpace); - } - - collector.addRenderable(*_stateWire, _quadScreen, _pivot2World._viewplaneSpace); - - if(show_x) - { - collector.addRenderable(*_stateFill, _arrowHeadX, _pivot2World._worldSpace); - } - if(show_y) - { - collector.addRenderable(*_stateFill, _arrowHeadY, _pivot2World._worldSpace); - } - if(show_z) - { - collector.addRenderable(*_stateFill, _arrowHeadZ, _pivot2World._worldSpace); - } -#endif -} - void TranslateManipulator::testSelect(SelectionTest& test, const Matrix4& pivot2world) { _pivot2World.update(_pivot.getMatrix4(), test.getVolume().GetModelview(), @@ -181,7 +136,7 @@ void TranslateManipulator::testSelect(SelectionTest& test, const Matrix4& pivot2 { SelectionIntersection best; - Quad_BestPoint(local2view, eClipCullCW, &_quadScreen.front(), best); + Quad_BestPoint(local2view, eClipCullCW, &_quadScreen.getRawPoints().front(), best); if(best.isValid()) { best = SelectionIntersection(0, 0); diff --git a/radiantcore/selection/manipulators/TranslateManipulator.h b/radiantcore/selection/manipulators/TranslateManipulator.h index 7a75a7211c..23760efc61 100644 --- a/radiantcore/selection/manipulators/TranslateManipulator.h +++ b/radiantcore/selection/manipulators/TranslateManipulator.h @@ -1,7 +1,6 @@ #pragma once #include "ManipulatorBase.h" -#include "selection/Renderables.h" #include "selection/Pivot2World.h" #include "ManipulatorComponents.h" #include "selection/BasicSelectable.h" @@ -48,7 +47,6 @@ class TranslateManipulator : } void onPreRender(const RenderSystemPtr& renderSystem, const VolumeTest& volume) override; - void render(IRenderableCollector& collector, const VolumeTest& volume) override; void clearRenderables() override; void testSelect(SelectionTest& test, const Matrix4& pivot2world) override; diff --git a/radiantcore/selection/textool/TextureToolRotateManipulator.h b/radiantcore/selection/textool/TextureToolRotateManipulator.h index 6d3d1a0de8..781c0c3fc8 100644 --- a/radiantcore/selection/textool/TextureToolRotateManipulator.h +++ b/radiantcore/selection/textool/TextureToolRotateManipulator.h @@ -3,7 +3,6 @@ #include "imanipulator.h" #include "../BasicSelectable.h" #include "selection/manipulators/ManipulatorComponents.h" -#include "../Renderables.h" #include "selection/textool/TextureToolManipulationPivot.h" namespace textool diff --git a/tools/msvc/DarkRadiantCore.vcxproj b/tools/msvc/DarkRadiantCore.vcxproj index d9e83466cc..2a53f71c6b 100644 --- a/tools/msvc/DarkRadiantCore.vcxproj +++ b/tools/msvc/DarkRadiantCore.vcxproj @@ -1029,7 +1029,6 @@ - diff --git a/tools/msvc/DarkRadiantCore.vcxproj.filters b/tools/msvc/DarkRadiantCore.vcxproj.filters index d747492e98..dd0f8bf620 100644 --- a/tools/msvc/DarkRadiantCore.vcxproj.filters +++ b/tools/msvc/DarkRadiantCore.vcxproj.filters @@ -1899,9 +1899,6 @@ src\selection - - src\selection - src\selection