[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20651] branches/soc-2009-jaguarandi/ source/blender/render/intern/source: Fixed reflections on bvh tree
André Pinto
andresusanopinto at gmail.com
Fri Jun 5 16:44:54 CEST 2009
Revision: 20651
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20651
Author: jaguarandi
Date: 2009-06-05 16:44:54 +0200 (Fri, 05 Jun 2009)
Log Message:
-----------
Fixed reflections on bvh tree
(its kinda of a hackish-fix.. must be improved later)
Modified Paths:
--------------
branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.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-05 14:06:29 UTC (rev 20650)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-06-05 14:44:54 UTC (rev 20651)
@@ -273,12 +273,12 @@
if(casted_rays++ % (1<<20) == 0)
printf("Casting %d rays\n", casted_rays);
-/* i->vec[0] *= i->labda;
+ i->labda = 10000.0;
+ i->vec[0] *= i->labda;
i->vec[1] *= i->labda;
i->vec[2] *= i->labda;
i->labda = 1.0f;
-*/
-// i->dist = VecLength(i->vec);
+ i->dist = VecLength(i->vec);
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_bvh.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c 2009-06-05 14:06:29 UTC (rev 20650)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c 2009-06-05 14:44:54 UTC (rev 20651)
@@ -55,6 +55,7 @@
{
RayObject rayobj;
BVHTree *bvh;
+ float bb[2][3];
} BVHObject;
@@ -65,36 +66,42 @@
assert( RayObject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */
obj->rayobj.api = &bvh_api;
- obj->bvh = BLI_bvhtree_new(size, 0.0, 2, 6);
+ obj->bvh = BLI_bvhtree_new(size, FLT_EPSILON, 2, 6);
+ INIT_MINMAX(obj->bb[0], obj->bb[1]);
return RayObject_unalign((RayObject*) obj);
}
static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
{
- Isect *isect = (Isect*)userdata;
+ Isect *isec = (Isect*)userdata;
RayObject *face = (RayObject*)index;
- if(RE_rayobject_intersect(face,isect))
+ if(RE_rayobject_intersect(face,isec))
{
hit->index = index;
- if(isect->mode == RE_RAY_SHADOW)
+ if(isec->mode == RE_RAY_SHADOW)
hit->dist = 0;
+// TODO
+// else
+// hit->dist = isec->labda;
}
}
static int RayObject_bvh_intersect(RayObject *o, Isect *isec)
{
BVHObject *obj = (BVHObject*)o;
-// float dir[3];
-// VECCOPY( dir, isec->vec );
-// Normalize( dir );
BVHTreeRayHit hit;
+ float dir[3];
+
+ VECCOPY(dir, isec->vec);
+ Normalize(dir);
+
hit.index = 0;
- hit.dist = isec->labda*isec->dist;
+ hit.dist = FLT_MAX; //TODO isec->labda;
- return BLI_bvhtree_ray_cast(obj->bvh, isec->start, isec->vec, 0.0, &hit, bvh_callback, isec) != 0;
+ return BLI_bvhtree_ray_cast(obj->bvh, isec->start, dir, 0.0, &hit, bvh_callback, isec);
}
static void RayObject_bvh_add(RayObject *o, RayObject *ob)
@@ -102,8 +109,12 @@
BVHObject *obj = (BVHObject*)o;
float min_max[6];
INIT_MINMAX(min_max, min_max+3);
- RE_rayobject_merge_bb(ob, min_max, min_max+3);
- BLI_bvhtree_insert(obj->bvh, (int)ob, min_max, 2 );
+ RE_rayobject_merge_bb(ob, min_max, min_max+3);
+
+ DO_MINMAX(min_max , obj->bb[0], obj->bb[1]);
+ DO_MINMAX(min_max+3, obj->bb[0], obj->bb[1]);
+
+ BLI_bvhtree_insert(obj->bvh, (int)ob, min_max, 2 );
}
static void RayObject_bvh_done(RayObject *o)
@@ -124,5 +135,7 @@
static void RayObject_bvh_bb(RayObject *o, float *min, float *max)
{
- assert(0);
+ BVHObject *obj = (BVHObject*)o;
+ DO_MINMAX( obj->bb[0], min, max );
+ DO_MINMAX( obj->bb[1], min, max );
}
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-05 14:06:29 UTC (rev 20650)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c 2009-06-05 14:44:54 UTC (rev 20651)
@@ -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");
@@ -433,6 +433,7 @@
VECCOPY(isec.vec, vec );
isec.labda = dist_mir > 0 ? dist_mir : RE_RAYTRACE_MAXDIST;
isec.mode= RE_RAY_MIRROR;
+ isec.skip = RE_SKIP_VLR_NEIGHBOUR;
isec.orig.ob = obi;
isec.orig.face = vlr;
More information about the Bf-blender-cvs
mailing list