Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-08-27 10:20:06 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-08-27 10:20:06 +0300
commit4498fbeb2e2141dbc4aa375f9b5d250afe9a285f (patch)
tree5c1eda71c1d9ee91b14123384cc78673395f5932
parent8b009e258c36eca920a5c5eeb430634ad62f610f (diff)
Handle multi-hidden-layers when converting groups to collections.
That is kind of mandatory with complex rigged-character groups, with hundreds of helper objects, and a few useful ones being hidden on specific layers (like e.g. the main rig...). It is especially critical point with static override, which won't allow to move objects between collections and such (that would be a nightmare to implement and handle). Note that this is rather basic implementation, we could go further and move all objects in all layers they are 'active', but that would probably be overkill. Reviewers: brecht Subscribers: brecht Differential Revision: https://developer.blender.org/D3649
-rw-r--r--source/blender/blenloader/intern/versioning_280.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index c101a0dd746..9c99344a3e4 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -81,6 +81,8 @@
#include "BKE_paint.h"
#include "BKE_object.h"
+#include "BLT_translation.h"
+
#include "BLO_readfile.h"
#include "readfile.h"
@@ -408,7 +410,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
BLI_snprintf(name,
sizeof(collection_master->id.name),
- "Collection %d",
+ DATA_("Collection %d"),
layer + 1);
Collection *collection = BKE_collection_add(bmain, collection_master, name);
@@ -595,18 +597,31 @@ void do_versions_after_linking_280(Main *bmain)
continue;
}
- Collection *collection_hidden = NULL;
+ Collection *hidden_collection_array[20] = {NULL};
for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
cob_next = cob->next;
Object *ob = cob->ob;
if (!(ob->lay & collection->layer)) {
- if (collection_hidden == NULL) {
- collection_hidden = BKE_collection_add(bmain, collection, "Hidden");
- collection_hidden->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
+ /* Find or create hidden collection matching object's first layer. */
+ Collection **collection_hidden = NULL;
+ int coll_idx = 0;
+ for (; coll_idx < 20; coll_idx++) {
+ if (ob->lay & (1 << coll_idx)) {
+ collection_hidden = &hidden_collection_array[coll_idx];
+ break;
+ }
+ }
+ BLI_assert(collection_hidden != NULL);
+
+ if (*collection_hidden == NULL) {
+ char name[MAX_ID_NAME];
+ BLI_snprintf(name, sizeof(name), DATA_("Hidden %d"), coll_idx + 1);
+ *collection_hidden = BKE_collection_add(bmain, collection, name);
+ (*collection_hidden)->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
}
- BKE_collection_object_add(bmain, collection_hidden, ob);
+ BKE_collection_object_add(bmain, *collection_hidden, ob);
BKE_collection_object_remove(bmain, collection, ob, true);
}
}