[Bf-blender-cvs] [538da79c6d1] master: Curves: fix applying materials when applying modifier

Jacques Lucke noreply at git.blender.org
Thu Jul 21 12:23:51 CEST 2022


Commit: 538da79c6d17a6e660a9484c280220240b306282
Author: Jacques Lucke
Date:   Thu Jul 21 12:23:10 2022 +0200
Branches: master
https://developer.blender.org/rB538da79c6d17a6e660a9484c280220240b306282

Curves: fix applying materials when applying modifier

The issue was that geometry nodes was run on the original curves,
and set a pointer to an evaluated material id on it. The fix is to not
mix up original and evaluated data by making sure that geometry nodes
does not modify the original data.

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

M	source/blender/editors/object/object_modifier.cc

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

diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index a3a41a5c5b1..e7cfcf48fd3 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -818,7 +818,7 @@ static bool modifier_apply_obdata(
     /* Create a temporary geometry set and component. */
     GeometrySet geometry_set;
     geometry_set.get_component_for_write<CurveComponent>().replace(
-        &curves, GeometryOwnershipType::Editable);
+        &curves, GeometryOwnershipType::ReadOnly);
 
     ModifierEvalContext mectx = {depsgraph, ob, (ModifierApplyFlag)0};
     mti->modifyGeometrySet(md_eval, &mectx, &geometry_set);
@@ -833,14 +833,11 @@ static bool modifier_apply_obdata(
         .attributes_for_write()
         .remove_anonymous();
 
-    /* If the modifier's output is a different curves data-block, copy the relevant information to
-     * the original. */
-    if (&curves_eval != &curves) {
-      blender::bke::CurvesGeometry::wrap(curves.geometry) = std::move(
-          blender::bke::CurvesGeometry::wrap(curves_eval.geometry));
-      Main *bmain = DEG_get_bmain(depsgraph);
-      BKE_object_material_from_eval_data(bmain, ob, &curves_eval.id);
-    }
+    /* Copy the relevant information to the original. */
+    blender::bke::CurvesGeometry::wrap(curves.geometry) = std::move(
+        blender::bke::CurvesGeometry::wrap(curves_eval.geometry));
+    Main *bmain = DEG_get_bmain(depsgraph);
+    BKE_object_material_from_eval_data(bmain, ob, &curves_eval.id);
   }
   else {
     /* TODO: implement for point clouds and volumes. */



More information about the Bf-blender-cvs mailing list