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>2016-01-08 13:05:39 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-01-08 13:13:58 +0300
commit4ef918d661510610728fe9bbebb3df1fb565eef2 (patch)
tree8b131ff6428e16763b945143c0819317eb03a050 /source/blender/blenloader
parent5c69345edc0819f5b518ab06438cc72d4dfa86ca (diff)
Koro request: add 'active layer' and 'selected' options to view3D' paste operator.
Those two are ON by default, since I think it's most common expected behavior (as with append/link ops).
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h4
-rw-r--r--source/blender/blenloader/intern/readfile.c64
2 files changed, 39 insertions, 29 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 51b016a77f8..9f549bb4e7b 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -103,7 +103,9 @@ struct ID *BLO_library_link_named_part_ex(
struct Scene *scene, struct View3D *v3d);
void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, short flag, struct Scene *scene, struct View3D *v3d);
-void BLO_library_link_all(struct Main *mainl, BlendHandle *bh);
+void BLO_library_link_all(
+ struct Main *mainl, BlendHandle *bh, const short flag,
+ struct Scene *scene, struct View3D *v3d);
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 86a7b10a378..84565fcb89f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9662,16 +9662,47 @@ static ID *link_named_part(Main *mainl, FileData *fd, const short idcode, const
return id;
}
+static void link_object_postprocess(ID *id, Scene *scene, View3D *v3d, const short flag)
+{
+ if (scene) {
+ Base *base;
+ Object *ob;
+
+ base = MEM_callocN(sizeof(Base), "app_nam_part");
+ BLI_addtail(&scene->base, base);
+
+ ob = (Object *)id;
+
+ /* link at active layer (view3d if available in context, else scene one */
+ if (flag & FILE_ACTIVELAY) {
+ ob->lay = BKE_screen_view3d_layer_active(v3d, scene);
+ }
+
+ ob->mode = OB_MODE_OBJECT;
+ base->lay = ob->lay;
+ base->object = ob;
+ base->flag = ob->flag;
+ ob->id.us++;
+
+ if (flag & FILE_AUTOSELECT) {
+ base->flag |= SELECT;
+ base->object->flag = base->flag;
+ /* do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level */
+ }
+ }
+}
+
/**
* Simple reader for copy/paste buffers.
*/
-void BLO_library_link_all(Main *mainl, BlendHandle *bh)
+void BLO_library_link_all(Main *mainl, BlendHandle *bh, const short flag, Scene *scene, View3D *v3d)
{
FileData *fd = (FileData *)(bh);
BHead *bhead;
- ID *id = NULL;
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
+ ID *id = NULL;
+
if (bhead->code == ENDB)
break;
if (bhead->code == ID_OB)
@@ -9681,6 +9712,8 @@ void BLO_library_link_all(Main *mainl, BlendHandle *bh)
/* sort by name in list */
ListBase *lb = which_libbase(mainl, GS(id->name));
id_sort_by_name(lb, id);
+
+ link_object_postprocess(id, scene, v3d, flag);
}
}
}
@@ -9692,32 +9725,7 @@ static ID *link_named_part_ex(
ID *id = link_named_part(mainl, fd, idcode, name);
if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */
- if (scene) {
- Base *base;
- Object *ob;
-
- base = MEM_callocN(sizeof(Base), "app_nam_part");
- BLI_addtail(&scene->base, base);
-
- ob = (Object *)id;
-
- /* link at active layer (view3d if available in context, else scene one */
- if (flag & FILE_ACTIVELAY) {
- ob->lay = BKE_screen_view3d_layer_active(v3d, scene);
- }
-
- ob->mode = OB_MODE_OBJECT;
- base->lay = ob->lay;
- base->object = ob;
- base->flag = ob->flag;
- ob->id.us++;
-
- if (flag & FILE_AUTOSELECT) {
- base->flag |= SELECT;
- base->object->flag = base->flag;
- /* do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level */
- }
- }
+ link_object_postprocess(id, scene, v3d, flag);
}
else if (id && (GS(id->name) == ID_GR)) {
/* tag as needing to be instantiated */