Fix #128499: dot dash modifier crashes because of missing attributes

These attributes are not guaranteed to exist. So they should either be used
conditionally, or with a fallback value. The fallback value for the opacity is
obvious, but for the radius it's more tricky. There is not a consistent fallback
value across Blender unfortunately. The one I used here is used in a couple of
places.

Pull Request: https://projects.blender.org/blender/blender/pulls/128847
This commit is contained in:
Jacques Lucke
2024-10-14 14:19:24 +02:00
parent 373d77aeb6
commit 2806d54320

View File

@@ -204,13 +204,13 @@ static bke::CurvesGeometry create_dashes(const PatternInfo &pattern_info,
const IndexMask &curves_mask)
{
const bke::AttributeAccessor src_attributes = src_curves.attributes();
const VArray<bool> src_cyclic = *src_attributes.lookup_or_default(
"cyclic", bke::AttrDomain::Curve, false);
const VArray<bool> src_cyclic = src_curves.cyclic();
const VArray<int> src_material = *src_attributes.lookup_or_default(
"material_index", bke::AttrDomain::Curve, 0);
const VArray<float> src_radius = *src_attributes.lookup<float>("radius", bke::AttrDomain::Point);
const VArray<float> src_opacity = *src_attributes.lookup<float>("opacity",
bke::AttrDomain::Point);
const VArray<float> src_radius = *src_attributes.lookup_or_default<float>(
"radius", bke::AttrDomain::Point, 0.01f);
const VArray<float> src_opacity = *src_attributes.lookup_or_default<float>(
"opacity", bke::AttrDomain::Point, 1.0f);
/* Count new curves and points. */
int dst_point_num = 0;