Пример #1
0
        public void NormalizeBodyAnchorList()
        {
            if (BodyAnchorList.Count <= 0)
            {
                return;
            }
            List <int> list = new List <int>(BodyAnchorList.Count);
            Dictionary <string, int> dictionary = new Dictionary <string, int>(BodyAnchorList.Count);

            for (int i = 0; i < BodyAnchorList.Count; i++)
            {
                BodyAnchor bodyAnchor = BodyAnchorList[i];
                string     key        = bodyAnchor.Body + "_" + bodyAnchor.Vertex;
                if (!dictionary.ContainsKey(key))
                {
                    dictionary.Add(key, i);
                }
                else
                {
                    list.Add(i);
                }
            }
            if (list.Count > 0)
            {
                int[] array = CP.SortIndexForRemove(list.ToArray());
                for (int j = 0; j < array.Length; j++)
                {
                    BodyAnchorList.RemoveAt(array[j]);
                }
            }
        }
Пример #2
0
        public void FromStreamEx(Stream s, PmxElementFormat f = null)
        {
            Name     = PmxStreamHelper.ReadString(s, f);
            NameE    = PmxStreamHelper.ReadString(s, f);
            Shape    = (ShapeKind)PmxStreamHelper.ReadElement_Int32(s, 1);
            Material = PmxStreamHelper.ReadElement_Int32(s, f.MaterialSize);
            Group    = PmxStreamHelper.ReadElement_Int32(s, 1);
            ushort bits = (ushort)PmxStreamHelper.ReadElement_Int32(s, 2, signed: false);

            PassGroup.FromFlagBits(bits);
            Flags = (SoftBodyFlags)PmxStreamHelper.ReadElement_Int32(s, 1);
            BendingLinkDistance = PmxStreamHelper.ReadElement_Int32(s);
            ClusterCount        = PmxStreamHelper.ReadElement_Int32(s);
            TotalMass           = PmxStreamHelper.ReadElement_Float(s);
            Margin             = PmxStreamHelper.ReadElement_Float(s);
            Config.AeroModel   = PmxStreamHelper.ReadElement_Int32(s);
            Config.VCF         = PmxStreamHelper.ReadElement_Float(s);
            Config.DP          = PmxStreamHelper.ReadElement_Float(s);
            Config.DG          = PmxStreamHelper.ReadElement_Float(s);
            Config.LF          = PmxStreamHelper.ReadElement_Float(s);
            Config.PR          = PmxStreamHelper.ReadElement_Float(s);
            Config.VC          = PmxStreamHelper.ReadElement_Float(s);
            Config.DF          = PmxStreamHelper.ReadElement_Float(s);
            Config.MT          = PmxStreamHelper.ReadElement_Float(s);
            Config.CHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.KHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.SHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.AHR         = PmxStreamHelper.ReadElement_Float(s);
            Config.SRHR_CL     = PmxStreamHelper.ReadElement_Float(s);
            Config.SKHR_CL     = PmxStreamHelper.ReadElement_Float(s);
            Config.SSHR_CL     = PmxStreamHelper.ReadElement_Float(s);
            Config.SR_SPLT_CL  = PmxStreamHelper.ReadElement_Float(s);
            Config.SK_SPLT_CL  = PmxStreamHelper.ReadElement_Float(s);
            Config.SS_SPLT_CL  = PmxStreamHelper.ReadElement_Float(s);
            Config.V_IT        = PmxStreamHelper.ReadElement_Int32(s);
            Config.P_IT        = PmxStreamHelper.ReadElement_Int32(s);
            Config.D_IT        = PmxStreamHelper.ReadElement_Int32(s);
            Config.C_IT        = PmxStreamHelper.ReadElement_Int32(s);
            MaterialConfig.LST = PmxStreamHelper.ReadElement_Float(s);
            MaterialConfig.AST = PmxStreamHelper.ReadElement_Float(s);
            MaterialConfig.VST = PmxStreamHelper.ReadElement_Float(s);
            int num = PmxStreamHelper.ReadElement_Int32(s);

            BodyAnchorList.Clear();
            BodyAnchorList.Capacity = num;
            for (int i = 0; i < num; i++)
            {
                int body   = PmxStreamHelper.ReadElement_Int32(s, f.BodySize);
                int vertex = PmxStreamHelper.ReadElement_Int32(s, f.VertexSize);
                int num2   = PmxStreamHelper.ReadElement_Int32(s, 1);
                BodyAnchorList.Add(new BodyAnchor
                {
                    Body   = body,
                    Vertex = vertex,
                    IsNear = (num2 != 0)
                });
            }
            num = PmxStreamHelper.ReadElement_Int32(s);
            VertexPinList.Clear();
            VertexPinList.Capacity = num;
            for (int j = 0; j < num; j++)
            {
                int vertex2 = PmxStreamHelper.ReadElement_Int32(s, f.VertexSize);
                VertexPinList.Add(new VertexPin
                {
                    Vertex = vertex2
                });
            }
            NormalizeBodyAnchorList();
            NormalizeVertexPinList();
            if (f.WithID)
            {
                base.UID = PmxStreamHelper.ReadElement_UInt(s);
                base.CID = PmxStreamHelper.ReadElement_UInt(s);
            }
        }