clray

diff rt.cl @ 30:04803c702014

debugging ...
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Aug 2010 23:57:19 +0100
parents 353d80127627
children 92786fc3317e
line diff
     1.1 --- a/rt.cl	Sat Aug 21 20:51:57 2010 +0100
     1.2 +++ b/rt.cl	Sat Aug 21 23:57:19 2010 +0100
     1.3 @@ -98,6 +98,7 @@
     1.4  	scn.lights = lights;
     1.5  	scn.num_lights = rinf->num_lights;
     1.6  	scn.matlib = matlib;
     1.7 +	scn.kdtree = kdtree;
     1.8  
     1.9  	struct Ray ray = primrays[idx];
    1.10  	transform_ray(&ray, xform, invtrans);
    1.11 @@ -161,7 +162,7 @@
    1.12  	return dcol + scol;
    1.13  }
    1.14  
    1.15 -#define STACK_SIZE	128
    1.16 +#define STACK_SIZE	64
    1.17  bool find_intersection(struct Ray ray, const struct Scene *scn, struct SurfPoint *spres)
    1.18  {
    1.19  	struct SurfPoint sp0;
    1.20 @@ -172,14 +173,17 @@
    1.21  	int sp = 0;			// points at the topmost element of the stack
    1.22  	idxstack[sp] = 1;	// root at tree[1] (heap)
    1.23  
    1.24 +	printf("check intersection\n");
    1.25 +
    1.26  	while(sp >= 0) {
    1.27  		int idx = idxstack[sp--];	// remove this index from the stack and process it
    1.28  
    1.29  		global struct KDNode *node = scn->kdtree + idx;
    1.30 +		printf("idx: %d (%p) num_faces: %d\n", idx, node, node->num_faces);
    1.31  
    1.32  		if(intersect_aabb(ray, node->aabb)) {
    1.33  			// leaf node ...
    1.34 -			if(node->num_faces) {
    1.35 +			if(node->num_faces >= 0) {
    1.36  				// check each face in turn and update the nearest intersection as needed
    1.37  				for(int i=0; i<node->num_faces; i++) {
    1.38  					struct SurfPoint sp;