Fix: Crash adding rest positions to empty mesh

The position attribute might not exist when the mesh is empty, which may
be another problem, but there is no need to count on it here.
This commit is contained in:
Hans Goudey 2022-11-02 13:59:25 +01:00
parent bc8b15f1a5
commit 0fc958a174
1 changed files with 1 additions and 1 deletions

View File

@ -747,7 +747,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
MutableAttributeAccessor attributes = mesh_final->attributes_for_write();
SpanAttributeWriter<float3> rest_positions =
attributes.lookup_or_add_for_write_only_span<float3>("rest_position", ATTR_DOMAIN_POINT);
if (rest_positions) {
if (rest_positions && attributes.domain_size(ATTR_DOMAIN_POINT) > 0) {
attributes.lookup<float3>("position").materialize(rest_positions.span);
rest_positions.finish();
}