Fix #68436: External Particle Disk Cache Playback Is Broken #117291

Merged
Philipp Oeser merged 3 commits from lichtwerk/blender:68436 into main 2024-01-19 11:47:45 +01:00
Member

This has been broken since 2.8.

The highlevel reason for this is that the "info file" (saved as frame
zero) was not written anymore.
Reason for that in turn is that when calling BKE_ptcache_write outside
the bake job, the PTCacheID calldata (a psys in our case) is not the
evaluated particle system, causing a check for totpoint to fail (these
were always zero).

Deeper reasoning is unclear, no further investigations were done as to
why/when this happened.

The solution proposed here is using the evaluated psys when writing the
info frame (and this is isolated to just this spot). File then gets
written and can/will be read when using this as an external disk cache
in another file.

This has been broken since 2.8. The highlevel reason for this is that the "info file" (saved as frame zero) was not written anymore. Reason for that in turn is that when calling `BKE_ptcache_write` outside the bake job, the `PTCacheID` `calldata` (a psys in our case) is not the evaluated particle system, causing a check for `totpoint` to fail (these were always zero). Deeper reasoning is unclear, no further investigations were done as to why/when this happened. The solution proposed here is using the evaluated psys when writing the info frame (and this is isolated to just this spot). File then gets written and can/will be read when using this as an external disk cache in another file.
Philipp Oeser added 1 commit 2024-01-18 16:44:36 +01:00
70be9a0236 Fix #68436: External Particle Disk Cache Playback Is Broken
This has been broken since 2.8.

The highlevel reason for this is that the "info file" (saved as frame
zero) was not written anymore.
Reason for that in turn is that when calling `BKE_ptcache_write` outside
the bake job, the `PTCacheID` `calldata` (a psys in our case) is not the
evaluated particle system, causing a check for `totpoint` to fail (these
were always zero).

Deeper reasoning is unclear, no further investigations were done as to
why/when this happened.

The solution proposed here is using the evaluated psys when writing the
info frame (and this is isolated to just this spot). File then gets
written and can/will be read when using this as an external disk cache
in another file.
Philipp Oeser added this to the Nodes & Physics project 2024-01-18 16:44:46 +01:00
Author
Member

I am aware that this is EOL, but this has been reported so often...

Maybe (just maybe?) this clicks with @Sergey ?

I am aware that this is EOL, but this has been reported so often... Maybe (just maybe?) this clicks with @Sergey ?
Sergey Sharybin requested changes 2024-01-18 17:00:20 +01:00
Sergey Sharybin left a comment
Owner

It does seem that write needs to happen from the evaluated state. And it also doesn't seem that we can pre-calculate pid of from the evlauated object earlier on, as it potentially might change (if psys is re-allocated as part of dependency graph evaluation and its copy-on-wtite thing).

I can not think of a better solution than what you did for querying the evaluated pid before writing.

See an inlined comment about some variable use, which needs to be corrected. Should be simple though!

It does seem that write needs to happen from the evaluated state. And it also doesn't seem that we can pre-calculate pid of from the evlauated object earlier on, as it potentially might change (if `psys` is re-allocated as part of dependency graph evaluation and its copy-on-wtite thing). I can not think of a better solution than what you did for querying the evaluated pid before writing. See an inlined comment about some variable use, which needs to be corrected. Should be simple though!
@ -3389,0 +3395,4 @@
Object *ob = (GS(id->name) == ID_OB) ? (Object *)id : nullptr;
ParticleSystem *psys = static_cast<ParticleSystem *>(pid->calldata);
ParticleSystem *psys_eval = psys_eval_get(baker->depsgraph, ob, psys);
BKE_ptcache_id_from_particles(pid, ob, psys_eval);

Original and evaluated pointers shouldn't be mixed without explicit comment why it is unavoidable. This should become BKE_ptcache_id_from_particles(pid_eval, ob_eval, psys_eval);

Also note that we shouldn't override the content of the pid, but get its evaluated counterpart to a separate variable. Otherwise the second iteration of this loop will access the previously modified pid state.

Original and evaluated pointers shouldn't be mixed without explicit comment why it is unavoidable. This should become `BKE_ptcache_id_from_particles(pid_eval, ob_eval, psys_eval);` Also note that we shouldn't override the content of the `pid`, but get its evaluated counterpart to a separate variable. Otherwise the second iteration of this loop will access the previously modified `pid` state.
Philipp Oeser added 1 commit 2024-01-19 10:40:42 +01:00
Sergey Sharybin approved these changes 2024-01-19 10:55:40 +01:00
Sergey Sharybin left a comment
Owner

Think it is fine now. Would be lovely if you tweak the cast style before land. Can happen without extra review iteration.

Think it is fine now. Would be lovely if you tweak the cast style before land. Can happen without extra review iteration.
@ -3358,2 +3361,3 @@
if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
ID *id = pid->owner_id;
Object *ob = (GS(id->name) == ID_OB) ? (Object *)id : nullptr;

Do not mix C and C++ style of casting, use the C++ one: Object *ob = (GS(id->name) == ID_OB) ? reinterpret_cast<Object *>(id) : nullptr;

Do not mix C and C++ style of casting, use the C++ one: `Object *ob = (GS(id->name) == ID_OB) ? reinterpret_cast<Object *>(id) : nullptr;`
Philipp Oeser added 1 commit 2024-01-19 11:32:46 +01:00
Philipp Oeser merged commit ab9c0af1ce into main 2024-01-19 11:47:45 +01:00
Philipp Oeser deleted branch 68436 2024-01-19 11:47:48 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117291
No description provided.