diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 4d3588452eb..b58a34f9942 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -411,7 +411,7 @@ void BVH::pack_instances(size_t nodes_size) size_t nsize_bbox = (use_qbvh)? nsize-2: nsize-1; int4 *bvh_nodes = &bvh->pack.nodes[0]; size_t bvh_nodes_size = bvh->pack.nodes.size(); - int *bvh_is_leaf = &bvh->pack.is_leaf[0]; + int *bvh_is_leaf = (bvh->pack.is_leaf.size() != 0) ? &bvh->pack.is_leaf[0] : NULL; for(size_t i = 0, j = 0; i < bvh_nodes_size; i+=nsize, j++) { memcpy(pack_nodes + pack_nodes_offset, bvh_nodes + i, nsize_bbox*sizeof(int4)); @@ -419,7 +419,7 @@ void BVH::pack_instances(size_t nodes_size) /* modify offsets into arrays */ int4 data = bvh_nodes[i + nsize_bbox]; - if(bvh_is_leaf[j]) { + if(bvh_is_leaf && bvh_is_leaf[j]) { data.x += tri_offset; data.y += tri_offset; }