public bool NormalizeSDEF_C0(List <PmxBone> boneList)
        {
            if (Deform != DeformType.SDEF)
            {
                return(true);
            }
            int     bone     = Weight[0].Bone;
            int     bone2    = Weight[1].Bone;
            PmxBone pmxBone  = null;
            PmxBone pmxBone2 = null;

            if (CP.InRange(boneList, bone))
            {
                pmxBone = boneList[bone];
                if (CP.InRange(boneList, bone2))
                {
                    pmxBone2 = boneList[bone2];
                    Vector3 position = pmxBone.Position;
                    Vector3 vector   = pmxBone2.Position - position;
                    vector.Normalize();
                    Vector3 position2 = Position;
                    position2 -= position;
                    float scale = Vector3.Dot(vector, position2);
                    C0 = vector * scale + position;
                    return(true);
                }
                return(false);
            }
            return(false);
        }
        // Token: 0x0600027E RID: 638 RVA: 0x00013C64 File Offset: 0x00011E64
        public bool IsSDEF_EnableBone(List <PmxBone> boneList)
        {
            int  bone  = this.Weight[0].Bone;
            int  bone2 = this.Weight[1].Bone;
            bool flag  = !CP.InRange <PmxBone>(boneList, bone);
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                PmxBone pmxBone = boneList[bone];
                bool    flag2   = CP.InRange <PmxBone>(boneList, bone2);
                if (flag2)
                {
                    PmxBone pmxBone2 = boneList[bone2];
                    result = (pmxBone.Parent == bone2 || pmxBone2.Parent == bone);
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Esempio n. 3
0
 public static void UpdateBoneIKKind(List <PmxBone> boneList)
 {
     for (int i = 0; i < boneList.Count; i++)
     {
         boneList[i].IKKind = PmxBone.IKKindType.None;
     }
     for (int j = 0; j < boneList.Count; j++)
     {
         PmxBone pmxBone = boneList[j];
         if (!pmxBone.GetFlag(PmxBone.BoneFlags.IK))
         {
             continue;
         }
         pmxBone.IKKind = PmxBone.IKKindType.IK;
         int target = pmxBone.IK.Target;
         if (CP.InRange(boneList, target))
         {
             boneList[target].IKKind = PmxBone.IKKindType.Target;
         }
         for (int k = 0; k < pmxBone.IK.LinkList.Count; k++)
         {
             int bone = pmxBone.IK.LinkList[k].Bone;
             if (CP.InRange(boneList, bone))
             {
                 boneList[bone].IKKind = PmxBone.IKKindType.Link;
             }
         }
     }
 }
Esempio n. 4
0
 // Token: 0x060000B6 RID: 182 RVA: 0x0000D528 File Offset: 0x0000B728
 public static void UpdateBoneIKKind(List <PmxBone> boneList)
 {
     for (int i = 0; i < boneList.Count; i++)
     {
         PmxBone pmxBone = boneList[i];
         pmxBone.IKKind = PmxBone.IKKindType.None;
     }
     for (int j = 0; j < boneList.Count; j++)
     {
         PmxBone pmxBone2 = boneList[j];
         bool    flag     = pmxBone2.GetFlag(PmxBone.BoneFlags.IK);
         if (flag)
         {
             pmxBone2.IKKind = PmxBone.IKKindType.IK;
             int  target = pmxBone2.IK.Target;
             bool flag2  = CP.InRange <PmxBone>(boneList, target);
             if (flag2)
             {
                 boneList[target].IKKind = PmxBone.IKKindType.Target;
             }
             for (int k = 0; k < pmxBone2.IK.LinkList.Count; k++)
             {
                 int  bone  = pmxBone2.IK.LinkList[k].Bone;
                 bool flag3 = CP.InRange <PmxBone>(boneList, bone);
                 if (flag3)
                 {
                     boneList[bone].IKKind = PmxBone.IKKindType.Link;
                 }
             }
         }
     }
 }
Esempio n. 5
0
        // Token: 0x06000066 RID: 102 RVA: 0x0000BC48 File Offset: 0x00009E48
        public static T SafeGetV <T>(IList <T> arr, int index) where T : struct
        {
            bool flag = arr != null && CP.InRange <T>(arr, index);
            T    result;

            if (flag)
            {
                result = arr[index];
            }
            else
            {
                result = default(T);
            }
            return(result);
        }
Esempio n. 6
0
        // Token: 0x06000062 RID: 98 RVA: 0x0000BB54 File Offset: 0x00009D54
        public static T SafeGet <T>(T[] arr, int index) where T : class
        {
            bool flag = arr != null && CP.InRange <T>(arr, index);
            T    result;

            if (flag)
            {
                result = arr[index];
            }
            else
            {
                result = default(T);
            }
            return(result);
        }
Esempio n. 7
0
        // Token: 0x06000065 RID: 101 RVA: 0x0000BC08 File Offset: 0x00009E08
        public static T SafeGetV <T>(T[] arr, int index, out bool flag) where T : struct
        {
            flag = false;
            bool flag2 = arr != null && CP.InRange <T>(arr, index);
            T    result;

            if (flag2)
            {
                flag   = true;
                result = arr[index];
            }
            else
            {
                result = default(T);
            }
            return(result);
        }
        // Token: 0x0600027D RID: 637 RVA: 0x00013B6C File Offset: 0x00011D6C
        public bool NormalizeSDEF_C0(List <PmxBone> boneList)
        {
            bool flag = this.Deform != PmxVertex.DeformType.SDEF;
            bool result;

            if (flag)
            {
                result = true;
            }
            else
            {
                int  bone  = this.Weight[0].Bone;
                int  bone2 = this.Weight[1].Bone;
                bool flag2 = !CP.InRange <PmxBone>(boneList, bone);
                if (flag2)
                {
                    result = false;
                }
                else
                {
                    PmxBone pmxBone = boneList[bone];
                    bool    flag3   = CP.InRange <PmxBone>(boneList, bone2);
                    if (flag3)
                    {
                        PmxBone pmxBone2  = boneList[bone2];
                        Vector3 position  = pmxBone.Position;
                        Vector3 position2 = pmxBone2.Position;
                        Vector3 vector    = position2 - position;
                        Vector3 vector2   = vector;
                        vector2.Normalize();
                        Vector3 vector3 = this.Position;
                        vector3 -= position;
                        float d = Vector3.Dot(vector2, vector3);
                        this.C0 = vector2 * d + position;
                        result  = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            return(result);
        }