Browse Source

Fix camera z rotation slider resetting other axes

Also update Z rotation slider when resetting the camera with Q + R

This was a left over bug from when I was experimenting with rotation
sliders for all axes.

Don't know how I didn't notice that the camera rotation was resetting
for axes other than Z while testing but whatever.
habeebweeb 4 years ago
parent
commit
c149c89c7a

+ 6 - 9
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/BackgroundWindowPanes/CameraPane.cs

@@ -9,9 +9,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private readonly SelectionGrid cameraGrid;
         private readonly Slider zRotationSlider;
         private readonly Slider fovSlider;
-
         private string header;
-        private Vector3 cameraRotation;
 
         public CameraPane(EnvironmentManager environmentManager)
         {
@@ -27,8 +25,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             zRotationSlider.ControlEvent += (s, a) =>
             {
                 if (updating) return;
-                cameraRotation.z = zRotationSlider.Value;
-                camera.transform.rotation = Quaternion.Euler(cameraRotation);
+                Vector3 newRotation = camera.transform.eulerAngles;
+                newRotation.z = zRotationSlider.Value;
+                camera.transform.rotation = Quaternion.Euler(newRotation);
             };
             fovSlider = new Slider(Translation.Get("cameraPane", "fov"), 20f, 150f, camera.fieldOfView);
             fovSlider.ControlEvent += (s, a) =>
@@ -66,13 +65,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public override void UpdatePane()
         {
-            Camera camera = CameraUtility.MainCamera.camera;
-            Vector3 eulerAngles = camera.transform.eulerAngles;
-            cameraRotation = eulerAngles;
-
             updating = true;
 
-            zRotationSlider.Value = eulerAngles.z;
+            Camera camera = CameraUtility.MainCamera.camera;
+
+            zRotationSlider.Value = camera.transform.eulerAngles.z;
             fovSlider.Value = camera.fieldOfView;
 
             cameraGrid.SelectedItemIndex = environmentManager.CurrentCameraIndex;

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs

@@ -294,6 +294,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             mainCamera.Reset(CameraMain.CameraType.Target, true);
             mainCamera.SetTargetPos(new Vector3(0f, 0.9f, 0f));
             mainCamera.SetDistance(3f);
+            CameraChange?.Invoke(this, EventArgs.Empty);
         }
 
         private void OnCubeSmall(object sender, EventArgs args)