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/bmesh/intern/bmesh_mesh_conv.c | |
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/bmesh/intern/bmesh_mesh_conv.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 6697430a88d..4c0c1507dbf 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -112,6 +112,7 @@ void BM_mesh_cd_flag_apply(BMesh *bm, const char cd_flag) /* CustomData_bmesh_init_pool() must run first */ BLI_assert(bm->vdata.totlayer == 0 || bm->vdata.pool != NULL); BLI_assert(bm->edata.totlayer == 0 || bm->edata.pool != NULL); + BLI_assert(bm->pdata.totlayer == 0 || bm->pdata.pool != NULL); if (cd_flag & ME_CDFLAG_VERT_BWEIGHT) { if (!CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) { @@ -145,6 +146,29 @@ void BM_mesh_cd_flag_apply(BMesh *bm, const char cd_flag) BM_data_layer_free(bm, &bm->edata, CD_CREASE); } } +#ifdef WITH_FREESTYLE + if (cd_flag & ME_CDFLAG_FREESTYLE_EDGE) { + if (!CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) { + BM_data_layer_add(bm, &bm->edata, CD_FREESTYLE_EDGE); + } + } + else { + if (CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) { + BM_data_layer_free(bm, &bm->edata, CD_FREESTYLE_EDGE); + } + } + + if (cd_flag & ME_CDFLAG_FREESTYLE_FACE) { + if (!CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) { + BM_data_layer_add(bm, &bm->pdata, CD_FREESTYLE_FACE); + } + } + else { + if (CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) { + BM_data_layer_free(bm, &bm->pdata, CD_FREESTYLE_FACE); + } + } +#endif } char BM_mesh_cd_flag_from_bmesh(BMesh *bm) @@ -159,6 +183,14 @@ char BM_mesh_cd_flag_from_bmesh(BMesh *bm) if (CustomData_has_layer(&bm->edata, CD_CREASE)) { cd_flag |= ME_CDFLAG_EDGE_CREASE; } +#ifdef WITH_FREESTYLE + if (CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) { + cd_flag |= ME_CDFLAG_FREESTYLE_EDGE; + } + if (CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) { + cd_flag |= ME_CDFLAG_FREESTYLE_FACE; + } +#endif return cd_flag; } |