fix for rare crash in cycles BVH tree packing.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 22 Aug 2012 11:18:37 +0000 (11:18 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 22 Aug 2012 11:18:37 +0000 (11:18 +0000)
intern/cycles/bvh/bvh.cpp

index 4d3588452ebb372e05c78cd5bf15cf331c40c55a..b58a34f99425862a2b3bae5cf5a0a9e7319bd5df 100644 (file)
@@ -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;
                                }