Page MenuHome

Fix T38994: Edited/linked particles cause crash.
AbandonedPublic

Authored by Lukas Tönne (lukastoenne) on Mar 7 2014, 6:22 PM.

Details

Summary

This is a consequence of the fundamentally flawed particle design where
hair and particle settings are mixed in the same datablock.
When switching the type in ParticleSettings all instances (users of
that settings block) would have to be updated properly.

This is not feasible due to messy particle code, so the next best
solution (and a step towards clean design) is to disallow changing the
type of particle settings. The type is defined once when creating the
settings and never touched again, effectively making 2 types of particle
settings for particles and for hair.

This is not really a limitation, since particle settings are just linked
to the respective particle systems. This means to change the particle
type one can simply swap out the ParticleSettings datablock.
The only downside is that settings have to be copied or readjusted when
selecting another datablock, but since many settings are not comparable
between particles and hair anyway this is not a serious issue.

When using the operators for adding new particle systems or settings
there is now a menu popup to select the actual type of particles.

Diff Detail

Branch
particle_settings_const_type

Event Timeline

Here are some minor initial comments. I smell that allowing sharing particle systems may be a can of worms in other ways, especially if hair editing is allowed on one mesh - for instance what happens if derived meshes of the objects are different?. I will test more thoroughly later.

source/blender/blenkernel/intern/particle_system.c
4808

Is this function really needed if we disallow changing the type?

See also PSYS_RECALC_TYPE flag

source/blender/editors/object/object_modifier.c
117

This means that it's not possible to add hair from the modifier list anymore. It would be good to eventually have separate modifiers, but this could be another patch entirely.

source/blender/makesrna/intern/rna_main_api.c
38

Picky: Is it possible to move all DNA files together?

Antonis Ryakiotakis (psy-fi) requested changes to this revision.Mar 8 2014, 11:44 AM
source/blender/blenkernel/intern/particle_system.c
4808

Yes, this is still needed because it primarily applies to the ParticleSystemand not the (ID) ParticleSettings block.

Previously each particle system for which this was called would modify the ParticleSettings data block which is really bad. At least now all modification here is limited to the psys.

Changing type of psys still happens when swapping out the settings datablock, only changes from the settings type property are no longer happening.

source/blender/editors/object/object_modifier.c
117

Yes, this would be nice to have, but it's not a regression:

When adding a psys via the modifiers it would previously also have started out as an "emitter" type and has to be switched afterward.

source/blender/makesrna/intern/rna_main_api.c
38

Can do (not that particle code is beautiful everywhere else ...)

Particles will get complete replacement, so will drop this idea. It would have worked, but invalidated too many docs for a single bugfix.