private GpuSmitsBVHNode[] BuildQHandle_CPP() { var triData = new DLLx.TriangleData( scene.Triangles.Select(tri => new DLLx.TriInfo() { id = 0, v1 = (int)tri.v0.VertexIndex, v2 = (int)tri.v1.VertexIndex, v3 = (int)tri.v2.VertexIndex }).ToArray(), scene.Vertices.Select(v => new DLLx.VertInfo(v.x, v.y, v.z)).ToArray()); Tracer.TraceLine("Start building"); using (qbvhHandle = new QBVHHandle(triData)) { var data = qbvhHandle.GetData(); Tracer.TraceLine("Complete!"); return data. //Except(new[]{data.First()}). Select(item => new GpuSmitsBVHNode() { //bbox = new BoundingVolumeHierarchyAccelerationStructure.BBox(new Vector(item.bbox.pMin.x, item.bbox.pMin.y, item.bbox.pMin.z), new Vector(item.bbox.pMax.x, item.bbox.pMax.y, item.bbox.pMax.z)), //primitive = item.primitive, //skipIndex = item.skipIndex }).ToArray(); } }
public GpuSmitsBVHNode[] BuildData(TriangleMeshInfo mi) { var nrm = mi.StartVertice == 0 ? -1 : mi.StartVertice - 1; var triData = new DLLx.TriangleData( scene.Triangles.ToList().GetRange(mi.StartTriangle, mi.EndTriangle - mi.StartTriangle - 1).Select(tri => new DLLx.TriInfo() { id = 0, v1 = (int)tri.v0.VertexIndex - nrm, v2 = (int)tri.v1.VertexIndex - nrm, v3 = (int)tri.v2.VertexIndex - nrm }).ToArray(), scene.Vertices.ToList().GetRange(mi.StartVertice, mi.EndVertice - mi.StartVertice).Select(v => new DLLx.VertInfo(v.x, v.y, v.z)).ToArray()); Tracer.TraceLine("Start building"); using (bvhHandle = new BVHHandle(triData, 2u, 4, 60, 20, 0.5f)) { var data = bvhHandle.GetData(); Tracer.TraceLine("Complete!"); return data. //Except(new[]{data.First()}). Select(item => new GpuSmitsBVHNode() { bbox = new AABBInfo(new Point(item.bbox.pMin.x, item.bbox.pMin.y, item.bbox.pMin.z), new Point(item.bbox.pMax.x, item.bbox.pMax.y, item.bbox.pMax.z)), primitive = item.primitive, skipIndex = item.skipIndex }).ToArray(); } }
public static GpuSmitsBVHNode[] CreateBVH(IEnumerable<TriangleDataInfo> triangles, IEnumerable<Point> vertices, uint treeType = 4u, int csamples = 4, int intersectionCost = 60, int traverseCost = 20, float emptyBonus = 20f) { var triData = new DLLx.TriangleData( triangles.Select(tri => new DLLx.TriInfo() { id = 0, v1 = (int)tri.v0.VertexIndex, v2 = (int)tri.v1.VertexIndex, v3 = (int)tri.v2.VertexIndex }).ToArray(), vertices.Select(v => new DLLx.VertInfo(v.x, v.y, v.z)).ToArray()); Tracer.TraceLine("Start building"); using (var bvhHandle = new BVHHandle(triData, treeType, csamples, intersectionCost, traverseCost, emptyBonus)) { var data = bvhHandle.GetData(); Tracer.TraceLine("Complete!"); return data. //Except(new[]{data.First()}). Select(item => new GpuSmitsBVHNode() { bbox = new AABBInfo(new Point(item.bbox.pMin.x, item.bbox.pMin.y, item.bbox.pMin.z), new Point(item.bbox.pMax.x, item.bbox.pMax.y, item.bbox.pMax.z)), primitive = item.primitive, skipIndex = item.skipIndex }).ToArray(); } }
private GpuSmitsBVHNode[] BuildHandle_CPP() { var triData = new DLLx.TriangleData( scene.Triangles.Select(tri => new DLLx.TriInfo() { id = 0, v1 = (int)tri.v0.VertexIndex, v2 = (int)tri.v1.VertexIndex, v3 = (int)tri.v2.VertexIndex }).ToArray(), scene.Vertices.Select(v => new DLLx.VertInfo(v.x, v.y, v.z)).ToArray()); Tracer.TraceLine("Start building"); using (bvhHandle = new BVHHandle(triData, 2u, 1, 60, 20, 1f)) { var data = bvhHandle.GetData(); Tracer.TraceLine("Complete!"); return data. //Except(new[]{data.First()}). Select(item => new GpuSmitsBVHNode() { bbox = new AABBInfo(new Point(item.bbox.pMin.x, item.bbox.pMin.y, item.bbox.pMin.z), new Point(item.bbox.pMax.x, item.bbox.pMax.y, item.bbox.pMax.z)), primitive = item.primitive, skipIndex = item.skipIndex }).ToArray(); } }