Mesh: Move sculpt mask to a generic attribute

Store paint masks as generic float attributes, with the name
`".sculpt_mask"`. This is similar to 060a534141, which made
the same change for face sets. The benefits are general
consistency, nicer code, and more support in newer areas
that deal with attributes like geometry nodes.

The RNA API is replaced with one created in Python. The new
API only presents a single layer as an attribute class, so it
should be simpler to use in general:
- Before: `object.data.vertex_paint_masks[0].data[0].value`
- After: `object.data.vertex_paint_mask.data[0].value`

Pull Request: https://projects.blender.org/blender/blender/pulls/115119
This commit is contained in:
Hans Goudey
2023-11-20 17:42:01 +01:00
committed by Hans Goudey
parent b3d4fc80fd
commit f2bcd73bd2
27 changed files with 168 additions and 207 deletions

View File

@@ -205,11 +205,6 @@ static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
(setter) nullptr,
bpy_bmlayeraccess_collection__skin_doc,
(void *)CD_MVERT_SKIN},
{"paint_mask",
(getter)bpy_bmlayeraccess_collection_get,
(setter) nullptr,
bpy_bmlayeraccess_collection__paint_mask_doc,
(void *)CD_PAINT_MASK},
{nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
@@ -1106,8 +1101,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
ret = BPy_BMDeformVert_CreatePyObject(static_cast<MDeformVert *>(value));
break;
}
case CD_PROP_FLOAT:
case CD_PAINT_MASK: {
case CD_PROP_FLOAT: {
ret = PyFloat_FromDouble(*(float *)value);
break;
}
@@ -1172,8 +1166,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
ret = BPy_BMDeformVert_AssignPyObject(static_cast<MDeformVert *>(value), py_value);
break;
}
case CD_PROP_FLOAT:
case CD_PAINT_MASK: {
case CD_PROP_FLOAT: {
const float tmp_val = PyFloat_AsDouble(py_value);
if (UNLIKELY(tmp_val == -1 && PyErr_Occurred())) {
PyErr_Format(