# HG changeset patch # User John Tsiombikas # Date 1282431439 -3600 # Node ID 04803c7020148b13a49505ffb186c69c51801763 # Parent 353d801276278a170fa07784877bd5a4b450151a debugging ... diff -r 353d80127627 -r 04803c702014 rt.cl --- a/rt.cl Sat Aug 21 20:51:57 2010 +0100 +++ b/rt.cl Sat Aug 21 23:57:19 2010 +0100 @@ -98,6 +98,7 @@ scn.lights = lights; scn.num_lights = rinf->num_lights; scn.matlib = matlib; + scn.kdtree = kdtree; struct Ray ray = primrays[idx]; transform_ray(&ray, xform, invtrans); @@ -161,7 +162,7 @@ return dcol + scol; } -#define STACK_SIZE 128 +#define STACK_SIZE 64 bool find_intersection(struct Ray ray, const struct Scene *scn, struct SurfPoint *spres) { struct SurfPoint sp0; @@ -172,14 +173,17 @@ int sp = 0; // points at the topmost element of the stack idxstack[sp] = 1; // root at tree[1] (heap) + printf("check intersection\n"); + while(sp >= 0) { int idx = idxstack[sp--]; // remove this index from the stack and process it global struct KDNode *node = scn->kdtree + idx; + printf("idx: %d (%p) num_faces: %d\n", idx, node, node->num_faces); if(intersect_aabb(ray, node->aabb)) { // leaf node ... - if(node->num_faces) { + if(node->num_faces >= 0) { // check each face in turn and update the nearest intersection as needed for(int i=0; inum_faces; i++) { struct SurfPoint sp; diff -r 353d80127627 -r 04803c702014 src/scene.cc --- a/src/scene.cc Sat Aug 21 20:51:57 2010 +0100 +++ b/src/scene.cc Sat Aug 21 23:57:19 2010 +0100 @@ -474,6 +474,8 @@ assert(node->right); kdtree_gpu_flatten(kdbuf, idx * 2, node->left, facebuf); kdtree_gpu_flatten(kdbuf, idx * 2 + 1, node->right, facebuf); + } else { + dest->num_faces = -1; } } @@ -481,10 +483,10 @@ { if(!node) return; - /*for(int i=0; inum_faces, node->cost);*/ + printf("- %d (cost: %f)\n", node->num_faces, node->cost); print_item_counts(node->left, level + 1); print_item_counts(node->right, level + 1);