Fix T60060: Corrective Smooth Modifier binding process is broken.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 2 Jan 2019 10:26:31 +0000 (11:26 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 2 Jan 2019 10:26:31 +0000 (11:26 +0100)
Same as with the other modifiers' binding ops, those need to be
performed outside of regular depsgraph eval.

source/blender/editors/object/object_modifier.c

index 2be86773057e26e87614b136628485ca249bb26e..15aca6a325394c2cbd7ca5e41fe1d58289c79eee 100644 (file)
@@ -1880,6 +1880,7 @@ static bool correctivesmooth_poll(bContext *C)
 
 static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
 {
 
 static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
 {
+       Depsgraph *depsgraph = CTX_data_depsgraph(C);
        Scene *scene = CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get(op, ob, eModifierType_CorrectiveSmooth);
        Scene *scene = CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get(op, ob, eModifierType_CorrectiveSmooth);
@@ -1906,9 +1907,16 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
        else {
                /* signal to modifier to recalculate */
                csmd->bind_coords_num = (unsigned int)-1;
        else {
                /* signal to modifier to recalculate */
                csmd->bind_coords_num = (unsigned int)-1;
+
+               /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */
+               const int mode = csmd->modifier.mode;
+               csmd->modifier.mode |= eModifierMode_Realtime;
+               object_force_modifier_update_for_bind(depsgraph, scene, ob);
+               csmd->modifier.mode = mode;
        }
 
        }
 
-       DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+       /* We need ID_RECALC_COPY_ON_WRITE to ensure (un)binding is flushed to CoW copies of the object... */
+       DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
        WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
 
        return OPERATOR_FINISHED;
        WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
 
        return OPERATOR_FINISHED;