public void RebuildPartModels() { MeshModels.Clear(); VertexBuffer.ClearBuffers(); var indices = new List <int>(); var vertices = new List <VertVNT>(); var distinctMeshes = new List <ModelMesh>(); foreach (var surfComp in Surface.Components) { foreach (var meshRef in surfComp.Meshes) { if (!meshRef.ModelMesh.CheckFileExist()) { Debug.WriteLine($"Error: Could not load model: {meshRef.ModelMesh.FileName}"); continue; } var addedModel = AddMeshGeometry(meshRef, indices, vertices); if (!distinctMeshes.Contains(meshRef.ModelMesh)) { distinctMeshes.Add(meshRef.ModelMesh); } } if (surfComp is FemaleStudModel femaleStud) { foreach (var meshRef in femaleStud.ReplacementMeshes) { if (!meshRef.ModelMesh.CheckFileExist()) { Debug.WriteLine($"Error: Could not load model: {meshRef.ModelMesh.FileName}"); continue; } var addedModel = AddMeshGeometry(meshRef, indices, vertices); addedModel.IsReplacementModel = true; if (!distinctMeshes.Contains(meshRef.ModelMesh)) { distinctMeshes.Add(meshRef.ModelMesh); } } } } distinctMeshes.ForEach(x => x.UnloadModel()); Indices = indices.ToArray(); Vertices = vertices.ToArray(); VertexBuffer.SetIndices(indices); VertexBuffer.SetVertices(vertices); }
public void Dispose() { if (VertexBuffer != null) { VertexBuffer.Dispose(); } Vertices = new VertVNT[0]; Indices = new int[0]; MeshModels.Clear(); Surface = null; }
public void Dispose() { if (VertexBuffer != null) { VertexBuffer.Dispose(); VertexBuffer = null; } //if (BoneWeightBuffer != null) // BoneWeightBuffer.Dispose(); Vertices = new VertVNT[0]; Indices = new int[0]; MeshModels.Clear(); Surface = null; }