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 | |
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')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 7 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 29 |
4 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 148196ec505..d8a7f59cf65 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -5661,6 +5661,7 @@ void BM_mesh_bevel( } } + BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { BLI_assert(find_bevvert(&bp, v) != NULL); diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 2400069a49a..3cf1d9f30f2 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -335,7 +335,7 @@ typedef struct BevelModifierData { float bevel_angle; /* if the MOD_BEVEL_VWEIGHT option is set, this will be the name of the vert group, MAX_VGROUP_NAME */ int hnmode; - float strength; + float hn_strength; char defgrp_name[64]; } BevelModifierData; @@ -357,6 +357,7 @@ enum { /* MOD_BEVEL_DIST = (1 << 12), */ /* same as above */ MOD_BEVEL_OVERLAP_OK = (1 << 13), MOD_BEVEL_EVEN_WIDTHS = (1 << 14), + MOD_BEVEL_SET_WN_STR = (1 << 15), }; /* BevelModifierData->val_flags (not used as flags any more) */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 04d8613c8d8..568b5b81ade 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -3127,11 +3127,16 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Normal Mode", "Weighting mode for Harden Normals"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "hn_strength", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_range(prop, 0, 10, 1, 2); RNA_def_property_ui_text(prop, "Normal Strength", "Strength of calculated normal"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "set_wn_strength", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_SET_WN_STR); + RNA_def_property_ui_text(prop, "Face Strength", "Set face strength of beveled faces for use in WN Modifier"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) 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 && |