*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
This commit is contained in:
@@ -78,9 +78,11 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* 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
|
||||
{
|
||||
|
||||
@@ -188,6 +188,7 @@ static int intersect_rayface(RayFace *face, Isect *is)
|
||||
#ifdef RE_RAYFACE_COORDS_VLAKREN
|
||||
{
|
||||
VlakRen *vlr = (VlakRen*)face->face;
|
||||
|
||||
VECCOPY(co1, vlr->v1->co);
|
||||
VECCOPY(co2, vlr->v2->co);
|
||||
if(vlr->v4)
|
||||
|
||||
@@ -180,6 +180,7 @@ static int is_raytraceable(Render *re, ObjectInstanceRen *obi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi)
|
||||
{
|
||||
//TODO
|
||||
@@ -283,6 +284,26 @@ static void makeraytree_hier(Render *re)
|
||||
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 @@ static void makeraytree_single(Render *re)
|
||||
ObjectRen *obr = obi->obr;
|
||||
obs++;
|
||||
|
||||
if(obi->flag & R_TRANSFORMED)
|
||||
if(has_special_rayobject(re, obi))
|
||||
{
|
||||
faces++;
|
||||
}
|
||||
@@ -326,7 +347,7 @@ static void makeraytree_single(Render *re)
|
||||
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 @@ static void makeraytree_single(Render *re)
|
||||
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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user