Cycles: Make it more clear offsets in BVH construction
Previously offsets were calculated based on the BVH node size, which is wrong and real PITA in cases when some extra data is to be added into (or removed from) the node. Now use offsets which are not calculated form the node size.
This commit is contained in:
parent
f27d87d300
commit
144096faad
@ -506,7 +506,10 @@ void BVH::pack_instances(size_t nodes_size)
|
||||
|
||||
/* merge nodes */
|
||||
if(bvh->pack.nodes.size()) {
|
||||
size_t nsize_bbox = (use_qbvh)? nsize-2: nsize-1;
|
||||
/* For QBVH we're packing ann child bbox into 6 float4,
|
||||
* and for regulat BVH they're packed into 3 float4.
|
||||
*/
|
||||
size_t nsize_bbox = (use_qbvh)? 6: 3;
|
||||
int4 *bvh_nodes = &bvh->pack.nodes[0];
|
||||
size_t bvh_nodes_size = bvh->pack.nodes.size();
|
||||
int *bvh_is_leaf = (bvh->pack.is_leaf.size() != 0) ? &bvh->pack.is_leaf[0] : NULL;
|
||||
|
@ -191,7 +191,7 @@ ccl_device bool BVH_FUNCTION_NAME
|
||||
|
||||
/* if node is leaf, fetch triangle list */
|
||||
if(nodeAddr < 0) {
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+(BVH_NODE_SIZE-1));
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+3);
|
||||
int primAddr = __float_as_int(leaf.x);
|
||||
|
||||
#if FEATURE(BVH_INSTANCING)
|
||||
|
@ -177,7 +177,7 @@ ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersectio
|
||||
|
||||
/* if node is leaf, fetch triangle list */
|
||||
if(nodeAddr < 0) {
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+(BVH_NODE_SIZE-1));
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+3);
|
||||
int primAddr = __float_as_int(leaf.x);
|
||||
|
||||
#if FEATURE(BVH_INSTANCING)
|
||||
|
@ -238,7 +238,7 @@ ccl_device bool BVH_FUNCTION_NAME
|
||||
|
||||
/* if node is leaf, fetch triangle list */
|
||||
if(nodeAddr < 0) {
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+(BVH_NODE_SIZE-1));
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+3);
|
||||
int primAddr = __float_as_int(leaf.x);
|
||||
|
||||
#if FEATURE(BVH_INSTANCING)
|
||||
|
@ -182,7 +182,7 @@ ccl_device bool BVH_FUNCTION_NAME(KernelGlobals *kg,
|
||||
|
||||
/* if node is leaf, fetch triangle list */
|
||||
if(nodeAddr < 0) {
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+(BVH_NODE_SIZE-1));
|
||||
float4 leaf = kernel_tex_fetch(__bvh_nodes, (-nodeAddr-1)*BVH_NODE_SIZE+3);
|
||||
int primAddr = __float_as_int(leaf.x);
|
||||
|
||||
#if FEATURE(BVH_INSTANCING)
|
||||
|
Loading…
Reference in New Issue
Block a user