Commit Graph

33 Commits

Author SHA1 Message Date
Bastien Montagne a54253f335 LibOverride: Add proper reports when deleting user-edited overrides as part of resync.
Logs are not enough here, we need proper warning visible for the user.
2021-05-07 12:54:13 +02:00
Bastien Montagne e92a7800b5 LibOverride: Fix several issues with resync code.
This commit essentially touches to post-processing of collections and
objects after resync itself has been done, to ensure their proper
instantiation in the scene:

 - Remove a lot of the process in resync case (resynced data are assumed
   to be already instantiated in the scene, unlike override creation
   case).

 - For auto-resync, only do post-processing once after all overrides
   have been resynced (doing it after each individual resynced was
   causing a lot of instantiation glitches, with a lot of unwanted
   extra objects and collections being added to the master collection).

It also deals in a much more reliable way with detection of objects
missing from the scene, by using the new `BKE_scene_objects_as_gset`
utils.

As a bonus this makes auto-resync process slightly faster (only by a few
percents, but that's always good to get).
2021-04-08 11:45:55 +02:00
Jeroen Bakker 87f9405c9a Overrides: API to create an override template.
This is functionality that isn't accessible via the user interface. The
API allows the creation and modification of an override template that
holds rules that needs to be checked when overriding the asset.

The API is setup that it cannot be changed after creation. Later on when
the system is more mature we will allow changing overrides operations.

NOTE: This is an experimental feature and should not be used in productions.

Reviewed By: mont29, sebbas

Differential Revision: https://developer.blender.org/D10792
2021-03-29 09:54:34 +02:00
Bastien Montagne a00249dd22 LibOverride: Stash away 'leftover' objects/collections from auto-resync process.
Instead of storing those in scne's master collection, which is fairly
annoying, we now add them to a (hidden) specific collection. Easy to
ignore, or check and cleanup.
2021-03-19 17:33:08 +01:00
Bastien Montagne 992abd4734 LibOverride: Add checks to address some degenerate blend file cases
Attempt to work around some full-corruption cases created at the studio.
Not clear how those were created, so not really fixing anything here,
just detecting and 'solving' as best as possible some high corruption of
local overrides.

This is good to have in general anyway, might help prevent further
corruption to happen too.
2021-03-15 15:21:40 +01:00
Bastien Montagne 74557ca4f7 LibOverride: Add a new operation to Outliner to enforce resync of hierarchies.
This is basically done by ignoring override operations from old override
affecting ID pointer properties, when the new (destination) one is not
NULL.

Fix T86501: New object added to overridden collection doesn't show up in linking file on Resync.

This is more of a work-around actually, since there is no real way to
fix the issue in a fully automated and consistent way, it is caused by
older blender files being saved with 'broken' overrides.

WARNING: This cannot ensure that some purposedly edited/overridden ID
pointer properties won't be lost in the process.
2021-03-12 12:31:25 +01:00
Bastien Montagne a023c1a34c LibOverride: Add second part of auto-resync code.
`BKE_lib_override_library_main_resync` uses
`LIB_TAG_LIB_OVERRIDE_NEED_RESYNC` tags set by RNA override apply code,
and perform detection for the remaining cases (those were new overrides
need to be created for data that was not present before in the library).

And then it actually resync all needed local overrides.

Part of T83811 & D10649.
2021-03-11 14:26:19 +01:00
Bastien Montagne 0a6ed7f035 LibOverride: Add a utils to check if override has been user-edited.
Part of T83811 & D10649.
2021-03-11 14:26:19 +01:00
Bastien Montagne 2a81d948ad LibOverride: refactor of relationships handling in library overrides.
First step towards a better handling of relationships between IDs in
override context, especially when a resync is needed.

First, introduce a new flag to override operations,
`IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE`, for ID pointers.
It keeps track of whether an RNA ID pointer has been kept to its
'natural overriden ID' (in override hierarchy context), or has actually
been re-assigned to some other data-block.

Second, refactor how we deal with relationships between IDs in override
hierarchy code, especially in resync case. This will fixe several cases
listed in T83811, especially the case where an ID pointer to an existing
override needs to be updated to a new one due to a matching change in
linked data.
2021-01-25 14:48:51 +01:00
Julian Eisel aa64fd69e7 UI: List library overrides in the Outliner
Having a centeral place to find a list of all library overrides should be
useful for managing production scenes where library overrides are used a lot.
This change adds the individually overridden properties of a data-block under
the data-block itself. Just how we show modifiers, constraints or pose channels
there. This way we can also expose library override operations/options better
in future.

There's also a filter option for the library overrides now, so they can be
hidden. It is only available in the View Layer display mode though, like the
other filter options.

One internal change this has to do is adding more informative return values to
undo pushes and the library override functions called by it. That way we can
send a notifier when library overrides change for the Outliner to know when to
rebuild the tree.

Differential Revision: https://developer.blender.org/D7631

Reviewed by: Andy Goralczyk, Bastien Montagne, William Reynish
2020-12-27 22:45:41 +01:00
Bastien Montagne 25543e6983 LibOverride: Better handling of missing linked data during resync.
We do not generate overrides for missing data-blocks (aka placeholder
ones) anymore, and properly delete the remaining old overrides of those
during the resync process.

This should prevent constant 'missing data-blocks' messages when opening
blend files with overrides whose libraries have beed edited.

Issue reported by @andy from Blender studio, thanks.
2020-12-16 15:12:56 +01:00
Campbell Barton 38a66903e5 Cleanup: sort struct declarations 2020-09-30 11:51:13 +10:00
Bastien Montagne c3a0618fbf LibOverride: Add operator to convert a proxy object into an override.
In the end the process is surpringly simple, we only need to manually
convert the proxy itself into an override (which is trivial), and then
run common code with the default 'make override' operation.

Fix T81059: Add operator to convert proxies to library overrides.
2020-09-23 11:07:03 +02:00
Bastien Montagne 4aa04b6490 LibOverride: Add 'delete and use linked data' operation.
This will re-link all usages of a library override data-block
(including all of its override dependencies) to its reference linked
IDs, and delete those liboverrides.

As usual, it is available in the ID sub-menu of the outliner context
right-click menu.

Part of T76555.
2020-08-20 12:35:16 +02:00
Bastien Montagne aeaf2b0dd4 LibOverride: Add initial version of 'resync' operation.
Available from the usual ID submenu in the Outliner context menu.

The goal of this operator is to re-create the override from the linked
data, while preserving existing defined overrides.

This allows to update local opverrides when relations between datablocks
are changed in source library linked data.

Part of T76555.
2020-08-19 16:27:49 +02:00
Jacques Lucke 7283e6fb73 Merge branch 'blender-v2.90-release' into master 2020-08-07 10:04:57 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Campbell Barton ef7b804e26 Cleanup: missing 'initialize' -> 'init' from previous cleanup 2020-08-05 11:56:14 +10:00
Bastien Montagne 60b80ce142 LibOverride: Add core functions to reset a library override.
This means that we delete all override properties except for those over
ID pointers *if* the assigned pointer matches the linked data hierarchy.

Then we reload affected datablocks.
2020-07-23 11:33:24 +02:00
Bastien Montagne 5057b28a2f LibOverride: move most of 'complete override creation' from ED_object to BKE_lib_override.
This code is fairly complex and can be used in more places, better not
duplicate that logic and just have it in BKE area.
2020-07-15 18:17:34 +02:00
Bastien Montagne c8a62e4f50 Cleanup: function name not following its module conventions. 2020-07-14 15:28:08 +02:00
Bastien Montagne 140b26909e LibOverride: Move code tagging reauired dependencies of an override into BKE.
This is fairly generic code that can be re-used in other places.
2020-07-14 14:51:13 +02:00
Bastien Montagne 3d587efef2 LibOverride: Cleanup: Remove option to disable library overrides.
Code is mature enough now to not need this anymore, people who do not
want to use liboverrides can just not create them.
2020-07-13 16:45:55 +02:00
Bastien Montagne e18d6f5206 LibOverride: Cleanup: remove unused parameter. 2020-06-19 17:01:20 +02:00
Bastien Montagne 74ec37b70c Enable (deep) copy of overrides.
This commit enables basic copy of overrides on generic ID level, as well
as from (deep) copy operators for objects and collections.

So e.g. if your linked overridden caracter is in a collection, you can
now (from the outliner) Duplicate that override collection to get a new
overriding copy of the character.

We still need operators (new or modifying existing ones) to handle that
from 3DView e.g.

Note that deep copy code for objects/collections (and incidently
animdata) had to be modified to avoid duplicating/making local IDs that
remain linked ones being used by overrides ones.
2020-06-10 16:48:49 +02:00
Bastien Montagne 81bb2a143c Fix T75730: Properly remove unused override properties/operations.
While code is supposed to handle gracefully invalid override operations,
it is much cleaner to avoid those completely.
2020-04-16 16:21:11 +02:00
Bastien Montagne 0438944b34 Refactor/strengthen a bit invalid operands checks when applying an override operation. 2020-04-16 16:21:11 +02:00
Jacques Lucke 5de56f9596 Cleanup: make remaining blenkernel headers work in C++ 2020-03-02 15:07:49 +01:00
Campbell Barton f829fefe8a Cleanup: spelling 2020-02-15 15:58:06 +11:00
Bastien Montagne e75e29ee47 Cleanup: Rename `BKE_library_override_` functions to `BKE_lib_override_library_`
pqrt of T72604.
2020-02-10 18:05:19 +01:00
Bastien Montagne ddad044cfe Fix mismatch in BKE headers' multi-include safeguards naming.
Forgot to update those in recent `BKE_lib_` files renames.
2020-02-10 16:54:24 +01:00
Bastien Montagne cd48b132ff Cleanup: Add basic doc about each `BKE_main` and `BKE_lib` files.
Including expected prefixes for functions in those files.

Part of T72604.
2020-02-10 15:05:54 +01:00
Bastien Montagne 56116bbdf4 Cleanup/refactor: Rename `BKE_library` files to `BKE_lib`.
Note that `BKE_library.h`/`library.c` were renamed to
`BKE_lib_id.h`/`lib_id.c` to avoid having a too generic name here.

Part of T72604.
2020-02-10 13:00:42 +01:00