diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-20 11:57:26 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-20 11:57:26 +0400 |
commit | a462d69bbf771e49d2fa49589608c375376b42ed (patch) | |
tree | 60d85d4131399a0a39dbc582e30a7144b14edc18 /source/blender/render/intern | |
parent | d433cd65f7127d60e17d05a824290423ad226eae (diff) |
Another big patch set by Bastien Montagne, thanks a lot!
* Made Freestyle optional (turned on by default).
* Fix for missing bpath.c updates in the previous merge of trunk changes.
Diffstat (limited to 'source/blender/render/intern')
5 files changed, 76 insertions, 27 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 45080de3148..c45c6dfc1bc 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -228,7 +228,9 @@ struct Render ListBase volumes; ListBase volume_precache_parts; +#ifdef WITH_FREESTYLE ListBase freestyle_renders; +#endif /* arena for allocating data for use during render, for * example dynamic TFaces to go in the VlakRen structure. @@ -382,7 +384,9 @@ typedef struct VlakRen { struct Material *mat; char puno; char flag, ec; +#ifdef WITH_FREESTYLE char freestyle_edge_mark; +#endif int index; } VlakRen; @@ -615,11 +619,13 @@ typedef struct LampRen { #define R_TRACEBLE 128 /* vlakren->freestyle_edge_mark */ -#define R_EDGE_V1V2 1 -#define R_EDGE_V2V3 2 -#define R_EDGE_V3V4 4 -#define R_EDGE_V3V1 4 -#define R_EDGE_V4V1 8 +#ifdef WITH_FREESTYLE +# define R_EDGE_V1V2 1 +# define R_EDGE_V2V3 2 +# define R_EDGE_V3V4 4 +# define R_EDGE_V3V1 4 +# define R_EDGE_V4V1 8 +#endif /* strandbuffer->flag */ #define R_STRAND_BSPLINE 1 diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index bc84661698f..08da5dff3e0 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -42,7 +42,9 @@ #include "BLI_memarena.h" #include "BLI_ghash.h" #include "BLI_linklist.h" -#include "BLI_edgehash.h" +#ifdef WITH_FREESTYLE +# include "BLI_edgehash.h" +#endif #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -2694,7 +2696,11 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, v2= mface->v2; v3= mface->v3; v4= mface->v4; - flag= mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE); +#ifdef WITH_FREESTYLE + flag = mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE); +#else + flag = mface->flag & ME_SMOOTH; +#endif vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= RE_findOrAddVert(obr, vertofs+v1); @@ -3219,6 +3225,7 @@ static void add_volume(Render *re, ObjectRen *obr, Material *ma) BLI_addtail(&re->volumes, vo); } +#ifdef WITH_FREESTYLE static EdgeHash *make_freestyle_edge_mark_hash(MEdge *medge, int totedge) { EdgeHash *edge_hash= BLI_edgehash_new(); @@ -3236,6 +3243,7 @@ static int has_freestyle_edge_mark(EdgeHash *edge_hash, int v1, int v2) MEdge *medge= BLI_edgehash_lookup(edge_hash, v1, v2); return (!medge) ? 0 : 1; } +#endif static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) { @@ -3356,14 +3364,16 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) } if (!timeoffset) { +#ifdef WITH_FREESTYLE EdgeHash *edge_hash; MEdge *medge; int totedge; /* create a hash table of Freestyle edge marks */ - medge= dm->getEdgeArray(dm); - totedge= dm->getNumEdges(dm); - edge_hash= make_freestyle_edge_mark_hash(medge, totedge); + medge = dm->getEdgeArray(dm); + totedge = dm->getNumEdges(dm); + edge_hash = make_freestyle_edge_mark_hash(medge, totedge); +#endif /* store customdata names, because DerivedMesh is freed */ RE_set_customdata_names(obr, &dm->faceData); @@ -3407,14 +3417,17 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if ( mface->mat_nr==a1 ) { float len; - int edge_mark= 0; int reverse_verts = (negative_scale != 0 && do_autosmooth == FALSE); int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3}; v1= reverse_verts==0 ? mface->v1 : mface->v3; v2= mface->v2; v3= reverse_verts==0 ? mface->v3 : mface->v1; v4= mface->v4; - flag= mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE); +#ifdef WITH_FREESTYLE + flag = mface->flag & (ME_SMOOTH | ME_FREESTYLE_FACE); +#else + flag = mface->flag & ME_SMOOTH; +#endif vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= RE_findOrAddVert(obr, vertofs+v1); @@ -3423,16 +3436,22 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if (v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4); else vlr->v4= 0; +#ifdef WITH_FREESTYLE /* Freestyle edge marks */ - if(has_freestyle_edge_mark(edge_hash, v1, v2)) edge_mark |= R_EDGE_V1V2; - if(has_freestyle_edge_mark(edge_hash, v2, v3)) edge_mark |= R_EDGE_V2V3; - if (!v4) { - if(has_freestyle_edge_mark(edge_hash, v3, v1)) edge_mark |= R_EDGE_V3V1; - } else { - if(has_freestyle_edge_mark(edge_hash, v3, v4)) edge_mark |= R_EDGE_V3V4; - if(has_freestyle_edge_mark(edge_hash, v4, v1)) edge_mark |= R_EDGE_V4V1; + { + int edge_mark = 0; + + if(has_freestyle_edge_mark(edge_hash, v1, v2)) edge_mark |= R_EDGE_V1V2; + if(has_freestyle_edge_mark(edge_hash, v2, v3)) edge_mark |= R_EDGE_V2V3; + if (!v4) { + if(has_freestyle_edge_mark(edge_hash, v3, v1)) edge_mark |= R_EDGE_V3V1; + } else { + if(has_freestyle_edge_mark(edge_hash, v3, v4)) edge_mark |= R_EDGE_V3V4; + if(has_freestyle_edge_mark(edge_hash, v4, v1)) edge_mark |= R_EDGE_V4V1; + } + vlr->freestyle_edge_mark= edge_mark; } - vlr->freestyle_edge_mark= edge_mark; +#endif /* render normals are inverted in render */ if (use_original_normals) { @@ -3501,8 +3520,10 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) } } +#ifdef WITH_FREESTYLE /* release the hash table of Freestyle edge marks */ BLI_edgehash_free(edge_hash, NULL); +#endif /* exception... we do edges for wire mode. potential conflict when faces exist... */ end= dm->getNumEdges(dm); @@ -4303,6 +4324,7 @@ static void check_non_flat_quads(ObjectRen *obr) normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co); normal_tri_v3(vlr1->n, vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); +#ifdef WITH_FREESTYLE /* Freestyle edge marks */ if (vlr->flag & R_DIVIDE_24) { vlr1->freestyle_edge_mark= @@ -4311,7 +4333,8 @@ static void check_non_flat_quads(ObjectRen *obr) vlr->freestyle_edge_mark= ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) | ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0); - } else { + } + else { vlr1->freestyle_edge_mark= ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0) | ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0); @@ -4319,6 +4342,7 @@ static void check_non_flat_quads(ObjectRen *obr) ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) | ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V2V3 : 0); } +#endif } /* clear the flag when not divided */ else vlr->flag &= ~R_DIVIDE_24; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 39df6a01f61..c7c5fcf354f 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -49,7 +49,6 @@ #include "BKE_camera.h" #include "BKE_global.h" #include "BKE_image.h" -#include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_pointcache.h" @@ -76,7 +75,10 @@ #include "RE_engine.h" #include "RE_pipeline.h" -#include "FRS_freestyle.h" +#ifdef WITH_FREESTYLE +# include "BKE_library.h" +# include "FRS_freestyle.h" +#endif /* internal */ #include "render_result.h" @@ -743,7 +745,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane) R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2; R.panodxv = (BLI_rctf_size_x(viewplane) * R.panodxp) / (float)(re->winx); - + /* shift viewplane */ R.viewplane.xmin = viewplane->xmin + R.panodxv; R.viewplane.xmax = viewplane->xmax + R.panodxv; @@ -943,7 +945,9 @@ void RE_TileProcessor(Render *re) /* ************ This part uses API, for rendering Blender scenes ********** */ +#ifdef WITH_FREESTYLE static void add_freestyle(Render *re); +#endif static void do_render_3d(Render *re) { @@ -985,10 +989,12 @@ static void do_render_3d(Render *re) if (!re->test_break(re->tbh)) add_halo_flare(re); +#ifdef WITH_FREESTYLE /* Freestyle */ if( re->r.mode & R_EDGE_FRS) if(!re->test_break(re->tbh)) add_freestyle(re); +#endif /* free all render verts etc */ RE_Database_Free(re); @@ -1429,6 +1435,7 @@ static void render_composit_stats(void *UNUSED(arg), char *str) R.i.infostr = NULL; } +#ifdef WITH_FREESTYLE /* invokes Freestyle stroke rendering */ static void add_freestyle(Render *re) { @@ -1495,7 +1502,7 @@ static void free_all_freestyle_renders(Scene *scene) BLI_freelistN( &re1->freestyle_renders ); } } - +#endif /* reads all buffers, calls optional composite, merges in first result->rectf */ static void do_merge_fullsample(Render *re, bNodeTree *ntree) @@ -1537,8 +1544,10 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) if (sample) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_exr_file_read(re1, sample); +#ifdef WITH_FREESTYLE if( re1->r.mode & R_EDGE_FRS) composite_freestyle_renders(re1, sample); +#endif BLI_rw_mutex_unlock(&re->resultmutex); } ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ @@ -1741,7 +1750,9 @@ static void do_render_composite_fields_blur_3d(Render *re) do_merge_fullsample(re, NULL); } +#ifdef WITH_FREESTYLE free_all_freestyle_renders(re->scene); +#endif /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay = render_get_active_layer(re, re->result); @@ -2190,7 +2201,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); do_render_all_options(re); - + if (write_still && !G.is_break) { if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { /* operator checks this but in case its called from elsewhere */ @@ -2214,6 +2225,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr G.is_rendering = FALSE; } +#ifdef WITH_FREESTYLE void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene) { re->result_ok= 0; @@ -2222,6 +2234,7 @@ void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene) } re->result_ok= 1; } +#endif static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const char *name_override) { diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index eb330177bac..1d84f0e5a94 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -57,7 +57,9 @@ #include "render_result.h" #include "render_types.h" -#include "FRS_freestyle_config.h" +#ifdef WITH_FREESTYLE +# include "FRS_freestyle_config.h" +#endif /********************************** Free *************************************/ @@ -566,7 +568,9 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rl->lay = (1 << 20) - 1; rl->layflag = 0x7FFF; /* solid ztra halo strand */ rl->passflag = SCE_PASS_COMBINED; +#ifdef WITH_FREESTYLE FRS_add_freestyle_config( srl ); +#endif re->r.actlay = 0; } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index a425d9a330b..c9c8501a3a4 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1713,12 +1713,14 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if (ma->mode & (MA_FACETEXTURE_ALPHA)) shi->alpha= shi->vcol[3]; } +#ifdef WITH_FREESTYLE else if (ma->vcol_alpha) { shi->r= shi->vcol[0]; shi->g= shi->vcol[1]; shi->b= shi->vcol[2]; shi->alpha= shi->vcol[3]; } +#endif else if (ma->mode & (MA_VERTEXCOLP)) { float neg_alpha = 1.0f - shi->vcol[3]; shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3]; |