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
This commit is contained in:
@@ -142,6 +142,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
|||||||
col.prop(md, "loop_slide")
|
col.prop(md, "loop_slide")
|
||||||
col.prop(md, "mark_seam")
|
col.prop(md, "mark_seam")
|
||||||
col.prop(md, "mark_sharp")
|
col.prop(md, "mark_sharp")
|
||||||
|
|
||||||
|
col.prop(md, "set_wn_strength")
|
||||||
|
|
||||||
layout.label(text="Limit Method:")
|
layout.label(text="Limit Method:")
|
||||||
layout.row().prop(md, "limit_method", expand=True)
|
layout.row().prop(md, "limit_method", expand=True)
|
||||||
|
@@ -5661,6 +5661,7 @@ void BM_mesh_bevel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) {
|
BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) {
|
||||||
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
|
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
|
||||||
BLI_assert(find_bevvert(&bp, v) != NULL);
|
BLI_assert(find_bevvert(&bp, v) != NULL);
|
||||||
|
@@ -335,7 +335,7 @@ typedef struct BevelModifierData {
|
|||||||
float bevel_angle;
|
float bevel_angle;
|
||||||
/* if the MOD_BEVEL_VWEIGHT option is set, this will be the name of the vert group, MAX_VGROUP_NAME */
|
/* if the MOD_BEVEL_VWEIGHT option is set, this will be the name of the vert group, MAX_VGROUP_NAME */
|
||||||
int hnmode;
|
int hnmode;
|
||||||
float strength;
|
float hn_strength;
|
||||||
char defgrp_name[64];
|
char defgrp_name[64];
|
||||||
} BevelModifierData;
|
} BevelModifierData;
|
||||||
|
|
||||||
@@ -357,6 +357,7 @@ enum {
|
|||||||
/* MOD_BEVEL_DIST = (1 << 12), */ /* same as above */
|
/* MOD_BEVEL_DIST = (1 << 12), */ /* same as above */
|
||||||
MOD_BEVEL_OVERLAP_OK = (1 << 13),
|
MOD_BEVEL_OVERLAP_OK = (1 << 13),
|
||||||
MOD_BEVEL_EVEN_WIDTHS = (1 << 14),
|
MOD_BEVEL_EVEN_WIDTHS = (1 << 14),
|
||||||
|
MOD_BEVEL_SET_WN_STR = (1 << 15),
|
||||||
};
|
};
|
||||||
|
|
||||||
/* BevelModifierData->val_flags (not used as flags any more) */
|
/* BevelModifierData->val_flags (not used as flags any more) */
|
||||||
|
@@ -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_ui_text(prop, "Normal Mode", "Weighting mode for Harden Normals");
|
||||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
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_range(prop, 0, 10);
|
||||||
RNA_def_property_ui_range(prop, 0, 10, 1, 2);
|
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_ui_text(prop, "Normal Strength", "Strength of calculated normal");
|
||||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
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)
|
static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_mesh_types.h"
|
#include "DNA_mesh_types.h"
|
||||||
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
@@ -77,6 +78,30 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
|||||||
return dataMask;
|
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)
|
* 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 loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
|
||||||
const bool mark_seam = (bmd->edge_flags & MOD_BEVEL_MARK_SEAM);
|
const bool mark_seam = (bmd->edge_flags & MOD_BEVEL_MARK_SEAM);
|
||||||
const bool mark_sharp = (bmd->edge_flags & MOD_BEVEL_MARK_SHARP);
|
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(
|
bm = BKE_mesh_to_bmesh_ex(
|
||||||
mesh,
|
mesh,
|
||||||
@@ -171,6 +197,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||||||
vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
|
vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
|
||||||
dvert, vgroup, mat, loop_slide, mark_seam, mark_sharp, bmd->hnmode, NULL);
|
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});
|
result = BKE_bmesh_to_mesh_nomain(bm, &(struct BMeshToMeshParams){0});
|
||||||
|
|
||||||
BLI_assert(bm->vtoolflagpool == NULL &&
|
BLI_assert(bm->vtoolflagpool == NULL &&
|
||||||
|
Reference in New Issue
Block a user