Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-07-03 16:30:04 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-09-09 18:01:17 +0300
commit565510bd7fd87ae146cabafb27f1dfd550450f58 (patch)
tree57ff84b2aa4ba7e5c1dc0511be858d6b3bf156e6 /source/blender/python/bmesh
parenta5db981b0ea044313239c3cc2ee92d19a8f682ea (diff)
Geometry: add .attributes in the Python API for Mesh, Hair and Point Cloud
This puts all generic float/int/vector/color/string geometry attributes in a new .attributes property. For meshes it provides a more general API for existing attributes, for point clouds attributes will be used as an essential part of particle nodes. This patch was implemented by @lichtwerk, with further changes by me. It's still a work in progress, but posting here to show what is going on and for early feedback. Ref T76659 Differential Revision: https://developer.blender.org/D8200
Diffstat (limited to 'source/blender/python/bmesh')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c87
1 files changed, 84 insertions, 3 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index a9a9a3ad5d9..a74be2b580e 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -84,6 +84,15 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__float_doc,
"Generic float custom-data layer.\n\ntype: :class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__int_doc,
"Generic int custom-data layer.\n\ntype: :class:`BMLayerCollection`");
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__float_vector_doc,
+ "Generic 3D vector with float precision custom-data layer.\n\ntype: "
+ ":class:`BMLayerCollection`");
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__float_color_doc,
+ "Generic RGBA color with float precision custom-data layer.\n\ntype: "
+ ":class:`BMLayerCollection`");
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__color_doc,
+ "Generic RGBA color with 8-bit precision custom-data layer.\n\ntype: "
+ ":class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__string_doc,
"Generic string custom-data layer (exposed as bytes, 255 max length).\n\ntype: "
":class:`BMLayerCollection`");
@@ -102,8 +111,6 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__crease_doc,
PyDoc_STRVAR(
bpy_bmlayeraccess_collection__uv_doc,
"Accessor for :class:`BMLoopUV` UV (as a 2D Vector).\n\ntype: :class:`BMLayerCollection`");
-PyDoc_STRVAR(bpy_bmlayeraccess_collection__color_doc,
- "Accessor for vertex color layer.\n\ntype: :class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__skin_doc,
"Accessor for skin layer.\n\ntype: :class:`BMLayerCollection`");
PyDoc_STRVAR(bpy_bmlayeraccess_collection__paint_mask_doc,
@@ -188,6 +195,21 @@ static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
(setter)NULL,
bpy_bmlayeraccess_collection__int_doc,
(void *)CD_PROP_INT32},
+ {"float_vector",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_vector_doc,
+ (void *)CD_PROP_FLOAT3},
+ {"float_color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_color_doc,
+ (void *)CD_PROP_COLOR},
+ {"color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__color_doc,
+ (void *)CD_MLOOPCOL},
{"string",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
@@ -229,6 +251,21 @@ static PyGetSetDef bpy_bmlayeraccess_edge_getseters[] = {
(setter)NULL,
bpy_bmlayeraccess_collection__int_doc,
(void *)CD_PROP_INT32},
+ {"float_vector",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_vector_doc,
+ (void *)CD_PROP_FLOAT3},
+ {"float_color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_color_doc,
+ (void *)CD_PROP_COLOR},
+ {"color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__color_doc,
+ (void *)CD_MLOOPCOL},
{"string",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
@@ -267,6 +304,21 @@ static PyGetSetDef bpy_bmlayeraccess_face_getseters[] = {
(setter)NULL,
bpy_bmlayeraccess_collection__int_doc,
(void *)CD_PROP_INT32},
+ {"float_vector",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_vector_doc,
+ (void *)CD_PROP_FLOAT3},
+ {"float_color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_color_doc,
+ (void *)CD_PROP_COLOR},
+ {"color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__color_doc,
+ (void *)CD_MLOOPCOL},
{"string",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
@@ -300,12 +352,21 @@ static PyGetSetDef bpy_bmlayeraccess_loop_getseters[] = {
(setter)NULL,
bpy_bmlayeraccess_collection__int_doc,
(void *)CD_PROP_INT32},
+ {"float_vector",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_vector_doc,
+ (void *)CD_PROP_FLOAT3},
+ {"float_color",
+ (getter)bpy_bmlayeraccess_collection_get,
+ (setter)NULL,
+ bpy_bmlayeraccess_collection__float_color_doc,
+ (void *)CD_PROP_COLOR},
{"string",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
bpy_bmlayeraccess_collection__string_doc,
(void *)CD_PROP_STRING},
-
{"uv",
(getter)bpy_bmlayeraccess_collection_get,
(setter)NULL,
@@ -1072,6 +1133,14 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
ret = PyLong_FromLong(*(int *)value);
break;
}
+ case CD_PROP_FLOAT3: {
+ ret = Vector_CreatePyObject_wrap((float *)value, 3, NULL);
+ break;
+ }
+ case CD_PROP_COLOR: {
+ ret = Vector_CreatePyObject_wrap((float *)value, 4, NULL);
+ break;
+ }
case CD_PROP_STRING: {
MStringProperty *mstring = value;
ret = PyBytes_FromStringAndSize(mstring->s, mstring->s_len);
@@ -1150,6 +1219,18 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
}
break;
}
+ case CD_PROP_FLOAT3: {
+ if (mathutils_array_parse((float *)value, 3, 3, py_value, "BMElem Float Vector") == -1) {
+ ret = -1;
+ }
+ break;
+ }
+ case CD_PROP_COLOR: {
+ if (mathutils_array_parse((float *)value, 4, 4, py_value, "BMElem Float Color") == -1) {
+ ret = -1;
+ }
+ break;
+ }
case CD_PROP_STRING: {
MStringProperty *mstring = value;
char *tmp_val;