Multiple Bevels with Edge Attribute Groups. Need UI Function to Get "Attributes"

I’m trying to make a small change to the bevel modifier that has been highly requested by artists over the years… and that is to “edge groups” or something similar to be able to apply several bevel modifiers with different edge weights.

I’ve got the RNA/DNA changes made, and I think I’m 90% of the way there. Basically it’s a simple UI element to add the selection of a custom attribute (edge weight) here, and then elsewhere in MOD_bevel.cc we just use that custom group instead of bevel_weight_edge:

  if (limit_method == MOD_BEVEL_ANGLE) {
    sub = uiLayoutColumn(col, false);
    uiLayoutSetActive(sub, edge_bevel);
    uiItemR(col, ptr, "angle_limit", UI_ITEM_NONE, nullptr, ICON_NONE);
  }
  else if (limit_method == MOD_BEVEL_WEIGHT) {
    // new UI element
    sub = uiLayoutColumn(col, false);
    uiLayoutSetActive(sub, edge_bevel);
    uiItemR(col, ptr, "custom_weight", UI_ITEM_NONE, nullptr, ICON_NONE);
    // how to populate a dropdown box that looks for attributes of edge -> float ?
  }
  else if (limit_method == MOD_BEVEL_VGROUP) {
    modifier_vgroup_ui(col, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
  }

But now I just need a UI function similar to the existing function that allows you to select a vertex group:

in MOD_bevel.cc:

modifier_vgroup_ui(col, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);

Which calls this guy:

void modifier_vgroup_ui(uiLayout *layout,
                        PointerRNA *ptr,
                        PointerRNA *ob_ptr,
                        const char *vgroup_prop,
                        const char *invert_vgroup_prop,
                        const char *text)
{
  bool has_vertex_group = RNA_string_length(ptr, vgroup_prop) != 0;

  uiLayout *row = uiLayoutRow(layout, true);
  uiItemPointerR(row, ptr, vgroup_prop, ob_ptr, "vertex_groups", text, ICON_GROUP_VERTEX);
  if (invert_vgroup_prop != nullptr) {
    uiLayout *sub = uiLayoutRow(row, true);
    uiLayoutSetActive(sub, has_vertex_group);
    uiLayoutSetPropDecorate(sub, false);
    uiItemR(sub, ptr, invert_vgroup_prop, UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
  }
}

I’d like to do the exact same thing, except populate a list of attributes that are of the type “Edge → Float”.

Any suggestions? Does such a UI function exist somewhere else?

If you don’t know what I’m talking about in terms of attributes, it’s pretty new in version 4. Bevel Edge Weights are no longer associated with the MeshEdge object, but now use the “Attributes” interface.

image

With this version of Blender we are closer then ever to being able to have multiple edge groups. Basically we just need to change the name of the Attribute which is pulled for the edge weights. I think this is a small change that could have a big impact for a lot of users (particularly hard surface modelers).

3 Likes

Update:

I found add_attribute_search_button in MOD_nodes.cc, but it’s a little beyond me right now. Obviously this won’t need “NodesModifierData” as an argument. So I think this method would need to be reworked, but it’s surprising there is no general method to accomplish this.

This is how that search function looks, which is exactly what I need:

image

Another update. Aside from the UI issue mentioned here in this post (which I’m still looking for some help with… please :slight_smile: ), I actually have the feature working:

You can see that the larger 5 segment bevel is placed using the “test2” attribute edge group, and the smaller bevel running along the edge is using the “test1” attribute edge group.

I have this working with the Weighted Normals and Smooth by Angle modifier, which is new in Blender 4.1 as well.

I’m a hard surface modeler myself and this might be a pretty big workflow improvement… if I can get any help with populate the “Custom Weight” dropdown with attributes that are of type Float → Edge, I think this feature would basically be done.

6 Likes

Fork/commit here:

Also I did a YouTube video explaining the feature and what I still need help with:

5 Likes

There is work being done to create a bevel node for geometry nodes, which I guess would be the preferred route to gain this functionality as the plan is to eventually phase out all old-style modifiers and replace them with pre-build node trees. Though I don’t really know if that work has stalled or if it is actively being worked on.

Maybe you should contact @Howard_Trickey to ask what the status is and if it would still be worthwhile to patch this into the current modifier.

2 Likes

PR, for anyone interested

6 Likes