Fix T92402: copy_particle_systems use_active fails outside the

Properties Editor

Similar to rBf9308a585ecd, use `psys_get_current` if we cant get the
active psys from context (which is only defined for the Properties
Editor). Other solution would be to define a "particle_system" context
member in other editors, but for now, stick with the simplest solution.

thx @mano-wii for additional input

Maniphest Tasks: T92402

Differential Revision: https://developer.blender.org/D13000
This commit is contained in:
Philipp Oeser 2021-10-26 09:55:50 +02:00
parent b3b2cd1fa9
commit ec77228f0f
Notes: blender-bot 2023-02-14 04:46:12 +01:00
Referenced by issue #92402, Copy particle hair from one mesh to another
1 changed files with 9 additions and 3 deletions

View File

@ -1235,9 +1235,15 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
const bool use_active = RNA_boolean_get(op->ptr, "use_active");
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;
ParticleSystem *psys_from = NULL;
if (use_active) {
psys_from = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
if (psys_from == NULL) {
/* Particle System context pointer is only valid in the Properties Editor. */
psys_from = psys_get_current(ob_from);
}
}
int changed_tot = 0;
int fail = 0;