Link/Append: separate instantiation of loose data from core link/append code #125814

Merged
Jacques Lucke merged 3 commits from JacquesLucke/blender:link-append-loose-data-instantiate into main 2024-08-07 09:35:28 +02:00
Member

When appending e.g. an object, it's generally expected that it is not just appended but also added to the active collection. Something similar happens for adding collections, or just geometry like a mesh data-block. This is called "loose data instantiation" in the source code.

Which data is instantiated and how depends on context. Generally, it's best to first do the low-level link or append operation and only afterwards do the instantiation at a higher level where more context is known. For example, when dragging an object asset into the 3D view, it's expected that the object is added to the active collection. When dragging a node group into the node editor that uses an object internally (e.g. as mesh storage), not so much.

This patch adds a new BKE_blendfile_link_append_instantiate_loose method that does the "default instantiation", i.e. the one we want to happen when using the general link/append operator to import data. Instead of calling this directly from low level BKE_blendfile_append, it's now called in wm_link_append_exec (and other places where desired).

Furthermore, view3d_ob_drop_copy_external_asset does not use this anymore, but explicitly adds only the dragged object to the active collection. Some places, e.g. when linking/appending using the Python API, don't do any instantiation at all. They didn't do this before either, but it was way less obvious (it used BLO_library_link_params_init instead of BLO_library_link_params_init_with_context). Now there is always an explicit call to do instantiation in higher level code.

When appending e.g. an object, it's generally expected that it is not just appended but also added to the active collection. Something similar happens for adding collections, or just geometry like a mesh data-block. This is called "loose data instantiation" in the source code. Which data is instantiated and how depends on context. Generally, it's best to first do the low-level link or append operation and only afterwards do the instantiation at a higher level where more context is known. For example, when dragging an object asset into the 3D view, it's expected that the object is added to the active collection. When dragging a node group into the node editor that uses an object internally (e.g. as mesh storage), not so much. This patch adds a new `BKE_blendfile_link_append_instantiate_loose` method that does the "default instantiation", i.e. the one we want to happen when using the general link/append operator to import data. Instead of calling this directly from low level `BKE_blendfile_append`, it's now called in `wm_link_append_exec` (and other places where desired). Furthermore, `view3d_ob_drop_copy_external_asset` does not use this anymore, but explicitly adds only the dragged object to the active collection. Some places, e.g. when linking/appending using the Python API, don't do any instantiation at all. They didn't do this before either, but it was way less obvious (it used `BLO_library_link_params_init` instead of `BLO_library_link_params_init_with_context`). Now there is always an explicit call to do instantiation in higher level code.
Jacques Lucke added 2 commits 2024-08-02 13:49:05 +02:00
fix
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
035441f113
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke requested review from Bastien Montagne 2024-08-02 14:07:41 +02:00
Bastien Montagne approved these changes 2024-08-05 15:15:36 +02:00
Bastien Montagne left a comment
Owner

LGTM

LGTM
@ -169,2 +169,4 @@
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports);
/**
* Instantiate loose objects in the scene (e.g. add object to the active collection).

loose data (or loose IDs), not loose objects ;)

`loose data` (or `loose IDs`), not `loose objects` ;)
JacquesLucke marked this conversation as resolved
@ -50,6 +50,9 @@ static void copybuffer_append(BlendfileLinkAppendContext *lapp_context,
/* Append, rather than linking */
BKE_blendfile_append(lapp_context, reports);
/* Instantiate loose objects in the scene (e.g. add object to the active collection). */

Same as above, instantiates more than objects

Same as above, instantiates more than objects
JacquesLucke marked this conversation as resolved
Jacques Lucke added 1 commit 2024-08-07 09:33:20 +02:00
Jacques Lucke merged commit 2858c3b287 into main 2024-08-07 09:35:28 +02:00
Jacques Lucke deleted branch link-append-loose-data-instantiate 2024-08-07 09:35:32 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
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#125814
No description provided.