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
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-09-08 16:08:35 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-09-08 16:08:35 +0300
commit6de08f6cd1cb9e50736a0a43bf37d621c6eb2b87 (patch)
treeaa20253a0ecb3028ae0fe73e2209353692e837fb /intern
parent27e2317513afd0459120eaef7101ab3c1e025ea0 (diff)
Cycles: Fix regular BVH nodes refit
For proper indexing to work we need to use unaligned node with identity transform instead of aligned nodes when doing refit. To be backported to 2.78 release.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/bvh/bvh.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 5221aa506cc..09bd03cd0c9 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -633,9 +633,9 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
{
if(leaf) {
assert(idx + BVH_NODE_LEAF_SIZE <= pack.leaf_nodes.size());
- int4 *data = &pack.leaf_nodes[idx];
- int c0 = data[0].x;
- int c1 = data[0].y;
+ const int4 *data = &pack.leaf_nodes[idx];
+ const int c0 = data[0].x;
+ const int c1 = data[0].y;
/* refit leaf node */
for(int prim = c0; prim < c1; prim++) {
int pidx = pack.prim_index[prim];
@@ -711,9 +711,11 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
}
else {
assert(idx + BVH_NODE_SIZE <= pack.nodes.size());
- int4 *data = &pack.nodes[idx];
- int c0 = data[0].z;
- int c1 = data[0].w;
+
+ const int4 *data = &pack.nodes[idx];
+ const bool is_unaligned = (data[0].x & PATH_RAY_NODE_UNALIGNED) != 0;
+ const int c0 = data[0].z;
+ const int c1 = data[0].w;
/* refit inner node, set bbox from children */
BoundBox bbox0 = BoundBox::empty, bbox1 = BoundBox::empty;
uint visibility0 = 0, visibility1 = 0;
@@ -721,7 +723,22 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
refit_node((c0 < 0)? -c0-1: c0, (c0 < 0), bbox0, visibility0);
refit_node((c1 < 0)? -c1-1: c1, (c1 < 0), bbox1, visibility1);
- pack_aligned_node(idx, bbox0, bbox1, c0, c1, visibility0, visibility1);
+ if(is_unaligned) {
+ Transform aligned_space = transform_identity();
+ pack_unaligned_node(idx,
+ aligned_space, aligned_space,
+ bbox0, bbox1,
+ c0, c1,
+ visibility0,
+ visibility1);
+ }
+ else {
+ pack_aligned_node(idx,
+ bbox0, bbox1,
+ c0, c1,
+ visibility0,
+ visibility1);
+ }
bbox.grow(bbox0);
bbox.grow(bbox1);