[Bf-blender-cvs] [51779d9] master: Cycles: Fix crash after recent BVH changes on empty BVH trees
Sergey Sharybin
noreply at git.blender.org
Mon Jan 12 15:12:44 CET 2015
Commit: 51779d9407a307475c72f0df7ec012fea8ab1d76
Author: Sergey Sharybin
Date: Mon Jan 12 19:11:32 2015 +0500
Branches: master
https://developer.blender.org/rB51779d9407a307475c72f0df7ec012fea8ab1d76
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++.
===================================================================
M intern/cycles/bvh/bvh.cpp
===================================================================
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 38773bf..5fc4ddb 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);
}
More information about the Bf-blender-cvs
mailing list