blob: fd9933bc52dd588929cc3f00da680c12d03197eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
using System;
using System.Collections.Generic;
using UnityEngine;
namespace NGS.MeshFusionPro;
public class CombinedMesh : IDisposable
{
private Mesh _mesh;
private CombinedMeshDataInternal _meshData;
private IMeshCombiner _combiner;
private IMeshCutter _cutter;
public Mesh Mesh => _mesh;
public CombinedMeshData MeshData => _meshData;
public CombinedMesh(IMeshCombiner combiner, IMeshCutter cutter)
{
if (combiner == null)
{
throw new ArgumentNullException("MeshCombiner not assigned");
}
if (cutter == null)
{
throw new ArgumentNullException("MeshCutter not assigned");
}
_mesh = new Mesh();
_mesh.MarkDynamic();
_combiner = combiner;
_cutter = cutter;
_meshData = CreateMeshData();
_meshData.Initialize(this);
}
public CombinedMeshPart[] Combine(IList<MeshCombineInfo> infos)
{
_combiner.Combine(_mesh, infos);
return _meshData.CreateParts(infos);
}
public void Cut(IList<CombinedMeshPart> parts)
{
MeshCuttingInfo[] array = new MeshCuttingInfo[parts.Count];
for (int i = 0; i < parts.Count; i++)
{
CombinedMeshPart combinedMeshPart = parts[i];
array[i] = new MeshCuttingInfo
{
vertexStart = combinedMeshPart.VertexStart,
vertexCount = combinedMeshPart.VertexCount,
triangleStart = combinedMeshPart.TrianglesStart,
triangleCount = combinedMeshPart.TrianglesCount
};
}
_cutter.Cut(_mesh, array);
_meshData.RemoveParts(parts);
}
public void Dispose()
{
_meshData.Dispose();
}
protected virtual CombinedMeshDataInternal CreateMeshData()
{
return new CombinedMeshDataInternal();
}
}
public class CombinedMesh<TCombinedMeshData> : CombinedMesh where TCombinedMeshData : CombinedMeshDataInternal, new()
{
public TCombinedMeshData MeshDataInternal => (TCombinedMeshData)base.MeshData;
public CombinedMesh(IMeshCombiner combiner, IMeshCutter cutter)
: base(combiner, cutter)
{
}
protected override CombinedMeshDataInternal CreateMeshData()
{
return new TCombinedMeshData();
}
}
|