Skip to content

Commit

Permalink
#5746: Start working on Vertex selection
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 19, 2021
1 parent 7b01e5b commit 9e76903
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/itexturetoolmodel.h
Expand Up @@ -61,7 +61,7 @@ class INode :
using Ptr = std::shared_ptr<INode>;

// Renders this node, with all coords relative to UV space origin
virtual void render() = 0;
virtual void render(SelectionMode mode) = 0;
};

// Node representing a single brush face
Expand Down
2 changes: 1 addition & 1 deletion radiant/textool/TexTool.cpp
Expand Up @@ -529,7 +529,7 @@ void TexTool::drawUVCoords()
{
GlobalTextureToolSceneGraph().foreachNode([&](const textool::INode::Ptr& node)
{
node->render();
node->render(GlobalTextureToolSelectionSystem().getMode());
return true;
});
#if 0
Expand Down
47 changes: 30 additions & 17 deletions radiantcore/selection/textool/FaceNode.h
Expand Up @@ -3,6 +3,7 @@
#include "ibrush.h"
#include "NodeBase.h"
#include "math/Matrix3.h"
#include "SelectableVertex.h"

namespace textool
{
Expand All @@ -15,10 +16,17 @@ class FaceNode :
IFace& _face;
mutable AABB _bounds;

std::vector<SelectableVertex> _vertices;

public:
FaceNode(IFace& face) :
_face(face)
{}
{
for (auto& vertex : _face.getWinding())
{
_vertices.emplace_back(vertex.texcoord);
}
}

IFace& getFace() override
{
Expand Down Expand Up @@ -87,13 +95,13 @@ class FaceNode :
}
}

void render() override
void render(SelectionMode mode) override
{
glEnable(GL_BLEND);
glBlendColor(0, 0, 0, 0.3f);
glBlendFunc(GL_CONSTANT_ALPHA_EXT, GL_ONE_MINUS_CONSTANT_ALPHA_EXT);

if (isSelected())
if (mode == SelectionMode::Surface && isSelected())
{
glColor3f(1, 0.5f, 0);
}
Expand All @@ -112,23 +120,28 @@ class FaceNode :
glEnd();
glDisable(GL_BLEND);

glPointSize(5);
glBegin(GL_POINTS);

glColor3f(0.7f, 0.7f, 0.7f);

for (const auto& vertex : _face.getWinding())
if (mode == SelectionMode::Vertex)
{
glVertex2d(vertex.texcoord[0], vertex.texcoord[1]);
glPointSize(5);
glBegin(GL_POINTS);

for (const auto& vertex : _vertices)
{
if (vertex.isSelected())
{
glColor3f(1, 0.5f, 0);
}
else
{
glColor3f(0.8f, 0.8f, 0.8f);
}

glVertex2d(vertex.getVertex().x(), vertex.getVertex().y());
}

glEnd();
}

//glColor3f(1, 1, 1);

//Vector2 centroid = _face.getWinding();
//glVertex2d(centroid[0], centroid[1]);

glEnd();

glDisable(GL_BLEND);
}
};
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/selection/textool/PatchNode.h
Expand Up @@ -104,7 +104,7 @@ class PatchNode :
#endif
}

void render() override
void render(SelectionMode mode) override
{
glEnable(GL_BLEND);
glBlendColor(0, 0, 0, 0.3f);
Expand Down
25 changes: 25 additions & 0 deletions radiantcore/selection/textool/SelectableVertex.h
@@ -0,0 +1,25 @@
#pragma once

#include "selection/BasicSelectable.h"

namespace textool
{

class SelectableVertex :
public selection::BasicSelectable
{
private:
Vector2& _texcoord;

public:
SelectableVertex(Vector2& texcoord) :
_texcoord(texcoord)
{}

const Vector2& getVertex() const
{
return _texcoord;
}
};

}
1 change: 1 addition & 0 deletions tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -1031,6 +1031,7 @@
<ClInclude Include="..\..\radiantcore\selection\textool\FaceNode.h" />
<ClInclude Include="..\..\radiantcore\selection\textool\NodeBase.h" />
<ClInclude Include="..\..\radiantcore\selection\textool\PatchNode.h" />
<ClInclude Include="..\..\radiantcore\selection\textool\SelectableVertex.h" />
<ClInclude Include="..\..\radiantcore\selection\textool\TextureToolDragManipulator.h" />
<ClInclude Include="..\..\radiantcore\selection\textool\TextureToolManipulationPivot.h" />
<ClInclude Include="..\..\radiantcore\selection\textool\TextureToolRotateManipulator.h" />
Expand Down
3 changes: 3 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -2238,5 +2238,8 @@
<ClInclude Include="..\..\radiantcore\selection\textool\TextureToolDragManipulator.h">
<Filter>src\selection\textool</Filter>
</ClInclude>
<ClInclude Include="..\..\radiantcore\selection\textool\SelectableVertex.h">
<Filter>src\selection\textool</Filter>
</ClInclude>
</ItemGroup>
</Project>

0 comments on commit 9e76903

Please sign in to comment.