[Bf-blender-cvs] [a078fe3] master: Fix T47750: Edited hair: disconnect (and connect!) operator do not support redo.

Bastien Montagne noreply at git.blender.org
Mon Mar 14 21:14:33 CET 2016


Commit: a078fe35396a34c8f6440e22c37a3b27e0c1f61a
Author: Bastien Montagne
Date:   Mon Mar 14 21:04:30 2016 +0100
Branches: master
https://developer.blender.org/rBa078fe35396a34c8f6440e22c37a3b27e0c1f61a

Fix T47750: Edited hair: disconnect (and connect!) operator do not support redo.

As suggested by Sergey, do not register those anymore, this way we keep undo step,
but user cannot 'redo' them (does not work, since cached DM in particle modifier data
is not yet re-created by depsgraph update after undo when operator is redone).

UI now has two buttons, one to (dic)connect current psys, the other to (dis)connect all.

Also fixed similar issue with Connect Hair op.

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

M	release/scripts/startup/bl_ui/properties_particle.py
M	source/blender/editors/physics/particle_object.c

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

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 207f6f8..08290f2 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -218,9 +218,13 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
                 row.prop(part, "hair_step")
                 if psys is not None and psys.is_edited:
                     if psys.is_global_hair:
-                        layout.operator("particle.connect_hair")
+                        row = layout.row(align=True)
+                        row.operator("particle.connect_hair").all = False
+                        row.operator("particle.connect_hair", text="Connect All").all = True
                     else:
-                        layout.operator("particle.disconnect_hair")
+                        row = layout.row(align=True)
+                        row.operator("particle.disconnect_hair").all = False
+                        row.operator("particle.disconnect_hair", text="Disconnect All").all = True
             elif psys is not None and part.type == 'REACTOR':
                 split.enabled = particle_panel_enabled(context, psys)
                 split.prop(psys, "reactor_target_object")
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 7aa4c24..1297133 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -649,7 +649,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
 	ot->exec = disconnect_hair_exec;
 	
 	/* flags */
-	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+	ot->flag = OPTYPE_UNDO;  /* No REGISTER, redo does not work due to missing update, see T47750. */
 
 	RNA_def_boolean(ot->srna, "all", 0, "All hair", "Disconnect all hair systems from the emitter mesh");
 }
@@ -862,7 +862,6 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
 	Object *ob= ED_object_context(C);
-	PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
 	ParticleSystem *psys= NULL;
 	const bool all = RNA_boolean_get(op->ptr, "all");
 	bool any_connected = false;
@@ -876,12 +875,13 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
 		}
 	}
 	else {
-		psys = ptr.data;
+		psys = psys_get_current(ob);
 		any_connected |= connect_hair(scene, ob, psys);
 	}
 
 	if (!any_connected) {
-		BKE_report(op->reports, RPT_ERROR, "Can't disconnect hair if particle system modifier is disabled");
+		BKE_report(op->reports, RPT_WARNING,
+		           "No hair connected (can't connect hair if particle system modifier is disabled)");
 		return OPERATOR_CANCELLED;
 	}
 
@@ -900,7 +900,7 @@ void PARTICLE_OT_connect_hair(wmOperatorType *ot)
 	ot->exec = connect_hair_exec;
 	
 	/* flags */
-	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+	ot->flag = OPTYPE_UNDO;  /* No REGISTER, redo does not work due to missing update, see T47750. */
 
 	RNA_def_boolean(ot->srna, "all", 0, "All hair", "Connect all hair systems to the emitter mesh");
 }




More information about the Bf-blender-cvs mailing list