Page MenuHome

Hair dynamics cache fix
Needs ReviewPublic

Authored by Pavel Rudko (PavelRudko) on Jul 4 2018, 9:38 AM.


Sybren A. Stüvel (sybren)
Group Reviewers

Guys, this is NOT the actual code change that should be commited and I haven't done a proper fix. This is just a dummy workaround and can be used for a reference so that you can see the problem more clearly. But I would like to ask you to investigate and to think of a proper solution.
The problem is that when we click 'Bake' button in particle system settings, particle system gets copied in depsgraph and the cache is copied as well. Progress bar is visible but the status is always '0 frames in memory'. After making some changes that should not make the cache outdated (for example applying different material to object) cache is destroyed.
In my workaround patch original cache is used in hair simulation instead of the copied one. It helps to preserve it during object changes and copying/freeing particle system. Also status shows the actual number of frames in memory.
And here's how I think it should work (tried to make it myself but I've got lost in the code):

  • When pressing the button and getting original cache from context, the copied cache should be found somehow and used in baking (this will fix status visible to users)
  • After depsgraph evaluation the copied cache should be copied to the original particle system (and it applies not to the hair as in my patch, but for particle systems in general)

I understand you've got a lot of work to do, but maybe my message and reference diff can help you somehow to look closely at this problem. Thank you!

Diff Detail

Event Timeline

Sybren A. Stüvel (sybren) requested changes to this revision.Jul 4 2018, 11:00 AM
Sybren A. Stüvel (sybren) edited reviewers, added: Physics; removed: BF Blender: 2.8.

This issue with pointcaches being copied to (and used on) evaluated copies of objects is something that I've been working on for rigid body physics as well. Probably an approach like what I did in 98a0bcd4252e could be appliccable here too?

Redefining a DNA flag value is a bad idea. Furthermore, the PSYS_MANUAL_BAKE flag is never cleared anywhere. I don't quite understand how this problem would only affect baking, why is this flag necessary in the first place?

This revision now requires changes to proceed.Jul 4 2018, 11:00 AM

Yes, using that flag is a bad idea, I made it just to see how everything will work once we 'freeze' baking. It should be cleared when the user clicks 'Free bake' button. But again, that's just a temporary hack. I'll look at your approach for rigid body physics, probably it will help and I'll be able to find a proper solution myself. Thank you!

T62563 and @Pavel Rudko (PavelRudko) discussion are related through the lack of persistence of the particle system cache management when a cache is being generated in the context of a Cntl + F12 rendering animation. Rendering depsgraphs are created and destroyed per frame now (since November 2018), so cache management doesn't persist. Ideally, Mr. Rudko's second bullet point furnishes the path to solve T62563, though practically, as Mr. Rudko points out, this proposal is a sketch, not a solution. So I'm putting a flag here for my reference. Noted: that a rewrite of the particle system may very well sweep this problem and its context entirely away, so solving this problem in this specific setting may not have very much long term value.

Resigning as a reviewer due to the inactivity on this patch.

This revision now requires review to proceed.Sep 27 2019, 5:42 PM