From 788fb8321a027eb4e635545dabc8c97ae164f984 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 25 Dec 2014 00:14:12 +0500 Subject: [PATCH] Cycles: Store proper empty boundbox for missing child nodes in QBVH The idea is to make sure those childs would never be intersected with a ray in order to make it so kernel never worries about number of child nodes. --- intern/cycles/bvh/bvh.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 8b1759ef6a4..b591d5973fe 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -721,13 +721,17 @@ void QBVH::pack_inner(const BVHStackEntry& e, const BVHStackEntry *en, int num) } for(int i = num; i < 4; i++) { - data[0][i] = 0.0f; - data[1][i] = 0.0f; - data[2][i] = 0.0f; + /* We store BB which would never be recorded as intersection + * so kernel might safely assume there are always 4 child nodes. + */ + data[0][i] = FLT_MAX; + data[1][i] = -FLT_MAX; - data[3][i] = 0.0f; - data[4][i] = 0.0f; - data[5][i] = 0.0f; + data[2][i] = FLT_MAX; + data[3][i] = -FLT_MAX; + + data[4][i] = FLT_MAX; + data[5][i] = -FLT_MAX; data[6][i] = __int_as_float(0); }