Skip to content

Commit

Permalink
#5547: Recalculate the texture tool view after normalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 5, 2021
1 parent b2efa1c commit 0b23fbc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion install/user.xml
Expand Up @@ -310,7 +310,7 @@
<toggletoolbutton name="textoolvertexmode" action="TextureToolVertexSelectionMode" tooltip="Select Vertices" icon="modify_vertices.png"/>
<separator/>
<toolbutton name="mergeitems" action="TexToolMergeItems" tooltip="Merge Selection" icon="textool_merge.png"/>
<toolbutton name="normaliseitems" action="TexToolNormaliseItems" tooltip="Normalise" icon="textool_normalise.png"/>
<toolbutton name="normaliseitems" action="TexToolNormaliseItems; TextureToolResetView" tooltip="Normalise" icon="textool_normalise.png"/>
<toolbutton name="texflips" action="TexToolFlipS" tooltip="Flip Selection Horiz (S-Axis)" icon="tex_flips.png"/>
<toolbutton name="texflipt" action="TexToolFlipT" tooltip="Flip Selection Vertical (T-Axis)" icon="tex_flipt.png"/>
<toolbutton name="selectrelated" action="TexToolSelectRelated" tooltip="Select Related Items" icon="textool_select_related.png"/>
Expand Down
7 changes: 7 additions & 0 deletions radiant/textool/TexTool.cpp
Expand Up @@ -790,6 +790,12 @@ void TexTool::onMouseScroll(wxMouseEvent& ev)
draw();
}

void TexTool::resetViewCmd(const cmd::ArgumentList& args)
{
Instance().recalculateVisibleTexSpace();
Instance().queueDraw();
}

void TexTool::toggle(const cmd::ArgumentList& args)
{
Instance().ToggleVisibility();
Expand All @@ -798,6 +804,7 @@ void TexTool::toggle(const cmd::ArgumentList& args)
void TexTool::registerCommands()
{
GlobalCommandSystem().addCommand("TextureTool", TexTool::toggle);
GlobalCommandSystem().addCommand("TextureToolResetView", TexTool::resetViewCmd);
GlobalEventManager().addRegistryToggle("TexToolToggleGrid", RKEY_GRID_STATE);

GlobalEventManager().addToggle("TextureToolUseLightTheme", [](bool toggled)
Expand Down
1 change: 1 addition & 0 deletions radiant/textool/TexTool.h
Expand Up @@ -203,6 +203,7 @@ class TexTool :
IInteractiveView& getInteractiveView() override;

private:
static void resetViewCmd(const cmd::ArgumentList& args);
void updateProjection();
double getTextureAspectRatio();
void onManipulatorModeChanged(selection::IManipulator::Type type);
Expand Down
6 changes: 6 additions & 0 deletions radiantcore/selection/textool/TextureToolSelectionSystem.cpp
Expand Up @@ -716,6 +716,12 @@ void TextureToolSelectionSystem::flipHorizontallyCmd(const cmd::ArgumentList& ar

void TextureToolSelectionSystem::normaliseSelectionCmd(const cmd::ArgumentList& args)
{
if (getSelectionMode() != SelectionMode::Surface)
{
rWarning() << "This command can only be executed in Surface manipulation mode" << std::endl;
return;
}

// Calculate the center based on the selection
selection::algorithm::TextureBoundsAccumulator accumulator;
foreachSelectedNode(accumulator);
Expand Down

0 comments on commit 0b23fbc

Please sign in to comment.