diff options
author | Rohan Rathi <rohanrathi08@gmail.com> | 2018-06-19 16:57:08 +0300 |
---|---|---|
committer | Rohan Rathi <rohanrathi08@gmail.com> | 2018-06-19 16:57:08 +0300 |
commit | dd752476b97aa3b35d1359422ca42e33d99ac851 (patch) | |
tree | f242f8747e50598473176a9403d96bd59b39c9a3 /source/blender/modifiers/intern/MOD_bevel.c | |
parent | e5880eb1ffdccc3295ca6a27fec8bb55fd20c27d (diff) |
Added face strength in bevel modifier
The selected face strength (Weak/Medium/High) can be used by the WN Modifier
to determine influence of current face in
Diffstat (limited to 'source/blender/modifiers/intern/MOD_bevel.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 4df8f1d06ae..7a20eb005f3 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -34,6 +34,7 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_scene_types.h" #include "BLI_utildefines.h" #include "BLI_math.h" @@ -77,6 +78,30 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } +static void bevel_set_weighted_normal_face_strength(BMesh *bm, Scene *scene) +{ + BMFace *f; + BMIter fiter; + const char *wn_layer_id = MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID; + int cd_prop_int_idx = CustomData_get_named_layer_index(&bm->pdata, CD_PROP_INT, wn_layer_id); + + if (cd_prop_int_idx == -1) { + BM_data_layer_add_named(bm, &bm->pdata, CD_PROP_INT, wn_layer_id); + cd_prop_int_idx = CustomData_get_named_layer_index(&bm->pdata, CD_PROP_INT, wn_layer_id); + } + cd_prop_int_idx -= CustomData_get_layer_index(&bm->pdata, CD_PROP_INT); + const int cd_prop_int_offset = CustomData_get_n_offset(&bm->pdata, CD_PROP_INT, cd_prop_int_idx); + + const int face_strength = scene->toolsettings->face_strength; + + BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_TAG)) { + int *strength = BM_ELEM_CD_GET_VOID_P(f, cd_prop_int_offset); + *strength = face_strength; + } + } +} + /* * This calls the new bevel code (added since 2.64) */ @@ -99,6 +124,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0; const bool mark_seam = (bmd->edge_flags & MOD_BEVEL_MARK_SEAM); const bool mark_sharp = (bmd->edge_flags & MOD_BEVEL_MARK_SHARP); + const bool set_wn_strength = (bmd->flags & MOD_BEVEL_SET_WN_STR); bm = BKE_mesh_to_bmesh_ex( mesh, @@ -171,6 +197,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp, dvert, vgroup, mat, loop_slide, mark_seam, mark_sharp, bmd->hnmode, NULL); + if(set_wn_strength) + bevel_set_weighted_normal_face_strength(bm, md->scene); + result = BKE_bmesh_to_mesh_nomain(bm, &(struct BMeshToMeshParams){0}); BLI_assert(bm->vtoolflagpool == NULL && |