Fix T90715: Remove correct particle modifier through Python API
Before this patch attempting to remove a particle modifier programmatically through Python would fail, because it deleted the modifier associated with the currently active particle system instead of the one passed as an argument to `bpy.types.ObjectModifiers.remove()`. This fix adds an additional argument for the particle system to `object_remove_particle_system`. This allows to specify which particle system and its associated modifier shall be removed. In case of `particle_system_remove_exec` it will remain the currently active particle system, whereas `object_remove_particle_system` passes the particle system of the modifier. Hence, the correct modifier will be removed. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D12234
This commit is contained in:
parent
551521cfa4
commit
38bdde852f
Notes:
blender-bot
2024-03-25 12:30:38 +01:00
Referenced by issue #90715, Removing particle system modifier through Python API, delete wrong modifier
|
@ -368,7 +368,10 @@ struct ModifierData *object_copy_particle_system(struct Main *bmain,
|
|||
struct Scene *scene,
|
||||
struct Object *ob,
|
||||
const struct ParticleSystem *psys_orig);
|
||||
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob);
|
||||
void object_remove_particle_system(struct Main *bmain,
|
||||
struct Scene *scene,
|
||||
struct Object *ob,
|
||||
struct ParticleSystem *psys);
|
||||
struct ParticleSettings *BKE_particlesettings_add(struct Main *bmain, const char *name);
|
||||
void psys_reset(struct ParticleSystem *psys, int mode);
|
||||
|
||||
|
|
|
@ -3967,16 +3967,18 @@ ModifierData *object_copy_particle_system(Main *bmain,
|
|||
return object_add_or_copy_particle_system(bmain, scene, ob, NULL, psys_orig);
|
||||
}
|
||||
|
||||
void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob)
|
||||
void object_remove_particle_system(Main *bmain,
|
||||
Scene *UNUSED(scene),
|
||||
Object *ob,
|
||||
ParticleSystem *psys)
|
||||
{
|
||||
ParticleSystem *psys = psys_get_current(ob);
|
||||
ParticleSystemModifierData *psmd;
|
||||
ModifierData *md;
|
||||
|
||||
if (!psys) {
|
||||
if (!ob || !psys) {
|
||||
return;
|
||||
}
|
||||
|
||||
ParticleSystemModifierData *psmd;
|
||||
ModifierData *md;
|
||||
|
||||
/* Clear particle system in fluid modifier. */
|
||||
if ((md = BKE_modifiers_findby_type(ob, eModifierType_Fluid))) {
|
||||
FluidModifierData *fmd = (FluidModifierData *)md;
|
||||
|
|
|
@ -352,7 +352,7 @@ static bool object_modifier_remove(
|
|||
|
||||
/* special cases */
|
||||
if (md->type == eModifierType_ParticleSystem) {
|
||||
object_remove_particle_system(bmain, scene, ob);
|
||||
object_remove_particle_system(bmain, scene, ob, ((ParticleSystemModifierData *)md)->psys);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,8 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
mode_orig = ob->mode;
|
||||
object_remove_particle_system(bmain, scene, ob);
|
||||
ParticleSystem *psys = psys_get_current(ob);
|
||||
object_remove_particle_system(bmain, scene, ob, psys);
|
||||
|
||||
/* possible this isn't the active object
|
||||
* object_remove_particle_system() clears the mode on the last psys
|
||||
|
|
Loading…
Reference in New Issue