[Bf-blender-cvs] [0fc958a1741] master: Fix: Crash adding rest positions to empty mesh

Hans Goudey noreply at git.blender.org
Wed Nov 2 14:00:03 CET 2022


Commit: 0fc958a174192b2b25c4187c170ec4a394dc308a
Author: Hans Goudey
Date:   Wed Nov 2 13:59:25 2022 +0100
Branches: master
https://developer.blender.org/rB0fc958a174192b2b25c4187c170ec4a394dc308a

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.

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

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

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

diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index 11ef2b08df4..97ff45e93ce 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -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();
     }



More information about the Bf-blender-cvs mailing list