[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22387] branches/soc-2009-jaguarandi/ source/blender/render/intern: *Instance support is only enabled if target mesh uses more than 4 faces
Andre Susano Pinto
andresusanopinto at gmail.com
Wed Aug 12 04:00:54 CEST 2009
Revision: 22387
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22387
Author: jaguarandi
Date: 2009-08-12 04:00:44 +0200 (Wed, 12 Aug 2009)
Log Message:
-----------
*Instance support is only enabled if target mesh uses more than 4 faces
if theres very few faces its not worth it to create a separated tree for beinng reused.
should speedup some particle renders.
This "fixes" a bug relationed with a arithmetic precision on instances and raytrace of very close objects
which usually happens on rendering (almost) overlapping alpha-enabled leafs/feathers
Modified Paths:
--------------
branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h
branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h 2009-08-11 20:48:19 UTC (rev 22386)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h 2009-08-12 02:00:44 UTC (rev 22387)
@@ -78,9 +78,11 @@
*/
/* defines where coordinates of rayface primitives are stored */
-//#define RE_RAYFACE_COORDS_LOCAL
+#define RE_RAYFACE_COORDS_LOCAL
+
+//(ATM this won't work good with all types of instances)
//#define RE_RAYFACE_COORDS_POINTER
-#define RE_RAYFACE_COORDS_VLAKREN
+//#define RE_RAYFACE_COORDS_VLAKREN
typedef struct RayFace
{
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-08-11 20:48:19 UTC (rev 22386)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-08-12 02:00:44 UTC (rev 22387)
@@ -188,6 +188,7 @@
#ifdef RE_RAYFACE_COORDS_VLAKREN
{
VlakRen *vlr = (VlakRen*)face->face;
+
VECCOPY(co1, vlr->v1->co);
VECCOPY(co2, vlr->v2->co);
if(vlr->v4)
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c 2009-08-11 20:48:19 UTC (rev 22386)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c 2009-08-12 02:00:44 UTC (rev 22387)
@@ -180,6 +180,7 @@
return 0;
}
+
RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi)
{
//TODO
@@ -283,6 +284,26 @@
re->stats_draw(re->sdh, &re->i);
}
+static int has_special_rayobject(Render *re, ObjectInstanceRen *obi)
+{
+ if( (obi->flag & R_TRANSFORMED) )
+ {
+ ObjectRen *obr = obi->obr;
+ int v, faces = 0;
+
+ for(v=0;v<obr->totvlak;v++)
+ {
+ VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
+ if(is_raytraceable_vlr(re, vlr))
+ {
+ faces++;
+ if(faces > 4)
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
/*
* create a single raytrace structure with all faces
*/
@@ -300,7 +321,7 @@
ObjectRen *obr = obi->obr;
obs++;
- if(obi->flag & R_TRANSFORMED)
+ if(has_special_rayobject(re, obi))
{
faces++;
}
@@ -326,7 +347,7 @@
for(obi=re->instancetable.first; obi; obi=obi->next)
if(is_raytraceable(re, obi))
{
- if(obi->flag & R_TRANSFORMED)
+ if(has_special_rayobject(re, obi))
{
RayObject *obj = makeraytree_object(re, obi);
RE_rayobject_add( re->raytree, obj );
@@ -342,6 +363,15 @@
if(is_raytraceable_vlr(re, vlr))
{
RE_rayface_from_vlak(face, obi, vlr);
+ if((obi->flag & R_TRANSFORMED))
+ {
+ Mat4MulVecfl(obi->mat, face->v1);
+ Mat4MulVecfl(obi->mat, face->v2);
+ Mat4MulVecfl(obi->mat, face->v3);
+ if(RE_rayface_isQuad(face))
+ Mat4MulVecfl(obi->mat, face->v4);
+ }
+
RE_rayobject_add( raytree, RayObject_unalignRayFace(face) );
face++;
}
More information about the Bf-blender-cvs
mailing list