[Bf-blender-cvs] [c566feb5c85] refactor-mesh-uv-map-generic: Various fixes and cleanups

Hans Goudey noreply at git.blender.org
Fri Aug 26 04:34:49 CEST 2022


Commit: c566feb5c857c7da1c3438adc3b5b82409581f7e
Author: Hans Goudey
Date:   Wed Aug 17 16:54:50 2022 -0400
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rBc566feb5c857c7da1c3438adc3b5b82409581f7e

Various fixes and cleanups

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

M	source/blender/blenkernel/BKE_attribute.h
M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/BKE_mesh_mapping.h
M	source/blender/blenkernel/intern/attribute_access.cc
M	source/blender/blenkernel/intern/attribute_access_intern.hh
M	source/blender/blenkernel/intern/layer_utils.c
M	source/blender/blenkernel/intern/mesh.cc
M	source/blender/blenkernel/intern/mesh_evaluate.cc
M	source/blender/blenkernel/intern/mesh_legacy_convert.cc
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/subdiv_mesh.c
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc
M	source/blender/editors/include/ED_uvedit.h
M	source/blender/editors/mesh/mesh_data.cc
M	source/blender/editors/sculpt_paint/sculpt_uv.c
M	source/blender/editors/uvedit/uvedit_intern.h
M	source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M	source/blender/makesdna/DNA_mesh_types.h
M	source/blender/makesdna/DNA_meshdata_types.h
M	source/blender/python/bmesh/bmesh_py_types_meshdata.c
M	source/blender/render/intern/texture_margin.cc

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

diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 610be64adf6..64019bb7a26 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -99,9 +99,10 @@ CustomDataLayer *BKE_id_attribute_from_index(struct ID *id,
                                              eAttrDomainMask domain_mask,
                                              eCustomDataMask layer_mask);
 
-/** Layer is allowed to be nullptr; if so -1 (layer not found) will be returned.
+/**
  * Returns the index in the list of attributes of the same type on the same domain.
- * note: this is *not* the CustomData layer index.
+ * Note: this is *not* the CustomData layer index.
+ * Layer is allowed to be nullptr; if so -1 (layer not found) will be returned.
  */
 int BKE_id_attribute_to_index(const struct ID *id,
                               const CustomDataLayer *layer,
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 4332f711ab6..02a0afd086e 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -734,7 +734,8 @@ void CustomData_blend_write(BlendWriter *writer,
 
 void CustomData_blend_read(struct BlendDataReader *reader, struct CustomData *data, int count);
 
-/* Uvmap related customdata offsets for BMesh.
+/**
+ * UV map related customdata offsets for BMesh.
  */
 typedef struct UVMap_Offsets {
   int uv;
@@ -743,7 +744,8 @@ typedef struct UVMap_Offsets {
   int pinned;
 } UVMap_Offsets;
 
-/* UV related CustomData pointers.
+/**
+ * UV related CustomData pointers.
  * The data pointers point directly to the CustomData arrays.
  * The uv_index is also stored for on-demand creation of the bool datalayers.
  */
@@ -764,10 +766,9 @@ typedef struct UVMap_Data {
 std::string UV_sublayer_name(char const *layername, char const *prefix);
 
 #endif
-/* get a descriptor containing offsets for all needed layers for the uvmap
- * \param name: Optional layer name. When name is NULL, the default layer is returned
- * \param offsets: Output parameter that will be filled with the offsets
-
+/**
+ * Get a descriptor containing offsets for layers used for user interaction with the UV map.
+ * \param name: Optional layer name. When null, the default layer is returned.
  */
 UVMap_Offsets CustomData_get_uvmap_offsets(const struct CustomData *data, char const *name);
 UVMap_Data CustomData_get_uvmap_data(const struct CustomData *data, char const *name);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index e445ff685d0..6fe7c06fbbc 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -737,7 +737,6 @@ float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
                               const struct MLoop *loopstart,
                               const struct MVert *mvarray);
 float BKE_mesh_calc_area(const struct Mesh *me);
-float BKE_mesh_calc_poly_uv_area(const struct MPoly *mpoly, const float (*uv_array)[2]);
 void BKE_mesh_calc_poly_angles(const struct MPoly *mpoly,
                                const struct MLoop *loopstart,
                                const struct MVert *mvarray,
diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index d7033e7bf75..2c450ffc006 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -320,7 +320,10 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
   ((CHECK_TYPE_ANY( \
         _tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \
     CHECK_TYPE_ANY(_v, unsigned int, const unsigned int, int, const int)), \
-   (((_tri)[0] == _v) ? 0 : ((_tri)[1] == _v) ? 1 : ((_tri)[2] == _v) ? 2 : -1))
+   (((_tri)[0] == _v) ? 0 : \
+    ((_tri)[1] == _v) ? 1 : \
+    ((_tri)[2] == _v) ? 2 : \
+                        -1))
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 1569f8cfa8e..017d8e43997 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -564,97 +564,6 @@ bool CustomDataAttributeProvider::foreach_attribute(const void *owner,
   return true;
 }
 
-GAttributeReader NamedLegacyCustomDataProvider::try_get_for_read(
-    const void *owner, const AttributeIDRef &attribute_id) const
-{
-  const CustomData *custom_data = custom_data_access_.get_const_custom_data(owner);
-  if (custom_data == nullptr) {
-    return {};
-  }
-  for (const CustomDataLayer &layer : Span(custom_data->layers, custom_data->totlayer)) {
-    if (layer.type == stored_type_) {
-      if (custom_data_layer_matches_attribute_id(layer, attribute_id)) {
-        const int domain_num = custom_data_access_.get_element_num(owner);
-        return {as_read_attribute_(layer.data, domain_num), domain_};
-      }
-    }
-  }
-  return {};
-}
-
-GAttributeWriter NamedLegacyCustomDataProvider::try_get_for_write(
-    void *owner, const AttributeIDRef &attribute_id) const
-{
-  CustomData *custom_data = custom_data_access_.get_custom_data(owner);
-  if (custom_data == nullptr) {
-    return {};
-  }
-  for (CustomDataLayer &layer : MutableSpan(custom_data->layers, custom_data->totlayer)) {
-    if (layer.type == stored_type_) {
-      if (custom_data_layer_matches_attribute_id(layer, attribute_id)) {
-        const int element_num = custom_data_access_.get_element_num(owner);
-        void *data_old = layer.data;
-        void *data_new = CustomData_duplicate_referenced_layer_named(
-            custom_data, stored_type_, layer.name, element_num);
-        if (data_old != data_new) {
-          if (custom_data_access_.update_custom_data_pointers) {
-            custom_data_access_.update_custom_data_pointers(owner);
-          }
-        }
-        return {as_write_attribute_(layer.data, element_num), domain_};
-      }
-    }
-  }
-  return {};
-}
-
-bool NamedLegacyCustomDataProvider::try_delete(void *owner,
-                                               const AttributeIDRef &attribute_id) const
-{
-  CustomData *custom_data = custom_data_access_.get_custom_data(owner);
-  if (custom_data == nullptr) {
-    return false;
-  }
-  for (const int i : IndexRange(custom_data->totlayer)) {
-    const CustomDataLayer &layer = custom_data->layers[i];
-    if (layer.type == stored_type_) {
-      if (custom_data_layer_matches_attribute_id(layer, attribute_id)) {
-        const int element_num = custom_data_access_.get_element_num(owner);
-        CustomData_free_layer(custom_data, stored_type_, element_num, i);
-        if (custom_data_access_.update_custom_data_pointers) {
-          custom_data_access_.update_custom_data_pointers(owner);
-        }
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
-bool NamedLegacyCustomDataProvider::foreach_attribute(
-    const void *owner, const AttributeForeachCallback callback) const
-{
-  const CustomData *custom_data = custom_data_access_.get_const_custom_data(owner);
-  if (custom_data == nullptr) {
-    return true;
-  }
-  for (const CustomDataLayer &layer : Span(custom_data->layers, custom_data->totlayer)) {
-    if (layer.type == stored_type_) {
-      AttributeMetaData meta_data{domain_, attribute_type_};
-      if (!callback(layer.name, meta_data)) {
-        return false;
-      }
-    }
-  }
-  return true;
-}
-
-void NamedLegacyCustomDataProvider::foreach_domain(
-    const FunctionRef<void(eAttrDomain)> callback) const
-{
-  callback(domain_);
-}
-
 CustomDataAttributes::CustomDataAttributes()
 {
   CustomData_reset(&data);
diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh
index 1a2607d9403..3ee5c4f7d4e 100644
--- a/source/blender/blenkernel/intern/attribute_access_intern.hh
+++ b/source/blender/blenkernel/intern/attribute_access_intern.hh
@@ -166,44 +166,6 @@ class CustomDataAttributeProvider final : public DynamicAttributesProvider {
   }
 };
 
-/**
- * This attribute provider is used for uv maps and vertex colors.
- */
-class NamedLegacyCustomDataProvider final : public DynamicAttributesProvider {
- private:
-  using AsReadAttribute = GVArray (*)(const void *data, int domain_num);
-  using AsWriteAttribute = GVMutableArray (*)(void *data, int domain_num);
-  const eAttrDomain domain_;
-  const eCustomDataType attribute_type_;
-  const eCustomDataType stored_type_;
-  const CustomDataAccessInfo custom_data_access_;
-  const AsReadAttribute as_read_attribute_;
-  const AsWriteAttribute as_write_attribute_;
-
- public:
-  NamedLegacyCustomDataProvider(const eAttrDomain domain,
-                                const eCustomDataType attribute_type,
-                                const eCustomDataType stored_type,
-                                const CustomDataAccessInfo custom_data_access,
-                                const AsReadAttribute as_read_attribute,
-                                const AsWriteAttribute as_write_attribute)
-      : domain_(domain),
-        attribute_type_(attribute_type),
-        stored_type_(stored_type),
-        custom_data_access_(custom_data_access),
-        as_read_attribute_(as_read_attribute),
-        as_write_attribute_(as_write_attribute)
-  {
-  }
-
-  GAttributeReader try_get_for_read(const void *owner,
-                                    const AttributeIDRef &attribute_id) const final;
-  GAttributeWriter try_get_for_write(void *owner, const AttributeIDRef &attribute_id) const final;
-  bool try_delete(void *owner, const AttributeIDRef &attribute_id) const final;
-  bool foreach_attribute(const void *owner, const AttributeForeachCallback callback) const final;
-  void foreach_domain(const FunctionRef<void(eAttrDomain)> callback) const final;
-};
-
 template<typename T> GVArray make_array_read_attribute(const void *data, const int domain_num)
 {
   return VArray<T>::ForSpan(Span<T>((const T *)data, domain_num));
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/int

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list