[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20617] branches/soc-2009-jaguarandi/ source/blender/render/intern/source: *enabled mirror rays again

André Pinto andresusanopinto at gmail.com
Thu Jun 4 01:56:07 CEST 2009


Revision: 20617
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20617
Author:   jaguarandi
Date:     2009-06-04 01:56:04 +0200 (Thu, 04 Jun 2009)

Log Message:
-----------
*enabled mirror rays again
	*octree is fine
	*bvh tree gives bad results

Modified Paths:
--------------
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_octree.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c

Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c	2009-06-03 23:33:56 UTC (rev 20616)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c	2009-06-03 23:56:04 UTC (rev 20617)
@@ -250,16 +250,9 @@
 		}
 #endif
 
-/*
-		TODO
-		if(is->mode!=RE_RAY_SHADOW) {
-			/ * for mirror & tra-shadow: large faces can be filled in too often, this prevents
-			   a face being detected too soon... * /
-			if(is->labda > is->ddalabda) {
-				return 0;
-			}
-		}
-*/		
+		if(is->mode!=RE_RAY_SHADOW && labda > is->labda)
+			return 0;
+
 		is->isect= ok;	// wich half of the quad
 		is->labda= labda;
 		is->u= u; is->v= v;
@@ -280,14 +273,13 @@
 	if(casted_rays++ % (1<<20) == 0)
 		printf("Casting %d rays\n", casted_rays);
 
-	i->vec[0] *= i->labda;
+/*	i->vec[0] *= i->labda;
 	i->vec[1] *= i->labda;
 	i->vec[2] *= i->labda;
-	i->labda = 1.0f; //RE_RAYTRACE_MAXDIST; //len;
-	i->dist = VecLength(i->vec);
+	i->labda = 1.0f;
+*/
+//	i->dist = VecLength(i->vec);
 	
-		
-	assert(i->mode==RE_RAY_SHADOW);
 	if(i->mode==RE_RAY_SHADOW && i->last_hit && RE_rayobject_intersect(i->last_hit, i))
 		return 1;
 

Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_octree.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_octree.c	2009-06-03 23:33:56 UTC (rev 20616)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_octree.c	2009-06-03 23:56:04 UTC (rev 20617)
@@ -664,7 +664,7 @@
 			RayObject *face = no->v[nr];
 			OcVal 		*ov = no->ov+nr;
 			
-			if(!face) break; //TODO? return 0;
+			if(!face) break;
 			
 			if( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) )
 			{
@@ -675,30 +675,20 @@
 	}
 	else
 	{			/* else mirror or glass or shadowtra, return closest face  */
-		Isect isect;
 		int found= 0;
 		
-		assert(0);
-		
-		is->labda= 1.0f;	/* needed? */
-		isect= *is;			/* copy for sorting */
-		
 		for(; no; no = no->next)
 		for(nr=0; nr<8; nr++)
 		{
 			RayObject *face = no->v[nr];
 			OcVal 		*ov = no->ov+nr;
 			
-			if(!face) return 0;
+			if(!face) break;
 			
 			if( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) )
 			{ 
-
 				if( RE_rayobject_intersect(face,is) )
-					if(isect.labda<is->labda) {
-						*is= isect;
-						found= 1;
-					}
+					found= 1;
 			}
 		}
 		
@@ -848,22 +838,6 @@
 	is->userdata= oc->userdata;
 #endif
 
-#if 0
-	/* only for shadow! */
-	if(is->mode==RE_RAY_SHADOW) {
-	
-		/* TODO check with last intersected shadow face */
-		if(is->last.face!=NULL && !(is->last.face==is->orig.face && is->last.ob==is->orig.ob)) {
-			if(checkfunc(is, is->last.ob, is->last.face)) {
-				is->ob= is->last.ob;
-				is->face= is->last.face;
-				VECSUB(is->vec, is->end, is->start);
-				if(RE_ray_face_intersection(is, oc->transformfunc, oc->coordsfunc)) return 1;
-			}
-		}
-	}
-#endif
-	
 	VECADDFAC( end, is->start, is->vec, is->labda );
 	ldx= end[0] - is->start[0];
 	u1= 0.0f;
@@ -880,6 +854,10 @@
 						if(cliptest(ldz, oc->max[2]-is->start[2], &u1,&u2)) {
 							c1=1;
 							if(u2<1.0f) {
+								is->vec[0] = u2*ldx;
+								is->vec[1] = u2*ldy;
+								is->vec[2] = u2*ldz;
+
 								end[0]= is->start[0]+u2*ldx;
 								end[1]= is->start[1]+u2*ldy;
 								end[2]= is->start[2]+u2*ldz;
@@ -917,16 +895,6 @@
 	ocy2= (int)oy2;
 	ocz2= (int)oz2;
 	
-//	for(ocx1=0; ocx1<oc->ocres; ocx1++)
-//	for(ocy1=0; ocy1<oc->ocres; ocy1++)
-//	for(ocz1=0; ocz1<oc->ocres; ocz1++)
-//	{
-//		no= ocread(oc, ocx1, ocy1, ocz1);
-//		if( testnode(oc, is, no, ocval) ) return 1;
-//	}
-
-//	return 0;
-
 	if(ocx1==ocx2 && ocy1==ocy2 && ocz1==ocz2) {
 		no= ocread(oc, ocx1, ocy1, ocz1);
 		if(no) {
@@ -934,7 +902,7 @@
 			vec1[0]= ox1; vec1[1]= oy1; vec1[2]= oz1;
 			vec2[0]= ox2; vec2[1]= oy2; vec2[2]= oz2;
 			calc_ocval_ray(&ocval, (float)ocx1, (float)ocy1, (float)ocz1, vec1, vec2);
-//			is->ddalabda= 1.0f;
+			is->labda = 1.0f;
 			if( testnode(oc, is, no, ocval) ) return 1;
 		}
 	}
@@ -1012,8 +980,8 @@
 				vec2[1]= oy1-ddalabda*doy;
 				vec2[2]= oz1-ddalabda*doz;
 				calc_ocval_ray(&ocval, (float)xo, (float)yo, (float)zo, vec1, vec2);
-							   
-//				is->ddalabda= ddalabda;
+
+				is->labda= ddalabda;
 				if( testnode(oc, is, no, ocval) ) return 1;
 			}
 

Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c	2009-06-03 23:33:56 UTC (rev 20616)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c	2009-06-03 23:56:04 UTC (rev 20617)
@@ -146,8 +146,8 @@
 	}
 	
 	printf("RE_rayobject_*_create( %d )\n", totface);
-//	re->raytree = RE_rayobject_octree_create( re->r.ocres, totface );
-	re->raytree = RE_rayobject_bvh_create( totface );
+	re->raytree = RE_rayobject_octree_create( re->r.ocres, totface );
+//	re->raytree = RE_rayobject_bvh_create( totface );
 	
 	//Fill rayfaces
 	re->rayfaces = (RayObject*)MEM_callocN(totface*sizeof(RayFace), "render faces");
@@ -424,8 +424,6 @@
 	float ref[3];
 	float dist_mir = origshi->mat->dist_mir;
 
-	assert(0);
-
 	/* Warning, This is not that nice, and possibly a bit slow for every ray,
 	however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
 	memset(&shi, 0, sizeof(ShadeInput)); 





More information about the Bf-blender-cvs mailing list