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:
authorJoseph Eagar <joeedh@gmail.com>2009-09-16 21:43:09 +0400
committerJoseph Eagar <joeedh@gmail.com>2009-09-16 21:43:09 +0400
commitdeebf4f8f0d79169a0e6c2a391670419b6492bfe (patch)
tree2a0aaf4042aa78e9d1d835f4544e07c6123e67a9 /source/blender/blenloader
parent6b0679a3999d8e5abc60730f523879eadbedcd8f (diff)
merge with 2.5/trunk at r23271
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h19
-rw-r--r--source/blender/blenloader/CMakeLists.txt10
-rw-r--r--source/blender/blenloader/SConscript2
-rw-r--r--source/blender/blenloader/intern/readblenentry.c26
-rw-r--r--source/blender/blenloader/intern/readfile.c416
-rw-r--r--source/blender/blenloader/intern/readfile.h2
-rw-r--r--source/blender/blenloader/intern/writefile.c29
7 files changed, 293 insertions, 211 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 4fafac29a6f..6e2772efea4 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -36,7 +36,6 @@ extern "C" {
struct bScreen;
struct direntry;
-struct FileList;
struct LinkNode;
struct Main;
struct MemFile;
@@ -45,6 +44,7 @@ struct Scene;
struct SpaceFile;
struct SpaceImaSel;
struct UserDef;
+struct bContext;
typedef struct BlendHandle BlendHandle;
@@ -197,12 +197,23 @@ BLO_blendhandle_close(
/***/
-char *BLO_gethome(void);
+#define GROUP_MAX 32
+
int BLO_has_bfile_extension(char *str);
-void BLO_library_append(BlendHandle **libfiledata, struct direntry* filelist, int totfile,
- char *dir, char* file, short flag, int idcode, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
+/* return ok when a blenderfile, in dir is the filename,
+ * in group the type of libdata
+ */
+int BLO_is_a_library(char *path, char *dir, char *group);
+
+struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, char *dir);
+void BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, char *name, int idcode, short flag);
+void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag);
+
+/* deprecated */
+#if 0
void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
+#endif
BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 7bdffdedc05..d31a85ab208 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -27,11 +27,11 @@
FILE(GLOB SRC intern/*.c)
SET(INC
- . ../../../intern/guardedalloc ../blenlib ../blenkernel
- ../makesdna ../readblenfile ../include ../makesrna
- ../python ../../kernel/gen_messaging
- ../render/extern/include
- ${ZLIB_INC}
+ . ../../../intern/guardedalloc ../blenlib ../blenkernel
+ ../makesdna ../readblenfile ../include ../makesrna
+ ../python ../../kernel/gen_messaging
+ ../render/extern/include
+ ${ZLIB_INC}
)
BLENDERLIB(bf_blenloader "${SRC}" "${INC}")
diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript
index 19a89b7e604..88d345290e5 100644
--- a/source/blender/blenloader/SConscript
+++ b/source/blender/blenloader/SConscript
@@ -11,4 +11,4 @@ incs += ' ' + env['BF_ZLIB_INC']
defs = []
-env.BlenderLib ( 'bf_blenloader', sources, Split(incs), defs, libtype=['core','player'], priority = [135, 30] )
+env.BlenderLib ( 'bf_blenloader', sources, Split(incs), defs, libtype=['core','player'], priority = [167,30] )
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 1f276913ea8..3d21bb54e2b 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -67,6 +67,10 @@
#include "BLO_sys_types.h" // needed for intptr_t
+#ifdef _WIN32
+#include "BLI_winstuff.h"
+#endif
+
/**
* IDType stuff, I plan to move this
* out into its own file + prefix, and
@@ -95,7 +99,6 @@ static IDType idtypes[]= {
{ ID_IP, "Ipo", IDTYPE_FLAGS_ISLINKABLE},
{ ID_KE, "Key", 0},
{ ID_LA, "Lamp", IDTYPE_FLAGS_ISLINKABLE},
- { ID_LF, "Life", 0},
{ ID_LI, "Library", 0},
{ ID_LT, "Lattice", IDTYPE_FLAGS_ISLINKABLE},
{ ID_MA, "Material", IDTYPE_FLAGS_ISLINKABLE},
@@ -106,7 +109,6 @@ static IDType idtypes[]= {
{ ID_SCE, "Scene", IDTYPE_FLAGS_ISLINKABLE},
{ ID_SCR, "Screen", 0},
{ ID_SEQ, "Sequence", 0},
- { ID_SE, "Sector", 0},
{ ID_SO, "Sound", IDTYPE_FLAGS_ISLINKABLE},
{ ID_TE, "Texture", IDTYPE_FLAGS_ISLINKABLE},
{ ID_TXT, "Text", IDTYPE_FLAGS_ISLINKABLE},
@@ -200,7 +202,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
buf[2]= buf[2]?buf[2]:' ';
buf[3]= buf[3]?buf[3]:' ';
- fprintf(fp, "['%.4s', '%s', %d, %ld ], \n", buf, name, bhead->nr, (intptr_t)bhead->len+sizeof(BHead));
+ fprintf(fp, "['%.4s', '%s', %d, %ld ], \n", buf, name, bhead->nr, (long int)bhead->len+sizeof(BHead));
}
}
fprintf(fp, "]\n");
@@ -331,11 +333,7 @@ BlendFileData *BLO_read_from_file(char *file, ReportList *reports)
fd = blo_openblenderfile(file, reports);
if (fd) {
fd->reports= reports;
- bfd= blo_read_file_internal(fd);
- if (bfd) {
- bfd->type= BLENFILETYPE_BLEND;
- strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
- }
+ bfd= blo_read_file_internal(fd, file);
blo_freefiledata(fd);
}
@@ -350,11 +348,7 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports)
fd = blo_openblendermemory(mem, memsize, reports);
if (fd) {
fd->reports= reports;
- bfd= blo_read_file_internal(fd);
- if (bfd) {
- bfd->type= BLENFILETYPE_BLEND;
- strcpy(bfd->main->name, "");
- }
+ bfd= blo_read_file_internal(fd, "");
blo_freefiledata(fd);
}
@@ -383,11 +377,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
/* makes lookup of existing images in old main */
blo_make_image_pointer_map(fd, oldmain);
- bfd= blo_read_file_internal(fd);
- if (bfd) {
- bfd->type= BLENFILETYPE_BLEND;
- strcpy(bfd->main->name, "");
- }
+ bfd= blo_read_file_internal(fd, "");
/* ensures relinked images are not freed */
blo_end_image_pointer_map(fd, oldmain);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 851f1bac018..cac072b76b2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -29,11 +29,6 @@
#include "zlib.h"
-#ifdef WIN32
-#include "winsock2.h"
-#include "BLI_winstuff.h"
-#endif
-
#include <limits.h>
#include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
#include <stdlib.h> // for getenv atoi
@@ -46,6 +41,8 @@
#include <sys/param.h> // for MAXPATHLEN
#else
#include <io.h> // for open close read
+#include "winsock2.h"
+#include "BLI_winstuff.h"
#endif
#include "DNA_anim_types.h"
@@ -117,6 +114,7 @@
#include "BKE_cloth.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h"
+#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_customdata.h"
#include "BKE_deform.h"
@@ -127,7 +125,6 @@
#include "BKE_group.h"
#include "BKE_image.h"
#include "BKE_ipo.h"
-#include "BKE_key.h" //void set_four_ipo
#include "BKE_lattice.h"
#include "BKE_library.h" // for wich_libbase
#include "BKE_main.h" // for Main
@@ -136,6 +133,7 @@
#include "BKE_multires.h"
#include "BKE_node.h" // for tree type defines
#include "BKE_object.h"
+#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_property.h" // for get_ob_property
@@ -144,7 +142,6 @@
#include "BKE_scene.h"
#include "BKE_softbody.h" // sbNew()
#include "BKE_bullet.h" // bsbNew()
-#include "BKE_sculpt.h"
#include "BKE_sequence.h"
#include "BKE_texture.h" // for open_plugin_tex
#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
@@ -1070,6 +1067,46 @@ int BLO_has_bfile_extension(char *str)
return (BLI_testextensie(str, ".ble") || BLI_testextensie(str, ".blend")||BLI_testextensie(str, ".blend.gz"));
}
+int BLO_is_a_library(char *path, char *dir, char *group)
+{
+ /* return ok when a blenderfile, in dir is the filename,
+ * in group the type of libdata
+ */
+ int len;
+ char *fd;
+
+ strcpy(dir, path);
+ len= strlen(dir);
+ if(len<7) return 0;
+ if( dir[len-1] != '/' && dir[len-1] != '\\') return 0;
+
+ group[0]= 0;
+ dir[len-1]= 0;
+
+ /* Find the last slash */
+ fd= (strrchr(dir, '/')>strrchr(dir, '\\'))?strrchr(dir, '/'):strrchr(dir, '\\');
+
+ if(fd==0) return 0;
+ *fd= 0;
+ if(BLO_has_bfile_extension(fd+1)) {
+ /* the last part of the dir is a .blend file, no group follows */
+ *fd= '/'; /* put back the removed slash separating the dir and the .blend file name */
+ }
+ else {
+ char *gp = fd+1; // in case we have a .blend file, gp points to the group
+
+ /* Find the last slash */
+ fd= (strrchr(dir, '/')>strrchr(dir, '\\'))?strrchr(dir, '/'):strrchr(dir, '\\');
+ if (!fd || !BLO_has_bfile_extension(fd+1)) return 0;
+
+ /* now we know that we are in a blend file and it is safe to
+ assume that gp actually points to a group */
+ if (BLI_streq("Screen", gp)==0)
+ BLI_strncpy(group, gp, GROUP_MAX);
+ }
+ return 1;
+}
+
/* ************** OLD POINTERS ******************* */
static void *newdataadr(FileData *fd, void *adr) /* only direct databocks */
@@ -1374,12 +1411,10 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData
prop->totallen = prop->len;
prop->data.pointer = newdataadr(fd, prop->data.pointer);
- if (switch_endian) {
- array= (IDProperty*) prop->data.pointer;
+ array= (IDProperty*) prop->data.pointer;
- for(i=0; i<prop->len; i++)
- IDP_DirectLinkProperty(&array[i], switch_endian, fd);
- }
+ for(i=0; i<prop->len; i++)
+ IDP_DirectLinkProperty(&array[i], switch_endian, fd);
}
static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd)
@@ -1391,19 +1426,22 @@ static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *f
prop->totallen = prop->len;
prop->data.pointer = newdataadr(fd, prop->data.pointer);
- if (switch_endian) {
- if(prop->subtype == IDP_GROUP) {
- test_pointer_array(fd, prop->data.pointer);
- array= prop->data.pointer;
+ if(prop->subtype == IDP_GROUP) {
+ test_pointer_array(fd, prop->data.pointer);
+ array= prop->data.pointer;
- for(i=0; i<prop->len; i++)
- IDP_DirectLinkProperty(array[i], switch_endian, fd);
- }
- else if(prop->subtype == IDP_DOUBLE) {
+ for(i=0; i<prop->len; i++)
+ IDP_DirectLinkProperty(array[i], switch_endian, fd);
+ }
+ else if(prop->subtype == IDP_DOUBLE) {
+ if (switch_endian) {
for (i=0; i<prop->len; i++) {
SWITCH_LONGINT(((double*)prop->data.pointer)[i]);
}
- } else {
+ }
+ }
+ else {
+ if (switch_endian) {
for (i=0; i<prop->len; i++) {
SWITCH_INT(((int*)prop->data.pointer)[i]);
}
@@ -2963,8 +3001,10 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
else
cache->mem_cache.first = cache->mem_cache.last = NULL;
- cache->flag &= ~(PTCACHE_SIMULATION_VALID|PTCACHE_BAKE_EDIT_ACTIVE);
+ cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
+ cache->edit= NULL;
+ cache->free_edit= NULL;
}
static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache)
@@ -3053,11 +3093,8 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles)
{
ParticleSystem *psys, *psysnext;
- int a;
for(psys=particles->first; psys; psys=psysnext){
- ParticleData *pa;
-
psysnext= psys->next;
psys->part = newlibadr_us(fd, id->lib, psys->part);
@@ -3068,12 +3105,6 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
pt->ob=newlibadr(fd, id->lib, pt->ob);
psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
-
- for(a=0,pa=psys->particles; a<psys->totpart; a++,pa++){
- pa->stick_ob=newlibadr(fd, id->lib, pa->stick_ob);
- }
-
-
}
else {
/* particle modifier must be removed before particle system */
@@ -3124,20 +3155,9 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
psys->child=newdataadr(fd,psys->child);
psys->effectors.first=psys->effectors.last=0;
- psys->soft= newdataadr(fd, psys->soft);
- if(psys->soft) {
- SoftBody *sb = psys->soft;
- sb->particles = psys;
- sb->bpoint= NULL; // init pointers so it gets rebuilt nicely
- sb->bspring= NULL;
- sb->scratch= NULL;
-
- direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache);
- }
-
link_list(fd, &psys->targets);
- psys->edit = 0;
+ psys->edit = NULL;
psys->free_edit = NULL;
psys->pathcache = 0;
psys->childcache = 0;
@@ -3147,6 +3167,23 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache);
+ if(psys->clmd) {
+ psys->clmd = newdataadr(fd, psys->clmd);
+ psys->clmd->clothObject = NULL;
+
+ psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms);
+ psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms);
+
+ if(psys->clmd->sim_parms) {
+ if(psys->clmd->sim_parms->presets > 10)
+ psys->clmd->sim_parms->presets = 0;
+ }
+
+ psys->hair_in_dm = psys->hair_out_dm = NULL;
+
+ psys->clmd->point_cache = psys->pointcache;
+ }
+
psys->tree = NULL;
}
return;
@@ -3617,6 +3654,8 @@ static void lib_link_object(FileData *fd, Main *main)
}
for(a=0; a<ob->totcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]);
+ ob->gpd= newlibadr_us(fd, ob->id.lib, ob->gpd);
+
ob->id.flag -= LIB_NEEDLINK;
/* if id.us==0 a new base will be created later on */
@@ -3860,8 +3899,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain->smd = smd;
smd->domain->fluid = NULL;
- smd->domain->view3d = NULL;
+ smd->domain->wt = NULL;
+ smd->domain->shadow = NULL;
smd->domain->tex = NULL;
+ smd->domain->tex_shadow = NULL;
+ smd->domain->tex_wt = NULL;
direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]));
direct_link_pointcache_list(fd, &(smd->domain->ptcaches[1]), &(smd->domain->point_cache[1]));
@@ -4210,6 +4252,7 @@ static void lib_link_scene(FileData *fd, Main *main)
sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
sce->set= newlibadr(fd, sce->id.lib, sce->set);
sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima);
+ sce->gpd= newlibadr_us(fd, sce->id.lib, sce->gpd);
link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
@@ -4517,11 +4560,14 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
static void lib_link_windowmanager(FileData *fd, Main *main)
{
wmWindowManager *wm;
+ wmWindow *win;
for(wm= main->wm.first; wm; wm= wm->id.next) {
- wmWindow *win;
- for(win= wm->windows.first; win; win= win->next) {
- win->screen= newlibadr(fd, NULL, win->screen);
+ if(wm->id.flag & LIB_NEEDLINK) {
+ for(win= wm->windows.first; win; win= win->next)
+ win->screen= newlibadr(fd, NULL, win->screen);
+
+ wm->id.flag -= LIB_NEEDLINK;
}
}
}
@@ -4983,6 +5029,10 @@ static void view3d_split_250(View3D *v3d, ListBase *regions)
QUATCOPY(rv3d->viewquat, v3d->viewquat);
}
}
+
+ /* this was not initialized correct always */
+ if(v3d->twtype == 0)
+ v3d->twtype= V3D_MANIP_TRANSLATE;
}
static void direct_link_screen(FileData *fd, bScreen *sc)
@@ -5228,7 +5278,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
static void direct_link_sound(FileData *fd, bSound *sound)
{
- sound->snd_sound = NULL;
+ sound->handle = NULL;
sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
@@ -5243,9 +5293,11 @@ static void lib_link_sound(FileData *fd, Main *main)
if(sound->id.flag & LIB_NEEDLINK) {
sound->id.flag -= LIB_NEEDLINK;
sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system
- sound->stream = 0;
-
+
sound_load(main, sound);
+
+ if(sound->cache)
+ sound_cache(sound, 1);
}
sound= sound->id.next;
}
@@ -8508,8 +8560,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches);
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- if(psys->soft && !psys->soft->pointcache)
- psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches);
+ //if(psys->soft && !psys->soft->pointcache)
+ // psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches);
if(!psys->pointcache)
psys->pointcache= BKE_ptcache_add(&psys->ptcaches);
}
@@ -9388,6 +9440,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
Material *ma;
Camera *cam;
Mesh *me;
+ Curve *cu;
Scene *sce;
Tex *tx;
ParticleSettings *part;
@@ -9534,6 +9587,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
//BLI_freelistN(&pidlist);
}
+
+ /* type was a mixed flag & enum. move the 2d flag elsewhere */
+ for(cu = main->curve.first; cu; cu= cu->id.next) {
+ Nurb *nu;
+
+ for(nu= cu->nurb.first; nu; nu= nu->next) {
+ nu->flag |= (nu->type & CU_2D);
+ nu->type &= CU_TYPE;
+ }
+ }
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) {
@@ -9754,6 +9817,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
Scene *sce;
+ Object *ob;
for(sce = main->scene.first; sce; sce = sce->id.next) {
if(fd->fileflags & G_FILE_ENABLE_ALL_FRAMES)
@@ -9786,10 +9850,33 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
sce->gm.flag |= GAME_DISPLAY_LISTS;
}
+
+ for(ob = main->object.first; ob; ob = ob->id.next) {
+ if(ob->flag & 8192) // OB_POSEMODE = 8192
+ ob->mode |= OB_MODE_POSE;
+ }
}
/* put 2.50 compatibility code here until next subversion bump */
{
+ Scene *sce;
+ Object *ob;
+
+ for(sce = main->scene.first; sce; sce = sce->id.next)
+ if(sce->unit.scale_length == 0.0f)
+ sce->unit.scale_length= 1.0f;
+
+ for(ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ /* add backwards pointer for fluidsim modifier RNA access */
+ for (md=ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fluidmd= (FluidsimModifierData*) md;
+ fluidmd->fss->fmd = fluidmd;
+ }
+ }
+ }
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
@@ -9843,16 +9930,6 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
bfd->user->uifonts.first= bfd->user->uifonts.last= NULL;
bfd->user->uistyles.first= bfd->user->uistyles.last= NULL;
- // AUD_XXX
- if(bfd->user->audiochannels == 0)
- bfd->user->audiochannels = 2;
- if(bfd->user->audiodevice == 0)
- bfd->user->audiodevice = 1;
- if(bfd->user->audioformat == 0)
- bfd->user->audioformat = 0x12;
- if(bfd->user->audiorate == 0)
- bfd->user->audiorate = 44100;
-
bhead = blo_nextbhead(fd, bhead);
/* read all attached data */
@@ -9865,7 +9942,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
return bhead;
}
-BlendFileData *blo_read_file_internal(FileData *fd)
+BlendFileData *blo_read_file_internal(FileData *fd, char *file)
{
BHead *bhead= blo_firstbhead(fd);
BlendFileData *bfd;
@@ -9876,6 +9953,9 @@ BlendFileData *blo_read_file_internal(FileData *fd)
bfd->main->versionfile= fd->fileversion;
+ bfd->type= BLENFILETYPE_BLEND;
+ strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
+
while(bhead) {
switch(bhead->code) {
case DATA:
@@ -10580,6 +10660,8 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
expand_doit(fd, mainvar, ob->poselib);
expand_constraints(fd, mainvar, &ob->constraints);
+ expand_doit(fd, mainvar, ob->gpd);
+
// XXX depreceated - old animation system (for version patching only)
expand_doit(fd, mainvar, ob->ipo);
expand_doit(fd, mainvar, ob->action);
@@ -10715,6 +10797,9 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
if(sce->r.dometext)
expand_doit(fd, mainvar, sce->gm.dome.warptext);
+
+ if(sce->gpd)
+ expand_doit(fd, mainvar, sce->gpd);
}
static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
@@ -10875,8 +10960,9 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, int is
}
-static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *name, int idcode, short flag)
+static void append_named_part(const bContext *C, Main *mainl, FileData *fd, char *name, int idcode, short flag)
{
+ Scene *scene= CTX_data_scene(C);
Object *ob;
Base *base;
BHead *bhead;
@@ -10892,9 +10978,9 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n
if(strcmp(idname+2, name)==0) {
- id= is_yet_read(fd, mainvar, bhead);
+ id= is_yet_read(fd, mainl, bhead);
if(id==NULL) {
- read_libblock(fd, mainvar, bhead, LIB_TESTEXT, NULL);
+ read_libblock(fd, mainl, bhead, LIB_TESTEXT, NULL);
}
else {
printf("append: already linked\n");
@@ -10909,13 +10995,18 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n
base= MEM_callocN( sizeof(Base), "app_nam_part");
BLI_addtail(&scene->base, base);
- if(id==NULL) ob= mainvar->object.last;
+ if(id==NULL) ob= mainl->object.last;
else ob= (Object *)id;
- /* XXX use context to find view3d->lay */
- //if((flag & FILE_ACTIVELAY)) {
- // scene->lay;
- //}
+ /* link at active layer (view3d->lay if in context, else scene->lay */
+ if((flag & FILE_ACTIVELAY)) {
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d) {
+ ob->lay = v3d->layact;
+ } else {
+ ob->lay = scene->lay;
+ }
+ }
base->lay= ob->lay;
base->object= ob;
ob->id.us++;
@@ -10934,6 +11025,12 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n
}
}
+void BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, char *name, int idcode, short flag)
+{
+ FileData *fd= (FileData*)(*bh);
+ append_named_part(C, mainl, fd, name, idcode, flag);
+}
+
static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
{
BHead *bhead;
@@ -10956,11 +11053,10 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
/* common routine to append/link something from a library */
-static Library* library_append(Main *mainvar, Scene *scene, char* file, char *dir, int idcode,
- int totsel, FileData **fd, struct direntry* filelist, int totfile, short flag)
+static Main* library_append_begin(const bContext *C, FileData **fd, char *dir)
{
+ Main *mainvar= CTX_data_main(C);
Main *mainl;
- Library *curlib;
/* make mains */
blo_split_main(&(*fd)->mainlist, mainvar);
@@ -10970,19 +11066,69 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di
mainl->versionfile= (*fd)->fileversion; /* needed for do_version */
- curlib= mainl->curlib;
+ return mainl;
+}
+
+Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, char *dir)
+{
+ FileData *fd= (FileData*)(*bh);
+ return library_append_begin(C, &fd, dir);
+}
+
+static void append_do_cursor(Scene *scene, Library *curlib, short flag)
+{
+ Base *centerbase;
+ Object *ob;
+ float *curs, centerloc[3], vec[3], min[3], max[3];
+ int count= 0;
+
+ /* when not linking (appending)... */
+ if(flag & FILE_LINK)
+ return;
+
+ /* we're not appending at cursor */
+ if((flag & FILE_ATCURSOR) == 0)
+ return;
- if(totsel==0) {
- append_named_part(*fd, mainl, scene, file, idcode, flag);
+ /* find the center of everything appended */
+ INIT_MINMAX(min, max);
+ centerbase= (scene->base.first);
+ while(centerbase) {
+ if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
+ VECCOPY(vec, centerbase->object->loc);
+ DO_MINMAX(vec, min, max);
+ count++;
+ }
+ centerbase= centerbase->next;
}
- else {
- int a;
- for(a=0; a<totfile; a++) {
- if(filelist[a].flags & ACTIVE) {
- append_named_part(*fd, mainl, scene, filelist[a].relname, idcode, flag);
- }
+ /* we haven't found any objects to move to cursor */
+ if(!count)
+ return;
+
+ /* move from the center of the appended objects to cursor */
+ centerloc[0]= (min[0]+max[0])/2;
+ centerloc[1]= (min[1]+max[1])/2;
+ centerloc[2]= (min[2]+max[2])/2;
+ curs = scene->cursor;
+ VECSUB(centerloc,curs,centerloc);
+
+ /* now translate the center of the objects */
+ centerbase= (scene->base.first);
+ while(centerbase) {
+ if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
+ ob= centerbase->object;
+ ob->loc[0] += centerloc[0];
+ ob->loc[1] += centerloc[1];
+ ob->loc[2] += centerloc[2];
}
+ centerbase= centerbase->next;
}
+}
+
+static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
+{
+ Main *mainvar= CTX_data_main(C);
+ Scene *scene= CTX_data_scene(C);
/* make main consistant */
expand_main(*fd, mainl);
@@ -10990,6 +11136,7 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di
/* do this when expand found other libs */
read_libraries(*fd, &(*fd)->mainlist);
+ /* make the lib path relative if required */
if(flag & FILE_STRINGCODE) {
/* use the full path, this could have been read by other library even */
@@ -11012,7 +11159,7 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di
if (flag & FILE_LINK) {
give_base_to_objects(mainvar, scene, NULL, 0);
} else {
- give_base_to_objects(mainvar, scene, curlib, 1);
+ give_base_to_objects(mainvar, scene, mainl->curlib, 1);
}
} else {
give_base_to_objects(mainvar, scene, NULL, 0);
@@ -11028,14 +11175,23 @@ static Library* library_append(Main *mainvar, Scene *scene, char* file, char *di
*fd = NULL;
}
- return curlib;
+ append_do_cursor(scene, mainl->curlib, flag);
+}
+
+void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
+{
+ FileData *fd= (FileData*)(*bh);
+ library_append_end(C, mainl, &fd, idcode, flag);
+ *bh= (BlendHandle*)fd;
}
/* this is a version of BLO_library_append needed by the BPython API, so
* scripts can load data from .blend files -- see Blender.Library module.*/
/* append to scene */
/* this should probably be moved into the Python code anyway */
-
+/* tentatively removed, Python should be able to use the split functions too: */
+/* BLO_library_append_begin, BLO_library_append_end, BLO_library_append_named_part */
+#if 0
void BLO_script_library_append(BlendHandle **bh, char *dir, char *name,
int idcode, short flag, Main *mainvar, Scene *scene, ReportList *reports)
{
@@ -11052,88 +11208,7 @@ void BLO_script_library_append(BlendHandle **bh, char *dir, char *name,
*bh= (BlendHandle*)fd;
}
-
-/* append to scene */
-void BLO_library_append(BlendHandle** bh, struct direntry* filelist, int totfile,
- char *dir, char* file, short flag, int idcode, Main *mainvar, Scene *scene, ReportList *reports)
-{
- FileData *fd= (FileData*)(*bh);
- Library *curlib;
- Base *centerbase;
- Object *ob;
- int a, totsel=0;
-
- /* are there files selected? */
- for(a=0; a<totfile; a++) {
- if(filelist[a].flags & ACTIVE) {
- totsel++;
- }
- }
-
- if(totsel==0) {
- /* is the indicated file in the filelist? */
- if(file[0]) {
- for(a=0; a<totfile; a++) {
- if( strcmp(filelist[a].relname, file)==0) break;
- }
- if(a==totfile) {
- BKE_report(reports, RPT_ERROR, "Wrong indicated name");
- return;
- }
- }
- else {
- BKE_report(reports, RPT_ERROR, "Nothing indicated");
- return;
- }
- }
- /* now we have or selected, or an indicated file */
-
- if(flag & FILE_AUTOSELECT) scene_deselect_all(scene);
-
- fd->reports= reports;
- curlib = library_append(mainvar, scene, file, dir, idcode, totsel, &fd, filelist, totfile,flag );
- if(fd) fd->reports= NULL;
-
- *bh= (BlendHandle*)fd;
-
- /* when not linking (appending)... */
- if((flag & FILE_LINK)==0) {
- if(flag & FILE_ATCURSOR) {
- float *curs, centerloc[3], vec[3], min[3], max[3];
- int count= 0;
-
- INIT_MINMAX(min, max);
-
- centerbase= (scene->base.first);
- while(centerbase) {
- if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
- 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 = scene->cursor;
- VECSUB(centerloc,curs,centerloc);
-
- centerbase= (scene->base.first);
- while(centerbase) {
- if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
- ob= centerbase->object;
- ob->loc[0] += centerloc[0];
- ob->loc[1] += centerloc[1];
- ob->loc[2] += centerloc[2];
- }
- centerbase= centerbase->next;
- }
- }
- }
- }
-}
+#endif
/* ************* READ LIBRARY ************** */
@@ -11177,9 +11252,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
printf("read library: lib %s\n", mainptr->curlib->name);
fd= blo_openblenderfile(mainptr->curlib->filename, &reports);
- fd->reports= basefd->reports;
if (fd) {
+ fd->reports= basefd->reports;
+
if (fd->libmap)
oldnewmap_free(fd->libmap);
@@ -11293,7 +11369,7 @@ BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize,
return NULL;
fd->reports= reports;
- bfd= blo_read_file_internal(fd);
+ bfd= blo_read_file_internal(fd, "");
blo_freefiledata(fd);
return bfd;
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index e39fefa8205..2a0b6c327d3 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -108,7 +108,7 @@ struct Main;
void blo_join_main(ListBase *mainlist);
void blo_split_main(ListBase *mainlist, struct Main *main);
-BlendFileData *blo_read_file_internal(FileData *fd);
+BlendFileData *blo_read_file_internal(FileData *fd, char *file);
FileData *blo_openblenderfile(char *name, struct ReportList *reports);
FileData *blo_openblendermemory(void *buffer, int buffersize, struct ReportList *reports);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 73832be7a53..586483d2e13 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -72,23 +72,23 @@ Any case: direct data is ALWAYS after the lib block
#include <config.h>
#endif
+#include <math.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
#include "zlib.h"
#ifndef WIN32
#include <unistd.h>
#else
#include "winsock2.h"
-#include "BLI_winstuff.h"
#include <io.h>
#include <process.h> // for getpid
+#include "BLI_winstuff.h"
#endif
-#include <math.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_action_types.h"
@@ -653,15 +653,20 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
}
if(psys->particles->boid && psys->part->phystype == PART_PHYS_BOIDS)
- writestruct(wd, DATA, "BoidData", psys->totpart, psys->particles->boid);
+ writestruct(wd, DATA, "BoidParticle", psys->totpart, psys->particles->boid);
}
pt = psys->targets.first;
for(; pt; pt=pt->next)
writestruct(wd, DATA, "ParticleTarget", 1, pt);
if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child);
- writestruct(wd, DATA, "SoftBody", 1, psys->soft);
- if(psys->soft) write_pointcaches(wd, &psys->soft->ptcaches);
+
+ if(psys->clmd) {
+ writestruct(wd, DATA, "ClothModifierData", 1, psys->clmd);
+ writestruct(wd, DATA, "ClothSimSettings", 1, psys->clmd->sim_parms);
+ writestruct(wd, DATA, "ClothCollSettings", 1, psys->clmd->coll_parms);
+ }
+
write_pointcaches(wd, &psys->ptcaches);
}
}
@@ -1208,7 +1213,7 @@ static void write_objects(WriteData *wd, ListBase *idbase)
writestruct(wd, DATA, "PartDeflect", 1, ob->pd);
writestruct(wd, DATA, "SoftBody", 1, ob->soft);
- if(ob->soft) writestruct(wd, DATA, "PointCache", 1, ob->soft->pointcache);
+ if(ob->soft) write_pointcaches(wd, &ob->soft->ptcaches);
writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
write_particlesystems(wd, &ob->particlesystem);
@@ -1358,7 +1363,7 @@ static void write_curves(WriteData *wd, ListBase *idbase)
}
nu= cu->nurb.first;
while(nu) {
- if( (nu->type & 7)==CU_BEZIER)
+ if(nu->type == CU_BEZIER)
writestruct(wd, DATA, "BezTriple", nu->pntsu, nu->bezt);
else {
writestruct(wd, DATA, "BPoint", nu->pntsu*nu->pntsv, nu->bp);