[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20525] branches/soc-2009-jaguarandi/ source/blender/render: *Some debug
André Pinto
andresusanopinto at gmail.com
Sun May 31 04:35:59 CEST 2009
Revision: 20525
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20525
Author: jaguarandi
Date: 2009-05-31 04:35:58 +0200 (Sun, 31 May 2009)
Log Message:
-----------
*Some debug
*Some more integration with bli bvh (just testing stuff)
Modified Paths:
--------------
branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h
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/extern/include/RE_raytrace.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h 2009-05-31 01:33:44 UTC (rev 20524)
+++ branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h 2009-05-31 02:35:58 UTC (rev 20525)
@@ -45,6 +45,7 @@
/* RayObject constructors */
RayObject* RE_rayobject_octree_create(int ocres, int size);
+RayObject* RE_rayobject_bvh_create(int size);
//RayObject* RayObject_derivedmesh_create(struct DerivedMesh*, void *ob);
RayObject* RE_rayobject_mesh_create(struct Mesh*, void *ob);
@@ -54,9 +55,12 @@
{
float start[3];
float vec[3];
+ float labda;
+
+ float dist; /* length of vec, configured by RE_rayobject_raycast */
/* float end[3]; - not used */
- float labda, u, v;
+ float u, v;
struct
{
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-05-31 01:33:44 UTC (rev 20524)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-05-31 02:35:58 UTC (rev 20525)
@@ -27,8 +27,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <assert.h>
+#include <stdio.h>
#include "BKE_utildefines.h"
+#include "BLI_arithb.h"
#include "RE_raytrace.h"
#include "render_types.h"
@@ -264,6 +266,7 @@
is->hit.ob = face->ob;
is->hit.face = face->face;
+ is->last_hit = (RayObject*)face;
return 1;
}
@@ -272,6 +275,19 @@
int RE_rayobject_raycast(RayObject *r, Isect *i)
{
+ static int casted_rays = 0;
+
+ if(casted_rays++ % (1<<20) == 0)
+ printf("Casting %d rays\n", casted_rays);
+
+ 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);
+
+
+ assert(i->mode==RE_RAY_SHADOW);
if(i->mode==RE_RAY_SHADOW && i->last_hit && RE_rayobject_intersect(i->last_hit, i))
return 1;
@@ -280,27 +296,14 @@
int RE_rayobject_intersect(RayObject *r, Isect *i)
{
- assert(i->mode==RE_RAY_SHADOW);
if(RayObject_isFace(r))
{
return intersect_rayface( (RayFace*) r, i);
}
else
{
- //TODO should be done somewhere else
-// float len = Normalize( i->vec );
- int hit;
- i->vec[0] *= i->labda;
- i->vec[1] *= i->labda;
- i->vec[2] *= i->labda;
- i->labda = 1.0f; //RE_RAYTRACE_MAXDIST; //len;
-
r = RayObject_align( r );
-
- hit = r->api->raycast( r, i );
-// i->labda /= len;
-
- return hit;
+ return r->api->raycast( r, i );
}
}
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-05-31 01:33:44 UTC (rev 20524)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c 2009-05-31 02:35:58 UTC (rev 20525)
@@ -65,7 +65,7 @@
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, 4, 6);
+ obj->bvh = BLI_bvhtree_new(size, 0.0, 2, 6);
return RayObject_unalign((RayObject*) obj);
}
@@ -78,19 +78,23 @@
if(RE_rayobject_intersect(face,isect))
{
hit->index = index;
-// hit.distance = TODO
+
+ if(isect->mode == RE_RAY_SHADOW)
+ hit->dist = 0;
}
}
static int RayObject_bvh_intersect(RayObject *o, Isect *isec)
{
BVHObject *obj = (BVHObject*)o;
- float dir[3];
- VECCOPY( dir, isec->vec );
- Normalize( dir );
+// float dir[3];
+// VECCOPY( dir, isec->vec );
+// Normalize( dir );
+ BVHTreeRayHit hit;
+ hit.index = 0;
+ hit.dist = isec->labda*isec->dist;
- //BLI_bvhtree_ray_cast returns -1 on non hit (in case we dont give a Hit structure
- return BLI_bvhtree_ray_cast(obj->bvh, isec->start, dir, 0.0, NULL, bvh_callback, isec) != -1;
+ return BLI_bvhtree_ray_cast(obj->bvh, isec->start, isec->vec, 0.0, &hit, bvh_callback, isec) != 0;
}
static void RayObject_bvh_add(RayObject *o, RayObject *ob)
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c 2009-05-31 01:33:44 UTC (rev 20524)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c 2009-05-31 02:35:58 UTC (rev 20525)
@@ -122,6 +122,7 @@
double lasttime= PIL_check_seconds_timer();
int v, totv = 0, totface = 0;
RayFace *faces, *cur_face;
+ int tot_quads = 0;
//TODO (for now octree only supports RayFaces so we need to create them)
//
@@ -144,7 +145,9 @@
}
}
- re->raytree = RE_rayobject_octree_create( re->r.ocres, totface );
+ printf("RE_rayobject_*_create( %d )\n", 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");
@@ -182,7 +185,7 @@
cur_face->v1 = vlr->v1->co;
cur_face->v2 = vlr->v2->co;
cur_face->v3 = vlr->v3->co;
- cur_face->v4 = vlr->v4 ? vlr->v4->co : NULL;
+ cur_face->v4 = vlr->v4 ? tot_quads++, vlr->v4->co : NULL;
cur_face->ob = (void*)obi;
cur_face->face = vlr;
@@ -194,7 +197,9 @@
}
}
+ printf("call RE_rayobject_done( %dtri, %dquads )\n", totface-tot_quads, tot_quads);
RE_rayobject_done( re->raytree );
+ printf("return RE_rayobject_done( )\n");
//TODO vlr_face_coords, vlr_check_intersect, vlr_get_transform, re);
re->i.infostr= NULL;
More information about the Bf-blender-cvs
mailing list