clray

changeset 30:04803c702014

debugging ...
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Aug 2010 23:57:19 +0100
parents 353d80127627
children 92786fc3317e
files rt.cl src/scene.cc
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
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;
     2.1 --- a/src/scene.cc	Sat Aug 21 20:51:57 2010 +0100
     2.2 +++ b/src/scene.cc	Sat Aug 21 23:57:19 2010 +0100
     2.3 @@ -474,6 +474,8 @@
     2.4  		assert(node->right);
     2.5  		kdtree_gpu_flatten(kdbuf, idx * 2, node->left, facebuf);
     2.6  		kdtree_gpu_flatten(kdbuf, idx * 2 + 1, node->right, facebuf);
     2.7 +	} else {
     2.8 +		dest->num_faces = -1;
     2.9  	}
    2.10  }
    2.11  
    2.12 @@ -481,10 +483,10 @@
    2.13  {
    2.14  	if(!node) return;
    2.15  
    2.16 -	/*for(int i=0; i<level; i++) {
    2.17 +	for(int i=0; i<level; i++) {
    2.18  		fputs("   ", stdout);
    2.19  	}
    2.20 -	printf("- %d (cost: %f)\n", node->num_faces, node->cost);*/
    2.21 +	printf("- %d (cost: %f)\n", node->num_faces, node->cost);
    2.22  
    2.23  	print_item_counts(node->left, level + 1);
    2.24  	print_item_counts(node->right, level + 1);