[Bf-blender-cvs] [f8a9715] cycles_hair_bvh: Cycles; Cleanup API in the unaligned heuristic
Sergey Sharybin
noreply at git.blender.org
Thu May 12 16:19:30 CEST 2016
Commit: f8a9715b4795460134dacb503c5e91dfc11f76c2
Author: Sergey Sharybin
Date: Wed May 11 17:15:40 2016 +0200
Branches: cycles_hair_bvh
https://developer.blender.org/rBf8a9715b4795460134dacb503c5e91dfc11f76c2
Cycles; Cleanup API in the unaligned heuristic
There are cases when we've got vector of references and sometimes we
only have an array. Having duplicated functions in heuristic is a bit
annoying and since it's quite low-level anyway let's just use pure
pointers there.
===================================================================
M intern/cycles/bvh/bvh_build.cpp
M intern/cycles/bvh/bvh_unaligned.cpp
M intern/cycles/bvh/bvh_unaligned.h
===================================================================
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 2a75786..192b833 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -469,8 +469,8 @@ BVHNode* BVHBuild::build_node(const BVHObjectBinning& range, int level)
float unalignedLeafSAH = FLT_MAX;
Transform aligned_space;
if(params.use_unaligned_nodes && splitSAH > 0.7f*leafSAH) {
- aligned_space = unaligned_heuristic.compute_aligned_space(range,
- references);
+ aligned_space = unaligned_heuristic.compute_aligned_space(
+ range, &references[0]);
unaligned_range = BVHObjectBinning(unaligned_heuristic,
aligned_space,
range,
@@ -503,9 +503,8 @@ BVHNode* BVHBuild::build_node(const BVHObjectBinning& range, int level)
BoundBox bounds;
if(unalignedSplitSAH < splitSAH) {
- bounds = unaligned_heuristic.compute_aligned_boundbox(range,
- references,
- aligned_space);
+ bounds = unaligned_heuristic.compute_aligned_boundbox(
+ range, &references[0], aligned_space);
}
else {
bounds = range.bounds();
diff --git a/intern/cycles/bvh/bvh_unaligned.cpp b/intern/cycles/bvh/bvh_unaligned.cpp
index 316a2c5..9ba9fe8 100644
--- a/intern/cycles/bvh/bvh_unaligned.cpp
+++ b/intern/cycles/bvh/bvh_unaligned.cpp
@@ -37,7 +37,7 @@ BVHUnaligned::BVHUnaligned(const vector<Object*>& objects)
Transform BVHUnaligned::compute_aligned_space(
const BVHObjectBinning& range,
- const vector<BVHReference>& references) const
+ const BVHReference *references) const
{
for(int i = range.start(); i < range.end(); ++i) {
const BVHReference& ref = references[i];
@@ -54,7 +54,7 @@ Transform BVHUnaligned::compute_aligned_space(
Transform BVHUnaligned::compute_aligned_space(
const BVHRange& range,
- const vector<BVHReference>& references) const
+ const BVHReference *references) const
{
for(int i = range.start(); i < range.end(); ++i) {
const BVHReference& ref = references[i];
@@ -118,26 +118,25 @@ BoundBox BVHUnaligned::compute_aligned_prim_boundbox(
BoundBox BVHUnaligned::compute_aligned_boundbox(
const BVHObjectBinning& range,
const BVHReference *references,
- const Transform& aligned_space) const
+ const Transform& aligned_space,
+ BoundBox *cent_bounds) const
{
BoundBox bounds = BoundBox::empty;
+ if(cent_bounds != NULL) {
+ *cent_bounds = BoundBox::empty;
+ }
for(int i = range.start(); i < range.end(); ++i) {
const BVHReference& ref = references[i];
BoundBox ref_bounds = compute_aligned_prim_boundbox(ref, aligned_space);
bounds.grow(ref_bounds);
+ if(cent_bounds != NULL) {
+ cent_bounds->grow(ref_bounds.center2());
+ }
}
return bounds;
}
BoundBox BVHUnaligned::compute_aligned_boundbox(
- const BVHObjectBinning& range,
- const vector<BVHReference>& references,
- const Transform& aligned_space) const
-{
- return compute_aligned_boundbox(range, &references[0], aligned_space);
-}
-
-BoundBox BVHUnaligned::compute_aligned_boundbox(
const BVHRange& range,
const BVHReference *references,
const Transform& aligned_space,
@@ -158,14 +157,6 @@ BoundBox BVHUnaligned::compute_aligned_boundbox(
return bounds;
}
-BoundBox BVHUnaligned::compute_aligned_boundbox(
- const BVHRange& range,
- const vector<BVHReference>& references,
- const Transform& aligned_space) const
-{
- return compute_aligned_boundbox(range, &references[0], aligned_space, NULL);
-}
-
Transform BVHUnaligned::compute_node_transform(
const BoundBox& bounds,
const Transform& aligned_space)
diff --git a/intern/cycles/bvh/bvh_unaligned.h b/intern/cycles/bvh/bvh_unaligned.h
index 10bf7f1..9e568e6 100644
--- a/intern/cycles/bvh/bvh_unaligned.h
+++ b/intern/cycles/bvh/bvh_unaligned.h
@@ -36,10 +36,10 @@ public:
/* Calculate alignment for the oriented node for a given range. */
Transform compute_aligned_space(
const BVHObjectBinning& range,
- const vector<BVHReference>& references) const;
+ const BVHReference *references) const;
Transform compute_aligned_space(
const BVHRange& range,
- const vector<BVHReference>& references) const;
+ const BVHReference *references) const;
/* Calculate alignment for the oriented node for a given reference.
*
@@ -56,21 +56,14 @@ public:
/* Calculate bounding box in given space. */
BoundBox compute_aligned_boundbox(
const BVHObjectBinning& range,
- const vector<BVHReference>& references,
- const Transform& aligned_space) const;
- BoundBox compute_aligned_boundbox(
- const BVHObjectBinning& range,
- const BVHReference* references,
- const Transform& aligned_space) const;
- BoundBox compute_aligned_boundbox(
- const BVHRange& range,
- const vector<BVHReference>& references,
- const Transform& aligned_space) const;
+ const BVHReference *references,
+ const Transform& aligned_space,
+ BoundBox *cent_bounds = NULL) const;
BoundBox compute_aligned_boundbox(
const BVHRange& range,
const BVHReference *references,
const Transform& aligned_space,
- BoundBox *cent_bounds) const;
+ BoundBox *cent_bounds = NULL) const;
/* Calculate affine transform for node packing.
* Bounds will be in the range of 0..1.
More information about the Bf-blender-cvs
mailing list