From c6b879bb1a5c617fd86464fe45af376122f0c9bf Mon Sep 17 00:00:00 2001 From: mykola-ambar Date: Fri, 20 Sep 2019 21:49:30 +0300 Subject: [PATCH] Fix sector offset transformation in Edit Selection mode (PR#274 by mykola-ambar) --- .../BuilderModes/ClassicModes/EditSelectionMode.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 9e63c3a3..2e109034 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -893,13 +893,14 @@ namespace CodeImp.DoomBuilder.BuilderModes float texrotation = Angle2D.PI2 - rotation; // Update texture offsets - if(transformoffsets) + if (transformoffsets) { - Vector2D toffset = (selectionbasecenter - selectioncenter).GetRotated((texrotation + si.Rotation)); - Vector2D soffset = si.Offset.GetRotated(texrotation + si.Rotation); + float trotation = rotateoffsets ? (si.Rotation + texrotation) : (si.Rotation); + Vector2D offset = selectioncenter.GetRotated(trotation); + + fields["xpanning" + si.Part] = new UniValue(UniversalType.Float, (float)Math.Round(-offset.x, General.Map.FormatInterface.VertexDecimals)); + fields["ypanning" + si.Part] = new UniValue(UniversalType.Float, (float)Math.Round(offset.y, General.Map.FormatInterface.VertexDecimals)); - fields["xpanning" + si.Part] = new UniValue(UniversalType.Float, (float)Math.Round(soffset.x + toffset.x, General.Map.FormatInterface.VertexDecimals) % si.TextureSize.Width); - fields["ypanning" + si.Part] = new UniValue(UniversalType.Float, (float)Math.Round(-(soffset.y + toffset.y), General.Map.FormatInterface.VertexDecimals) % si.TextureSize.Height); } // Restore texture offsets else @@ -1825,7 +1826,7 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.RenderRectangleFilled(rotategrips[i], General.Colors.Background, true); renderer.RenderRectangle(rotategrips[i], 2, General.Colors.Indication, true); } - + renderer.Finish(); }