Skip to content

Commit

Permalink
#5584: TranslateManipulator migrated, including RenderableQuad.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 23, 2022
1 parent 927f86a commit 7506e06
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 122 deletions.
7 changes: 0 additions & 7 deletions libs/render.h
Expand Up @@ -474,10 +474,3 @@ inline void draw_circle(const std::size_t segments, const double radius, VertexA
{
draw_ellipse<remap_policy>(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);
}
6 changes: 3 additions & 3 deletions libs/selection/BestPoint.h
Expand Up @@ -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);
}
}
Expand Down
51 changes: 0 additions & 51 deletions radiantcore/selection/Renderables.h

This file was deleted.

1 change: 0 additions & 1 deletion radiantcore/selection/manipulators/ModelScaleManipulator.h
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions radiantcore/selection/manipulators/Renderables.h
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion radiantcore/selection/manipulators/RotateManipulator.h
Expand Up @@ -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"
Expand Down
59 changes: 7 additions & 52 deletions radiantcore/selection/manipulators/TranslateManipulator.cpp
Expand Up @@ -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()
{
Expand Down Expand Up @@ -99,6 +98,8 @@ void TranslateManipulator::onPreRender(const RenderSystemPtr& renderSystem, cons
_arrowZ.clear();
_arrowHeadZ.clear();
}

_quadScreen.update(_lineShader);
}

void TranslateManipulator::clearRenderables()
Expand All @@ -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(),
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions 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"
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -1029,7 +1029,6 @@
<ClInclude Include="..\..\radiantcore\selection\manipulators\RotateManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\manipulators\TranslateManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\RadiantSelectionSystem.h" />
<ClInclude Include="..\..\radiantcore\selection\Renderables.h" />
<ClInclude Include="..\..\radiantcore\selection\SceneManipulationPivot.h" />
<ClInclude Include="..\..\radiantcore\selection\SceneWalkers.h" />
<ClInclude Include="..\..\radiantcore\selection\SelectedNodeList.h" />
Expand Down
3 changes: 0 additions & 3 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -1899,9 +1899,6 @@
<ClInclude Include="..\..\radiantcore\selection\RadiantSelectionSystem.h">
<Filter>src\selection</Filter>
</ClInclude>
<ClInclude Include="..\..\radiantcore\selection\Renderables.h">
<Filter>src\selection</Filter>
</ClInclude>
<ClInclude Include="..\..\radiantcore\selection\SceneWalkers.h">
<Filter>src\selection</Filter>
</ClInclude>
Expand Down

0 comments on commit 7506e06

Please sign in to comment.