Mesh: Move bevel weight to generic attribute

Store bevel weights in two new named float attributes:
- `bevel_weight_vert`
- `bevel_weight_edge`

These attributes are naming conventions. Blender doesn't enforce
their data type or domain at all, but some editing features and
modifiers use the hard-coded name. Eventually those tools should
become more generic, but this is a simple change to allow more
flexibility in the meantime.

The largest user-visible changes are that the attributes populate the
attribute list, and are propagated by geometry nodes. The method of
removing this data is now the attribute list as well.

This is a breaking change. Forward compatibility is not preserved, and
the vertex and edge `bevel_weight` properties are removed. Python API
users are expected to use the attribute API to get and set the values.

Fixes #106949

Pull Request: blender/blender#108023
This commit is contained in:
2023-05-19 14:31:31 +02:00
committed by Hans Goudey
parent 51923c09e2
commit 2a56403cb0
27 changed files with 273 additions and 348 deletions

View File

@@ -87,8 +87,6 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__deform_doc,
PyDoc_STRVAR(
bpy_bmlayeraccess_collection__shape_doc,
"Vertex shapekey absolute location (as a 3D Vector).\n\n:type: :class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__bevel_weight_doc,
"Bevel weight float in [0 - 1].\n\n:type: :class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__crease_doc,
"Crease for subdivision surface - float in [0 - 1].\n\n:type: "
":class:`BMLayerCollection`");
@@ -205,11 +203,6 @@ static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
(setter)NULL,
bpy_bmlayeraccess_collection__shape_doc,
(void *)CD_SHAPEKEY},
{"bevel_weight",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
bpy_bmlayeraccess_collection__bevel_weight_doc,
(void *)CD_BWEIGHT},
{"crease",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
@@ -261,11 +254,6 @@ static PyGetSetDef bpy_bmlayeraccess_edge_getseters[] = {
bpy_bmlayeraccess_collection__string_doc,
(void *)CD_PROP_STRING},
{"bevel_weight",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
bpy_bmlayeraccess_collection__bevel_weight_doc,
(void *)CD_BWEIGHT},
{"crease",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
@@ -1160,10 +1148,6 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
ret = Vector_CreatePyObject_wrap((float *)value, 3, NULL);
break;
}
case CD_BWEIGHT: {
ret = PyFloat_FromDouble(*(float *)value);
break;
}
case CD_CREASE: {
ret = PyFloat_FromDouble(*(float *)value);
break;
@@ -1275,18 +1259,6 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
}
break;
}
case CD_BWEIGHT: {
const float tmp_val = PyFloat_AsDouble(py_value);
if (UNLIKELY(tmp_val == -1 && PyErr_Occurred())) {
PyErr_Format(
PyExc_TypeError, "expected a float, not a %.200s", Py_TYPE(py_value)->tp_name);
ret = -1;
}
else {
*(float *)value = clamp_f(tmp_val, 0.0f, 1.0f);
}
break;
}
case CD_CREASE: {
const float tmp_val = PyFloat_AsDouble(py_value);
if (UNLIKELY(tmp_val == -1 && PyErr_Occurred())) {