UI: Add custom attribute edge groups for bevel modifier #117366
|
@ -82,7 +82,9 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
|
|||
miter_inner,
|
||||
spread,
|
||||
custom_profile,
|
||||
vmesh_method);
|
||||
vmesh_method,
|
||||
"bevel_weight_edge",
|
||||
"bevel_weight_vert");
|
||||
|
||||
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
|
||||
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
|
||||
|
|
|
@ -7719,7 +7719,9 @@ void BM_mesh_bevel(BMesh *bm,
|
|||
const int miter_inner,
|
||||
const float spread,
|
||||
const CurveProfile *custom_profile,
|
||||
const int vmesh_method)
|
||||
const int vmesh_method,
|
||||
const char *edge_weight_name,
|
||||
const char *vertex_weight_name)
|
||||
{
|
||||
BMIter iter, liter;
|
||||
BMVert *v, *v_next;
|
||||
|
@ -7737,9 +7739,9 @@ void BM_mesh_bevel(BMesh *bm,
|
|||
bp.affect_type = affect_type;
|
||||
bp.use_weights = use_weights;
|
||||
bp.bweight_offset_vert = CustomData_get_offset_named(
|
||||
&bm->vdata, CD_PROP_FLOAT, "bevel_weight_vert");
|
||||
&bm->vdata, CD_PROP_FLOAT, vertex_weight_name);
|
||||
bp.bweight_offset_edge = CustomData_get_offset_named(
|
||||
&bm->edata, CD_PROP_FLOAT, "bevel_weight_edge");
|
||||
&bm->edata, CD_PROP_FLOAT, edge_weight_name);
|
||||
bp.loop_slide = loop_slide;
|
||||
bp.limit_offset = limit_offset;
|
||||
bp.offset_adjust = (bp.affect_type != BEVEL_AFFECT_VERTICES) &&
|
||||
|
|
|
@ -44,4 +44,6 @@ void BM_mesh_bevel(BMesh *bm,
|
|||
int miter_inner,
|
||||
float spread,
|
||||
const CurveProfile *custom_profile,
|
||||
int vmesh_method);
|
||||
int vmesh_method,
|
||||
const char *bevel_weight_name,
|
||||
const char *vertex_weight_name);
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
.miter_outer = MOD_BEVEL_MITER_SHARP, \
|
||||
.affect_type = MOD_BEVEL_AFFECT_EDGES, \
|
||||
.profile = 0.5f, \
|
||||
.edge_weight_name = "bevel_weight_edge", \
|
||||
.vertex_weight_name = "vertex_weight_edge", \
|
||||
.bevel_angle = DEG2RADF(30.0f), \
|
||||
.spread = 0.1f, \
|
||||
.defgrp_name = "", \
|
||||
|
|
|
@ -481,6 +481,12 @@ typedef struct BevelModifierData {
|
|||
struct CurveProfile *custom_profile;
|
||||
|
||||
void *_pad2;
|
||||
/** Custom bevel edge weight name. */
|
||||
char edge_weight_name[64];
|
||||
|
||||
/** Custom bevel vertex weight name. */
|
||||
char vertex_weight_name[64];
|
||||
|
||||
} BevelModifierData;
|
||||
|
||||
/** #BevelModifierData.flags and BevelModifierData.lim_flags */
|
||||
|
|
|
@ -952,6 +952,20 @@ static bool rna_HookModifier_object_override_apply(Main *bmain,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void rna_BevelModifier_edge_weight_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
BevelModifierData *bmd = static_cast<BevelModifierData *>(ptr->data);
|
||||
Mike93 marked this conversation as resolved
Outdated
|
||||
|
||||
STRNCPY(bmd->edge_weight_name, value);
|
||||
}
|
||||
|
||||
static void rna_BevelModifier_vertex_weight_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
BevelModifierData *bmd = static_cast<BevelModifierData *>(ptr->data);
|
||||
|
||||
STRNCPY(bmd->vertex_weight_name, value);
|
||||
}
|
||||
|
||||
static void rna_HookModifier_subtarget_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
Object *owner = (Object *)ptr->owner_id;
|
||||
|
@ -4312,6 +4326,20 @@ static void rna_def_modifier_bevel(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Limit Method", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "edge_weight", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, nullptr, "edge_weight_name");
|
||||
RNA_def_property_ui_text(prop, "Edge Attribute", "Edge weight attribute");
|
||||
RNA_def_property_string_funcs(
|
||||
prop, nullptr, nullptr, "rna_BevelModifier_edge_weight_name_set");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "vertex_weight", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, nullptr, "vertex_weight_name");
|
||||
RNA_def_property_ui_text(prop, "Vertex Attribute", "Vertex weight attribute");
|
||||
RNA_def_property_string_funcs(
|
||||
prop, nullptr, nullptr, "rna_BevelModifier_vertex_weight_name_set");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "bevel_angle");
|
||||
RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
|
||||
|
|
|
@ -124,9 +124,9 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
|
|||
}
|
||||
|
||||
const int bweight_offset_vert = CustomData_get_offset_named(
|
||||
&bm->vdata, CD_PROP_FLOAT, "bevel_weight_vert");
|
||||
&bm->vdata, CD_PROP_FLOAT, bmd->vertex_weight_name);
|
||||
const int bweight_offset_edge = CustomData_get_offset_named(
|
||||
&bm->edata, CD_PROP_FLOAT, "bevel_weight_edge");
|
||||
&bm->edata, CD_PROP_FLOAT, bmd->edge_weight_name);
|
||||
|
||||
if (bmd->affect_type == MOD_BEVEL_AFFECT_VERTICES) {
|
||||
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
|
||||
|
@ -214,7 +214,9 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
|
|||
miter_inner,
|
||||
spread,
|
||||
bmd->custom_profile,
|
||||
bmd->vmesh_method);
|
||||
bmd->vmesh_method,
|
||||
bmd->edge_weight_name,
|
||||
bmd->vertex_weight_name);
|
||||
|
||||
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh);
|
||||
|
||||
|
@ -281,6 +283,17 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
|
|||
uiLayoutSetActive(sub, edge_bevel);
|
||||
uiItemR(col, ptr, "angle_limit", UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
}
|
||||
else if (limit_method == MOD_BEVEL_WEIGHT) {
|
||||
sub = uiLayoutColumn(col, false);
|
||||
uiLayoutSetActive(sub, edge_bevel);
|
||||
|
||||
const char* weight_type = "edge_weight";
|
||||
if (!edge_bevel) {
|
||||
weight_type = "vertex_weight";
|
||||
}
|
||||
|
||||
uiItemR(col, ptr, weight_type, UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
}
|
||||
else if (limit_method == MOD_BEVEL_VGROUP) {
|
||||
modifier_vgroup_ui(col, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Remove this line; you never used this result.