Browse Source

Add reset position when double clicking drag point

The position that the object is reset to is Vector3.zero by default.
habeebweeb 4 years ago
parent
commit
5dfef7d2bb

+ 11 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPointGeneral.cs

@@ -13,6 +13,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private bool scaling;
         private Quaternion currentRotation;
         public Quaternion DefaultRotation { get; set; } = Quaternion.identity;
+        public Vector3 DefaultPosition { get; set; } = Vector3.zero;
         public float ScaleFactor { get; set; } = 1f;
         public bool ConstantScale { get; set; }
         public static readonly Color moveColour = new Color(0.2f, 0.5f, 0.95f, defaultAlpha);
@@ -89,13 +90,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void OnMouseDown()
         {
-            if (CurrentDragType == DragType.Delete)
+            if (Deleting)
             {
                 OnDelete();
                 return;
             }
 
-            if (CurrentDragType == DragType.Select)
+            if (Selecting)
             {
                 OnSelect();
                 return;
@@ -109,18 +110,24 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void OnDoubleClick()
         {
-            if (CurrentDragType == DragType.Scale)
+            if (Scaling)
             {
                 MyObject.localScale = Vector3.one;
                 OnScale();
                 OnEndScale();
             }
 
-            if (CurrentDragType == DragType.RotLocalY || CurrentDragType == DragType.RotLocalXZ)
+            if (Rotating)
             {
                 MyObject.rotation = DefaultRotation;
                 OnRotate();
             }
+
+            if (Moving)
+            {
+                MyObject.position = DefaultPosition;
+                OnMove();
+            }
         }
 
         protected override void OnMouseUp()

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPointLight.cs

@@ -164,6 +164,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             SetLightType(MPSLightType.Normal);
             ScaleFactor = 50f;
             DefaultRotation = LightProperty.DefaultRotation;
+            DefaultPosition = LightProperty.DefaultPosition;
         }
 
         protected override void OnDestroy()

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPointOther.cs

@@ -65,6 +65,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             base.Set(myObject);
             DefaultRotation = MyObject.rotation;
+            DefaultPosition = MyObject.position;
             meshRenderers = new List<Renderer>(MyObject.GetComponentsInChildren<SkinnedMeshRenderer>());
             meshRenderers.AddRange(MyObject.GetComponentsInChildren<MeshRenderer>());
         }