Browse Source

Refactor dragpoints

habeebweeb 4 years ago
parent
commit
32e625f782

+ 37 - 49
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/DragPointManager.cs

@@ -129,6 +129,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public bool Active { get; set; }
         public bool IsBone { get; set; }
         private static bool cubeActive = false;
+
         public DragPointManager(Meido meido)
         {
             this.meido = meido;
@@ -316,32 +317,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Vector3 limbDragPointSizeBone = Vector3.one * 0.07f;
             Vector3 fingerDragPointSize = Vector3.one * 0.015f;
 
-            Material transparentBlue = new Material(Shader.Find("Transparent/Diffuse"))
-            {
-                color = new Color(0.4f, 0.4f, 1f, 0.3f)
-            };
-
-            Material transparentBlue2 = new Material(Shader.Find("Transparent/Diffuse"))
-            {
-                color = new Color(0.5f, 0.5f, 1f, 0.8f)
-            };
-
-            Func<PrimitiveType, Vector3, Material, GameObject> MakeDragPoint = (primitive, scale, material) =>
-            {
-                GameObject dragPoint = GameObject.CreatePrimitive(primitive);
-                dragPoint.transform.localScale = scale;
-                dragPoint.GetComponent<Renderer>().material = material;
-                dragPoint.layer = 8;
-                return dragPoint;
-            };
-
             Func<Transform[], Transform[], Transform[], bool, BaseDrag[]> MakeIKChainDragPoint =
                 (upper, middle, lower, leg) =>
             {
                 GameObject[] dragPoints = new GameObject[3];
                 for (int i = 0; i < dragPoints.Length; i++)
                 {
-                    dragPoints[i] = MakeDragPoint(PrimitiveType.Sphere, limbDragPointSize, transparentBlue);
+                    dragPoints[i] =
+                         BaseDrag.MakeDragPoint(PrimitiveType.Sphere, limbDragPointSize, BaseDrag.LightBlue);
                 }
 
                 return new BaseDrag[3] {
@@ -354,8 +337,31 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 };
             };
 
+            // TODO: Modify dragpoint sizes for each joint
+            Action<Bone, Bone, int> MakeFingerDragPoint = (start, end, joints) =>
+            {
+                for (Bone it = start; it <= end; it += joints)
+                {
+                    for (int i = 0; i < joints - 1; i++)
+                    {
+                        Bone bone = it + 1 + i;
+                        DragPoint[bone] = BaseDrag.MakeDragPoint(PrimitiveType.Sphere, fingerDragPointSize, BaseDrag.Blue)
+                            .AddComponent<DragJointFinger>()
+                            .Initialize(new Transform[3] {
+                                BoneTransform[bone - 1],
+                                BoneTransform[bone - 1],
+                                BoneTransform[bone]
+                                }, i == 0, meido, () => BoneTransform[bone].position, () => Vector3.zero
+                            );
+                        DragPoint[bone].gameObject.layer = 0;
+                        DragPoint[bone].DragPointVisible = true;
+                    }
+                }
+            };
+
             // Cube Dragpoint
-            DragPoint[Bone.Cube] = MakeDragPoint(PrimitiveType.Cube, new Vector3(0.12f, 0.12f, 0.12f), transparentBlue2)
+            DragPoint[Bone.Cube] =
+                BaseDrag.MakeDragPoint(PrimitiveType.Cube, new Vector3(0.12f, 0.12f, 0.12f), BaseDrag.Blue)
                 .AddComponent<DragBody>()
                 .Initialize(meido,
                     () => maid.transform.position,
@@ -366,7 +372,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             dragCube.DragPointVisible = true;
 
             // Body Dragpoint
-            DragPoint[Bone.Body] = MakeDragPoint(PrimitiveType.Capsule, new Vector3(0.2f, 0.3f, 0.24f), transparentBlue)
+            DragPoint[Bone.Body] =
+                BaseDrag.MakeDragPoint(PrimitiveType.Capsule, new Vector3(0.2f, 0.3f, 0.24f), BaseDrag.LightBlue)
                 .AddComponent<DragBody>()
                 .Initialize(meido,
                     () => new Vector3(
@@ -385,7 +392,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             dragBody.Scale += (s, a) => SetDragPointScale(maid.transform.localScale.x);
 
             // Head Dragpoint
-            DragPoint[Bone.Head] = MakeDragPoint(PrimitiveType.Sphere, new Vector3(0.2f, 0.24f, 0.2f), transparentBlue)
+            DragPoint[Bone.Head] =
+                BaseDrag.MakeDragPoint(PrimitiveType.Sphere, new Vector3(0.2f, 0.24f, 0.2f), BaseDrag.LightBlue)
                 .AddComponent<DragHead>()
                 .Initialize(BoneTransform[Bone.Neck], meido,
                 () => new Vector3(
@@ -405,7 +413,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             // Torso Dragpoint
             DragPoint[Bone.Torso] =
-                MakeDragPoint(PrimitiveType.Capsule, new Vector3(0.2f, 0.19f, 0.24f), transparentBlue)
+                BaseDrag.MakeDragPoint(PrimitiveType.Capsule, new Vector3(0.2f, 0.19f, 0.24f), BaseDrag.LightBlue)
                 .AddComponent<DragTorso>();
             Transform spineTrans1 = BoneTransform[Bone.Spine1];
             Transform spineTrans2 = BoneTransform[Bone.Spine1a];
@@ -431,7 +439,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             // Pelvis Dragpoint
             DragPoint[Bone.Pelvis] =
-                MakeDragPoint(PrimitiveType.Capsule, new Vector3(0.2f, 0.15f, 0.24f), transparentBlue)
+                BaseDrag.MakeDragPoint(PrimitiveType.Capsule, new Vector3(0.2f, 0.15f, 0.24f), BaseDrag.LightBlue)
                 .AddComponent<DragPelvis>();
             Transform pelvisTrans = BoneTransform[Bone.Pelvis];
             Transform spineTrans = BoneTransform[Bone.Spine];
@@ -451,7 +459,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             // Left Mune Dragpoint
             DragPoint[Bone.MuneL] =
-                MakeDragPoint(PrimitiveType.Sphere, new Vector3(0.12f, 0.12f, 0.12f), transparentBlue)
+                BaseDrag.MakeDragPoint(PrimitiveType.Sphere, new Vector3(0.12f, 0.12f, 0.12f), BaseDrag.LightBlue)
                 .AddComponent<DragMune>();
             Transform[] muneIKChainL = new Transform[3] {
                 BoneTransform[Bone.MuneL],
@@ -466,7 +474,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             // Right Mune Dragpoint
             DragPoint[Bone.MuneR] =
-                MakeDragPoint(PrimitiveType.Sphere, new Vector3(0.12f, 0.12f, 0.12f), transparentBlue)
+                BaseDrag.MakeDragPoint(PrimitiveType.Sphere, new Vector3(0.12f, 0.12f, 0.12f), BaseDrag.LightBlue)
                 .AddComponent<DragMune>();
             Transform[] muneIKChainR = new Transform[3] {
                 BoneTransform[Bone.MuneR],
@@ -577,7 +585,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             for (Bone bone = Bone.Neck; bone <= Bone.ThighR; ++bone)
             {
                 Transform pos = BoneTransform[bone];
-                DragPoint[bone] = MakeDragPoint(PrimitiveType.Sphere, Vector3.one * 0.04f, transparentBlue)
+                DragPoint[bone] = BaseDrag.MakeDragPoint(PrimitiveType.Sphere, Vector3.one * 0.04f, BaseDrag.LightBlue)
                     .AddComponent<DragSpine>()
                     .Initialize(BoneTransform[bone], false, meido,
                         () => pos.position,
@@ -586,33 +594,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
 
             // Hip DragPoint
-            DragPoint[Bone.Hip] = MakeDragPoint(PrimitiveType.Cube, Vector3.one * 0.045f, transparentBlue)
+            DragPoint[Bone.Hip] = BaseDrag.MakeDragPoint(PrimitiveType.Cube, Vector3.one * 0.045f, BaseDrag.LightBlue)
                 .AddComponent<DragSpine>()
                 .Initialize(BoneTransform[Bone.Hip], true, meido,
                     () => BoneTransform[Bone.Hip].position,
                     () => Vector3.zero
                 );
 
-            Action<Bone, Bone, int> MakeFingerDragPoint = (start, end, joints) =>
-            {
-                for (Bone it = start; it <= end; it += joints)
-                {
-                    for (int i = 0; i < joints - 1; i++)
-                    {
-                        Bone bone = it + 1 + i;
-                        DragPoint[bone] = MakeDragPoint(PrimitiveType.Sphere, fingerDragPointSize, transparentBlue2)
-                            .AddComponent<DragJointFinger>()
-                            .Initialize(new Transform[3] {
-                                BoneTransform[bone - 1],
-                                BoneTransform[bone - 1],
-                                BoneTransform[bone]
-                                }, i == 0, meido, () => BoneTransform[bone].position, () => Vector3.zero
-                            );
-                        DragPoint[bone].DragPointVisible = true;
-                    }
-                }
-            };
-
             MakeFingerDragPoint(Bone.Finger0L, Bone.Finger4R, 4);
             MakeFingerDragPoint(Bone.Toe0L, Bone.Toe2R, 3);
         }

+ 70 - 85
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/BaseDrag.cs

@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using static CustomGizmo;
     // TODO: Finalize dragpopint scaling
     public abstract class BaseDrag : MonoBehaviour
     {
@@ -12,6 +13,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         protected const int hand = 2;
         protected const int upperArmRot = 0;
         protected const int handRot = 1;
+        private GameObject gizmoGo;
         protected Maid maid;
         protected Meido meido;
         protected Func<Vector3> position;
@@ -20,32 +22,43 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         protected Collider dragPointCollider;
         protected Vector3 worldPoint;
         protected Vector3 mousePos;
-        protected DragType dragType = DragType.None;
+        private DragType dragType = DragType.None;
+        protected DragType CurrentDragType
+        {
+            get => dragType;
+            set
+            {
+                dragType = value;
+                reInitDrag = dragType != dragTypeOld;
+                dragTypeOld = dragType;
+            }
+        }
         protected DragType dragTypeOld;
-        protected GizmoType gizmoType;
-        protected GizmoType gizmoTypeOld;
         protected float doubleClickStart = 0f;
         protected bool reInitDrag = false;
         protected bool isPlaying;
-        protected GizmoRender gizmo;
-        public Vector3 BaseScale { get; private set; }
-        public Vector3 DragPointScale
+        protected CustomGizmo gizmo;
+        protected GizmoType CurrentGizmoType
         {
-            get => transform.localScale;
+            get => gizmo?.CurrentGizmoType ?? GizmoType.None;
             set
             {
-                transform.localScale = value;
+                if (gizmo != null)
+                {
+                    if (GizmoActive) gizmo.CurrentGizmoType = value;
+                }
             }
         }
-        public bool IsBone { get; set; }
-        public float GizmoScale
+        public Vector3 BaseScale { get; private set; }
+        public Vector3 DragPointScale
         {
-            get => gizmo.offsetScale;
+            get => transform.localScale;
             set
             {
-                if (gizmo != null) gizmo.offsetScale = value;
+                transform.localScale = value;
             }
         }
+        public bool IsBone { get; set; }
         public bool GizmoVisible
         {
             get => gizmo?.Visible ?? false;
@@ -60,8 +73,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             get => gizmoActive;
             set
             {
-                gizmoActive = value;
-                GizmoVisible = gizmoActive;
+                if (gizmoGo != null)
+                {
+                    gizmoActive = value;
+                    gizmoGo.SetActive(gizmoActive);
+                    GizmoVisible = gizmoActive;
+                }
             }
         }
         private bool dragPointVisible;
@@ -84,7 +101,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 dragPointCollider.enabled = dragPointActive;
             }
         }
-        protected static bool IsGizmoDrag => Utility.GetFieldValue<GizmoRender, bool>(null, "is_drag_");
         public event EventHandler DragEvent;
         protected enum DragType
         {
@@ -92,74 +108,60 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             MoveXZ, MoveY, RotLocalXZ, RotY, RotLocalY,
             Scale
         }
-        protected enum GizmoType
+
+        public static Material LightBlue = new Material(Shader.Find("Transparent/Diffuse"))
         {
-            Rotate, Move, Scale, None
-        }
+            color = new Color(0.4f, 0.4f, 1f, 0.3f)
+        };
 
-        public virtual void Initialize(Func<Vector3> position, Func<Vector3> rotation)
+        public static Material Blue = new Material(Shader.Find("Transparent/Diffuse"))
         {
-            this.BaseScale = transform.localScale;
-            this.position = position;
-            this.rotation = rotation;
-            this.dragPointRenderer = GetComponent<Renderer>();
-            this.dragPointCollider = GetComponent<Collider>();
-            this.DragPointVisible = true;
+            color = new Color(0.5f, 0.5f, 1f, 0.8f)
+        };
+
+        public static GameObject MakeDragPoint(PrimitiveType primitiveType, Vector3 scale, Material material)
+        {
+            GameObject dragPoint = GameObject.CreatePrimitive(primitiveType);
+            dragPoint.transform.localScale = scale;
+            dragPoint.GetComponent<Renderer>().material = material;
+            dragPoint.layer = 8;
+            return dragPoint;
         }
 
-        public virtual BaseDrag Initialize(Meido meido, Func<Vector3> position, Func<Vector3> rotation)
+        public BaseDrag Initialize(Meido meido, Func<Vector3> position, Func<Vector3> rotation)
         {
-            this.Initialize(position, rotation);
+            this.InitializeDragPoint(position, rotation);
             this.meido = meido;
             this.maid = meido.Maid;
             isPlaying = !meido.IsStop;
             return this;
         }
 
-        protected void InitializeGizmo(GameObject target, float scale = 0.25f)
+        protected void InitializeDragPoint(Func<Vector3> position, Func<Vector3> rotation)
         {
-            gizmo = target.AddComponent<GizmoRender>();
-            gizmo.eRotate = true;
-            gizmo.offsetScale = scale;
-            gizmo.lineRSelectedThick = 0.25f;
-            GizmoVisible = false;
-        }
-
-        protected void InitializeGizmo(Transform target, float scale = 0.25f)
-        {
-            InitializeGizmo(target.gameObject, scale);
+            this.BaseScale = transform.localScale;
+            this.position = position;
+            this.rotation = rotation;
+            this.dragPointRenderer = GetComponent<Renderer>();
+            this.dragPointCollider = GetComponent<Collider>();
+            this.DragPointVisible = true;
         }
 
-        protected void SetGizmo(GizmoType type)
+        protected void InitializeGizmo(Transform target, float scale = 0.25f, GizmoMode mode = GizmoMode.Local)
         {
-            if (type == GizmoType.Move)
+            gizmoGo = CustomGizmo.MakeGizmo(target, scale, mode);
+            gizmo = gizmoGo.GetComponent<CustomGizmo>();
+            if (meido != null)
             {
-                gizmo.eAxis = true;
-                gizmo.eRotate = false;
-                gizmo.eScal = false;
-                GizmoVisible = true;
-            }
-            else if (type == GizmoType.Rotate)
-            {
-                gizmo.eAxis = false;
-                gizmo.eRotate = true;
-                gizmo.eScal = false;
-                GizmoVisible = true;
-            }
-            else if (type == GizmoType.Scale)
-            {
-                gizmo.eAxis = false;
-                gizmo.eRotate = false;
-                gizmo.eScal = true;
-                GizmoVisible = true;
-            }
-            else if (type == GizmoType.None)
-            {
-                gizmo.eAxis = false;
-                gizmo.eRotate = false;
-                gizmo.eScal = false;
-                GizmoVisible = false;
+                gizmo.GizmoDrag += (s, a) =>
+                {
+                    meido.IsStop = true;
+                    isPlaying = false;
+                };
             }
+
+            GizmoActive = false;
+            GizmoVisible = false;
         }
 
         public void SetDragProp(bool gizmoActive, bool dragPointActive, bool dragPointVisible)
@@ -197,35 +199,18 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             GetDragType();
 
-            reInitDrag = dragType != dragTypeOld;
-
-            dragTypeOld = dragType;
-
             transform.position = position();
             transform.eulerAngles = rotation();
-
-            if (GizmoActive)
-            {
-                if (meido != null && IsGizmoDrag)
-                {
-                    meido.IsStop = true;
-                    isPlaying = false;
-                }
-
-                if (gizmoType != gizmoTypeOld) SetGizmo(gizmoType);
-
-                gizmoTypeOld = gizmoType;
-            }
         }
 
-        private void OnMouseDown()
+        protected virtual void OnMouseDown()
         {
             InitializeDrag();
         }
 
-        private void OnMouseDrag()
+        protected virtual void OnMouseDrag()
         {
-            if (dragType == DragType.Select) return;
+            if (CurrentDragType == DragType.Select) return;
 
             if (reInitDrag)
             {

+ 15 - 15
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragBody.cs

@@ -19,29 +19,29 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             bool holdShift = Utility.GetModKey(Utility.ModKey.Shift);
             if (Input.GetKey(KeyCode.A))
             {
-                dragType = DragType.Select;
+                CurrentDragType = DragType.Select;
             }
             else if (Input.GetKey(KeyCode.Z))
             {
-                if (Utility.GetModKey(Utility.ModKey.Control)) dragType = DragType.MoveY;
-                else dragType = holdShift ? DragType.RotY : DragType.MoveXZ;
+                if (Utility.GetModKey(Utility.ModKey.Control)) CurrentDragType = DragType.MoveY;
+                else CurrentDragType = holdShift ? DragType.RotY : DragType.MoveXZ;
             }
             else if (Input.GetKey(KeyCode.X))
             {
-                dragType = holdShift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = holdShift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else if (Input.GetKey(KeyCode.C))
             {
-                dragType = DragType.Scale;
+                CurrentDragType = DragType.Scale;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
         protected override void InitializeDrag()
         {
-            if (dragType == DragType.Select)
+            if (CurrentDragType == DragType.Select)
             {
                 Select?.Invoke(this, EventArgs.Empty);
                 return;
@@ -63,13 +63,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void DoubleClick()
         {
-            if (dragType == DragType.Scale)
+            if (CurrentDragType == DragType.Scale)
             {
                 maid.transform.localScale = new Vector3(1f, 1f, 1f);
                 Scale?.Invoke(this, EventArgs.Empty);
             }
 
-            if (dragType == DragType.RotLocalY || dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalY || CurrentDragType == DragType.RotLocalXZ)
                 maid.transform.eulerAngles = new Vector3(0f, maid.transform.eulerAngles.y, 0f);
         }
 
@@ -89,17 +89,17 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)
             ) + off - off2;
 
-            if (dragType == DragType.MoveXZ)
+            if (CurrentDragType == DragType.MoveXZ)
             {
                 maid.transform.position = new Vector3(pos.x, maid.transform.position.y, pos.z);
             }
 
-            if (dragType == DragType.MoveY)
+            if (CurrentDragType == DragType.MoveY)
             {
                 maid.transform.position = new Vector3(maid.transform.position.x, pos.y, maid.transform.position.z);
             }
 
-            if (dragType == DragType.RotY)
+            if (CurrentDragType == DragType.RotY)
             {
                 Vector3 posOther = Input.mousePosition - mousePos;
                 maid.transform.eulerAngles = new Vector3(
@@ -108,7 +108,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             }
 
-            if (dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalXZ)
             {
                 Vector3 posOther = Input.mousePosition - mousePos;
                 Transform transform = Camera.main.transform;
@@ -132,7 +132,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 mousePos2 = Input.mousePosition;
             }
 
-            if (dragType == DragType.RotLocalY)
+            if (CurrentDragType == DragType.RotLocalY)
             {
                 Vector3 posOther = Input.mousePosition - mousePos;
                 Transform transform = Camera.main.transform;
@@ -148,7 +148,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 mousePos2 = Input.mousePosition;
             }
 
-            if (dragType == DragType.Scale)
+            if (CurrentDragType == DragType.Scale)
             {
                 scaling = true;
                 Vector3 posOther = Input.mousePosition - mousePos;

+ 13 - 13
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragHead.cs

@@ -33,30 +33,30 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             if (Utility.GetModKey(Utility.ModKey.Alt) && Utility.GetModKey(Utility.ModKey.Control))
             {
                 // eyes
-                dragType = Utility.GetModKey(Utility.ModKey.Shift) ? DragType.MoveY : DragType.MoveXZ;
+                CurrentDragType = Utility.GetModKey(Utility.ModKey.Shift) ? DragType.MoveY : DragType.MoveXZ;
             }
             else if (Utility.GetModKey(Utility.ModKey.Alt))
             {
                 // head
-                dragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else if (Input.GetKey(KeyCode.A))
             {
-                dragType = DragType.Select;
+                CurrentDragType = DragType.Select;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
         protected override void DoubleClick()
         {
-            if (dragType == DragType.MoveXZ || dragType == DragType.MoveY)
+            if (CurrentDragType == DragType.MoveXZ || CurrentDragType == DragType.MoveY)
             {
                 maid.body0.quaDefEyeL.eulerAngles = defEyeRotL;
                 maid.body0.quaDefEyeR.eulerAngles = defEyeRotR;
             }
-            if (dragType == DragType.RotLocalY || dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalY || CurrentDragType == DragType.RotLocalXZ)
             {
                 meido.IsFreeLook = !meido.IsFreeLook;
             }
@@ -64,7 +64,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void InitializeDrag()
         {
-            if (dragType == DragType.Select)
+            if (CurrentDragType == DragType.Select)
             {
                 Select?.Invoke(this, EventArgs.Empty);
                 return;
@@ -83,9 +83,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void Drag()
         {
-            if ((dragType == DragType.None || dragType == DragType.Select) || IsBone) return;
+            if ((CurrentDragType == DragType.None || CurrentDragType == DragType.Select) || IsBone) return;
 
-            if (!(dragType == DragType.MoveXZ || dragType == DragType.MoveY))
+            if (!(CurrentDragType == DragType.MoveXZ || CurrentDragType == DragType.MoveY))
             {
                 if (isPlaying) meido.IsStop = true;
             }
@@ -96,23 +96,23 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Vector3 vec32 = t.TransformDirection(Vector3.right);
             Vector3 vec33 = t.TransformDirection(Vector3.forward);
 
-            if (dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalXZ)
             {
                 head.localEulerAngles = rotate;
                 head.RotateAround(head.position, new Vector3(vec32.x, 0.0f, vec32.z), vec31.y / 3f);
                 head.RotateAround(head.position, new Vector3(vec33.x, 0.0f, vec33.z), (-vec31.x / 4.5f));
             }
 
-            if (dragType == DragType.RotLocalY)
+            if (CurrentDragType == DragType.RotLocalY)
             {
                 head.localEulerAngles = rotate;
                 head.localRotation = Quaternion.Euler(head.localEulerAngles)
                     * Quaternion.AngleAxis(vec31.x / 3f, Vector3.right);
             }
 
-            if (dragType == DragType.MoveXZ || dragType == DragType.MoveY)
+            if (CurrentDragType == DragType.MoveXZ || CurrentDragType == DragType.MoveY)
             {
-                int inv = dragType == DragType.MoveY ? -1 : 1;
+                int inv = CurrentDragType == DragType.MoveY ? -1 : 1;
                 Vector3 vec34 = new Vector3(eyeRotR.x, eyeRotR.y + vec31.x / 10f, eyeRotR.z + vec31.y / 10f);
 
                 mousePosOther.y = vec31.y;

+ 4 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragJointFinger.cs

@@ -43,11 +43,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (Utility.GetModKey(Utility.ModKey.Shift))
             {
-                dragType = DragType.RotLocalY;
+                CurrentDragType = DragType.RotLocalY;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
 
@@ -79,7 +79,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)
             ) + off - off2;
 
-            if (dragType == DragType.None)
+            if (CurrentDragType == DragType.None)
             {
                 IK.Porc(ikChain[upperArm], ikChain[foreArm], ikChain[hand], pos, Vector3.zero, ikData);
 
@@ -102,7 +102,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             else
             {
-                if (dragType == DragType.RotLocalY)
+                if (CurrentDragType == DragType.RotLocalY)
                 {
                     Vector3 vec31 = Input.mousePosition - mousePos;
                     ikChain[upperArm].localEulerAngles = jointRotation[upperArmRot];

+ 4 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragJointForearm.cs

@@ -44,11 +44,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (knee && Utility.GetModKey(Utility.ModKey.Shift) && Utility.GetModKey(Utility.ModKey.Alt))
             {
-                dragType = DragType.RotLocalY;
+                CurrentDragType = DragType.RotLocalY;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
 
@@ -77,7 +77,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             IKCtrlData ikData = maid.body0.IKCtrl.GetIKData("左手");
             Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)) + off - off2;
 
-            if (dragType == DragType.None)
+            if (CurrentDragType == DragType.None)
             {
                 IK.Porc(ikChain[upperArm], ikChain[foreArm], ikChain[hand], pos, Vector3.zero, ikData);
 
@@ -90,7 +90,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 Vector3 vec31 = Input.mousePosition - mousePos;
 
-                if (dragType == DragType.RotLocalY)
+                if (CurrentDragType == DragType.RotLocalY)
                 {
                     ikChain[upperArm].localEulerAngles = jointRotation[upperArmRot];
                     ikChain[upperArm].localRotation = Quaternion.Euler(ikChain[upperArm].localEulerAngles)

+ 9 - 9
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragJointHand.cs

@@ -52,19 +52,19 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (Utility.GetModKey(Utility.ModKey.Shift) && Utility.GetModKey(Utility.ModKey.Alt))
             {
-                dragType = DragType.RotLocalY;
+                CurrentDragType = DragType.RotLocalY;
             }
             else if (Utility.GetModKey(Utility.ModKey.Alt))
             {
-                dragType = DragType.RotLocalXZ;
+                CurrentDragType = DragType.RotLocalXZ;
             }
             else if (Utility.GetModKey(Utility.ModKey.Control))
             {
-                dragType = DragType.MoveXZ;
+                CurrentDragType = DragType.MoveXZ;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
 
@@ -72,7 +72,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             base.InitializeDrag();
 
-            Transform[] ikChain = dragType == DragType.MoveXZ ? this.ikChainLock : this.ikChain;
+            Transform[] ikChain = CurrentDragType == DragType.MoveXZ ? this.ikChainLock : this.ikChain;
 
             IKCtrlData ikData = maid.body0.IKCtrl.GetIKData("左手");
             off = transform.position - Camera.main.ScreenToWorldPoint(
@@ -97,9 +97,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)
             ) + off - off2;
 
-            if (dragType == DragType.None || dragType == DragType.MoveXZ)
+            if (CurrentDragType == DragType.None || CurrentDragType == DragType.MoveXZ)
             {
-                Transform[] ikChain = dragType == DragType.MoveXZ ? this.ikChainLock : this.ikChain;
+                Transform[] ikChain = CurrentDragType == DragType.MoveXZ ? this.ikChainLock : this.ikChain;
 
                 IK.Porc(ikChain[upperArm], ikChain[foreArm], ikChain[hand], pos, Vector3.zero, ikData);
 
@@ -112,14 +112,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 Vector3 vec31 = Input.mousePosition - mousePos;
 
-                if (dragType == DragType.RotLocalY)
+                if (CurrentDragType == DragType.RotLocalY)
                 {
                     ikChain[hand].localEulerAngles = jointRotation[handRot];
                     ikChain[hand].localRotation = Quaternion.Euler(ikChain[hand].localEulerAngles)
                         * Quaternion.AngleAxis(vec31.x / 1.5f, Vector3.right);
                 }
 
-                if (dragType == DragType.RotLocalXZ)
+                if (CurrentDragType == DragType.RotLocalXZ)
                 {
                     ikChain[hand].localEulerAngles = jointRotation[handRot];
                     ikChain[hand].localRotation = Quaternion.Euler(ikChain[hand].localEulerAngles)

+ 5 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragMune.cs

@@ -37,17 +37,17 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftAlt))
             {
-                dragType = DragType.RotLocalXZ;
+                CurrentDragType = DragType.RotLocalXZ;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
 
         protected override void DoubleClick()
         {
-            if (dragType == DragType.RotLocalXZ) meido.SetMune();
+            if (CurrentDragType == DragType.RotLocalXZ) meido.SetMune();
         }
 
         protected override void InitializeDrag()
@@ -69,7 +69,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void Drag()
         {
-            if (dragType == DragType.None) return;
+            if (CurrentDragType == DragType.None) return;
 
             if (isPlaying) meido.IsStop = true;
             IKCtrlData ikData = maid.body0.IKCtrl.GetIKData("左手");
@@ -77,7 +77,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)
             ) + off - off2;
 
-            if (dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalXZ)
             {
                 IK.Porc(ikChain[upperArm], ikChain[foreArm], ikChain[hand], pos, Vector3.zero, ikData);
 

+ 5 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPelvis.cs

@@ -20,11 +20,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             bool shift = Input.GetKey(KeyCode.LeftShift);
             if (Input.GetKey(KeyCode.LeftAlt))
             {
-                dragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
 
@@ -36,7 +36,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void Drag()
         {
-            if (dragType == DragType.None) return;
+            if (CurrentDragType == DragType.None) return;
 
             if (isPlaying) meido.IsStop = true;
 
@@ -46,14 +46,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Vector3 vec32 = t.TransformDirection(Vector3.right);
             Vector3 vec33 = t.TransformDirection(Vector3.forward);
 
-            if (dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalXZ)
             {
                 pelvis.localEulerAngles = pelvisRotation;
                 pelvis.RotateAround(pelvis.position, new Vector3(vec32.x, 0.0f, vec32.z), vec31.y / 4f);
                 pelvis.RotateAround(pelvis.position, new Vector3(vec33.x, 0.0f, vec33.z), vec31.x / 6f);
             }
 
-            if (dragType == DragType.RotLocalY)
+            if (CurrentDragType == DragType.RotLocalY)
             {
                 pelvis.localEulerAngles = pelvisRotation;
                 pelvis.localRotation = Quaternion.Euler(pelvis.localEulerAngles)

+ 11 - 8
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragSpine.cs

@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using static CustomGizmo;
     public class DragSpine : BaseDrag
     {
         private Transform spine;
@@ -28,13 +29,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (isHip && Utility.GetModKey(Utility.ModKey.Control))
             {
-                dragType = DragType.MoveY;
-                if (GizmoActive) SetGizmo(GizmoType.Rotate);
+                CurrentDragType = DragType.MoveY;
             }
             else
             {
-                dragType = DragType.None;
-                if (GizmoActive) SetGizmo(GizmoType.Rotate);
+                CurrentDragType = DragType.None;
             }
         }
 
@@ -45,7 +44,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             if (isHip)
             {
-                off = transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z));
+                off = transform.position - Camera.main.ScreenToWorldPoint(
+                    new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)
+                );
                 off2 = new Vector3(
                     transform.position.x - spine.position.x,
                     transform.position.y - spine.position.y,
@@ -58,7 +59,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (isPlaying) meido.IsStop = true;
 
-            if (dragType == DragType.None)
+            if (CurrentDragType == DragType.None)
             {
                 Vector3 vec31 = Input.mousePosition - mousePos;
                 Transform t = GameMain.Instance.MainCamera.gameObject.transform;
@@ -70,9 +71,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 spine.RotateAround(spine.position, new Vector3(vec33.x, 0.0f, vec33.z), (-vec31.x / 4.5f));
             }
 
-            if (dragType == DragType.MoveY)
+            if (CurrentDragType == DragType.MoveY)
             {
-                Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)) + off - off2;
+                Vector3 pos = Camera.main.ScreenToWorldPoint(
+                    new Vector3(Input.mousePosition.x, Input.mousePosition.y, worldPoint.z)
+                ) + off - off2;
                 spine.position = new Vector3(spine.position.x, pos.y, spine.position.z);
             }
         }

+ 5 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragTorso.cs

@@ -20,11 +20,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             bool shift = Input.GetKey(KeyCode.LeftShift);
             if (Input.GetKey(KeyCode.LeftAlt))
             {
-                dragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
+                CurrentDragType = shift ? DragType.RotLocalY : DragType.RotLocalXZ;
             }
             else
             {
-                dragType = DragType.None;
+                CurrentDragType = DragType.None;
             }
         }
 
@@ -40,7 +40,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void Drag()
         {
-            if (dragType == DragType.None) return;
+            if (CurrentDragType == DragType.None) return;
 
             if (isPlaying) meido.IsStop = true;
 
@@ -50,7 +50,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Vector3 vec32 = t.TransformDirection(Vector3.right);
             Vector3 vec33 = t.TransformDirection(Vector3.forward);
 
-            if (dragType == DragType.RotLocalXZ)
+            if (CurrentDragType == DragType.RotLocalXZ)
             {
                 for (int i = 0; i < 4; i++)
                 {
@@ -73,7 +73,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 spine[3].RotateAround(spine[3].position, new Vector3(vec33.x, 0f, vec33.z), -vec31.x / num1 * num6);
             }
 
-            if (dragType == DragType.RotLocalY)
+            if (CurrentDragType == DragType.RotLocalY)
             {
                 for (int i = 0; i < 4; i++)
                 {