diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2004-09-13 10:57:24 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2004-09-13 10:57:24 +0400 |
commit | 538e11a45d0d456e6da502765082662e3c76f015 (patch) | |
tree | 3d3d2e3395d46dc09c7a6861ee0b67c64f58cd77 /source/blender/blenloader | |
parent | 025e6b8b4f9234d1dda508132de649d383611f4f (diff) |
Add two new options for appending *objects*:
1) append in current active layer (off by default)
2) append at 3d cursor (off by default). When more than one object is selected this will first calculate the bounding box of the centers of the objects, and then use the distance of the bounding box center to the 3d cursor to transform all objects.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1e9b7aa8e99..8da7ff687c8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -101,6 +101,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_arithb.h" #include "BLI_storage_types.h" // for relname flags #include "BKE_bad_level_calls.h" // for reopen_text build_seqar (from WHILE_SEQ) open_plugin_seq set_rects_butspace check_imasel_copy @@ -117,6 +118,8 @@ #include "BKE_mesh.h" // for ME_ defines (patching) #include "BKE_armature.h" // for precalc_bonelist_irestmats #include "BKE_action.h" +#include "BKE_object.h" +#include "BKE_scene.h" #include "BIF_butspace.h" // for do_versions, patching event codes @@ -5135,6 +5138,7 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n if(id==0) ob= mainvar->object.last; else ob= (Object *)id; + if((flag & FILE_ACTIVELAY)) ob->lay = G.scene->lay; base->lay= ob->lay; base->object= ob; ob->id.us++; @@ -5213,7 +5217,12 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) FileData *fd= (FileData*) sfile->libfiledata; ListBase mainlist; Main *mainl; - int a, totsel=0; + int a, totsel=0,count=0; + float *curs,centerloc[3],vec[3],min[3],max[3]; + Base *centerbase; + Object *ob; + + INIT_MINMAX(min, max); /* are there files selected? */ for(a=0; a<sfile->totfile; a++) { @@ -5277,6 +5286,7 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) /* give a base to loose objects */ /* give_base_to_objects(G.scene, &(G.main->object)); */ /* has been removed... erm, why? (ton) */ + /* 20040907: looks like they are give base already in append_named_part(); -Nathan L */ /* patch to prevent switch_endian happens twice */ if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) { @@ -5285,6 +5295,37 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode) } if(sfile->flag & FILE_STRINGCODE) BLI_makestringcode(G.sce, mainl->curlib->name); + + if(sfile->flag & FILE_ATCURSOR) { + centerbase= (G.scene->base.first); + while(centerbase) { + if(((centerbase)->flag & SELECT)) { + VECCOPY(vec, centerbase->object->loc); + DO_MINMAX(vec, min, max); + count++; + } + centerbase= centerbase->next; + } + if(count) { + centerloc[0]= (min[0]+max[0])/2; + centerloc[1]= (min[1]+max[1])/2; + centerloc[2]= (min[2]+max[2])/2; + curs = G.scene->cursor; + VECSUB(centerloc,curs,centerloc); + + centerbase= (G.scene->base.first); + while(centerbase) { + if( ((centerbase)->flag & SELECT)) { + ob= centerbase->object; + ob->loc[0] += centerloc[0]; + ob->loc[1] += centerloc[1]; + ob->loc[2] += centerloc[2]; + } + centerbase= centerbase->next; + } + } + + } } /* ************* READ LIBRARY ************** */ |