diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-23 16:33:07 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-23 16:33:07 +0300 |
commit | 1925b9b2fac4e637cc2e0e2053e25059c5098664 (patch) | |
tree | 31a924afb33ac8d2e65a5102b370667c69fce748 /source/blender/editors/physics | |
parent | c61cb0e0765915d7ad2d9e91f6f72dfcea662744 (diff) |
Particle: Add option to duplicate settings together with particle system itself
This way it's possible to copy combed hair, use it as a basis for another
particle system to do some awesome artistic stuff.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 545042e1d84..895d791b8e2 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -993,7 +993,13 @@ static void remove_particle_systems_from_object(Object *ob_to) } /* single_psys_from is optional, if NULL all psys of ob_from are copied */ -static bool copy_particle_systems_to_object(Scene *scene, Object *ob_from, ParticleSystem *single_psys_from, Object *ob_to, int space) +static bool copy_particle_systems_to_object(Main *bmain, + Scene *scene, + Object *ob_from, + ParticleSystem *single_psys_from, + Object *ob_to, + int space, + bool duplicate_settings) { ModifierData *md; ParticleSystem *psys_start = NULL, *psys, *psys_from; @@ -1070,6 +1076,11 @@ static bool copy_particle_systems_to_object(Scene *scene, Object *ob_from, Parti if (psys_from->edit) copy_particle_edit(scene, ob_to, psys, psys_from); + + if (duplicate_settings) { + id_us_min(psys->part); + psys->part = BKE_particlesettings_copy(bmain, psys->part); + } } MEM_freeN(tmp_psys); @@ -1131,6 +1142,7 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) const int space = RNA_enum_get(op->ptr, "space"); const bool remove_target_particles = RNA_boolean_get(op->ptr, "remove_target_particles"); const bool use_active = RNA_boolean_get(op->ptr, "use_active"); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob_from = ED_object_active_context(C); ParticleSystem *psys_from = use_active ? CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data : NULL; @@ -1146,7 +1158,7 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) remove_particle_systems_from_object(ob_to); changed = true; } - if (copy_particle_systems_to_object(scene, ob_from, psys_from, ob_to, space)) + if (copy_particle_systems_to_object(bmain, scene, ob_from, psys_from, ob_to, space, false)) changed = true; else fail++; @@ -1201,12 +1213,14 @@ static int duplicate_particle_systems_poll(bContext *C) return true; } -static int duplicate_particle_systems_exec(bContext *C, wmOperator *UNUSED(op)) +static int duplicate_particle_systems_exec(bContext *C, wmOperator *op) { + const bool duplicate_settings = RNA_boolean_get(op->ptr, "use_duplicate_settings"); 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); + copy_particle_systems_to_object(CTX_data_main(C), scene, ob, psys, ob, + PAR_COPY_SPACE_OBJECT, duplicate_settings); return OPERATOR_FINISHED; } @@ -1221,4 +1235,7 @@ void PARTICLE_OT_duplicate_particle_system(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "use_duplicate_settings", false, "Duplicate Settings", + "Duplicate settings as well, so new particle system uses own settings"); } |