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>2015-01-12 17:11:32 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-01-12 17:11:32 +0300
commit51779d9407a307475c72f0df7ec012fea8ab1d76 (patch)
tree298ff9052de2ab8eeee761fce4e162f26d165c5c /intern
parentf9a4f8ada426c4f165d57decd398a4ddb6678966 (diff)
Cycles: Fix crash after recent BVH changes on empty BVH trees
It's apparently not nice to access 0th element of zero-size vector in C++.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/bvh/bvh.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 38773bfbc4e..5fc4ddb3a0e 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -510,11 +510,12 @@ void RegularBVH::pack_leaf(const BVHStackEntry& e, const LeafNode *leaf)
leaf->m_visibility, leaf->m_visibility);
}
else {
+ int prim_type = leaf->num_triangles() ? pack.prim_type[leaf->m_lo] : 0;
/* Triangle/curve primitive leaf. */
pack_node(e.idx, leaf->m_bounds, leaf->m_bounds,
leaf->m_lo, leaf->m_hi,
leaf->m_visibility,
- pack.prim_type[leaf->m_lo]);
+ prim_type);
}
}
@@ -707,7 +708,9 @@ void QBVH::pack_leaf(const BVHStackEntry& e, const LeafNode *leaf)
data[6].y = __int_as_float(leaf->m_hi);
}
data[6].z = __uint_as_float(leaf->m_visibility);
- data[6].w = __uint_as_float(pack.prim_type[leaf->m_lo]);
+ if(leaf->num_triangles() != 0) {
+ data[6].w = __uint_as_float(pack.prim_type[leaf->m_lo]);
+ }
memcpy(&pack.nodes[e.idx * BVH_QNODE_SIZE], data, sizeof(float4)*BVH_QNODE_SIZE);
}