Merged changes in the trunk up to revision 46045.
[blender-staging.git] / source / blender / blenloader / intern / writefile.c
index 4739d01c72490cf62789f2878d5a24782e7296a3..b0bc7c1e73b8665a54818b6a698422a9b377b9eb 100644 (file)
@@ -489,7 +489,7 @@ static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
                                        FMod_Python *data = (FMod_Python *)fcm->data;
                                        
                                        /* Write ID Properties -- and copy this comment EXACTLY for easy finding
-                                        of library blocks that implement this.*/
+                                        of library blocks that implement this.*/
                                        IDP_WriteProperty(data->prop, wd);
                                }
                                        break;
@@ -758,24 +758,30 @@ static void current_screen_compat(Main *mainvar, bScreen **screen)
        *screen= (window)? window->screen: NULL;
 }
 
+typedef struct RenderInfo {
+       int sfra;
+       int efra;
+       char scene_name[MAX_ID_NAME - 2];
+} RenderInfo;
+
 static void write_renderinfo(WriteData *wd, Main *mainvar)             /* for renderdeamon */
 {
        bScreen *curscreen;
        Scene *sce;
-       int data[8];
+       RenderInfo data;
 
        /* XXX in future, handle multiple windows with multiple screnes? */
        current_screen_compat(mainvar, &curscreen);
 
        for (sce= mainvar->scene.first; sce; sce= sce->id.next) {
                if (sce->id.lib==NULL  && ( sce==curscreen->scene || (sce->r.scemode & R_BG_RENDER)) ) {
-                       data[0]= sce->r.sfra;
-                       data[1]= sce->r.efra;
+                       data.sfra = sce->r.sfra;
+                       data.efra = sce->r.efra;
+                       memset(data.scene_name, 0, sizeof(data.scene_name));
 
-                       memset(data+2, 0, sizeof(int)*6);
-                       BLI_strncpy((char *)(data+2), sce->id.name+2, sizeof(sce->id.name)-2);
+                       BLI_strncpy(data.scene_name, sce->id.name + 2, sizeof(data.scene_name));
 
-                       writedata(wd, REND, 32, data);
+                       writedata(wd, REND, sizeof(data), &data);
                }
        }
 }
@@ -832,7 +838,7 @@ static void write_boid_state(WriteData *wd, BoidState *state)
        writestruct(wd, DATA, "BoidState", 1, state);
 
        for (; rule; rule=rule->next) {
-               switch(rule->type) {
+               switch (rule->type) {
                        case eBoidRuleType_Goal:
                        case eBoidRuleType_Avoid:
                                writestruct(wd, DATA, "BoidRuleGoalAvoid", 1, rule);
@@ -1025,7 +1031,7 @@ static void write_sensors(WriteData *wd, ListBase *lb)
 
                writedata(wd, DATA, sizeof(void *)*sens->totlinks, sens->links);
 
-               switch(sens->type) {
+               switch (sens->type) {
                case SENS_NEAR:
                        writestruct(wd, DATA, "bNearSensor", 1, sens->data);
                        break;
@@ -1086,7 +1092,7 @@ static void write_controllers(WriteData *wd, ListBase *lb)
 
                writedata(wd, DATA, sizeof(void *)*cont->totlinks, cont->links);
 
-               switch(cont->type) {
+               switch (cont->type) {
                case CONT_EXPRESSION:
                        writestruct(wd, DATA, "bExpressionCont", 1, cont->data);
                        break;
@@ -1109,7 +1115,7 @@ static void write_actuators(WriteData *wd, ListBase *lb)
        while (act) {
                writestruct(wd, DATA, "bActuator", 1, act);
 
-               switch(act->type) {
+               switch (act->type) {
                case ACT_ACTION:
                case ACT_SHAPEACTION:
                        writestruct(wd, DATA, "bActionActuator", 1, act->data);
@@ -1213,7 +1219,7 @@ static void write_constraints(WriteData *wd, ListBase *conlist)
                                                writestruct(wd, DATA, "bConstraintTarget", 1, ct);
                                        
                                        /* Write ID Properties -- and copy this comment EXACTLY for easy finding
-                                        of library blocks that implement this.*/
+                                        of library blocks that implement this.*/
                                        IDP_WriteProperty(data->prop, wd);
                                }
                                        break;
@@ -1245,7 +1251,7 @@ static void write_pose(WriteData *wd, bPose *pose)
        /* Write channels */
        for (chan=pose->chanbase.first; chan; chan=chan->next) {
                /* Write ID Properties -- and copy this comment EXACTLY for easy finding
-                of library blocks that implement this.*/
+                of library blocks that implement this.*/
                if (chan->prop)
                        IDP_WriteProperty(chan->prop, wd);
                
@@ -1311,10 +1317,8 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
                else if (md->type==eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData*) md;
                        
-                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
-                       {
-                               if (smd->domain)
-                               {
+                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
+                               if (smd->domain) {
                                        write_pointcaches(wd, &(smd->domain->ptcaches[0]));
 
                                        /* create fake pointcache so that old blender versions can read it */
@@ -1348,8 +1352,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
                else if (md->type==eModifierType_DynamicPaint) {
                        DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
                        
-                       if (pmd->canvas)
-                       {
+                       if (pmd->canvas) {
                                DynamicPaintSurface *surface;
                                writestruct(wd, DATA, "DynamicPaintCanvasSettings", 1, pmd->canvas);
                                
@@ -1363,8 +1366,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
                                        writestruct(wd, DATA, "EffectorWeights", 1, surface->effector_weights);
                                }
                        }
-                       if (pmd->brush)
-                       {
+                       if (pmd->brush) {
                                writestruct(wd, DATA, "DynamicPaintBrushSettings", 1, pmd->brush);
                                writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp);
                                writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp);
@@ -1418,8 +1420,8 @@ static void write_objects(WriteData *wd, ListBase *idbase)
                        /* write LibData */
                        writestruct(wd, ID_OB, "Object", 1, ob);
                        
-                       /*Write ID Properties -- and copy this comment EXACTLY for easy finding
-                         of library blocks that implement this.*/
+                       /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+                        * of library blocks that implement this.*/
                        if (ob->id.properties) IDP_WriteProperty(ob->id.properties, wd);
                        
                        if (ob->adt) write_animdata(wd, ob->adt);
@@ -1679,8 +1681,8 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
                        CustomData_file_write_info(layer->type, &structname, &structnum);
                        if (structnum) {
                                /* when using partial visibility, the MEdge and MFace layers
-                                  are smaller than the original, so their type and count is
-                                  passed to make this work */
+                                * are smaller than the original, so their type and count is
+                                * passed to make this work */
                                if (layer->type != partial_type) datasize= structnum*count;
                                else datasize= structnum*partial_count;
 
@@ -1801,10 +1803,10 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
                                write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, -1, 0);
                                write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, -1, 0);
                                /* harmless for older blender versioins but _not_ writing these keeps file size down */
-                               /*
+#if 0
                                write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, -1, 0);
                                write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, -1, 0);
-                               */
+#endif
 
                                /* restore */
                                mesh->mpoly = backup_mesh.mpoly;
@@ -1962,10 +1964,10 @@ static void write_materials(WriteData *wd, ListBase *idbase)
                        /* write LibData */
                        writestruct(wd, ID_MA, "Material", 1, ma);
                        
-                       /*Write ID Properties -- and copy this comment EXACTLY for easy finding
-                         of library blocks that implement this.*/
-                       /*manually set head group property to IDP_GROUP, just in case it hadn't been
-                         set yet :) */
+                       /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+                        * of library blocks that implement this.*/
+                       /* manually set head group property to IDP_GROUP, just in case it hadn't been
+                        * set yet :) */
                        if (ma->id.properties) IDP_WriteProperty(ma->id.properties, wd);
                        
                        if (ma->adt) write_animdata(wd, ma->adt);
@@ -2109,19 +2111,19 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
                        
                        /* reset write flags too */
                        
-                       SEQ_BEGIN(ed, seq) {
+                       SEQ_BEGIN (ed, seq) {
                                if (seq->strip) seq->strip->done= 0;
                                writestruct(wd, DATA, "Sequence", 1, seq);
                        }
                        SEQ_END
                        
-                       SEQ_BEGIN(ed, seq) {
+                       SEQ_BEGIN (ed, seq) {
                                if (seq->strip && seq->strip->done==0) {
                                        /* write strip with 'done' at 0 because readfile */
                                        
                                        if (seq->plugin) writestruct(wd, DATA, "PluginSeq", 1, seq->plugin);
                                        if (seq->effectdata) {
-                                               switch(seq->type) {
+                                               switch (seq->type) {
                                                case SEQ_COLOR:
                                                        writestruct(wd, DATA, "SolidColorVars", 1, seq->effectdata);
                                                        break;
@@ -2265,7 +2267,7 @@ static void write_region(WriteData *wd, ARegion *ar, int spacetype)
        writestruct(wd, DATA, "ARegion", 1, ar);
        
        if (ar->regiondata) {
-               switch(spacetype) {
+               switch (spacetype) {
                        case SPACE_VIEW3D:
                                if (ar->regiontype==RGN_TYPE_WINDOW) {
                                        RegionView3D *rv3d= ar->regiondata;
@@ -2481,7 +2483,7 @@ static void write_bone(WriteData *wd, Bone* bone)
        writestruct(wd, DATA, "Bone", 1, bone);
 
        /* Write ID Properties -- and copy this comment EXACTLY for easy finding
-        of library blocks that implement this.*/
+        of library blocks that implement this.*/
        if (bone->prop)
                IDP_WriteProperty(bone->prop, wd);