diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-12-18 08:23:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-12-18 08:23:38 +0300 |
commit | 372fd07a8e13613e0e4ecfda2951fc0d2747d8d4 (patch) | |
tree | 771decf933c1892dced629d844e4e43463c7da88 /source/blender/blenloader | |
parent | afc4cd1e678b2e0717115d03910af58456f4a038 (diff) |
Fix paste/append w/ local-view
Paste in local-view wasn't setting local-view bits.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 46 |
2 files changed, 36 insertions, 14 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index df8cc164869..a3714e6ac8d 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -142,10 +142,10 @@ struct ID *BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, con struct ID *BLO_library_link_named_part_ex( struct Main *mainl, BlendHandle **bh, const short idcode, const char *name, const int flag, - struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer); + struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d); void BLO_library_link_end( struct Main *mainl, BlendHandle **bh, int flag, - struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer); + struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d); void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6dd9c80b5d9..d3721273ce9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -10268,7 +10268,8 @@ static Collection *get_collection_active( } static void add_loose_objects_to_scene( - Main *mainvar, Main *bmain, Scene *scene, ViewLayer *view_layer, Library *lib, const short flag) + Main *mainvar, Main *bmain, + Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag) { const bool is_link = (flag & FILE_LINK) != 0; @@ -10296,6 +10297,11 @@ static void add_loose_objects_to_scene( Collection *active_collection = get_collection_active(bmain, scene, view_layer, FILE_ACTIVE_COLLECTION); BKE_collection_object_add(bmain, active_collection, ob); Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (v3d != NULL) { + base->local_view_bits |= v3d->local_view_uuid; + } + BKE_scene_object_base_flag_sync_from_base(base); if (flag & FILE_AUTOSELECT) { @@ -10316,7 +10322,8 @@ static void add_loose_objects_to_scene( } static void add_collections_to_scene( - Main *mainvar, Main *bmain, Scene *scene, ViewLayer *view_layer, Library *UNUSED(lib), const short flag) + Main *mainvar, Main *bmain, + Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *UNUSED(lib), const short flag) { Collection *active_collection = get_collection_active(bmain, scene, view_layer, FILE_ACTIVE_COLLECTION); @@ -10334,6 +10341,10 @@ static void add_collections_to_scene( BKE_collection_object_add(bmain, active_collection, ob); Base *base = BKE_view_layer_base_find(view_layer, ob); + if (v3d != NULL) { + base->local_view_bits |= v3d->local_view_uuid; + } + if (base->flag & BASE_SELECTABLE) { base->flag |= BASE_SELECTED; } @@ -10428,7 +10439,8 @@ static ID *link_named_part( return id; } -static void link_object_postprocess(ID *id, Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag) +static void link_object_postprocess( + ID *id, Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d, const int flag) { if (scene) { /* link to scene */ @@ -10444,6 +10456,11 @@ static void link_object_postprocess(ID *id, Main *bmain, Scene *scene, ViewLayer base = BKE_view_layer_base_find(view_layer, ob); BKE_scene_object_base_flag_sync_from_base(base); + /* Link at active local view (view3d if available in context. */ + if (v3d != NULL) { + base->local_view_bits |= v3d->local_view_uuid; + } + if (flag & FILE_AUTOSELECT) { if (base->flag & BASE_SELECTABLE) { base->flag |= BASE_SELECTED; @@ -10491,12 +10508,12 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh) static ID *link_named_part_ex( Main *mainl, FileData *fd, const short idcode, const char *name, const int flag, - Main *bmain, Scene *scene, ViewLayer *view_layer) + Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d) { ID *id = link_named_part(mainl, fd, idcode, name, flag); if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */ - link_object_postprocess(id, bmain, scene, view_layer, flag); + link_object_postprocess(id, bmain, scene, view_layer, v3d, flag); } else if (id && (GS(id->name) == ID_GR)) { /* tag as needing to be instantiated or linked */ @@ -10537,10 +10554,10 @@ ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcod ID *BLO_library_link_named_part_ex( Main *mainl, BlendHandle **bh, const short idcode, const char *name, const int flag, - Main *bmain, Scene *scene, ViewLayer *view_layer) + Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d) { FileData *fd = (FileData *)(*bh); - return link_named_part_ex(mainl, fd, idcode, name, flag, bmain, scene, view_layer); + return link_named_part_ex(mainl, fd, idcode, name, flag, bmain, scene, view_layer, v3d); } static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id) @@ -10653,7 +10670,9 @@ static void split_main_newid(Main *mainptr, Main *main_newid) } /* scene and v3d may be NULL. */ -static void library_link_end(Main *mainl, FileData **fd, const short flag, Main *bmain, Scene *scene, ViewLayer *view_layer) +static void library_link_end( + Main *mainl, FileData **fd, const short flag, Main *bmain, + Scene *scene, ViewLayer *view_layer, const View3D *v3d) { Main *mainvar; Library *curlib; @@ -10711,8 +10730,8 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Main * Only directly linked objects & collections are instantiated by `BLO_library_link_named_part_ex()` & co, * here we handle indirect ones and other possible edge-cases. */ if (scene) { - add_collections_to_scene(mainvar, bmain, scene, view_layer, curlib, flag); - add_loose_objects_to_scene(mainvar, bmain, scene, view_layer, curlib, flag); + add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag); + add_loose_objects_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag); } else { /* printf("library_append_end, scene is NULL (objects wont get bases)\n"); */ @@ -10739,11 +10758,14 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Main * \param bmain: The main database in which to instantiate objects/collections * \param scene: The scene in which to instantiate objects/collections (if NULL, no instantiation is done). * \param view_layer: The scene layer in which to instantiate objects/collections (if NULL, no instantiation is done). + * \param v3d: The active View3D (only to define local-view for instantiated objects & groups, can be NULL). */ -void BLO_library_link_end(Main *mainl, BlendHandle **bh, int flag, Main *bmain, Scene *scene, ViewLayer *view_layer) +void BLO_library_link_end( + Main *mainl, BlendHandle **bh, int flag, Main *bmain, + Scene *scene, ViewLayer *view_layer, const View3D *v3d) { FileData *fd = (FileData *)(*bh); - library_link_end(mainl, &fd, flag, bmain, scene, view_layer); + library_link_end(mainl, &fd, flag, bmain, scene, view_layer, v3d); *bh = (BlendHandle *)fd; } |