[Bf-blender-cvs] [128ebdb0624] master: Fix: Remove incorrect asserts for empty attributes

Hans Goudey noreply at git.blender.org
Wed Dec 1 18:44:15 CET 2021


Commit: 128ebdb062404fa54fdae72043058655a504ade1
Author: Hans Goudey
Date:   Wed Dec 1 12:44:02 2021 -0500
Branches: master
https://developer.blender.org/rB128ebdb062404fa54fdae72043058655a504ade1

Fix: Remove incorrect asserts for empty attributes

While it is an edge case, it isn't incorrect for the attribute storage
to have a zero size, it will just return an empty span or nothing.

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

M	source/blender/blenkernel/intern/attribute_access.cc

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

diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 5663f6b8756..79070500888 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -744,7 +744,6 @@ CustomDataAttributes &CustomDataAttributes::operator=(const CustomDataAttributes
 
 std::optional<GSpan> CustomDataAttributes::get_for_read(const AttributeIDRef &attribute_id) const
 {
-  BLI_assert(size_ != 0);
   for (const CustomDataLayer &layer : Span(data.layers, data.totlayer)) {
     if (custom_data_layer_matches_attribute_id(layer, attribute_id)) {
       const CPPType *cpp_type = custom_data_type_to_cpp_type((CustomDataType)layer.type);
@@ -783,8 +782,6 @@ GVArray CustomDataAttributes::get_for_read(const AttributeIDRef &attribute_id,
 
 std::optional<GMutableSpan> CustomDataAttributes::get_for_write(const AttributeIDRef &attribute_id)
 {
-  /* If this assert hits, it most likely means that #reallocate was not called at some point. */
-  BLI_assert(size_ != 0);
   for (CustomDataLayer &layer : MutableSpan(data.layers, data.totlayer)) {
     if (custom_data_layer_matches_attribute_id(layer, attribute_id)) {
       const CPPType *cpp_type = custom_data_type_to_cpp_type((CustomDataType)layer.type);



More information about the Bf-blender-cvs mailing list