diff options
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 34 |
2 files changed, 25 insertions, 10 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index d7e71b3e531..8414b6aefe3 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -499,6 +499,7 @@ typedef struct LampRen { #define R_NEED_TANGENT 32 #define R_SKIP_MULTIRES 64 #define R_BAKE_TRACE 128 +#define R_BAKING 256 /* vlakren->flag (vlak = face in dutch) char!!! */ #define R_SMOOTH 1 diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index dbade68ba1d..bef3690a43a 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3935,7 +3935,7 @@ static void set_fullsample_flag(Render *re, ObjectRen *obr) } } -static void check_non_flat_quads(ObjectRen *obr) +static void check_non_flat_quads(ObjectRen *obr, int quad_flip) { VlakRen *vlr, *vlr1; VertRen *v1, *v2, *v3, *v4; @@ -3997,20 +3997,27 @@ static void check_non_flat_quads(ObjectRen *obr) xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; if(ABS(xn) < 0.999995 ) { // checked on noisy fractal grid + float d1, d2; vlr1= RE_vlakren_copy(obr, vlr); vlr1->flag |= R_FACE_SPLIT; - /* split direction based on vnorms */ - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, nor); - d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2]; + if (quad_flip==0) { /* nonzero quad_flip is used to force dividing one way */ + /* split direction based on vnorms */ + CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, nor); + d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2]; - CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, nor); - d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2]; + CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, nor); + d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2]; - if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; - else vlr->flag &= ~R_DIVIDE_24; + if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; + else vlr->flag &= ~R_DIVIDE_24; + } else if (quad_flip==1) { + vlr->flag &= ~R_DIVIDE_24; + } else { /* quad_flip == 3 */ + vlr->flag |= R_DIVIDE_24; + } /* new vertex pointers */ if (vlr->flag & R_DIVIDE_24) { @@ -4064,8 +4071,14 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset) ob->smoothresh= 0.0; if((re->r.mode & R_RAYTRACE) && (re->r.mode & R_SHADOW)) set_phong_threshold(obr); - - check_non_flat_quads(obr); + + if (re->flag & R_BAKING) { + /* Baking lets us define a quad split order */ + check_non_flat_quads(obr, re->r.bake_quad_split); + } else { + check_non_flat_quads(obr, 0); + } + set_fullsample_flag(re, obr); /* compute bounding boxes for clipping */ @@ -5421,6 +5434,7 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob) RE_init_threadcount(re); re->flag |= R_GLOB_NOPUNOFLIP; + re->flag |= R_BAKING; re->excludeob= actob; if(type == RE_BAKE_LIGHT) re->flag |= R_SKIP_MULTIRES; |