diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-13 10:44:43 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-13 10:44:43 +0400 |
commit | 894c240f9d007271e9d587d3c1b6f961c445b1b8 (patch) | |
tree | 369079e17a0c80a5b39e323a67045ca397849491 /source/blender/render | |
parent | 2d801f2bec3c4de663f33b0f0f198a12f09ef989 (diff) |
New implementation of Freestyle edge/face marks
The previous implementation of Freestyle edge/face marks was refactored
based on suggestions from the latest code review by Campbell. The new
implementation relies on mesh CustomData to store edge/face marks, instead
of introducing extra flags in the core Mesh and BMesh data structures.
The CustomData-based implementation will allow further additions of new
edge/face attributes because of the independence from Mesh/BMesh.
This revision is work in progress, mainly intended to address the review
comments and ask for further code review in view of the trunk merger in
the upcoming 2.67 release.
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 51 |
2 files changed, 32 insertions, 20 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index deba6d165f2..f3cd60d8031 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -396,6 +396,7 @@ typedef struct VlakRen { char flag, ec; #ifdef WITH_FREESTYLE char freestyle_edge_mark; + char freestyle_face_mark; #endif int index; } VlakRen; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 496edae9a38..cbc357b3d60 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2657,6 +2657,9 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, MVert *mvert = NULL; MFace *mface; Material *ma; +#ifdef WITH_FREESTYLE + FreestyleFace *ffa; +#endif /* Curve *cu= ELEM(ob->type, OB_FONT, OB_CURVE) ? ob->data : NULL; */ mvert= dm->getVertArray(dm); @@ -2686,6 +2689,9 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, ma= give_render_material(re, ob, mat_iter+1); end= dm->getNumTessFaces(dm); mface= dm->getTessFaceArray(dm); +#ifdef WITH_FREESTYLE + ffa= dm->getTessFaceDataArray(dm, CD_FREESTYLE_FACE); +#endif for (a=0; a<end; a++, mface++) { int v1, v2, v3, v4, flag; @@ -2697,11 +2703,7 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, v2= mface->v2; v3= mface->v3; v4= mface->v4; -#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); @@ -2719,6 +2721,9 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, vlr->mat= ma; vlr->flag= flag; vlr->ec= 0; /* mesh edges rendered separately */ +#ifdef WITH_FREESTYLE + vlr->freestyle_face_mark= (ffa && (ffa[a].flag & FREESTYLE_FACE_MARK)) ? 1 : 0; +#endif if (len==0) obr->totvlak--; else { @@ -3227,14 +3232,21 @@ static void add_volume(Render *re, ObjectRen *obr, Material *ma) } #ifdef WITH_FREESTYLE -static EdgeHash *make_freestyle_edge_mark_hash(MEdge *medge, int totedge) +static EdgeHash *make_freestyle_edge_mark_hash(DerivedMesh *dm) { EdgeHash *edge_hash= BLI_edgehash_new(); - int a; - - for(a=0; a<totedge; a++) { - if(medge[a].flag & ME_FREESTYLE_EDGE) - BLI_edgehash_insert(edge_hash, medge[a].v1, medge[a].v2, medge+a); + FreestyleEdge *fed; + MEdge *medge; + int totedge, a; + + medge = dm->getEdgeArray(dm); + totedge = dm->getNumEdges(dm); + fed = dm->getEdgeDataArray(dm, CD_FREESTYLE_EDGE); + if (fed) { + for (a = 0; a < totedge; a++) { + if (fed[a].flag & FREESTYLE_EDGE_MARK) + BLI_edgehash_insert(edge_hash, medge[a].v1, medge[a].v2, medge+a); + } } return edge_hash; } @@ -3265,6 +3277,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int use_original_normals = FALSE; int recalc_normals = 0; /* false by default */ int negative_scale; +#ifdef WITH_FREESTYLE + FreestyleFace *ffa; +#endif me= ob->data; @@ -3392,13 +3407,9 @@ 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); + edge_hash = make_freestyle_edge_mark_hash(dm); #endif /* store customdata names, because DerivedMesh is freed */ @@ -3437,6 +3448,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if (ok) { end= dm->getNumTessFaces(dm); mface= dm->getTessFaceArray(dm); +#ifdef WITH_FREESTYLE + ffa= dm->getTessFaceDataArray(dm, CD_FREESTYLE_FACE); +#endif for (a=0; a<end; a++, mface++) { int v1, v2, v3, v4, flag; @@ -3449,11 +3463,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) v2= mface->v2; v3= reverse_verts==0 ? mface->v3 : mface->v1; v4= mface->v4; -#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); @@ -3463,7 +3473,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) else vlr->v4= 0; #ifdef WITH_FREESTYLE - /* Freestyle edge marks */ + /* Freestyle edge/face marks */ { int edge_mark = 0; @@ -3477,6 +3487,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) } vlr->freestyle_edge_mark= edge_mark; } + vlr->freestyle_face_mark= (ffa && (ffa[a].flag & FREESTYLE_FACE_MARK)) ? 1 : 0; #endif /* render normals are inverted in render */ |