diff options
author | Hans Goudey <h.goudey@me.com> | 2021-10-21 00:54:04 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-10-21 00:54:04 +0300 |
commit | 3f8b45d8d1fff8a082e3d35221d39854484e8551 (patch) | |
tree | d50b1788d66ee572abb78b1016c5ed7a65850523 /source/blender/blenkernel/intern/geometry_component_curve.cc | |
parent | 98c53f660a57af837a160a842eb2e7a9a4c37de8 (diff) |
Fix: Builtin curve attributes unavailable
After the addition of the `id` attribute in rB40c3b8836b7a, the `exists`
function assumed that all attributes were stored in the custom data.
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_curve.cc')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_curve.cc | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc index c3d7eff4e6f..2f2851b4fd4 100644 --- a/source/blender/blenkernel/intern/geometry_component_curve.cc +++ b/source/blender/blenkernel/intern/geometry_component_curve.cc @@ -1074,6 +1074,7 @@ template<typename T> class BuiltinPointAttributeProvider : public BuiltinAttribu const GetSpan get_span_; const GetMutableSpan get_mutable_span_; const UpdateOnWrite update_on_write_; + bool stored_in_custom_data_; public: BuiltinPointAttributeProvider(std::string attribute_name, @@ -1081,7 +1082,8 @@ template<typename T> class BuiltinPointAttributeProvider : public BuiltinAttribu const DeletableEnum deletable, const GetSpan get_span, const GetMutableSpan get_mutable_span, - const UpdateOnWrite update_on_write) + const UpdateOnWrite update_on_write, + const bool stored_in_custom_data) : BuiltinAttributeProvider(std::move(attribute_name), ATTR_DOMAIN_POINT, bke::cpp_type_to_custom_data_type(CPPType::get<T>()), @@ -1090,7 +1092,8 @@ template<typename T> class BuiltinPointAttributeProvider : public BuiltinAttribu deletable), get_span_(get_span), get_mutable_span_(get_mutable_span), - update_on_write_(update_on_write) + update_on_write_(update_on_write), + stored_in_custom_data_(stored_in_custom_data) { } @@ -1168,8 +1171,10 @@ template<typename T> class BuiltinPointAttributeProvider : public BuiltinAttribu return false; } - if (!curve->splines().first()->attributes.get_for_read(name_)) { - return false; + if (stored_in_custom_data_) { + if (!curve->splines().first()->attributes.get_for_read(name_)) { + return false; + } } bool has_point = false; @@ -1202,7 +1207,8 @@ class PositionAttributeProvider final : public BuiltinPointAttributeProvider<flo BuiltinAttributeProvider::NonDeletable, [](const Spline &spline) { return spline.positions(); }, [](Spline &spline) { return spline.positions(); }, - [](Spline &spline) { spline.mark_cache_invalid(); }) + [](Spline &spline) { spline.mark_cache_invalid(); }, + false) { } @@ -1529,7 +1535,8 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() std::optional<GMutableSpan> span = spline.attributes.get_for_write("id"); return span ? span->typed<int>() : MutableSpan<int>(); }, - {}); + {}, + true); static BuiltinPointAttributeProvider<float> radius( "radius", @@ -1537,7 +1544,8 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() BuiltinAttributeProvider::NonDeletable, [](const Spline &spline) { return spline.radii(); }, [](Spline &spline) { return spline.radii(); }, - nullptr); + nullptr, + false); static BuiltinPointAttributeProvider<float> tilt( "tilt", @@ -1545,7 +1553,8 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() BuiltinAttributeProvider::NonDeletable, [](const Spline &spline) { return spline.tilts(); }, [](Spline &spline) { return spline.tilts(); }, - [](Spline &spline) { spline.mark_cache_invalid(); }); + [](Spline &spline) { spline.mark_cache_invalid(); }, + false); static DynamicPointAttributeProvider point_custom_data; |