Particles: Add operator to quicly duplicate active particle system to the same object
This commit is contained in:
parent
776a8548f0
commit
1d03bc73ce
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue