Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-02-22 18:33:42 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-03-31 14:52:38 +0300
commit791a0852e8d7f17887896245ef62a826b2228648 (patch)
tree8ceff1a90c366afe0ccb50875d4b56abfef07f90 /intern/cycles/bvh
parent4ec95d621ada1ffe9df742e0afee00679ce137ad (diff)
Cycles: Name cleanup and some comments in BVH code
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r--intern/cycles/bvh/bvh_build.cpp8
-rw-r--r--intern/cycles/bvh/bvh_params.h19
-rw-r--r--intern/cycles/bvh/bvh_split.cpp32
3 files changed, 35 insertions, 24 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 9f1fb9c520d..6d785dffadf 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -243,10 +243,10 @@ BVHNode* BVHBuild::run()
spatial_storage.resize(1);
size_t num_bins = max(root.size(), (int)BVHParams::NUM_SPATIAL_BINS) - 1;
foreach(BVHSpatialStorage &storage, spatial_storage) {
- storage.spatial_right_bounds.clear();
- storage.spatial_right_bounds.resize(num_bins);
- storage.spatial_indices.clear();
- storage.spatial_indices.reserve(num_bins);
+ storage.right_bounds.clear();
+ storage.right_bounds.resize(num_bins);
+ storage.reference_indices.clear();
+ storage.reference_indices.reserve(num_bins);
}
}
diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index 2e579ba85a4..022ecbcb923 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -183,10 +183,21 @@ struct BVHSpatialBin
*/
struct BVHSpatialStorage {
- vector<BoundBox> spatial_right_bounds;
- BVHSpatialBin spatial_bins[3][BVHParams::NUM_SPATIAL_BINS];
- vector<int> spatial_indices;
- vector<BVHReference> spatial_new_refs;
+ /* Accumulated bounds when sweeping from right to left. */
+ vector<BoundBox> right_bounds;
+
+ /* Bins used for histogram when selecting best split plane. */
+ BVHSpatialBin bins[3][BVHParams::NUM_SPATIAL_BINS];
+
+ /* Indices to a reference array used by object splitter to speed up
+ * sorting process.
+ */
+ vector<int> reference_indices;
+
+ /* Temporary storage for the new references. Used by spatial split to store
+ * new references in before they're getting inserted into actual array,
+ */
+ vector<BVHReference> new_references;
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/bvh/bvh_split.cpp b/intern/cycles/bvh/bvh_split.cpp
index 5d33238912f..7ca07675a3a 100644
--- a/intern/cycles/bvh/bvh_split.cpp
+++ b/intern/cycles/bvh/bvh_split.cpp
@@ -42,8 +42,8 @@ BVHObjectSplit::BVHObjectSplit(const BVHBuild& builder,
const BVHReference *ref_ptr = &builder.references[range.start()];
float min_sah = FLT_MAX;
- storage->spatial_indices.resize(range.size());
- int *indices = &storage->spatial_indices[0];
+ storage->reference_indices.resize(range.size());
+ int *indices = &storage->reference_indices[0];
for(int dim = 0; dim < 3; dim++) {
/* Sort references.
@@ -61,7 +61,7 @@ BVHObjectSplit::BVHObjectSplit(const BVHBuild& builder,
for(int i = range.size() - 1; i > 0; i--) {
right_bounds.grow(ref_ptr[indices[i]].bounds());
- storage_->spatial_right_bounds[i - 1] = right_bounds;
+ storage_->right_bounds[i - 1] = right_bounds;
}
/* sweep left to right and select lowest SAH. */
@@ -69,7 +69,7 @@ BVHObjectSplit::BVHObjectSplit(const BVHBuild& builder,
for(int i = 1; i < range.size(); i++) {
left_bounds.grow(ref_ptr[indices[i - 1]].bounds());
- right_bounds = storage_->spatial_right_bounds[i - 1];
+ right_bounds = storage_->right_bounds[i - 1];
float sah = nodeSAH +
left_bounds.safe_area() * builder.params.primitive_cost(i) +
@@ -117,7 +117,7 @@ BVHSpatialSplit::BVHSpatialSplit(const BVHBuild& builder,
for(int dim = 0; dim < 3; dim++) {
for(int i = 0; i < BVHParams::NUM_SPATIAL_BINS; i++) {
- BVHSpatialBin& bin = storage_->spatial_bins[dim][i];
+ BVHSpatialBin& bin = storage_->bins[dim][i];
bin.bounds = BoundBox::empty;
bin.enter = 0;
@@ -143,13 +143,13 @@ BVHSpatialSplit::BVHSpatialSplit(const BVHBuild& builder,
BVHReference leftRef, rightRef;
split_reference(builder, leftRef, rightRef, currRef, dim, origin[dim] + binSize[dim] * (float)(i + 1));
- storage_->spatial_bins[dim][i].bounds.grow(leftRef.bounds());
+ storage_->bins[dim][i].bounds.grow(leftRef.bounds());
currRef = rightRef;
}
- storage_->spatial_bins[dim][lastBin[dim]].bounds.grow(currRef.bounds());
- storage_->spatial_bins[dim][firstBin[dim]].enter++;
- storage_->spatial_bins[dim][lastBin[dim]].exit++;
+ storage_->bins[dim][lastBin[dim]].bounds.grow(currRef.bounds());
+ storage_->bins[dim][firstBin[dim]].enter++;
+ storage_->bins[dim][lastBin[dim]].exit++;
}
}
@@ -159,8 +159,8 @@ BVHSpatialSplit::BVHSpatialSplit(const BVHBuild& builder,
BoundBox right_bounds = BoundBox::empty;
for(int i = BVHParams::NUM_SPATIAL_BINS - 1; i > 0; i--) {
- right_bounds.grow(storage_->spatial_bins[dim][i].bounds);
- storage_->spatial_right_bounds[i - 1] = right_bounds;
+ right_bounds.grow(storage_->bins[dim][i].bounds);
+ storage_->right_bounds[i - 1] = right_bounds;
}
/* sweep left to right and select lowest SAH. */
@@ -169,13 +169,13 @@ BVHSpatialSplit::BVHSpatialSplit(const BVHBuild& builder,
int rightNum = range.size();
for(int i = 1; i < BVHParams::NUM_SPATIAL_BINS; i++) {
- left_bounds.grow(storage_->spatial_bins[dim][i - 1].bounds);
- leftNum += storage_->spatial_bins[dim][i - 1].enter;
- rightNum -= storage_->spatial_bins[dim][i - 1].exit;
+ left_bounds.grow(storage_->bins[dim][i - 1].bounds);
+ leftNum += storage_->bins[dim][i - 1].enter;
+ rightNum -= storage_->bins[dim][i - 1].exit;
float sah = nodeSAH +
left_bounds.safe_area() * builder.params.primitive_cost(leftNum) +
- storage_->spatial_right_bounds[i - 1].safe_area() * builder.params.primitive_cost(rightNum);
+ storage_->right_bounds[i - 1].safe_area() * builder.params.primitive_cost(rightNum);
if(sah < this->sah) {
this->sah = sah;
@@ -220,7 +220,7 @@ void BVHSpatialSplit::split(BVHBuild *builder, BVHRange& left, BVHRange& right,
* Duplication happens into a temporary pre-allocated vector in order to
* reduce number of memmove() calls happening in vector.insert().
*/
- vector<BVHReference>& new_refs = storage_->spatial_new_refs;
+ vector<BVHReference>& new_refs = storage_->new_references;
new_refs.clear();
new_refs.reserve(right_start - left_end);
while(left_end < right_start) {