private static void TransformAndAddVInfo(List <VInfo> list, VInfo input, CopyAndTransformVInfo xform) { VInfo result; xform(input, out result); list.Add(result); }
// vertices grouped into 3's (3 verts per triangle) public CSGModel(List<Vec3> modelVerts, List<VInfo> matchingInfos) : this() { List<CSGVertex> vertexMapping = new List<CSGVertex>(); for (int i = 0; i < modelVerts.Count; i++) vertexMapping.Add(GetVertex(modelVerts[i], true)); for (int i = 0; i < modelVerts.Count; i += 3) { CSGVertex[] tri = new CSGVertex[3]; VInfo[] vinfos = new VInfo[3]; bool acceptable = true; for (int j = 0; j < 3; j++) { tri[j] = vertexMapping[i + j]; for (int k = 0; k < j; k++) if (tri[j] == tri[k]) acceptable = false; vinfos[j] = matchingInfos[i + j]; if (!acceptable) break; } if (acceptable) { CSGSourceTriangle triangle = new CSGSourceTriangle(this, tri, vinfos); foreach (CSGShape shape in triangle.divisions) shapes.Add(shape); sourceTriangles.Add(triangle); } } }
// clone a model (scraps any WIP intersection info) // not suitable if there's custom vinfo public CSGModel CloneModel() { return(CloneModel(new ModelUtil.CopyAndTransformVInfo( (VInfo basis, out VInfo result) => { result = new VInfo(); }))); }
public CSGSourceTriangle(CSGModel model, CSGVertex[] verts, VInfo[] vinfos) : this() { this.model = model; for(int i = 0; i< 3;i++) { sourceVerts[i] = verts[i]; vertexVInfos[verts[i].id] = vinfos[i]; } ComputePlane(); divisions.Add(new CSGShape(model, this)); }
public CSGModel(List <Vec3> modelVerts, List <VInfo> matchingInfos) // vertices grouped into 3's (3 verts per triangle) : this() { List <CSGVertex> vertexMapping = new List <CSGVertex>(); for (int i = 0; i < modelVerts.Count; i++) { vertexMapping.Add(GetVertex(modelVerts[i], true)); } for (int i = 0; i < modelVerts.Count; i += 3) { CSGVertex[] tri = new CSGVertex[3]; VInfo[] vinfos = new VInfo[3]; bool acceptable = true; for (int j = 0; j < 3; j++) { tri[j] = vertexMapping[i + j]; for (int k = 0; k < j; k++) { if (tri[j] == tri[k]) { acceptable = false; } } vinfos[j] = matchingInfos[i + j]; if (!acceptable) { break; } } if (acceptable) { CSGSourceTriangle triangle = new CSGSourceTriangle(this, tri, vinfos); foreach (CSGShape shape in triangle.divisions) { shapes.Add(shape); } sourceTriangles.Add(triangle); } } }
// clone a model (scraps any WIP intersection info) // not suitable if there's custom vinfo public CSGModel CloneModel() { return CloneModel(new ModelUtil.CopyAndTransformVInfo( (VInfo basis, out VInfo result) => { result = new VInfo(); })); }
private static void TransformAndAddVInfo(List<VInfo> list, VInfo input, CopyAndTransformVInfo xform) { VInfo result; xform(input, out result); list.Add(result); }