浏览代码

Changing C# arrays to List.

/4.0
Todd Stinson 5 年前
当前提交
8fd8ba8f
共有 1 个文件被更改,包括 18 次插入9 次删除
  1. 27
      Assets/Scenes/Meshing/Scripts/MeshClassificationFracking.cs

27
Assets/Scenes/Meshing/Scripts/MeshClassificationFracking.cs


Action<MeshFilter> m_RemoveMeshAction;
/// <summary>
/// An array to store the triangle vertices of the base mesh.
/// </summary>
readonly List<int> m_BaseTriangles = new List<int>();
/// <summary>
/// An array to store the triangle vertices of the classified mesh.
/// </summary>
readonly List<int> m_ClassifiedTriangles = new List<int>();
/// <summary>
/// On awake, set up the mesh filter delegates.
/// </summary>
void Awake()

// If there were matching face classifications, build a new mesh from the base mesh.
if (classifiedFaceCount > 0)
{
int[] baseTriangles = baseMesh.triangles;
Debug.Assert(baseTriangles.Length == (faceClassifications.Length * 3),
baseMesh.GetTriangles(m_BaseTriangles, 0);
Debug.Assert(m_BaseTriangles.Count == (faceClassifications.Length * 3),
int[] classifiedTriangles = new int[classifiedFaceCount * 3];
m_ClassifiedTriangles.Clear();
m_ClassifiedTriangles.Capacity = classifiedFaceCount * 3;
int classifiedTriangleIndex = 0;
for (int i = 0; i < faceClassifications.Length; ++i)
{
if (faceClassifications[i] == selectedMeshClassification)

classifiedTriangles[classifiedTriangleIndex + 0] = baseTriangles[baseTriangleIndex + 0];
classifiedTriangles[classifiedTriangleIndex + 1] = baseTriangles[baseTriangleIndex + 1];
classifiedTriangles[classifiedTriangleIndex + 2] = baseTriangles[baseTriangleIndex + 2];
classifiedTriangleIndex += 3;
m_ClassifiedTriangles.Add(m_BaseTriangles[baseTriangleIndex + 0]);
m_ClassifiedTriangles.Add(m_BaseTriangles[baseTriangleIndex + 1]);
m_ClassifiedTriangles.Add(m_BaseTriangles[baseTriangleIndex + 2]);
classifiedMesh.triangles = classifiedTriangles;
classifiedMesh.SetTriangles(m_ClassifiedTriangles, 0);
}
}

正在加载...
取消
保存