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:
authorJacques Lucke <jacques@blender.org>2022-04-21 17:11:26 +0300
committerJacques Lucke <jacques@blender.org>2022-04-21 17:11:26 +0300
commitb9799dfb8a78dddbb3591dcb3e0b4de954c80fee (patch)
tree531a96e1ff7774b07ae1c91a4242c86d7d7f156e /source/blender/editors/geometry
parentaca083fbf38246437caa6e50a6feeeb23b64ee18 (diff)
Geometry Nodes: better support for byte color attributes
Since {rBeae36be372a6b16ee3e76eff0485a47da4f3c230} the distinction between float and byte colors is more explicit in the ui. So far, geometry nodes couldn't really deal with byte colors in general. This patch fixes that. There is still only one color socket, which contains float colors. Conversion to and from byte colors is done when read from or writing to attributes. * Support writing to byte color attributes in Store Named Attribute node. * Support converting to/from byte color in attribute conversion operator. * Support propagating byte color attributes. * Add all the implicit conversions from byte colors to the other types. * Display byte colors as integers in spreadsheet. Differential Revision: https://developer.blender.org/D14705
Diffstat (limited to 'source/blender/editors/geometry')
-rw-r--r--source/blender/editors/geometry/geometry_attributes.cc18
1 files changed, 1 insertions, 17 deletions
diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc
index 446aabd13c8..452f1df86fb 100644
--- a/source/blender/editors/geometry/geometry_attributes.cc
+++ b/source/blender/editors/geometry/geometry_attributes.cc
@@ -241,7 +241,6 @@ enum class ConvertAttributeMode {
Generic,
UVMap,
VertexGroup,
- VertexColor,
};
static bool geometry_attribute_convert_poll(bContext *C)
@@ -288,7 +287,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
const CustomDataType dst_type = static_cast<CustomDataType>(
RNA_enum_get(op->ptr, "data_type"));
- if (ELEM(dst_type, CD_PROP_STRING, CD_PROP_BYTE_COLOR)) {
+ if (ELEM(dst_type, CD_PROP_STRING)) {
BKE_report(op->reports, RPT_ERROR, "Cannot convert to the selected type");
return OPERATOR_CANCELLED;
}
@@ -314,20 +313,6 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
&mesh->ldata, CD_MLOOPUV, CD_ASSIGN, dst_uvs, mesh->totloop, name.c_str());
break;
}
- case ConvertAttributeMode::VertexColor: {
- MLoopCol *dst_colors = static_cast<MLoopCol *>(
- MEM_calloc_arrayN(mesh->totloop, sizeof(MLoopCol), __func__));
- VArray<ColorGeometry4f> src_varray = mesh_component.attribute_get_for_read<ColorGeometry4f>(
- name, ATTR_DOMAIN_CORNER, ColorGeometry4f{0.0f, 0.0f, 0.0f, 1.0f});
- for (const int i : IndexRange(mesh->totloop)) {
- ColorGeometry4b encoded_color = src_varray[i].encode();
- copy_v4_v4_uchar(&dst_colors[i].r, &encoded_color.r);
- }
- mesh_component.attribute_try_delete(name);
- CustomData_add_layer_named(
- &mesh->ldata, CD_PROP_BYTE_COLOR, CD_ASSIGN, dst_colors, mesh->totloop, name.c_str());
- break;
- }
case ConvertAttributeMode::VertexGroup: {
Array<float> src_weights(mesh->totvert);
VArray<float> src_varray = mesh_component.attribute_get_for_read<float>(
@@ -550,7 +535,6 @@ void GEOMETRY_OT_attribute_convert(wmOperatorType *ot)
{int(ConvertAttributeMode::Generic), "GENERIC", 0, "Generic", ""},
{int(ConvertAttributeMode::UVMap), "UV_MAP", 0, "UV Map", ""},
{int(ConvertAttributeMode::VertexGroup), "VERTEX_GROUP", 0, "Vertex Group", ""},
- {int(ConvertAttributeMode::VertexColor), "VERTEX_COLOR", 0, "Color Attribute", ""},
{0, nullptr, 0, nullptr, nullptr},
};