clray
diff rt.cl @ 35:7d77ded5f890
stopped using a heap to flatten the kdtree. added explicit left/right indices
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 26 Aug 2010 20:24:07 +0100 |
parents | 92786fc3317e |
children | 980bc07be868 |
line diff
1.1 --- a/rt.cl Tue Aug 24 05:47:04 2010 +0100 1.2 +++ b/rt.cl Thu Aug 26 20:24:07 2010 +0100 1.3 @@ -62,7 +62,8 @@ 1.4 struct AABBox aabb; 1.5 int face_idx[32]; 1.6 int num_faces; 1.7 - int padding[3]; 1.8 + int left, right; 1.9 + int padding; 1.10 }; 1.11 1.12 #define MIN_ENERGY 0.001 1.13 @@ -117,9 +118,9 @@ 1.14 ray.origin = sp.pos; 1.15 ray.dir = reflect(-ray.dir, sp.norm); 1.16 1.17 - energy *= sp.mat.ks * sp.mat.kr; 1.18 + energy *= refl_col; 1.19 } else { 1.20 - iter = INT_MAX - 1; // to break out of the loop 1.21 + break; 1.22 } 1.23 } 1.24 1.25 @@ -171,7 +172,7 @@ 1.26 1.27 int idxstack[STACK_SIZE]; 1.28 int top = 0; // points after the topmost element of the stack 1.29 - idxstack[top++] = 1; // root at tree[1] (heap) 1.30 + idxstack[top++] = 0; // root at tree[0] 1.31 1.32 while(top > 0) { 1.33 int idx = idxstack[--top]; // remove this index from the stack and process it 1.34 @@ -186,7 +187,7 @@ 1.35 }*/ 1.36 1.37 if(intersect_aabb(ray, node->aabb)) { 1.38 - if(node->num_faces >= 0) { 1.39 + if(node->left == -1) { 1.40 // leaf node... check each face in turn and update the nearest intersection as needed 1.41 for(int i=0; i<node->num_faces; i++) { 1.42 struct SurfPoint spt; 1.43 @@ -199,10 +200,10 @@ 1.44 } else { 1.45 // internal node... recurse to the children 1.46 /*if(get_global_id(0) == 0) { 1.47 - printf("pushing %d's children %d and %d\n", idx, idx * 2, idx * 2 + 1); 1.48 + printf("pushing %d's children %d and %d\n", idx, node->left, node->right); 1.49 }*/ 1.50 - idxstack[top++] = idx * 2; 1.51 - idxstack[top++] = idx * 2 + 1; 1.52 + idxstack[top++] = node->left; 1.53 + idxstack[top++] = node->right; 1.54 } 1.55 } 1.56 }