diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-23 15:32:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-23 15:32:36 +0300 |
commit | 1d03bc73cea8b24ad1b90f7df5a3124a91370524 (patch) | |
tree | 455b21d022e5b78eef8f0e5c93b91cf192851897 /source | |
parent | 776a8548f03a049d56f19943e6bc4590ecd53028 (diff) |
Particles: Add operator to quicly duplicate active particle system to the same object
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 34 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_ops.c | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 0dd00df6182..2462061c331 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 361c058647a..6b6df15e987 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 5074a41ad20..7ba4b2be43b 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); |