Seems to be an issue of not correctly freeing the PTCacheEdit (see T68645 for details), after discussion with sergey we went with the quick and dirty fix to free the path cache early for now. Other solution of freeing it in 'psys_cache_paths' for the non-evaluated psys [which would also fix the particle delete, then undo crash from T69000] needs more deep investigation and, possibly, reconsideration.
Details
Diff Detail
- Repository
- rB Blender
Event Timeline
From reading i don't see this is necessarily a threading issue, more like some missing update tag or so? Maybe need to do ID_RECALC_PSYS_RESET or ID_RECALC_PSYS_CHILD ?
couple of notes:
- not a threading issue probably, agree
- cant get it to work with suggested ID_RECAL flags
- specifically calling psys_free_path_cache(NULL, edit) is also used by ADD and CUT brush, also done by shape_cut_exec
For the depsgraph side of things:
- I can see psys_free is called alongside deg_evaluate_copy_on_write:
- this calls psys_free_path_cache(psys, NULL), so only frees the ParticleSystem pathcache, but not the PTCacheEdit pathcache, hm...
- a bit later we reach particle_system_update (this gets called, too) > hair_step > psys_update_path_cache > psys_cache_paths
- this calls psys_free_path_cache(psys, psys->edit) (this should free both ParticleSystem and PTCacheEdit pathcache-- hooray!), but psys->edit is actually NULL here, hm...
- reminds me of D5758: PTCacheEdit does not live on evaluated object... so will update the diff to use psys_orig_edit_getin that place...
- if we go with the second suggestion, I can also check for ADD and CUT brush as well as shape_cut_exec (if their usage of psys_free_path_cache(NULL, edit) is obsolete...)
- particle code still make me a little dizzy, so not sure if I can be of more help here :)
- I know the old psys is not fun to look at, and is EOL, but I still think we should fix some stuff that is just broken in 2.8 compared to 2.79...
Note this also fixes the crasher mentioned in T69000: Hair: changing children related settings not updating in particle editmode
Did some look into the particle_edit.c. It seems a lot of code does sequence of
update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
So perhaps better to go with your original suggestion.
P.S. I would really love to see this code be more straightforward, but that's separate story :/
| source/blender/blenkernel/intern/particle.c | ||
|---|---|---|
| 2919–2920 ↗ | (On Diff #18321) | You are freeing cache for an original psys, but allocating it for evaluated one? |
| source/blender/blenkernel/intern/particle.c | ||
|---|---|---|
| 2919–2920 ↗ | (On Diff #18321) | During DEG evaluation:
But regarding the PTCacheEdit->pathcache [ I am only looking at this atm ]:
not sure what that tells us?
Anyways:
What do you think to get this finally of the table: (a) or (b)? |
For now just follow original proposal (which is currently commented out code in particle_edit.c). That was sufficient AFAIR, and that is how other tools are working here.
Bigger picture needs more deep investigation and, possibly, reconsideration.