diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 34 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 4 |
4 files changed, 30 insertions, 11 deletions
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 7b1b979b777..aae8a697cbe 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -274,7 +274,7 @@ typedef struct RenderData { /* Bake Render options */ short bake_osa, bake_filter, bake_mode, bake_flag; - short bake_normal_space, bpad; + short bake_normal_space, bake_quad_split; float bake_maxdist, bake_biasdist, bake_pad; /* yafray: global panel params. TODO: move elsewhere */ 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; diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index b98a8c58102..cc26f1fc2bf 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -2150,6 +2150,10 @@ static void render_panel_bake(void) "Normalized displacement value to fit the 'Dist' range" ); } + + uiDefButS(block, MENU, B_NOP, "Quad Split Order%t|Quad Split Auto%x0|Quad Split A (0,1,2) (0,2,3)%x1|Quad Split B (1,2,3) (1,3,0)%x2", + 10,30,190,20, &G.scene->r.bake_quad_split, 0, 0, 0, 0, "Method to divide quads (use A or B for external applications that use a fixed order)"); + #if 0 uiBlockBeginAlign(block); uiDefButBitS(block, TOG, R_BAKE_OSA, B_DIFF, "OSA", 10,120,190,20, &G.scene->r.bake_flag, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)"); |