From b2efa1c1c252e4fcd347e25441a0942437bca2c8 Mon Sep 17 00:00:00 2001 From: codereader Date: Tue, 5 Oct 2021 20:31:41 +0200 Subject: [PATCH] #5547: Add ability to normalise a set of texture tool items as a whole --- install/bitmaps/textool_normalise.png | Bin 0 -> 5625 bytes install/user.xml | 1 + .../textool/TextureToolSelectionSystem.cpp | 23 ++++++++++++++++-- .../textool/TextureToolSelectionSystem.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 install/bitmaps/textool_normalise.png diff --git a/install/bitmaps/textool_normalise.png b/install/bitmaps/textool_normalise.png new file mode 100644 index 0000000000000000000000000000000000000000..1044687bce59d4f2e0c531436006604d98b93b0f GIT binary patch literal 5625 zcmeHKYgAKL77ie9v_3$=5eX@1QIgz*yiJrh1PD+-L`2{wxq(1lBsUNctwIY0EEcFJ z6ckbGPz$ZaQXhy?pjD8rs+86u6kDu3d{C^!sE!zz?=kyrv@;dBLr zg*0Lj2BZ1mUg_r2f!C~jWUw%BDKUOWA9kgeGT&&IW% z)Xa=eR-ISmx%sVkDq#BNb|f4;TE&;0Z7;7MPi~q?`MiDWI(z%9RX#O6aRt*;Th^Uj z7Z?+28E3V*cU|dp;lI+RQ^_Yoj$C`y!r8&4HIhfz#rRFx8zCb zotJ+d>Yy~-uY5E;?|$?J_L{4EzjfSKyX;nD*~!Zb27X64W^8`0K)3nrP%(3N16l2K3t>-`sIdZ)fg)> zOVY`x$KVpX=25;6iocceiQ|r9dTXfp@=P&1+HhNoLy761^9Fqo15X==To~Q z-bt!E%DtAOs%|SS|LjJ@%I-GujtxO`{>83>ZHuW ztJc;q0sF4e!~psd_MQ@;Y}bB`$r!~PTLqC-U-nt@;F7YAtgVaY#pakF8*?(rYN~&; z+4OAO!0@S}$@6VI*+63Tw7HUUh2uC`*<+L>ZIXT%9&O$!W%#J`@8x>{k9zM7~PoLu&ne>p0W2mk-@Y`lRmQK+)737>WrkD?}YrIb_m_LP5Hhb zw4>}CVOwwJ``h?zTVMG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2K}u%cdP`lm@E7@t1uYL#puW2YVVGRh|v`0@_bBhSr{+2cPPK#cONkw<9d5U zFgkjRPAvKYu<|*W>Dq78=xOV?+da@OvI_37a0w@SMP4)$8t;j>=!p5IxoBOXVb{e+ z#gAqh`fq#nrMBL{EW={V8HsM{2h-^GwJA5?5 zQ9MB_k4d5Vj*&!zW_IzBPS=-C4ld2lZq5{`t(6~-%#R+sYj1ru=^Qov_g|Nf%q!m6 i>q#>BiuG`Hic#kHD#zT49S@L{Ff);tbYT;U`Rj! literal 0 HcmV?d00001 diff --git a/install/user.xml b/install/user.xml index bb46bb9123..f6e7e8f896 100644 --- a/install/user.xml +++ b/install/user.xml @@ -310,6 +310,7 @@ + diff --git a/radiantcore/selection/textool/TextureToolSelectionSystem.cpp b/radiantcore/selection/textool/TextureToolSelectionSystem.cpp index 3307770380..d1e725e1f0 100644 --- a/radiantcore/selection/textool/TextureToolSelectionSystem.cpp +++ b/radiantcore/selection/textool/TextureToolSelectionSystem.cpp @@ -50,6 +50,8 @@ void TextureToolSelectionSystem::initialiseModule(const IApplicationContext& ctx std::bind(&TextureToolSelectionSystem::selectRelatedCmd, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("TexToolSnapToGrid", std::bind(&TextureToolSelectionSystem::snapSelectionToGridCmd, this, std::placeholders::_1)); + GlobalCommandSystem().addCommand("TexToolNormaliseItems", + std::bind(&TextureToolSelectionSystem::normaliseSelectionCmd, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("TexToolMergeItems", std::bind(&TextureToolSelectionSystem::mergeSelectionCmd, this, std::placeholders::_1), { cmd::ARGTYPE_VECTOR2 | cmd::ARGTYPE_OPTIONAL }); @@ -700,8 +702,6 @@ void TextureToolSelectionSystem::flipSelected(int axis) selection::algorithm::TextureFlipper flipper(flipCenter, axis); foreachSelectedNode(flipper); - - radiant::TextureChangedMessage::Send(); } void TextureToolSelectionSystem::flipVerticallyCmd(const cmd::ArgumentList& args) @@ -714,6 +714,25 @@ void TextureToolSelectionSystem::flipHorizontallyCmd(const cmd::ArgumentList& ar flipSelected(0); } +void TextureToolSelectionSystem::normaliseSelectionCmd(const cmd::ArgumentList& args) +{ + // Calculate the center based on the selection + selection::algorithm::TextureBoundsAccumulator accumulator; + foreachSelectedNode(accumulator); + + if (!accumulator.getBounds().isValid()) + { + return; + } + + Vector2 normaliseCenter(accumulator.getBounds().origin.x(), accumulator.getBounds().origin.y()); + + UndoableCommand cmd("normaliseTexcoords"); + + selection::algorithm::TextureNormaliser normaliser(normaliseCenter); + foreachSelectedNode(normaliser); +} + module::StaticModule _textureToolSelectionSystemModule; } diff --git a/radiantcore/selection/textool/TextureToolSelectionSystem.h b/radiantcore/selection/textool/TextureToolSelectionSystem.h index e14368c95d..13352588c7 100644 --- a/radiantcore/selection/textool/TextureToolSelectionSystem.h +++ b/radiantcore/selection/textool/TextureToolSelectionSystem.h @@ -92,6 +92,7 @@ class TextureToolSelectionSystem : void mergeSelectionCmd(const cmd::ArgumentList& args); void flipHorizontallyCmd(const cmd::ArgumentList& args); void flipVerticallyCmd(const cmd::ArgumentList& args); + void normaliseSelectionCmd(const cmd::ArgumentList& args); void flipSelected(int axis); void performSelectionTest(Selector& selector, SelectionTest& test);