[Bf-blender-cvs] [e6538ac] temp-cycles-microdisplacement: Add geometry cache ; bvh
Mai Lavelle
noreply at git.blender.org
Tue Apr 12 18:45:53 CEST 2016
Commit: e6538ac8bb7ba061e5d219ae51422286191f5212
Author: Mai Lavelle
Date: Wed Feb 24 12:46:10 2016 -0500
Branches: temp-cycles-microdisplacement
https://developer.blender.org/rBe6538ac8bb7ba061e5d219ae51422286191f5212
Add geometry cache ; bvh
===================================================================
M intern/cycles/bvh/bvh.cpp
M intern/cycles/bvh/bvh_build.cpp
M intern/cycles/bvh/bvh_params.h
===================================================================
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index f78ad3e..bb2a898 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -205,7 +205,7 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
if(pack.prim_index[i] != -1) {
if(pack.prim_type[i] & PRIMITIVE_ALL_CURVE)
pack.prim_index[i] += objects[pack.prim_object[i]]->mesh->curve_offset;
- else
+ else if(pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE)
pack.prim_index[i] += objects[pack.prim_object[i]]->mesh->tri_offset;
}
@@ -311,6 +311,8 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
for(size_t i = 0; i < bvh_prim_index_size; i++) {
if(bvh->pack.prim_type[i] & PRIMITIVE_ALL_CURVE)
pack_prim_index[pack_prim_index_offset] = bvh_prim_index[i] + mesh_curve_offset;
+ else if(bvh->pack.prim_type[i] & PRIMITIVE_SUBPATCH)
+ pack_prim_index[pack_prim_index_offset] = bvh_prim_index[i];
else
pack_prim_index[pack_prim_index_offset] = bvh_prim_index[i] + mesh_tri_offset;
@@ -534,6 +536,12 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
}
}
}
+ else if(pack.prim_type[prim] & PRIMITIVE_SUBPATCH) {
+ /* Subpatches. */
+ const Mesh::SubPatch& subpatch = mesh->subpatches[pidx];
+
+ subpatch.bounds_grow(bbox);
+ }
else {
/* triangles */
int tri_offset = (params.top_level)? mesh->tri_offset: 0;
@@ -798,6 +806,12 @@ void QBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
}
}
}
+ else if(pack.prim_type[prim] & PRIMITIVE_SUBPATCH) {
+ /* Subpatches. */
+ const Mesh::SubPatch& subpatch = mesh->subpatches[pidx];
+
+ subpatch.bounds_grow(bbox);
+ }
else {
/* Triangles. */
int tri_offset = (params.top_level)? mesh->tri_offset: 0;
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 255051c..e2b2a64 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -177,6 +177,20 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh,
}
}
}
+
+ for(uint j = 0; j < mesh->subpatches.size(); j++) {
+ Mesh::SubPatch& subpatch = mesh->subpatches[j];
+ BoundBox bounds = BoundBox::empty;
+ PrimitiveType type = PRIMITIVE_SUBPATCH;
+
+ subpatch.bounds_grow(bounds);
+
+ if(bounds.valid()) {
+ references.push_back(BVHReference(bounds, j, i, type));
+ root.grow(bounds);
+ center.grow(bounds.center2());
+ }
+ }
}
void BVHBuild::add_reference_object(BoundBox& root, BoundBox& center, Object *ob, int i)
@@ -206,6 +220,7 @@ void BVHBuild::add_references(BVHRange& root)
if(!ob->mesh->is_instanced()) {
num_alloc_references += ob->mesh->triangles.size();
num_alloc_references += count_curve_segments(ob->mesh);
+ num_alloc_references += ob->mesh->subpatches.size();
}
else
num_alloc_references++;
@@ -213,6 +228,7 @@ void BVHBuild::add_references(BVHRange& root)
else {
num_alloc_references += ob->mesh->triangles.size();
num_alloc_references += count_curve_segments(ob->mesh);
+ num_alloc_references += ob->mesh->subpatches.size();
}
}
@@ -412,6 +428,7 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange& range,
size_t num_triangles = 0;
size_t num_curves = 0;
size_t num_motion_curves = 0;
+ size_t num_subpatches = 0;
for(int i = 0; i < size; i++) {
const BVHReference& ref = references[range.start() + i];
@@ -422,11 +439,14 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange& range,
num_motion_curves++;
else if(ref.prim_type() & PRIMITIVE_ALL_TRIANGLE)
num_triangles++;
+ else if(ref.prim_type() & PRIMITIVE_SUBPATCH)
+ num_subpatches++;
}
return (num_triangles < params.max_triangle_leaf_size) &&
(num_curves < params.max_curve_leaf_size) &&
- (num_motion_curves < params.max_curve_leaf_size);
+ (num_motion_curves < params.max_curve_leaf_size) &&
+ (num_subpatches < params.max_subpatch_leaf_size);
}
/* multithreaded binning builder */
@@ -615,6 +635,8 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range,
BoundBox bounds[PRIMITIVE_NUM_TOTAL] = {BoundBox::empty,
BoundBox::empty,
BoundBox::empty,
+ BoundBox::empty,
+ BoundBox::empty,
BoundBox::empty};
int ob_num = 0;
diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index cf683df..3969749 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -39,6 +39,7 @@ public:
int min_leaf_size;
int max_triangle_leaf_size;
int max_curve_leaf_size;
+ int max_subpatch_leaf_size;
/* object or mesh level bvh */
bool top_level;
@@ -66,6 +67,7 @@ public:
min_leaf_size = 1;
max_triangle_leaf_size = 8;
max_curve_leaf_size = 2;
+ max_subpatch_leaf_size = 1;
top_level = false;
use_qbvh = false;
More information about the Bf-blender-cvs
mailing list