void BVH4Triangle1vBuilderFast::createSmallLeaf(BuildRecord& current, Allocator& leafAlloc, size_t threadID) { size_t items = current.size(); size_t start = current.begin; assert(items<=4); /* allocate leaf node */ Triangle1v* accel = (Triangle1v*) leafAlloc.malloc(items*sizeof(Triangle1v)); *current.parent = bvh->encodeLeaf((char*)accel,items); for (size_t i=0; i<items; i++) { const size_t geomID = prims[start+i].geomID(); const size_t primID = prims[start+i].primID(); const TriangleMesh* __restrict__ const mesh = scene->getTriangleMesh(geomID); const TriangleMesh::Triangle& tri = mesh->triangle(primID); const ssef v0 = select(0x7,(ssef)mesh->vertex(tri.v[0]),zero); const ssef v1 = select(0x7,(ssef)mesh->vertex(tri.v[1]),zero); const ssef v2 = select(0x7,(ssef)mesh->vertex(tri.v[2]),zero); const ssef e1 = v0 - v1; const ssef e2 = v2 - v0; const ssef normal = cross(e1,e2); store4f_nt(&accel[i].v0,cast(insert<3>(cast(v0),primID))); store4f_nt(&accel[i].v1,cast(insert<3>(cast(v1),geomID))); store4f_nt(&accel[i].v2,cast(insert<3>(cast(v2),mesh->mask))); } }
void BVH4Triangle4vBuilderFast::createSmallLeaf(BuildRecord& current, Allocator& leafAlloc, size_t threadID) { size_t items = current.size(); size_t start = current.begin; assert(items<=4); /* allocate leaf node */ Triangle4v* accel = (Triangle4v*) leafAlloc.malloc(sizeof(Triangle4v)); *current.parent = bvh->encodeLeaf((char*)accel,1); ssei vgeomID = -1, vprimID = -1, vmask = -1; sse3f v0 = zero, v1 = zero, v2 = zero; for (size_t i=0; i<items; i++) { const size_t geomID = prims[start+i].geomID(); const size_t primID = prims[start+i].primID(); const TriangleMesh* __restrict__ const mesh = scene->getTriangleMesh(geomID); const TriangleMesh::Triangle& tri = mesh->triangle(primID); const Vec3fa& p0 = mesh->vertex(tri.v[0]); const Vec3fa& p1 = mesh->vertex(tri.v[1]); const Vec3fa& p2 = mesh->vertex(tri.v[2]); vgeomID [i] = geomID; vprimID [i] = primID; vmask [i] = mesh->mask; v0.x[i] = p0.x; v0.y[i] = p0.y; v0.z[i] = p0.z; v1.x[i] = p1.x; v1.y[i] = p1.y; v1.z[i] = p1.z; v2.x[i] = p2.x; v2.y[i] = p2.y; v2.z[i] = p2.z; } Triangle4v::store_nt(accel,Triangle4v(v0,v1,v2,vgeomID,vprimID,vmask)); }
void BVH4UserGeometryBuilderFast::createSmallLeaf(BuildRecord& current, Allocator& leafAlloc, size_t threadID) { size_t items = current.size(); size_t start = current.begin; /* allocate leaf node */ AccelSetItem* accel = (AccelSetItem*) leafAlloc.malloc(sizeof(AccelSetItem)*items); *current.parent = bvh->encodeLeaf(accel,items); for (size_t i=0; i<items; i++) { const PrimRef& prim = prims[start+i]; accel[i].accel = (AccelSet*) (UserGeometryBase*) scene->get(prim.geomID()); //(*accels)[prim.geomID()]; accel[i].item = prim.primID(); } }
void BVH4Bezier1iBuilderFast::createSmallLeaf(BuildRecord& current, Allocator& leafAlloc, size_t threadID) { size_t items = current.size(); size_t start = current.begin; /* allocate leaf node */ Bezier1i* accel = (Bezier1i*) leafAlloc.malloc(items*sizeof(Bezier1i)); *current.parent = bvh->encodeLeaf((char*)accel,items); for (size_t i=0; i<items; i++) { const size_t geomID = prims[start+i].geomID(); const size_t primID = prims[start+i].primID(); const BezierCurves* curves = scene->getBezierCurves(geomID); const Vec3fa& p0 = curves->vertex(curves->curve(primID)); new (&accel[i]) Bezier1i(&p0,geomID,primID); } }
void BVH4Triangle4iBuilderFast::createSmallLeaf(BuildRecord& current, Allocator& leafAlloc, size_t threadID) { size_t items = current.size(); size_t start = current.begin; assert(items<=4); /* allocate leaf node */ Triangle4i* accel = (Triangle4i*) leafAlloc.malloc(sizeof(Triangle4i)); *current.parent = bvh->encodeLeaf((char*)accel,1); ssei geomID = -1, primID = -1; Vec3f* v0[4] = { NULL, NULL, NULL, NULL }; ssei v1 = zero, v2 = zero; for (size_t i=0; i<items; i++) { const PrimRef& prim = prims[start+i]; const TriangleMesh* mesh = scene->getTriangleMesh(prim.geomID()); const TriangleMesh::Triangle& tri = mesh->triangle(prim.primID()); geomID[i] = prim.geomID(); primID[i] = prim.primID(); v0[i] = (Vec3f*) &mesh->vertex(tri.v[0]); v1[i] = (int*)&mesh->vertex(tri.v[1])-(int*)v0[i]; v2[i] = (int*)&mesh->vertex(tri.v[2])-(int*)v0[i]; } for (size_t i=items; i<4; i++) { geomID[i] = -1; primID[i] = -1; v0[i] = v0[0]; v1[i] = 0; v2[i] = 0; } new (accel) Triangle4i(v0,v1,v2,geomID,primID); }