[Bf-blender-cvs] [1d03bc7] master: Particles: Add operator to quicly duplicate active particle system to the same object

Sergey Sharybin noreply at git.blender.org
Fri Sep 23 14:32:44 CEST 2016


Commit: 1d03bc73cea8b24ad1b90f7df5a3124a91370524
Author: Sergey Sharybin
Date:   Fri Sep 23 14:32:14 2016 +0200
Branches: master
https://developer.blender.org/rB1d03bc73cea8b24ad1b90f7df5a3124a91370524

Particles: Add operator to quicly duplicate active particle system to the same object

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 89ea9df..4e2666d 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -79,6 +79,8 @@ class PARTICLE_MT_specials(Menu):
         props.use_active = False
         props.remove_target_particles = True
 
+        layout.operator("particle.duplicate_particle_system")
+
 
 class PARTICLE_MT_hair_dynamics_presets(Menu):
     bl_label = "Hair Dynamics Presets"
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 0dd00df..2462061 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -1187,3 +1187,37 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot)
 	RNA_def_boolean(ot->srna, "remove_target_particles", true, "Remove Target Particles", "Remove particle systems on the target objects");
 	RNA_def_boolean(ot->srna, "use_active", false, "Use Active", "Use the active particle system from the context");
 }
+
+static int duplicate_particle_systems_poll(bContext *C)
+{
+	if (!ED_operator_object_active_editable(C)) {
+		return false;
+	}
+	Object *ob = ED_object_active_context(C);
+	if (BLI_listbase_is_empty(&ob->particlesystem)) {
+		return false;
+	}
+	return true;
+}
+
+static int duplicate_particle_systems_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Scene *scene = CTX_data_scene(C);
+	Object *ob = ED_object_active_context(C);
+	ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
+	copy_particle_systems_to_object(scene, ob, psys, ob, PAR_COPY_SPACE_OBJECT);
+	return OPERATOR_FINISHED;
+}
+
+void PARTICLE_OT_duplicate_particle_system(wmOperatorType *ot)
+{
+	ot->name = "Duplicate Particle Systems";
+	ot->description = "Duplicate particle system within the active object";
+	ot->idname = "PARTICLE_OT_duplicate_particle_system";
+
+	ot->poll = duplicate_particle_systems_poll;
+	ot->exec = duplicate_particle_systems_exec;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index 361c058..6b6df15 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -75,6 +75,7 @@ void PARTICLE_OT_target_move_down(struct wmOperatorType *ot);
 void PARTICLE_OT_connect_hair(struct wmOperatorType *ot);
 void PARTICLE_OT_disconnect_hair(struct wmOperatorType *ot);
 void PARTICLE_OT_copy_particle_systems(struct wmOperatorType *ot);
+void PARTICLE_OT_duplicate_particle_system(struct wmOperatorType *ot);
 
 void PARTICLE_OT_dupliob_copy(struct wmOperatorType *ot);
 void PARTICLE_OT_dupliob_remove(struct wmOperatorType *ot);
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 5074a41..7ba4b2b 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -83,6 +83,7 @@ static void operatortypes_particle(void)
 	WM_operatortype_append(PARTICLE_OT_connect_hair);
 	WM_operatortype_append(PARTICLE_OT_disconnect_hair);
 	WM_operatortype_append(PARTICLE_OT_copy_particle_systems);
+	WM_operatortype_append(PARTICLE_OT_duplicate_particle_system);
 
 	WM_operatortype_append(PARTICLE_OT_dupliob_copy);
 	WM_operatortype_append(PARTICLE_OT_dupliob_remove);




More information about the Bf-blender-cvs mailing list