/// <summary> /// メッシュデータの各頂点の選択情報を取得する /// </summary> /// <param name="meshData"></param> /// <returns></returns> public List <int> GetSelectionData(MeshData meshData, List <MeshData> childMeshDataList) { List <int> selects = new List <int>(); if (meshData != null) { // 親頂点に影響する子頂点情報 Dictionary <int, List <uint> > dict = meshData.GetVirtualToChildVertexDict(); // 現在の選択データの頂点ハッシュ辞書リスト var hashList = GetSelectionVertexHashList(); int vcnt = meshData.VertexCount; for (int i = 0; i < vcnt; i++) { int data = GetSelection(meshData, i, dict, childMeshDataList, hashList); selects.Add(data); } } else { // そのまま if (selectionList.Count > 0) { selects = new List <int>(selectionList[0].selectData); } } return(selects); }
/// <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(); }