diff options
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r-- | intern/cycles/bvh/bvh.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/bvh/bvh8.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/bvh/bvh_build.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/bvh/bvh_embree.cpp | 28 | ||||
-rw-r--r-- | intern/cycles/bvh/bvh_optix.cpp | 38 |
5 files changed, 38 insertions, 38 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index e6502a40313..0313bcd68b0 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -229,8 +229,6 @@ void BVH::refit_primitives(int start, int end, BoundBox &bbox, uint &visibility) curve.bounds_grow(k, &hair->curve_keys[0], &hair->curve_radius[0], bbox); - visibility |= PATH_RAY_CURVE; - /* Motion curves. */ if (hair->use_motion_blur) { Attribute *attr = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); @@ -327,9 +325,6 @@ void BVH::pack_primitives() pack.prim_tri_index[i] = -1; } pack.prim_visibility[i] = ob->visibility_for_tracing(); - if (pack.prim_type[i] & PRIMITIVE_ALL_CURVE) { - pack.prim_visibility[i] |= PATH_RAY_CURVE; - } } else { pack.prim_tri_index[i] = -1; diff --git a/intern/cycles/bvh/bvh8.cpp b/intern/cycles/bvh/bvh8.cpp index 342dd9e85a5..b805865b2c8 100644 --- a/intern/cycles/bvh/bvh8.cpp +++ b/intern/cycles/bvh/bvh8.cpp @@ -439,8 +439,6 @@ void BVH8::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility) curve.bounds_grow(k, &hair->curve_keys[0], &hair->curve_radius[0], bbox); - visibility |= PATH_RAY_CURVE; - /* Motion curves. */ if (hair->use_motion_blur) { Attribute *attr = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index db156219f09..814b5ced5d2 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -885,9 +885,6 @@ BVHNode *BVHBuild::create_leaf_node(const BVHRange &range, const vector<BVHRefer bounds[type_index].grow(ref.bounds()); visibility[type_index] |= objects[ref.prim_object()]->visibility_for_tracing(); - if (ref.prim_type() & PRIMITIVE_ALL_CURVE) { - visibility[type_index] |= PATH_RAY_CURVE; - } ++num_new_prims; } else { diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp index 9356adf3ea5..6735202835b 100644 --- a/intern/cycles/bvh/bvh_embree.cpp +++ b/intern/cycles/bvh/bvh_embree.cpp @@ -16,11 +16,6 @@ /* This class implements a ray accelerator for Cycles using Intel's Embree library. * It supports triangles, curves, object and deformation blur and instancing. - * Not supported are thick line segments, those have no native equivalent in Embree. - * They could be implemented using Embree's thick curves, at the expense of wasted memory. - * User defined intersections for Embree could also be an option, but since Embree only uses - * aligned BVHs for user geometry, this would come with reduced performance and/or higher memory - * usage. * * Since Embree allows object to be either curves or triangles but not both, Cycles object IDs are * mapped to Embree IDs by multiplying by two and adding one for curves. @@ -775,6 +770,21 @@ void BVHEmbree::update_curve_vertex_buffer(RTCGeometry geom_id, const Hair *hair } } } +# if RTC_VERSION >= 30900 + if (!use_curves) { + unsigned char *flags = (unsigned char *)rtcSetNewGeometryBuffer(geom_id, + RTC_BUFFER_TYPE_FLAGS, + 0, + RTC_FORMAT_UCHAR, + sizeof(unsigned char), + num_keys_embree); + flags[0] = RTC_CURVE_FLAG_NEIGHBOR_RIGHT; + ::memset(flags + 1, + RTC_CURVE_FLAG_NEIGHBOR_RIGHT | RTC_CURVE_FLAG_NEIGHBOR_RIGHT, + num_keys_embree - 2); + flags[num_keys_embree - 1] = RTC_CURVE_FLAG_NEIGHBOR_LEFT; + } +# endif } void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i) @@ -810,10 +820,18 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i) size_t prim_tri_index_size = pack.prim_index.size(); pack.prim_tri_index.resize(prim_tri_index_size + num_segments); +# if RTC_VERSION >= 30900 + enum RTCGeometryType type = (!use_curves) ? + (use_ribbons ? RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE : + RTC_GEOMETRY_TYPE_ROUND_LINEAR_CURVE) : + (use_ribbons ? RTC_GEOMETRY_TYPE_FLAT_CATMULL_ROM_CURVE : + RTC_GEOMETRY_TYPE_ROUND_CATMULL_ROM_CURVE); +# else enum RTCGeometryType type = (!use_curves) ? RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE : (use_ribbons ? RTC_GEOMETRY_TYPE_FLAT_CATMULL_ROM_CURVE : RTC_GEOMETRY_TYPE_ROUND_CATMULL_ROM_CURVE); +# endif RTCGeometry geom_id = rtcNewGeometry(rtc_shared_device, type); rtcSetGeometryTessellationRate(geom_id, curve_subdivisions); diff --git a/intern/cycles/bvh/bvh_optix.cpp b/intern/cycles/bvh/bvh_optix.cpp index 26b64c24db5..740994b2ebc 100644 --- a/intern/cycles/bvh/bvh_optix.cpp +++ b/intern/cycles/bvh/bvh_optix.cpp @@ -156,6 +156,19 @@ void BVHOptiX::pack_tlas() PackedBVH &bvh_pack = geom->bvh->pack; int geom_prim_offset = geom->prim_offset; + // Merge visibility flags of all objects and fix object indices for non-instanced geometry + int object_index = 0; // Unused for instanced geometry + int object_visibility = 0; + foreach (Object *ob, objects) { + if (ob->geometry == geom) { + object_visibility |= ob->visibility_for_tracing(); + if (!geom->is_instanced()) { + object_index = ob->get_device_index(); + break; + } + } + } + // Merge primitive, object and triangle indexes if (!bvh_pack.prim_index.empty()) { int *bvh_prim_type = &bvh_pack.prim_type[0]; @@ -174,8 +187,8 @@ void BVHOptiX::pack_tlas() } pack_prim_type[pack_offset] = bvh_prim_type[i]; - pack_prim_object[pack_offset] = 0; // Unused for instanced geometry - pack_prim_visibility[pack_offset] = bvh_prim_visibility[i]; + pack_prim_object[pack_offset] = object_index; + pack_prim_visibility[pack_offset] = bvh_prim_visibility[i] | object_visibility; } } @@ -188,27 +201,6 @@ void BVHOptiX::pack_tlas() pack_verts_offset += prim_tri_size; } } - - // Merge visibility flags of all objects and fix object indices for non-instanced geometry - foreach (Object *ob, objects) { - Geometry *const geom = ob->geometry; - size_t num_primitives = 0; - - if (geom->type == Geometry::MESH) { - num_primitives = static_cast<Mesh *const>(geom)->num_triangles(); - } - else if (geom->type == Geometry::HAIR) { - num_primitives = static_cast<Hair *const>(geom)->num_segments(); - } - - for (size_t i = 0; i < num_primitives; ++i) { - if (!geom->is_instanced()) { - assert(pack.prim_object[geom->optix_prim_offset + i] == 0); - pack.prim_object[geom->optix_prim_offset + i] = ob->get_device_index(); - } - pack.prim_visibility[geom->optix_prim_offset + i] |= ob->visibility_for_tracing(); - } - } } void BVHOptiX::pack_nodes(const BVHNode *) |