示例#1
0
        /// <summary>
        /// メッシュデータの指定インデクスの選択情報を取得する
        /// </summary>
        /// <param name="meshData"></param>
        /// <param name="vindex"></param>
        /// <returns></returns>
        private int GetSelection(MeshData meshData, int vindex, Dictionary <int, List <uint> > dict, List <MeshData> childMeshDataList, List <Dictionary <ulong, int> > hashList)
        {
            int data = Invalid;

            // セレクションデータ読み込み
            if (meshData != null && meshData.ChildCount > 0)
            {
                // 親頂点に影響する子頂点情報から取得
                if (dict.ContainsKey(vindex))
                {
                    foreach (var pack in dict[vindex])
                    {
                        int cmindex = DataUtility.Unpack16Hi(pack);
                        int cvindex = DataUtility.Unpack16Low(pack);

                        if (cmindex < selectionList.Count && cvindex < selectionList[cmindex].selectData.Count)
                        {
                            // 頂点ハッシュがある場合はハッシュからインデックスを取得する
                            // 現在メッシュの頂点ハッシュ
                            ulong vhash = 0;
                            if (childMeshDataList != null && cmindex < childMeshDataList.Count)
                            {
                                var cmdata = childMeshDataList[cmindex];
                                if (cmdata != null && cvindex < cmdata.VertexHashCount)
                                {
                                    vhash = cmdata.vertexHashList[cvindex];
                                }
                            }

                            // セレクションデータに頂点ハッシュが記録されているならば照合する
                            if (vhash != 0 && cmindex < hashList.Count)
                            {
                                if (hashList[cmindex].ContainsKey(vhash))
                                {
                                    // ハッシュ値に紐づく頂点ペイントデータに入れ替える
                                    cvindex = hashList[cmindex][vhash];
                                }
                            }

                            data = Mathf.Max(selectionList[cmindex].selectData[cvindex], data);
                        }
                    }
                }
            }
            else
            {
                // そのまま
                int dindex = 0;
                if (dindex < selectionList.Count)
                {
                    if (vindex < selectionList[dindex].selectData.Count)
                    {
                        data = selectionList[dindex].selectData[vindex];
                    }
                }
            }

            return(data);
        }
示例#2
0
        /// <summary>
        /// メッシュ頂点の選択データを設定する
        /// </summary>
        /// <param name="meshData"></param>
        /// <param name="selects"></param>
        public void SetSelectionData(MeshData meshData, List <int> selects, List <MeshData> childMeshDataList)
        {
            // 選択データ初期化
            selectionList.Clear();
            if (meshData != null && meshData.ChildCount > 0)
            {
                for (int i = 0; i < meshData.ChildCount; i++)
                {
                    var dsel  = new DeformerSelection();
                    int cvcnt = meshData.childDataList[i].VertexCount;
                    for (int j = 0; j < cvcnt; j++)
                    {
                        dsel.selectData.Add(Invalid);
                        dsel.vertexHashList.Add(0); // ハッシュ0=無効
                    }

                    selectionList.Add(dsel);
                }
            }
            else
            {
                // そのまま
                var dsel  = new DeformerSelection();
                int cvcnt = selects.Count;
                for (int j = 0; j < cvcnt; j++)
                {
                    dsel.selectData.Add(Invalid);
                    dsel.vertexHashList.Add(0); // ハッシュ0=無効
                }

                selectionList.Add(dsel);
            }

            // 選択データに追加
            for (int i = 0; i < selects.Count; i++)
            {
                int data = selects[i];
                if (meshData != null && meshData.ChildCount > 0)
                {
                    // 親頂点に影響する子頂点情報
                    Dictionary <int, List <uint> > dict = meshData.GetVirtualToChildVertexDict();

                    // 親頂点に影響する子頂点に記録
                    if (dict.ContainsKey(i))
                    {
                        foreach (var pack in dict[i])
                        {
                            int cmindex = DataUtility.Unpack16Hi(pack);
                            int cvindex = DataUtility.Unpack16Low(pack);

                            selectionList[cmindex].selectData[cvindex] = data;

                            // 頂点ハッシュも記録
                            if (cmindex < childMeshDataList.Count)
                            {
                                var cmdata = childMeshDataList[cmindex];
                                if (cmdata != null && cvindex < cmdata.VertexHashCount)
                                {
                                    selectionList[cmindex].vertexHashList[cvindex] = cmdata.vertexHashList[cvindex];
                                }
                            }
                        }
                    }
                }
                else
                {
                    // そのまま
                    selectionList[0].selectData[i] = data;
                }
            }

            // データハッシュ設定
            CreateVerifyData();
        }