Page MenuHome

LineArt: Cache relations in depsgraph and load objects from it.
Needs ReviewPublic

Authored by YimingWu (NicksBest) on May 20 2022, 1:42 PM.

Details

Summary

Problem

The problem with current line art object loading code is that it iterates through the scene to access objects, which is unsafe during evaluation because the original data could be freed/replaced by depsgraph.

What this patch does

This fix is more or less a copy pasta from the physics relation cache code, does work correctly for regular objects and instanced collection, and I used duplilist when loading objects "from cached relations", so they will all load correctly.

Potential problem: duplilist could access some instances that is set as lineart exclude, in which case their relations are not added. Not sure the best way to get around this problem...

Update:

Sergey actually did say that we might need a "thread-safe" iterator during depsgraph evaluation. I'm not sure how it's gonna be implemented, should I personally go inside and try to mess around DG code or do I wait a bit?

The thing about is the old iterator code is 1) not actually crashing although it's technically unsafe, no crash reports is related to that part since line art has become a gp modifier. 2) I haven't had any crashes either (although rarely I could have one or two leaked memory blocks?) 3) It actually can handle instanced objects like particles stuff. So I'm thinking if this depsgraph problem is not very high priority in line art scope, can I revert back to using the old FOREACH_OBJECT_BEGIN thing? This patch is even not very usable (nor am I sure my method here is correct because apparently sometimes it crashes and the reference object pointer thing it gives line art is almost always wrong...?)

Diff Detail

Repository
rB Blender

Event Timeline

YimingWu (NicksBest) requested review of this revision.May 20 2022, 1:42 PM
YimingWu (NicksBest) created this revision.
YimingWu (NicksBest) edited the summary of this revision. (Show Details)

Use duplilist when loading objects from "cached relation".

This fixed problems I could find. Should be very stable as long as these doesn't happen:

  • There's a particle system/child instance object whose instance object/collection is set to Exclude in line art.
  • There's a particle system who uses an object from outside the current active scene.

In theory those two conditions can be unsafe, but I haven't made them to crash. Please test more to see if there's any problem.

Adding Sergey as a reviewer because Sebastian is on break now... Or maybe other people might be more suitable?

Updated to latest master

Consider this a WIP for now.

If the patch is not ready for review, please mark it as "Changes Planned".

For the final review it seems to be more for the depsgraph people to have a look, which will be Sybren and me, and not Sebastian.

clear lineart_relations in init.

YimingWu (NicksBest) edited the summary of this revision. (Show Details)May 30 2022, 5:29 PM