Fix: Various issues with auto smooth versioning #119539
No reviewers
Labels
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 project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#119539
Loading…
Reference in New Issue
No description provided.
Delete Branch "HooglyBoogly/blender:fix-auto-smooth-versioning"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR fixes several issues with the versioning that replaces the old
auto smooth flag with a modifier.
One issue is that the flag wasn't cleared in the initial versioning
code. That means some objects have the replacement modifier but their
meshes still have the flag set. The fix for that is to make the
versioning idempotent by trying to find an existing node group before
adding a new one. The versionig is now re-run on all objects to clear
the flags. Flags on all meshes are cleared too, even unused meshes.
That could cause loss of the auto-smooth when the mesh is linked from
a different blend-file, but that situation should be very rare.
Another issue was that the versioning wasn't run when linking objects.
That was simple to solve by adding the versioning where the proxy
versioning already existed for that case.
Finally, arguably the largest issue was that the the newly added node
groups were always added as local data-blocks. When linking, having
library data-blocks point to local data-blocks not in that library is
quite bad and breaks assumptions around Blender. This is solved by
having an auto smooth node group per library.
Resolves #119516, #119455, #119447
WIP: Fix: Various issues with auto smooth versioningto Fix: Various issues with auto smooth versioning@ -2244,0 +2256,4 @@
return result;
}
static bool is_auto_smooth_node_tree(const bNodeTree &group)
Would be good to mention the function name that builds the node group we compare against here.
@ -2247,2 +2335,3 @@
BKE_modifier_unique_name(&object.modifiers, &md->modifier);
md->node_group = get_node_group();
md->node_group = get_node_group(object.id.lib);
md->node_group->id.us++;
Any reason for using direct increment/decrement instead of the corresponding utility methods? (
id_us_plus
)Hmm, no, I'll use those
@ -2268,3 +2357,4 @@
using namespace blender;
using namespace blender::bke;
/* Add the node group lazily and share it among all objects in the main database. */
This comment seems outdated.
@ -2276,0 +2378,4 @@
/* Remove the default user. The count is tracked manually when assigning to modifiers. */
new_group->id.us--;
if (new_group->id.lib != library) {
Is this semantically the same as comparing to
nullptr
here?Semantically I think it's different. This is really asking "do we have to move the data-block to a different library.
Physically I think it's the same (though that assumes a new data-blocks
.lib
pointer is alwaysnullptr
, which I'm not 100% sure about with thecurlib
stuff. So I'd rather be safe here since this check doesn't hurt.@ -2276,0 +2382,4 @@
/* Move the node group to the requested library so that library data-blocks don't point to
* local data-blocks. This requires making sure the name is unique in that library and
* changing the name maps to be consistent with the new state. */
new_group->id.lib = library;
Are there other places which move something into a library after it has been created? Seems ok, but don't know if just setting this one property is enough to make it part of the library.
As far as I can tell (reading other code that does
->lib =
), yeah, this looks like enough. Bastien also said this:Out of the flags I checked,
LIB_TAG_EXTERN
may need to be set, but hard to say for sure.I think
LIB_TAG_INDIRECT
should be set, which means linked indirectly through another linked datablock.LIB_TAG_EXTERN
means linked directly.One thing I would suggest to test is to link an object datablock like this, and then make it local. See if it gets correctly converted.
When I make a linked object local, the node group remains linked. The object's mesh data does too though, so I wouldn't expect the node group to become local.
Semantically
LIB_TAG_INDIRECT
makes sense though, so I'll add the tag (it didn't change the object make local behavior anyway).I also checked "Make Local" on the node group itself, that does work.
Also fixes the bug I was investigating this morning in Simons file.
@ -37,2 +37,4 @@
#include "BKE_idprop.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_main_namemap.hh"
Might need
#include "BKE_node_runtime.hh"
for.all_nodes()
.Already there :)
@blender-bot build
Code looks good, seems to work fine in testing.
This unfortunately causes a crash for me on the Amy Restaurant demo file: