[Bf-blender-cvs] [b4757873bf1] refactor-mesh-uv-map-generic: Merge branch 'master' into refactor-mesh-uv-map-generic

Martijn Versteegh noreply at git.blender.org
Sat Nov 12 00:09:12 CET 2022


Commit: b4757873bf1c2fb5e3f858a085af62359d3c1b3f
Author: Martijn Versteegh
Date:   Fri Nov 11 19:44:16 2022 +0100
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rBb4757873bf1c2fb5e3f858a085af62359d3c1b3f

Merge branch 'master' into refactor-mesh-uv-map-generic

===================================================================



===================================================================

diff --cc source/blender/editors/geometry/geometry_attributes.cc
index 1a4c93afcdc,7f163da493b..5b0202dcbe1
--- a/source/blender/editors/geometry/geometry_attributes.cc
+++ b/source/blender/editors/geometry/geometry_attributes.cc
@@@ -290,23 -290,32 +289,15 @@@ static int geometry_attribute_convert_e
     * 4. Create a new attribute based on the previously copied data. */
    switch (mode) {
      case ConvertAttributeMode::Generic: {
-       const eAttrDomain dst_domain = static_cast<eAttrDomain>(RNA_enum_get(op->ptr, "domain"));
-       const eCustomDataType dst_type = static_cast<eCustomDataType>(
-           RNA_enum_get(op->ptr, "data_type"));
- 
-       if (ELEM(dst_type, CD_PROP_STRING)) {
-         BKE_report(op->reports, RPT_ERROR, "Cannot convert to the selected type");
+       if (!ED_geometry_attribute_convert(mesh,
+                                          name.c_str(),
+                                          eCustomDataType(RNA_enum_get(op->ptr, "data_type")),
+                                          eAttrDomain(RNA_enum_get(op->ptr, "domain")),
+                                          op->reports)) {
          return OPERATOR_CANCELLED;
        }
- 
-       GVArray src_varray = attributes.lookup_or_default(name, dst_domain, dst_type);
-       const CPPType &cpp_type = src_varray.type();
-       void *new_data = MEM_malloc_arrayN(src_varray.size(), cpp_type.size(), __func__);
-       src_varray.materialize_to_uninitialized(new_data);
-       attributes.remove(name);
-       attributes.add(name, dst_domain, dst_type, blender::bke::AttributeInitMoveArray(new_data));
        break;
      }
 -    case ConvertAttributeMode::UVMap: {
 -      MLoopUV *dst_uvs = static_cast<MLoopUV *>(
 -          MEM_calloc_arrayN(mesh->totloop, sizeof(MLoopUV), __func__));
 -      VArray<float2> src_varray = attributes.lookup_or_default<float2>(
 -          name, ATTR_DOMAIN_CORNER, {0.0f, 0.0f});
 -      for (const int i : IndexRange(mesh->totloop)) {
 -        copy_v2_v2(dst_uvs[i].uv, src_varray[i]);
 -      }
 -      attributes.remove(name);
 -      CustomData_add_layer_named(
 -          &mesh->ldata, CD_MLOOPUV, CD_ASSIGN, dst_uvs, mesh->totloop, name.c_str());
 -      int *active_index = BKE_id_attributes_active_index_p(&mesh->id);
 -      if (*active_index > 0) {
 -        *active_index -= 1;
 -      }
 -      break;
 -    }
      case ConvertAttributeMode::VertexGroup: {
        Array<float> src_weights(mesh->totvert);
        VArray<float> src_varray = attributes.lookup_or_default<float>(



More information about the Bf-blender-cvs mailing list