Ver Fonte

Fix dragpoint distorting transform position

The gizmos destroy the maid's bone structure when dragging (mouse hold +
move) prior to enabling the gizmo.

This is a part of the problem in MultipleMaids where bone mode is prone
to destroying maid poses. This fix alleviates that issue slightly but
more fiddling is needed.
habeebweeb há 4 anos atrás
pai
commit
d1e0d9b936

+ 10 - 9
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/CustomGizmo.cs

@@ -33,7 +33,16 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 gizmoTypeOld = gizmoType;
             }
         }
-        public bool IsGizmoDrag => IsDrag && SelectedType != 0;
+        public bool IsGizmoDrag => GizmoVisible && IsDrag && SelectedType != 0;
+        public bool GizmoVisible
+        {
+            get => base.Visible;
+            set
+            {
+                if (value && IsDrag) is_drag_.SetValue(null, false);
+                base.Visible = value;
+            }
+        }
         public GizmoMode gizmoMode = GizmoMode.Local;
         public event EventHandler GizmoDrag;
         public enum GizmoType
@@ -166,13 +175,5 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             GizmoDrag?.Invoke(this, EventArgs.Empty);
         }
-
-        private void OnEnable()
-        {
-            if (target != null)
-            {
-                SetTransform();
-            }
-        }
     }
 }

+ 4 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPoint.cs

@@ -103,7 +103,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             Gizmo = CustomGizmo.Make(this.MyObject, scale, mode);
             GizmoGo = Gizmo.gameObject;
-            GizmoGo.SetActive(false);
+            Gizmo.GizmoVisible = false;
             ApplyDragType();
         }
 
@@ -113,7 +113,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             this.collider.enabled = active;
             this.renderer.enabled = visible;
-            this.GizmoGo?.SetActive(gizmo);
+            if (this.Gizmo != null) this.Gizmo.GizmoVisible = gizmo;
         }
 
         protected Vector3 MouseDelta() => Input.mousePosition - startMousePosition;
@@ -186,12 +186,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 transform.position = position();
                 transform.eulerAngles = rotation();
             }
+            if (GizmoGo != null) GizmoGo.SetActive(true);
             ApplyDragType();
         }
 
         private void OnDisable()
         {
-            if (GizmoGo) GizmoGo.SetActive(false);
+            if (GizmoGo != null) GizmoGo.SetActive(false);
         }
 
         protected virtual void OnDestroy() => GameObject.Destroy(GizmoGo);