Browse Source

Cache IKCtrlData

Noticed that there are IKCtrlData other than "左手." Regardless, it
seems like it doesn't matter which IKCtrlData is used.

Need to look into it some more though.
habeebweeb 4 years ago
parent
commit
0b5c48e9c8

+ 2 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPointMeido.cs

@@ -11,6 +11,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         protected const int jointLower = 2;
         protected const int jointLower = 2;
         protected Meido meido;
         protected Meido meido;
         protected Maid maid;
         protected Maid maid;
+        protected IKCtrlData IkCtrlData => meido.Body.IKCtrl.GetIKData("左手");
         protected bool isPlaying;
         protected bool isPlaying;
         private bool isBone;
         private bool isBone;
         public bool IsBone
         public bool IsBone
@@ -55,9 +56,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             iKCmo.Init(upper, middle, lower, maid.body0);
             iKCmo.Init(upper, middle, lower, maid.body0);
         }
         }
 
 
-        protected void Porc(TBody.IKCMO ikCmo, Transform upper, Transform middle, Transform lower)
+        protected void Porc(TBody.IKCMO ikCmo, IKCtrlData ikData, Transform upper, Transform middle, Transform lower)
         {
         {
-            IKCtrlData ikData = maid.body0.IKCtrl.GetIKData("左手");
             ikCmo.Porc(upper, middle, lower, CursorPosition(), Vector3.zero, ikData);
             ikCmo.Porc(upper, middle, lower, CursorPosition(), Vector3.zero, ikData);
         }
         }
     }
     }

+ 4 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointChain.cs

@@ -7,6 +7,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     {
     {
         private readonly TBody.IKCMO IK = new TBody.IKCMO();
         private readonly TBody.IKCMO IK = new TBody.IKCMO();
         private readonly Quaternion[] jointRotation = new Quaternion[3];
         private readonly Quaternion[] jointRotation = new Quaternion[3];
+        private IKCtrlData ikCtrlData;
         private Transform[] ikChain;
         private Transform[] ikChain;
         private int foot = 1;
         private int foot = 1;
         private bool isLower;
         private bool isLower;
@@ -28,6 +29,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 myObject
                 myObject
             };
             };
             if (isLower) ikChain[0] = ikChain[0].parent;
             if (isLower) ikChain[0] = ikChain[0].parent;
+
+            ikCtrlData = IkCtrlData;
         }
         }
 
 
         private void InitializeRotation()
         private void InitializeRotation()
@@ -115,7 +118,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
             {
                 int upperJoint = altRotation ? jointMiddle : jointUpper;
                 int upperJoint = altRotation ? jointMiddle : jointUpper;
 
 
-                Porc(IK, ikChain[upperJoint], ikChain[jointMiddle], ikChain[jointLower]);
+                Porc(IK, ikCtrlData, ikChain[upperJoint], ikChain[jointMiddle], ikChain[jointLower]);
 
 
                 InitializeRotation();
                 InitializeRotation();
             }
             }

+ 4 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragPointFinger.cs

@@ -5,11 +5,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     using Input = InputManager;
     using Input = InputManager;
     internal class DragPointFinger : DragPointMeido
     internal class DragPointFinger : DragPointMeido
     {
     {
+        private static readonly Color dragpointColour = new Color(0.1f, 0.4f, 0.95f, defaultAlpha);
         private readonly TBody.IKCMO IK = new TBody.IKCMO();
         private readonly TBody.IKCMO IK = new TBody.IKCMO();
         private readonly Quaternion[] jointRotation = new Quaternion[2];
         private readonly Quaternion[] jointRotation = new Quaternion[2];
+        private IKCtrlData ikCtrlData;
         private Transform[] ikChain;
         private Transform[] ikChain;
         private bool baseFinger;
         private bool baseFinger;
-        private static readonly Color dragpointColour = new Color(0.1f, 0.4f, 0.95f, defaultAlpha);
 
 
         public override void Set(Transform myObject)
         public override void Set(Transform myObject)
         {
         {
@@ -21,6 +22,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 myObject.parent,
                 myObject.parent,
                 myObject
                 myObject
             };
             };
+            ikCtrlData = IkCtrlData;
         }
         }
 
 
         private void SetRotation(int joint)
         private void SetRotation(int joint)
@@ -61,7 +63,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
 
             if (CurrentDragType == DragType.MoveXZ)
             if (CurrentDragType == DragType.MoveXZ)
             {
             {
-                Porc(IK, ikChain[jointUpper], ikChain[jointUpper], ikChain[jointMiddle]);
+                Porc(IK, ikCtrlData, ikChain[jointUpper], ikChain[jointUpper], ikChain[jointMiddle]);
                 if (!baseFinger)
                 if (!baseFinger)
                 {
                 {
                     SetRotation(jointUpper);
                     SetRotation(jointUpper);