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:
authorBenoit Bolsee <benoit.bolsee@online.be>2011-09-07 19:34:04 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2011-09-07 19:34:04 +0400
commitdbd6658d737b1592a633ddf6397be14e50e434d9 (patch)
tree57081721d70622a3c3141909b258f9bce8a5b1e3 /source/blender/blenloader
parentb5bd86e5907c3fa98546dabeda9703dfb15862f4 (diff)
parent884fc84793be1c5fdd6643ad267331381f8e1c6b (diff)
svn merge -r 37306:39975 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h16
-rw-r--r--source/blender/blenloader/BLO_sys_types.h11
-rw-r--r--source/blender/blenloader/CMakeLists.txt5
-rw-r--r--source/blender/blenloader/SConscript2
-rw-r--r--source/blender/blenloader/intern/readblenentry.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c738
-rw-r--r--source/blender/blenloader/intern/writefile.c95
7 files changed, 635 insertions, 234 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 85d4b936c51..47931477728 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -211,7 +211,16 @@ int BLO_has_bfile_extension(char *str);
*/
int BLO_is_a_library(const char *path, char *dir, char *group);
-struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath);
+
+/**
+ * Initialize the BlendHandle for appending or linking library data.
+ *
+ * @param mainvar The current main database eg G.main or CTX_data_main(C).
+ * @param bh A blender file handle as returned by BLO_blendhandle_from_file or BLO_blendhandle_from_memory.
+ * @param filepath Used for relative linking, copied to the lib->name
+ * @return the library Main, to be passed to BLO_library_append_named_part as mainl.
+ */
+struct Main* BLO_library_append_begin(struct Main *mainvar, BlendHandle** bh, const char *filepath);
/**
@@ -243,11 +252,6 @@ void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendH
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
-/* deprecated */
-#if 1
-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);
#ifdef __cplusplus
diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h
index d56723ec1c5..4b3902dca43 100644
--- a/source/blender/blenloader/BLO_sys_types.h
+++ b/source/blender/blenloader/BLO_sys_types.h
@@ -83,7 +83,7 @@ typedef unsigned long uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
-#elif defined(__linux__) || defined(__NetBSD__)
+#elif defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
/* Linux-i386, Linux-Alpha, Linux-ppc */
#include <stdint.h>
@@ -93,7 +93,8 @@ typedef unsigned long uintptr_t;
#include <inttypes.h>
#elif defined(FREE_WINDOWS)
-
+/* define htoln here, there must be a syntax error in winsock2.h in MinGW */
+unsigned long __attribute__((__stdcall__)) htonl(unsigned long);
#include <stdint.h>
#else
@@ -105,8 +106,14 @@ typedef unsigned long uintptr_t;
#ifdef _WIN32
+#ifndef FREE_WINDOWS
+#ifndef htonl
#define htonl(x) correctByteOrder(x)
+#endif
+#ifndef ntohl
#define ntohl(x) correctByteOrder(x)
+#endif
+#endif
#elif defined (__FreeBSD__) || defined (__OpenBSD__)
#include <sys/param.h>
#elif defined (__APPLE__)
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 312a6546e22..ab00a8e90dd 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -26,10 +26,11 @@
set(INC
.
- ../blenlib
../blenkernel
+ ../blenlib
../makesdna
../makesrna
+ ../nodes
../render/extern/include
../../../intern/guardedalloc
)
@@ -55,7 +56,7 @@ set(SRC
)
if(WITH_BUILDINFO)
- add_definitions(-DNAN_BUILDINFO)
+ add_definitions(-DWITH_BUILDINFO)
endif()
blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript
index be9908d84e6..d5d2df3ea35 100644
--- a/source/blender/blenloader/SConscript
+++ b/source/blender/blenloader/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c')
incs = '. #/intern/guardedalloc ../blenlib ../blenkernel'
incs += ' ../makesdna ../editors/include'
-incs += ' ../render/extern/include ../makesrna'
+incs += ' ../render/extern/include ../makesrna ../nodes'
incs += ' ' + env['BF_ZLIB_INC']
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 4ce5685ff18..31b3724e9f6 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -115,7 +115,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, (long int)bhead->len+sizeof(BHead));
+ fprintf(fp, "['%.4s', '%s', %d, %ld ], \n", buf, name, bhead->nr, (long int)(bhead->len+sizeof(BHead)));
}
}
fprintf(fp, "]\n");
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 53d4ceec4e1..f15d7a7b772 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -75,6 +75,7 @@
#include "DNA_node_types.h"
#include "DNA_object_fluidsim.h" // NT
#include "DNA_packedFile_types.h"
+#include "DNA_particle_types.h"
#include "DNA_property_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
@@ -84,6 +85,7 @@
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_smoke_types.h"
+#include "DNA_speaker_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_vfont_types.h"
@@ -132,6 +134,8 @@
#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
#include "BKE_sound.h"
+#include "NOD_socket.h"
+
//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes
//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie
//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo
@@ -2050,10 +2054,21 @@ static void lib_link_nodetree(FileData *fd, Main *main)
}
}
+static void lib_nodetree_init_types_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+ bNode *node;
+
+ ntreeInitTypes(ntree);
+
+ /* XXX could be replaced by do_versions for new nodes */
+ for (node=ntree->nodes.first; node; node=node->next)
+ node_verify_socket_templates(ntree, node);
+}
+
/* updates group node socket own_index so that
* external links to/from the group node are preserved.
*/
-static void lib_node_do_versions_group(bNode *gnode)
+static void lib_node_do_versions_group_indices(bNode *gnode)
{
bNodeTree *ngroup= (bNodeTree*)gnode->id;
bNode *intnode;
@@ -2086,92 +2101,101 @@ static void lib_node_do_versions_group(bNode *gnode)
}
/* updates external links for all group nodes in a tree */
-static void lib_nodetree_do_versions_group(bNodeTree *ntree)
+static void lib_nodetree_do_versions_group_indices_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
for (node=ntree->nodes.first; node; node=node->next) {
if (node->type==NODE_GROUP) {
bNodeTree *ngroup= (bNodeTree*)node->id;
- if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS))
- lib_node_do_versions_group(node);
+ if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE))
+ lib_node_do_versions_group_indices(node);
}
}
}
+/* make an update call for the tree */
+static void lib_nodetree_do_versions_update_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+ if (ntree->update)
+ ntreeUpdateTree(ntree);
+}
+
/* verify types for nodes and groups, all data has to be read */
/* open = 0: appending/linking, open = 1: open new file (need to clean out dynamic
* typedefs*/
static void lib_verify_nodetree(Main *main, int UNUSED(open))
{
- Scene *sce;
- Material *ma;
- Tex *tx;
bNodeTree *ntree;
-
+ int i;
+ bNodeTreeType *ntreetype;
+
/* this crashes blender on undo/redo
if(open==1) {
reinit_nodesystem();
}*/
- /* now create the own typeinfo structs an verify nodes */
- /* here we still assume no groups in groups */
- for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) {
- ntreeVerifyTypes(ntree); /* internal nodes, no groups! */
+ /* set node->typeinfo pointers */
+ for (i=0; i < NUM_NTREE_TYPES; ++i) {
+ ntreetype= ntreeGetType(i);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, lib_nodetree_init_types_cb);
}
+ for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
+ ntreeInitTypes(ntree);
{
- /*int has_old_groups=0;*/ /*UNUSED*/
+ int has_old_groups=0;
/* XXX this should actually be part of do_versions, but since we need
* finished library linking, it is not possible there. Instead in do_versions
* we have set the NTREE_DO_VERSIONS flag, so at this point we can do the
* actual group node updates.
*/
for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) {
- if (ntree->flag & NTREE_DO_VERSIONS) {
+ if (ntree->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE) {
/* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
- nodeGroupExposeAllSockets(ntree);
- /*has_old_groups = 1;*/ /*UNUSED*/
+ node_group_expose_all_sockets(ntree);
+ has_old_groups = 1;
}
}
- /* now verify all types in material trees, groups are set OK now */
- for(ma= main->mat.first; ma; ma= ma->id.next) {
- if(ma->nodetree)
- lib_nodetree_do_versions_group(ma->nodetree);
- }
- /* and scene trees */
- for(sce= main->scene.first; sce; sce= sce->id.next) {
- if(sce->nodetree)
- lib_nodetree_do_versions_group(sce->nodetree);
- }
- /* and texture trees */
- for(tx= main->tex.first; tx; tx= tx->id.next) {
- if(tx->nodetree)
- lib_nodetree_do_versions_group(tx->nodetree);
+
+ if (has_old_groups) {
+ for (i=0; i < NUM_NTREE_TYPES; ++i) {
+ ntreetype= ntreeGetType(i);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, lib_nodetree_do_versions_group_indices_cb);
+ }
}
for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
- ntree->flag &= ~NTREE_DO_VERSIONS;
- }
-
- /* now verify all types in material trees, groups are set OK now */
- for(ma= main->mat.first; ma; ma= ma->id.next) {
- if(ma->nodetree)
- ntreeVerifyTypes(ma->nodetree);
+ ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE;
}
- /* and scene trees */
- for(sce= main->scene.first; sce; sce= sce->id.next) {
- if(sce->nodetree)
- ntreeVerifyTypes(sce->nodetree);
+
+ /* verify all group user nodes */
+ for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) {
+ ntreeVerifyNodes(main, &ntree->id);
}
- /* and texture trees */
- for(tx= main->tex.first; tx; tx= tx->id.next) {
- if(tx->nodetree)
- ntreeVerifyTypes(tx->nodetree);
+
+ /* make update calls where necessary */
+ {
+ for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
+ if (ntree->update)
+ ntreeUpdateTree(ntree);
+ for (i=0; i < NUM_NTREE_TYPES; ++i) {
+ ntreetype= ntreeGetType(i);
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, lib_nodetree_do_versions_update_cb);
+ }
}
}
-
+static void direct_link_node_socket(FileData *fd, bNodeSocket *sock)
+{
+ sock->link= newdataadr(fd, sock->link);
+ sock->storage= newdataadr(fd, sock->storage);
+ sock->default_value= newdataadr(fd, sock->default_value);
+ sock->cache= NULL;
+}
/* ntree itself has been read! */
static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
@@ -2183,6 +2207,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
ntree->init= 0; /* to set callbacks and force setting types */
ntree->progress= NULL;
+ ntree->execdata= NULL;
ntree->adt= newdataadr(fd, ntree->adt);
direct_link_animdata(fd, ntree->adt);
@@ -2195,9 +2220,11 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
node->typeinfo= NULL;
}
+ link_list(fd, &node->inputs);
+ link_list(fd, &node->outputs);
+
node->storage= newdataadr(fd, node->storage);
if(node->storage) {
-
/* could be handlerized at some point */
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
direct_link_curvemapping(fd, node->storage);
@@ -2214,8 +2241,6 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
((ImageUser *)node->storage)->ok= 1;
}
}
- link_list(fd, &node->inputs);
- link_list(fd, &node->outputs);
}
link_list(fd, &ntree->links);
@@ -2225,15 +2250,19 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
/* and we connect the rest */
for(node= ntree->nodes.first; node; node= node->next) {
+ node->parent = newdataadr(fd, node->parent);
node->preview= newimaadr(fd, node->preview);
node->lasty= 0;
+
for(sock= node->inputs.first; sock; sock= sock->next)
- sock->link= newdataadr(fd, sock->link);
+ direct_link_node_socket(fd, sock);
for(sock= node->outputs.first; sock; sock= sock->next)
- sock->ns.data= NULL;
+ direct_link_node_socket(fd, sock);
}
+ for(sock= ntree->inputs.first; sock; sock= sock->next)
+ direct_link_node_socket(fd, sock);
for(sock= ntree->outputs.first; sock; sock= sock->next)
- sock->link= newdataadr(fd, sock->link);
+ direct_link_node_socket(fd, sock);
for(link= ntree->links.first; link; link= link->next) {
link->fromnode= newdataadr(fd, link->fromnode);
@@ -3161,9 +3190,40 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
if(part->effector_weights)
part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
- dw = part->dupliweights.first;
- for(; dw; dw=dw->next)
- dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+ if(part->dupliweights.first && part->dup_group) {
+ int index_ok = 0;
+ /* check for old files without indices (all indexes 0) */
+ dw = part->dupliweights.first;
+ if(part->dupliweights.first == part->dupliweights.last) {
+ /* special case for only one object in the group */
+ index_ok = 1;
+ }
+ else {
+ for(; dw; dw=dw->next) {
+ if(dw->index > 0) {
+ index_ok = 1;
+ break;
+ }
+ }
+ }
+
+ if(index_ok) {
+ /* if we have indexes, let's use them */
+ dw = part->dupliweights.first;
+ for(; dw; dw=dw->next) {
+ GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index);
+ dw->ob = go ? go->ob : NULL;
+ }
+ }
+ else {
+ /* otherwise try to get objects from own library (won't work on library linked groups) */
+ for(; dw; dw=dw->next)
+ dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+ }
+ }
+ else {
+ part->dupliweights.first = part->dupliweights.last = NULL;
+ }
if(part->boids) {
BoidState *state = part->boids->states.first;
@@ -3538,6 +3598,18 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
mesh->mr->edge_creases= newdataadr(fd, mesh->mr->edge_creases);
mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
+
+ /* If mesh has the same number of vertices as the
+ highest multires level, load the current mesh verts
+ into multires and discard the old data. Needed
+ because some saved files either do not have a verts
+ array, or the verts array contains out-of-date
+ data. */
+ if(mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert) {
+ if(mesh->mr->verts)
+ MEM_freeN(mesh->mr->verts);
+ mesh->mr->verts = MEM_dupallocN(mesh->mvert);
+ }
for(; lvl; lvl= lvl->next) {
lvl->verts= newdataadr(fd, lvl->verts);
@@ -3547,16 +3619,11 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
}
}
- /* Gracefully handle corrupted mesh */
+ /* if multires is present but has no valid vertex data,
+ there's no way to recover it; silently remove multires */
if(mesh->mr && !mesh->mr->verts) {
- /* If totals match, simply load the current mesh verts into multires */
- if(mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert)
- mesh->mr->verts = MEM_dupallocN(mesh->mvert);
- else {
- /* Otherwise, we can't recover the data, silently remove multires */
- multires_free(mesh->mr);
- mesh->mr = NULL;
- }
+ multires_free(mesh->mr);
+ mesh->mr = NULL;
}
if((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {
@@ -3848,26 +3915,10 @@ static void lib_link_object(FileData *fd, Main *main)
if(smd && smd->type == MOD_SMOKE_TYPE_DOMAIN && smd->domain)
{
- smd->domain->coll_group = newlibadr_us(fd, ob->id.lib, smd->domain->coll_group);
- smd->domain->eff_group = newlibadr_us(fd, ob->id.lib, smd->domain->eff_group);
- smd->domain->fluid_group = newlibadr_us(fd, ob->id.lib, smd->domain->fluid_group);
-
- smd->domain->effector_weights->group = newlibadr(fd, ob->id.lib, smd->domain->effector_weights->group);
-
smd->domain->flags |= MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */
}
}
- {
- ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
-
- if(clmd)
- {
- clmd->sim_parms->effector_weights->group = newlibadr(fd, ob->id.lib, clmd->sim_parms->effector_weights->group);
- clmd->coll_parms->group= newlibadr(fd, ob->id.lib, clmd->coll_parms->group);
- }
- }
-
/* texture field */
if(ob->pd)
lib_link_partdeflect(fd, &ob->id, ob->pd);
@@ -4342,6 +4393,7 @@ static void direct_link_object(FileData *fd, Object *ob)
MEM_freeN(hook);
}
+ ob->customdata_mask= 0;
ob->bb= NULL;
ob->derivedDeform= NULL;
ob->derivedFinal= NULL;
@@ -4453,7 +4505,7 @@ static void lib_link_scene(FileData *fd, Main *main)
#endif
if(sce->ed)
- seq_update_muting(sce, sce->ed);
+ seq_update_muting(sce->ed);
if(sce->nodetree) {
lib_link_ntree(fd, &sce->id, sce->nodetree);
@@ -4707,6 +4759,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
wm->keyconfigs.first= wm->keyconfigs.last= NULL;
wm->defaultconf= NULL;
+ wm->addonconf= NULL;
+ wm->userconf= NULL;
wm->jobs.first= wm->jobs.last= NULL;
wm->drags.first= wm->drags.last= NULL;
@@ -4849,7 +4903,6 @@ static void lib_link_screen(FileData *fd, Main *main)
else if(sl->spacetype==SPACE_FILE) {
SpaceFile *sfile= (SpaceFile *)sl;
sfile->files= NULL;
- sfile->params= NULL;
sfile->op= NULL;
sfile->layout= NULL;
sfile->folders_prev= NULL;
@@ -4936,15 +4989,22 @@ static void lib_link_screen(FileData *fd, Main *main)
SpaceNode *snode= (SpaceNode *)sl;
snode->id= newlibadr(fd, sc->id.lib, snode->id);
+ snode->edittree= NULL;
- /* internal data, a bit patchy */
- if(snode->id) {
- if(GS(snode->id->name)==ID_MA)
- snode->nodetree= ((Material *)snode->id)->nodetree;
- else if(GS(snode->id->name)==ID_SCE)
- snode->nodetree= ((Scene *)snode->id)->nodetree;
- else if(GS(snode->id->name)==ID_TE)
- snode->nodetree= ((Tex *)snode->id)->nodetree;
+ if (ELEM3(snode->treetype, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE)) {
+ /* internal data, a bit patchy */
+ snode->nodetree= NULL;
+ if(snode->id) {
+ if(GS(snode->id->name)==ID_MA)
+ snode->nodetree= ((Material *)snode->id)->nodetree;
+ else if(GS(snode->id->name)==ID_SCE)
+ snode->nodetree= ((Scene *)snode->id)->nodetree;
+ else if(GS(snode->id->name)==ID_TE)
+ snode->nodetree= ((Tex *)snode->id)->nodetree;
+ }
+ }
+ else {
+ snode->nodetree= newlibadr_us(fd, sc->id.lib, snode->nodetree);
}
snode->linkdrag.first = snode->linkdrag.last = NULL;
@@ -5164,15 +5224,19 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
snode->id= restore_pointer_by_name(newmain, snode->id, 1);
snode->edittree= NULL;
- if(snode->id==NULL)
+ if (ELEM3(snode->treetype, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE)) {
snode->nodetree= NULL;
+ if(snode->id) {
+ if(GS(snode->id->name)==ID_MA)
+ snode->nodetree= ((Material *)snode->id)->nodetree;
+ else if(GS(snode->id->name)==ID_SCE)
+ snode->nodetree= ((Scene *)snode->id)->nodetree;
+ else if(GS(snode->id->name)==ID_TE)
+ snode->nodetree= ((Tex *)snode->id)->nodetree;
+ }
+ }
else {
- if(GS(snode->id->name)==ID_MA)
- snode->nodetree= ((Material *)snode->id)->nodetree;
- else if(GS(snode->id->name)==ID_SCE)
- snode->nodetree= ((Scene *)snode->id)->nodetree;
- else if(GS(snode->id->name)==ID_TE)
- snode->nodetree= ((Tex *)snode->id)->nodetree;
+ snode->nodetree= restore_pointer_by_name(newmain, &snode->nodetree->id, 1);
}
}
}
@@ -5401,7 +5465,6 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
snode->gpd= newdataadr(fd, snode->gpd);
direct_link_gpencil(fd, snode->gpd);
}
- snode->nodetree= snode->edittree= NULL;
}
else if(sl->spacetype==SPACE_TIME) {
SpaceTime *stime= (SpaceTime *)sl;
@@ -5462,7 +5525,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
sfile->files= NULL;
sfile->layout= NULL;
sfile->op= NULL;
- sfile->params= NULL;
+ sfile->params= newdataadr(fd, sfile->params);
}
}
@@ -5551,12 +5614,51 @@ static void fix_relpaths_library(const char *basepath, Main *main)
}
}
+/* ************ READ SPEAKER ***************** */
+
+static void lib_link_speaker(FileData *fd, Main *main)
+{
+ Speaker *spk;
+
+ spk= main->speaker.first;
+ while(spk) {
+ if(spk->id.flag & LIB_NEEDLINK) {
+ if (spk->adt) lib_link_animdata(fd, &spk->id, spk->adt);
+
+ spk->sound= newlibadr(fd, spk->id.lib, spk->sound);
+ if (spk->sound) {
+ spk->sound->id.us++;
+ }
+
+ spk->id.flag -= LIB_NEEDLINK;
+ }
+ spk= spk->id.next;
+ }
+}
+
+static void direct_link_speaker(FileData *fd, Speaker *spk)
+{
+ spk->adt= newdataadr(fd, spk->adt);
+ direct_link_animdata(fd, spk->adt);
+
+ /*spk->sound= newdataadr(fd, spk->sound);
+ direct_link_sound(fd, spk->sound);*/
+}
+
/* ************** READ SOUND ******************* */
static void direct_link_sound(FileData *fd, bSound *sound)
{
sound->handle = NULL;
sound->playback_handle = NULL;
+ sound->waveform = NULL;
+
+ // versioning stuff, if there was a cache, then we enable caching:
+ if(sound->cache)
+ {
+ sound->flags |= SOUND_FLAGS_CACHING;
+ sound->cache = NULL;
+ }
sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
@@ -5573,9 +5675,6 @@ static void lib_link_sound(FileData *fd, Main *main)
sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system
sound_load(main, sound);
-
- if(sound->cache)
- sound_cache(sound, 1);
}
sound= sound->id.next;
}
@@ -5646,6 +5745,7 @@ static const char *dataname(short id_code)
case ID_SCR: return "Data from SCR";
case ID_VF: return "Data from VF";
case ID_TXT : return "Data from TXT";
+ case ID_SPK: return "Data from SPK";
case ID_SO: return "Data from SO";
case ID_NT: return "Data from NT";
case ID_BR: return "Data from BR";
@@ -5663,11 +5763,10 @@ static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *a
while(bhead && bhead->code==DATA) {
void *data;
#if 0
- /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
+ /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
short *sp= fd->filesdna->structs[bhead->SDNAnr];
- char *allocname = fd->filesdna->types[ sp[0] ];
char *tmp= malloc(100);
-
+ allocname = fd->filesdna->types[ sp[0] ];
strcpy(tmp, allocname);
data= read_struct(fd, bhead, tmp);
#else
@@ -5791,6 +5890,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
case ID_CA:
direct_link_camera(fd, (Camera *)id);
break;
+ case ID_SPK:
+ direct_link_speaker(fd, (Speaker *)id);
+ break;
case ID_SO:
direct_link_sound(fd, (bSound *)id);
break;
@@ -6871,6 +6973,62 @@ static void do_version_bone_roll_256(Bone *bone)
do_version_bone_roll_256(child);
}
+static void do_versions_socket_default_value(bNodeSocket *sock)
+{
+ bNodeSocketValueFloat *valfloat;
+ bNodeSocketValueVector *valvector;
+ bNodeSocketValueRGBA *valrgba;
+
+ if (sock->default_value)
+ return;
+
+ switch (sock->type) {
+ case SOCK_FLOAT:
+ valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat), "default socket value");
+ valfloat->value = sock->ns.vec[0];
+ valfloat->min = sock->ns.min;
+ valfloat->max = sock->ns.max;
+ valfloat->subtype = PROP_NONE;
+ break;
+ case SOCK_VECTOR:
+ valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector), "default socket value");
+ copy_v3_v3(valvector->value, sock->ns.vec);
+ valvector->min = sock->ns.min;
+ valvector->max = sock->ns.max;
+ valvector->subtype = PROP_NONE;
+ break;
+ case SOCK_RGBA:
+ valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA), "default socket value");
+ copy_v4_v4(valrgba->value, sock->ns.vec);
+ break;
+ }
+}
+
+static void do_versions_nodetree_default_value(bNodeTree *ntree)
+{
+ bNode *node;
+ bNodeSocket *sock;
+ for (node=ntree->nodes.first; node; node=node->next) {
+ for (sock=node->inputs.first; sock; sock=sock->next)
+ do_versions_socket_default_value(sock);
+ for (sock=node->outputs.first; sock; sock=sock->next)
+ do_versions_socket_default_value(sock);
+ }
+ for (sock=ntree->inputs.first; sock; sock=sock->next)
+ do_versions_socket_default_value(sock);
+ for (sock=ntree->outputs.first; sock; sock=sock->next)
+ do_versions_socket_default_value(sock);
+}
+
+static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree)
+{
+ bNodeSocket *sock;
+ for (sock=ntree->inputs.first; sock; sock=sock->next)
+ sock->flag |= SOCK_DYNAMIC;
+ for (sock=ntree->outputs.first; sock; sock=sock->next)
+ sock->flag |= SOCK_DYNAMIC;
+}
+
static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -9932,12 +10090,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if(ed) {
SEQP_BEGIN(ed, seq) {
if (seq->strip && seq->strip->proxy){
- if (sce->r.size != 100.0) {
- seq->strip->proxy->size
- = sce->r.size;
- } else {
- seq->strip->proxy->size = 25;
- }
seq->strip->proxy->quality =90;
}
}
@@ -10027,7 +10179,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
!(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR))
{
- snprintf(seq->strip->proxy->dir,
+ BLI_snprintf(seq->strip->proxy->dir,
FILE_MAXDIR, "%s/BL_proxy",
seq->strip->dir);
}
@@ -10044,7 +10196,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
* to have them show in RNA viewer and accessible otherwise.
*/
for(ma= main->mat.first; ma; ma= ma->id.next) {
- if(ma->nodetree && strlen(ma->nodetree->id.name)==0)
+ if(ma->nodetree && ma->nodetree->id.name[0] == '\0')
strcpy(ma->nodetree->id.name, "NTShader Nodetree");
/* which_output 0 is now "not specified" */
@@ -10058,7 +10210,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
/* and composit trees */
for(sce= main->scene.first; sce; sce= sce->id.next) {
- if(sce->nodetree && strlen(sce->nodetree->id.name)==0)
+ if(sce->nodetree && sce->nodetree->id.name[0] == '\0')
strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
/* move to cameras */
@@ -10080,7 +10232,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
bNode *node;
if(tx->nodetree) {
- if(strlen(tx->nodetree->id.name)==0)
+ if(tx->nodetree->id.name[0] == '\0')
strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
/* which_output 0 is now "not specified" */
@@ -10267,8 +10419,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
sce->gm.attrib = sce->r.attrib;
//Stereo
- sce->gm.xsch = sce->r.xsch;
- sce->gm.ysch = sce->r.ysch;
sce->gm.stereomode = sce->r.stereomode;
/* reassigning stereomode NO_STEREO and DOME to a separeted flag*/
if (sce->gm.stereomode == 1){ //1 = STEREO_NOSTEREO
@@ -11547,7 +11697,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
* is done in lib_verify_nodetree, because at this point the internal
* nodes may not be up-to-date! (missing lib-link)
*/
- ntree->flag |= NTREE_DO_VERSIONS;
+ ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE;
}
}
@@ -11632,9 +11782,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
- /* put compatibility code here until next subversion bump */
-
- {
+ if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)){
/* screen view2d settings were not properly initialized [#27164]
* v2d->scroll caused the bug but best reset other values too which are in old blend files only.
* need to make less ugly - possibly an iterator? */
@@ -11672,12 +11820,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
Tex *tex;
for(tex= main->tex.first; tex; tex= tex->id.next) {
if(tex->pd) {
- if (tex->pd->falloff_speed_scale == 0.0)
- tex->pd->falloff_speed_scale = 100.0;
-
+ if (tex->pd->falloff_speed_scale == 0.0f)
+ tex->pd->falloff_speed_scale = 100.0f;
+
if (!tex->pd->falloff_curve) {
tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
-
+
tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
@@ -11686,8 +11834,193 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+
+ {
+ /* add default value for behind strength of camera actuator */
+ Object *ob;
+ bActuator *act;
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ for(act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_CAMERA) {
+ bCameraActuator *ba= act->data;
+
+ ba->damping = 1.0/32.0;
+ }
+ }
+ }
+ }
+
+ {
+ ParticleSettings *part;
+ for(part = main->particle.first; part; part = part->id.next) {
+ /* Initialize particle billboard scale */
+ part->bb_size[0] = part->bb_size[1] = 1.0f;
+ }
+ }
}
-
+
+ if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)){
+ {
+ Scene *scene;
+ Sequence *seq;
+
+ for (scene=main->scene.first; scene; scene=scene->id.next)
+ {
+ scene->r.ffcodecdata.audio_channels = 2;
+ scene->audio.volume = 1.0f;
+ SEQ_BEGIN(scene->ed, seq) {
+ seq->pitch = 1.0f;
+ }
+ SEQ_END
+ }
+ }
+ {
+ bScreen *screen;
+ for(screen= main->screen.first; screen; screen= screen->id.next) {
+ ScrArea *sa;
+ /* add regions */
+ for(sa= screen->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl= sa->spacedata.first;
+ if(sl->spacetype==SPACE_SEQ) {
+ ARegion *ar;
+ for (ar=sa->regionbase.first; ar; ar= ar->next) {
+ if(ar->regiontype == RGN_TYPE_WINDOW) {
+ if(ar->v2d.min[1] == 4.0f)
+ ar->v2d.min[1]= 0.5f;
+ }
+ }
+ }
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if(sl->spacetype==SPACE_SEQ) {
+ ARegion *ar;
+ for (ar=sl->regionbase.first; ar; ar= ar->next) {
+ if(ar->regiontype == RGN_TYPE_WINDOW) {
+ if(ar->v2d.min[1] == 4.0f)
+ ar->v2d.min[1]= 0.5f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ {
+ /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
+ *
+ * We're only patching F-Curves in Actions here, since it is assumed that most
+ * drivers out there won't be using this (and if they are, they're in the minority).
+ * While we should aim to fix everything ideally, in practice it's far too hard
+ * to get to every animdata block, not to mention the performance hit that'd have
+ */
+ bAction *act;
+ FCurve *fcu;
+
+ for (act = main->action.first; act; act = act->id.next) {
+ for (fcu = act->curves.first; fcu; fcu = fcu->next) {
+ BezTriple *bezt;
+ unsigned int i = 0;
+
+ /* only need to touch curves that had this flag set */
+ if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
+ continue;
+ if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+ continue;
+
+ /* only change auto-handles to auto-clamped */
+ for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM;
+ if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM;
+ }
+
+ fcu->flag &= ~FCURVE_AUTO_HANDLES;
+ }
+ }
+ }
+ {
+ /* convert fcurve and shape action actuators to action actuators */
+ Object *ob;
+ bActuator *act;
+ bIpoActuator *ia;
+ bActionActuator *aa;
+
+ for (ob= main->object.first; ob; ob= ob->id.next) {
+ for (act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_IPO) {
+ // Create the new actuator
+ ia= act->data;
+ aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version");
+
+ // Copy values
+ aa->type = ia->type;
+ aa->flag = ia->flag;
+ aa->sta = ia->sta;
+ aa->end = ia->end;
+ strcpy(aa->name, ia->name);
+ strcpy(aa->frameProp, ia->frameProp);
+ if (ob->adt)
+ aa->act = ob->adt->action;
+
+ // Get rid of the old actuator
+ MEM_freeN(ia);
+
+ // Assign the new actuator
+ act->data = aa;
+ act->type= act->otype= ACT_ACTION;
+
+ }
+ else if (act->type == ACT_SHAPEACTION) {
+ act->type = act->otype = ACT_ACTION;
+ }
+ }
+ }
+ }
+ }
+
+ if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)){
+ {
+ /* Convert default socket values from bNodeStack */
+ Scene *sce;
+ Material *mat;
+ Tex *tex;
+ bNodeTree *ntree;
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+ do_versions_nodetree_default_value(ntree);
+ ntree->update |= NTREE_UPDATE;
+ }
+ for (sce=main->scene.first; sce; sce=sce->id.next)
+ if (sce->nodetree) {
+ do_versions_nodetree_default_value(sce->nodetree);
+ sce->nodetree->update |= NTREE_UPDATE;
+ }
+ for (mat=main->mat.first; mat; mat=mat->id.next)
+ if (mat->nodetree) {
+ do_versions_nodetree_default_value(mat->nodetree);
+ mat->nodetree->update |= NTREE_UPDATE;
+ }
+ for (tex=main->tex.first; tex; tex=tex->id.next)
+ if (tex->nodetree) {
+ do_versions_nodetree_default_value(tex->nodetree);
+ tex->nodetree->update |= NTREE_UPDATE;
+ }
+ }
+
+ /* add SOCK_DYNAMIC flag to existing group sockets */
+ {
+ bNodeTree *ntree;
+ /* only need to do this for trees in main, local trees are not used as groups */
+ for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+ do_versions_nodetree_dynamic_sockets(ntree);
+ ntree->update |= NTREE_UPDATE;
+ }
+ }
+ }
+
+ /* put compatibility code here until next subversion bump */
+
+ {
+
+ }
+
//set defaults for obstacle avoidance, recast data
{
Scene *sce;
@@ -11760,6 +12093,7 @@ static void lib_link_all(FileData *fd, Main *main)
lib_link_latt(fd, main);
lib_link_text(fd, main);
lib_link_camera(fd, main);
+ lib_link_speaker(fd, main);
lib_link_sound(fd, main);
lib_link_group(fd, main);
lib_link_armature(fd, main);
@@ -11774,38 +12108,63 @@ static void lib_link_all(FileData *fd, Main *main)
lib_link_library(fd, main); /* only init users */
}
+static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi)
+{
+ kmi->properties= newdataadr(fd, kmi->properties);
+ if(kmi->properties)
+ IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ kmi->ptr= NULL;
+ kmi->flag &= ~KMI_UPDATE;
+}
static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
{
UserDef *user;
wmKeyMap *keymap;
wmKeyMapItem *kmi;
+ wmKeyMapDiffItem *kmdi;
bfd->user= user= read_struct(fd, bhead, "user def");
/* read all data into fd->datamap */
bhead= read_data_into_oldnewmap(fd, bhead, "user def");
+ if(user->keymaps.first) {
+ /* backwards compatibility */
+ user->user_keymaps= user->keymaps;
+ user->keymaps.first= user->keymaps.last= NULL;
+ }
+
link_list(fd, &user->themes);
- link_list(fd, &user->keymaps);
+ link_list(fd, &user->user_keymaps);
link_list(fd, &user->addons);
- for(keymap=user->keymaps.first; keymap; keymap=keymap->next) {
+ for(keymap=user->user_keymaps.first; keymap; keymap=keymap->next) {
keymap->modal_items= NULL;
keymap->poll= NULL;
+ keymap->flag &= ~KEYMAP_UPDATE;
+ link_list(fd, &keymap->diff_items);
link_list(fd, &keymap->items);
- for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
- kmi->properties= newdataadr(fd, kmi->properties);
- if(kmi->properties)
- IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- kmi->ptr= NULL;
+
+ for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+ kmdi->remove_item= newdataadr(fd, kmdi->remove_item);
+ kmdi->add_item= newdataadr(fd, kmdi->add_item);
+
+ if(kmdi->remove_item)
+ direct_link_keymapitem(fd, kmdi->remove_item);
+ if(kmdi->add_item)
+ direct_link_keymapitem(fd, kmdi->add_item);
}
+
+ for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+ direct_link_keymapitem(fd, kmi);
}
// XXX
user->uifonts.first= user->uifonts.last= NULL;
- user->uistyles.first= user->uistyles.last= NULL;
+
+ link_list(fd, &user->uistyles);
/* free fd->datamap again */
oldnewmap_free_unused(fd->datamap);
@@ -12680,6 +13039,14 @@ static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
expand_animdata(fd, mainvar, ca->adt);
}
+static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk)
+{
+ expand_doit(fd, mainvar, spk->sound);
+
+ if (spk->adt)
+ expand_animdata(fd, mainvar, spk->adt);
+}
+
static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
{
expand_doit(fd, mainvar, snd->ipo); // XXX depreceated - old animation system
@@ -12742,6 +13109,9 @@ static void expand_main(FileData *fd, Main *mainvar)
case ID_CA:
expand_camera(fd, mainvar, (Camera *)id);
break;
+ case ID_SPK:
+ expand_speaker(fd, mainvar,(Speaker *)id);
+ break;
case ID_SO:
expand_sound(fd, mainvar, (bSound *)id);
break;
@@ -12787,7 +13157,6 @@ static int object_in_any_scene(Main *mainvar, Object *ob)
return 0;
}
-/* when *lib set, it also does objects that were in the appended group */
static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, const short idcode, const short is_link)
{
Object *ob;
@@ -12822,8 +13191,14 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, const
/* when appending, make sure any indirectly loaded objects
* get a base else they cant be accessed at all [#27437] */
if(ob->id.us==1 && is_link==FALSE && ob->id.lib==lib) {
- if(object_in_any_scene(mainvar, ob)==0) {
- do_it= 1;
+
+ /* we may be appending from a scene where we already
+ * have a linked object which is not in any scene [#27616] */
+ if((ob->id.flag & LIB_PRE_EXISTING)==0) {
+
+ if(object_in_any_scene(mainvar, ob)==0) {
+ do_it= 1;
+ }
}
}
}
@@ -12844,7 +13219,6 @@ static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, const
}
}
-/* when *lib set, it also does objects that were in the appended group */
static void give_base_to_groups(Main *mainvar, Scene *scene)
{
Group *group;
@@ -12987,9 +13361,8 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
/* common routine to append/link something from a library */
-static Main* library_append_begin(const bContext *C, FileData **fd, const char *filepath)
+static Main* library_append_begin(Main *mainvar, FileData **fd, const char *filepath)
{
- Main *mainvar= CTX_data_main(C);
Main *mainl;
/* make mains */
@@ -13005,64 +13378,17 @@ static Main* library_append_begin(const bContext *C, FileData **fd, const char *
return mainl;
}
-Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, const char *filepath)
+Main* BLO_library_append_begin(Main *mainvar, BlendHandle** bh, const char *filepath)
{
FileData *fd= (FileData*)(*bh);
- return library_append_begin(C, &fd, filepath);
+ return library_append_begin(mainvar, &fd, filepath);
}
-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;
-
- /* 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;
- }
- /* we haven't found any objects to move to cursor */
- if(!count)
- return;
-
- /* move from the center of the appended objects to cursor */
- mid_v3_v3v3(centerloc, min, max);
- 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;
- }
-}
+/* Context == NULL signifies not to do any scene manipulation */
static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
{
Main *mainvar;
- Scene *scene= CTX_data_scene(C);
Library *curlib;
/* make main consistent */
@@ -13091,22 +13417,26 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
lib_verify_nodetree(mainvar, FALSE);
fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
- /* give a base to loose objects. If group append, do it for objects too */
- if(scene) {
- const short is_link= (flag & FILE_LINK) != 0;
- if(idcode==ID_SCE) {
- /* dont instance anything when linking in scenes, assume the scene its self instances the data */
- }
- else {
- give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+ if(C) {
+ Scene *scene= CTX_data_scene(C);
+
+ /* give a base to loose objects. If group append, do it for objects too */
+ if(scene) {
+ const short is_link= (flag & FILE_LINK) != 0;
+ if(idcode==ID_SCE) {
+ /* dont instance anything when linking in scenes, assume the scene its self instances the data */
+ }
+ else {
+ give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
- if (flag & FILE_GROUP_INSTANCE) {
- give_base_to_groups(mainvar, scene);
+ if (flag & FILE_GROUP_INSTANCE) {
+ give_base_to_groups(mainvar, scene);
+ }
}
}
- }
- else {
- printf("library_append_end, scene is NULL (objects wont get bases)\n");
+ else {
+ printf("library_append_end, scene is NULL (objects wont get bases)\n");
+ }
}
/* has been removed... erm, why? s..ton) */
/* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
@@ -13117,8 +13447,6 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
blo_freefiledata( *fd );
*fd = NULL;
}
-
- append_do_cursor(scene, curlib, flag);
}
void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index fe4f914dfa4..9275852d424 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -123,6 +123,7 @@ Any case: direct data is ALWAYS after the lib block
#include "DNA_smoke_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
+#include "DNA_speaker_types.h"
#include "DNA_sound_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
@@ -641,6 +642,14 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
writestruct(wd, DATA, "CurveMapPoint", cumap->cm[a].totpoint, cumap->cm[a].curve);
}
+static void write_node_socket(WriteData *wd, bNodeSocket *sock)
+{
+ bNodeSocketType *stype= ntreeGetSocketType(sock->type);
+ writestruct(wd, DATA, "bNodeSocket", 1, sock);
+ if (sock->default_value)
+ writestruct(wd, DATA, stype->value_structname, 1, sock->default_value);
+}
+
/* this is only direct data, tree itself should have been written */
static void write_nodetree(WriteData *wd, bNodeTree *ntree)
{
@@ -656,6 +665,12 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
writestruct(wd, DATA, "bNode", 1, node);
for(node= ntree->nodes.first; node; node= node->next) {
+ for(sock= node->inputs.first; sock; sock= sock->next)
+ write_node_socket(wd, sock);
+ for(sock= node->outputs.first; sock; sock= sock->next)
+ write_node_socket(wd, sock);
+
+
if(node->storage && node->type!=NODE_DYNAMIC) {
/* could be handlerized at some point, now only 1 exception still */
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
@@ -664,13 +679,9 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
write_curvemapping(wd, node->storage);
else if(ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) )
write_curvemapping(wd, node->storage);
- else
+ else
writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
}
- for(sock= node->inputs.first; sock; sock= sock->next)
- writestruct(wd, DATA, "bNodeSocket", 1, sock);
- for(sock= node->outputs.first; sock; sock= sock->next)
- writestruct(wd, DATA, "bNodeSocket", 1, sock);
}
for(link= ntree->links.first; link; link= link->next)
@@ -678,9 +689,9 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
/* external sockets */
for(sock= ntree->inputs.first; sock; sock= sock->next)
- writestruct(wd, DATA, "bNodeSocket", 1, sock);
+ write_node_socket(wd, sock);
for(sock= ntree->outputs.first; sock; sock= sock->next)
- writestruct(wd, DATA, "bNodeSocket", 1, sock);
+ write_node_socket(wd, sock);
}
static void current_screen_compat(Main *mainvar, bScreen **screen)
@@ -717,31 +728,48 @@ static void write_renderinfo(WriteData *wd, Main *mainvar) /* for renderdeamon
}
}
+static void write_keymapitem(WriteData *wd, wmKeyMapItem *kmi)
+{
+ writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
+ if(kmi->properties)
+ IDP_WriteProperty(kmi->properties, wd);
+}
+
static void write_userdef(WriteData *wd)
{
bTheme *btheme;
wmKeyMap *keymap;
wmKeyMapItem *kmi;
+ wmKeyMapDiffItem *kmdi;
bAddon *bext;
-
+ uiStyle *style;
+
writestruct(wd, USER, "UserDef", 1, &U);
for(btheme= U.themes.first; btheme; btheme=btheme->next)
writestruct(wd, DATA, "bTheme", 1, btheme);
- for(keymap= U.keymaps.first; keymap; keymap=keymap->next) {
+ for(keymap= U.user_keymaps.first; keymap; keymap=keymap->next) {
writestruct(wd, DATA, "wmKeyMap", 1, keymap);
- for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
- writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
-
- if(kmi->properties)
- IDP_WriteProperty(kmi->properties, wd);
+ for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+ writestruct(wd, DATA, "wmKeyMapDiffItem", 1, kmdi);
+ if(kmdi->remove_item)
+ write_keymapitem(wd, kmdi->remove_item);
+ if(kmdi->add_item)
+ write_keymapitem(wd, kmdi->add_item);
}
+
+ for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+ write_keymapitem(wd, kmi);
}
for(bext= U.addons.first; bext; bext=bext->next)
writestruct(wd, DATA, "bAddon", 1, bext);
+
+ for(style= U.uistyles.first; style; style= style->next) {
+ writestruct(wd, DATA, "uiStyle", 1, style);
+ }
}
static void write_boid_state(WriteData *wd, BoidState *state)
@@ -832,6 +860,7 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase)
{
ParticleSettings *part;
ParticleDupliWeight *dw;
+ GroupObject *go;
int a;
part= idbase->first;
@@ -846,8 +875,18 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase)
writestruct(wd, DATA, "EffectorWeights", 1, part->effector_weights);
dw = part->dupliweights.first;
- for(; dw; dw=dw->next)
+ for(; dw; dw=dw->next) {
+ /* update indices */
+ dw->index = 0;
+ if(part->dup_group) { /* can be NULL if lining fails or set to None */
+ go = part->dup_group->gobject.first;
+ while(go && go->ob != dw->ob) {
+ go=go->next;
+ dw->index++;
+ }
+ }
writestruct(wd, DATA, "ParticleDupliWeight", 1, dw);
+ }
if(part->boids && part->phystype == PART_PHYS_BOIDS) {
BoidState *state = part->boids->states.first;
@@ -904,7 +943,7 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
writestruct(wd, DATA, "ClothSimSettings", 1, psys->clmd->sim_parms);
writestruct(wd, DATA, "ClothCollSettings", 1, psys->clmd->coll_parms);
}
-
+
write_pointcaches(wd, &psys->ptcaches);
}
}
@@ -2101,7 +2140,11 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
writestruct(wd, DATA, "SpaceButs", 1, sl);
}
else if(sl->spacetype==SPACE_FILE) {
+ SpaceFile *sfile= (SpaceFile *)sl;
+
writestruct(wd, DATA, "SpaceFile", 1, sl);
+ if(sfile->params)
+ writestruct(wd, DATA, "FileSelectParams", 1, sfile->params);
}
else if(sl->spacetype==SPACE_SEQ) {
writestruct(wd, DATA, "SpaceSeq", 1, sl);
@@ -2313,6 +2356,23 @@ static void write_texts(WriteData *wd, ListBase *idbase)
mywrite(wd, MYWRITE_FLUSH, 0);
}
+static void write_speakers(WriteData *wd, ListBase *idbase)
+{
+ Speaker *spk;
+
+ spk= idbase->first;
+ while(spk) {
+ if(spk->id.us>0 || wd->current) {
+ /* write LibData */
+ writestruct(wd, ID_SPK, "Speaker", 1, spk);
+ if (spk->id.properties) IDP_WriteProperty(spk->id.properties, wd);
+
+ if (spk->adt) write_animdata(wd, spk->adt);
+ }
+ spk= spk->id.next;
+ }
+}
+
static void write_sounds(WriteData *wd, ListBase *idbase)
{
bSound *sound;
@@ -2434,7 +2494,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
fg.subversion= BLENDER_SUBVERSION;
fg.minversion= BLENDER_MINVERSION;
fg.minsubversion= BLENDER_MINSUBVERSION;
-#ifdef NAN_BUILDINFO
+#ifdef WITH_BUILDINFO
{
extern char build_rev[];
fg.revision= atoi(build_rev);
@@ -2491,6 +2551,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
write_keys (wd, &mainvar->key);
write_worlds (wd, &mainvar->world);
write_texts (wd, &mainvar->text);
+ write_speakers (wd, &mainvar->speaker);
write_sounds (wd, &mainvar->sound);
write_groups (wd, &mainvar->group);
write_armatures(wd, &mainvar->armature);