From e6a7751c2dc828f36ce80c1c2d441362bd4f35ff Mon Sep 17 00:00:00 2001
From: biwa <6475593+biwa@users.noreply.github.com>
Date: Sun, 27 Sep 2020 14:46:16 +0200
Subject: [PATCH] Visual Mode: added "Apply Camera Rotation To Things" action
that applies the Visual Mode's current camera pitch and yaw to the selected
things. No default key bound
---
.../BuilderModes/Resources/Actions.cfg | 10 ++++++++
.../VisualModes/BaseVisualMode.cs | 23 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg
index fde04b11..987f7ef7 100755
--- a/Source/Plugins/BuilderModes/Resources/Actions.cfg
+++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg
@@ -1444,4 +1444,14 @@ archbetweenhandles
allowkeys = true;
allowmouse = true;
allowscroll = false;
+}
+
+applycamerarotationtothings
+{
+ title = "Apply Camera Rotation To Things";
+ category = "visual";
+ description = "Applies the Visual Mode's current camera pitch and yaw to the selected things.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = false;
}
\ No newline at end of file
diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs
index 8381790c..d384bbd4 100755
--- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs
@@ -4318,6 +4318,29 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
+ ///
+ /// Applies the Visual Mode's current camera pitch and yaw to the selected things
+ ///
+ [BeginAction("applycamerarotationtothings")]
+ public void ApplyCameraRotationToThings()
+ {
+ List things = GetSelectedThings();
+
+ if(things.Count == 0)
+ {
+ General.Interface.DisplayStatus(StatusType.Warning, "Can't apply camera rotation to things: no things selected.");
+ return;
+ }
+
+ General.Map.UndoRedo.CreateUndo("Apply camera rotation to things");
+
+ foreach (Thing t in things)
+ {
+ t.Rotate(General.Map.VisualCamera.AngleXY);
+ t.SetPitch((int)Angle2D.RadToDeg(-General.Map.VisualCamera.AngleZ));
+ }
+ }
+
#endregion
#region ================== Texture Alignment