style cleanup
[blender.git] / source / blender / blenkernel / intern / pointcache.c
index 2812592c69a33d0c71f76b501ed3dd03fa22e5c2..9c3c1b0e508ce0a00136e798a9e4009b0db2b9b5 100644 (file)
@@ -69,7 +69,6 @@
 #include "BKE_scene.h"
 #include "BKE_smoke.h"
 #include "BKE_softbody.h"
-#include "BKE_utildefines.h"
 
 #include "BIK_api.h"
 
 #  include "BLI_winstuff.h"
 #endif
 
-#define PTCACHE_DATA_FROM(data, type, from)            if (data[type]) { memcpy(data[type], from, ptcache_data_size[type]); }
-#define PTCACHE_DATA_TO(data, type, index, to) if (data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); }
+#define PTCACHE_DATA_FROM(data, type, from)  \
+       if (data[type]) { \
+               memcpy(data[type], from, ptcache_data_size[type]); \
+       } (void)0
+
+#define PTCACHE_DATA_TO(data, type, index, to)  \
+       if (data[type]) { \
+               memcpy(to, (char *)(data)[type] + ((index) ? (index) * ptcache_data_size[type] : 0), ptcache_data_size[type]); \
+       } (void)0
 
 /* could be made into a pointcache option */
 #define DURIAN_POINTCACHE_LIB_OK 1
@@ -222,7 +228,7 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo
        
        /* no rotation info, so make something nice up */
        if (data[BPHYS_DATA_ROTATION]==NULL) {
-               vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ);
+               vec_to_quat(key->rot, key->vel, OB_NEGX, OB_POSZ);
        }
        else {
                PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot);
@@ -243,9 +249,9 @@ static int  ptcache_particle_write(int index, void *psys_v, void **data, int cfr
        if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step))
                return 0;
 
-       times[0]= pa->time;
-       times[1]= pa->dietime;
-       times[2]= pa->lifetime;
+       times[0] = pa->time;
+       times[1] = pa->dietime;
+       times[2] = pa->lifetime;
 
        PTCACHE_DATA_FROM(data, BPHYS_DATA_INDEX, &index);
        PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, pa->state.co);
@@ -319,8 +325,7 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
 
        /* default to no rotation */
        if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
-               pa->state.rot[0]=1.0f;
-               pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0;
+               unit_qt(pa->state.rot);
        }
 }
 static void ptcache_particle_interpolate(int index, void *psys_v, void **data, float cfra, float cfra1, float cfra2, float *old_data)
@@ -366,7 +371,7 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f
 
        /* determine rotation from velocity */
        if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
-               vec_to_quat( keys[2].rot,keys[2].vel, OB_NEGX, OB_POSZ);
+               vec_to_quat(keys[2].rot, keys[2].vel, OB_NEGX, OB_POSZ);
        }
 
        if (cfra > pa->time)
@@ -400,7 +405,7 @@ static int  ptcache_particle_totwrite(void *psys_v, int cfra)
        if (cfra == 0)
                return psys->totpart;
 
-       for (p=0; p<psys->totpart; p++,pa++)
+       for (p=0; p<psys->totpart; p++, pa++)
                totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step);
 
        return totwrite;
@@ -433,7 +438,7 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS
        PTCacheExtra *extra = pm->extradata.first;
 
        for (; extra; extra=extra->next) {
-               switch(extra->type) {
+               switch (extra->type) {
                        case BPHYS_EXTRA_FLUID_SPRINGS:
                        {
                                if (psys->fluid_springs)
@@ -527,20 +532,31 @@ static int  ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
        SmokeDomainSettings *sds = smd->domain;
        
        if (sds->fluid) {
-               return sds->res[0]*sds->res[1]*sds->res[2];
+               return sds->base_res[0]*sds->base_res[1]*sds->base_res[2];
        }
        else
                return 0;
 }
+
+#define SMOKE_CACHE_VERSION "1.04"
+
 static int  ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
 {      
        SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
        SmokeDomainSettings *sds = smd->domain;
        int ret = 0;
+       int fluid_fields = smoke_get_data_flags(sds);
+
+       /* version header */
+       ptcache_file_write(pf, SMOKE_CACHE_VERSION, 4, sizeof(char));
+       ptcache_file_write(pf, &fluid_fields, 1, sizeof(int));
+       ptcache_file_write(pf, &sds->active_fields, 1, sizeof(int));
+       ptcache_file_write(pf, &sds->res, 3, sizeof(int));
+       ptcache_file_write(pf, &sds->dx, 1, sizeof(float));
        
        if (sds->fluid) {
                size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-               float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
+               float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
                unsigned char *obstacles;
                unsigned int in_len = sizeof(float)*(unsigned int)res;
                unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
@@ -548,22 +564,40 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
                int mode=1;             // light
                if (sds->cache_comp == SM_CACHE_HEAVY) mode=2;  // heavy
 
-               smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
+               smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
 
                ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode);
                ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode);
-               ptcache_file_compressed_write(pf, (unsigned char *)densold, in_len, out, mode); 
-               ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode);
-               ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode);
+               if (fluid_fields & SM_ACTIVE_HEAT) {
+                       ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode);
+               }
+               if (fluid_fields & SM_ACTIVE_FIRE) {
+                       ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)react, in_len, out, mode);
+               }
+               if (fluid_fields & SM_ACTIVE_COLORS) {
+                       ptcache_file_compressed_write(pf, (unsigned char *)r, in_len, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)g, in_len, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)b, in_len, out, mode);
+               }
                ptcache_file_compressed_write(pf, (unsigned char *)vx, in_len, out, mode);
                ptcache_file_compressed_write(pf, (unsigned char *)vy, in_len, out, mode);
                ptcache_file_compressed_write(pf, (unsigned char *)vz, in_len, out, mode);
-               ptcache_file_compressed_write(pf, (unsigned char *)vxold, in_len, out, mode);
-               ptcache_file_compressed_write(pf, (unsigned char *)vyold, in_len, out, mode);
-               ptcache_file_compressed_write(pf, (unsigned char *)vzold, in_len, out, mode);
                ptcache_file_compressed_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode);
                ptcache_file_write(pf, &dt, 1, sizeof(float));
                ptcache_file_write(pf, &dx, 1, sizeof(float));
+               ptcache_file_write(pf, &sds->p0, 3, sizeof(float));
+               ptcache_file_write(pf, &sds->p1, 3, sizeof(float));
+               ptcache_file_write(pf, &sds->dp0, 3, sizeof(float));
+               ptcache_file_write(pf, &sds->shift, 3, sizeof(int));
+               ptcache_file_write(pf, &sds->obj_shift_f, 3, sizeof(float));
+               ptcache_file_write(pf, &sds->obmat, 16, sizeof(float));
+               ptcache_file_write(pf, &sds->base_res, 3, sizeof(int));
+               ptcache_file_write(pf, &sds->res_min, 3, sizeof(int));
+               ptcache_file_write(pf, &sds->res_max, 3, sizeof(int));
+               ptcache_file_write(pf, &sds->active_color, 3, sizeof(float));
 
                MEM_freeN(out);
                
@@ -574,7 +608,7 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
                int res_big_array[3];
                int res_big;
                int res = sds->res[0]*sds->res[1]*sds->res[2];
-               float *dens, *densold, *tcu, *tcv, *tcw;
+               float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
                unsigned int in_len = sizeof(float)*(unsigned int)res;
                unsigned int in_len_big;
                unsigned char *out;
@@ -588,11 +622,20 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
 
                in_len_big = sizeof(float) * (unsigned int)res_big;
 
-               smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
+               smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
 
                out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer");
                ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len_big, out, mode);
-               ptcache_file_compressed_write(pf, (unsigned char *)densold, in_len_big, out, mode);     
+               if (fluid_fields & SM_ACTIVE_FIRE) {
+                       ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len_big, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len_big, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)react, in_len_big, out, mode);
+               }
+               if (fluid_fields & SM_ACTIVE_COLORS) {
+                       ptcache_file_compressed_write(pf, (unsigned char *)r, in_len_big, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)g, in_len_big, out, mode);
+                       ptcache_file_compressed_write(pf, (unsigned char *)b, in_len_big, out, mode);
+               }
                MEM_freeN(out);
 
                out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
@@ -610,34 +653,95 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 {
        SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
        SmokeDomainSettings *sds = smd->domain;
+       char version[4];
+       int ch_res[3];
+       float ch_dx;
+       int fluid_fields = smoke_get_data_flags(sds);
+       int cache_fields = 0;
+       int active_fields = 0;
+       int reallocate = 0;
+
+       /* version header */
+       ptcache_file_read(pf, version, 4, sizeof(char));
+       if (strncmp(version, SMOKE_CACHE_VERSION, 4)) return 0;
+       /* fluid info */
+       ptcache_file_read(pf, &cache_fields, 1, sizeof(int));
+       ptcache_file_read(pf, &active_fields, 1, sizeof(int));
+       ptcache_file_read(pf, &ch_res, 3, sizeof(int));
+       ptcache_file_read(pf, &ch_dx, 1, sizeof(float));
+
+       /* check if resolution has changed */
+       if (sds->res[0] != ch_res[0] ||
+               sds->res[1] != ch_res[1] ||
+               sds->res[2] != ch_res[2]) {
+               if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)
+                       reallocate = 1;
+               else
+                       return 0;
+       }
+       /* check if active fields have changed */
+       if (fluid_fields != cache_fields ||
+               active_fields != sds->active_fields)
+               reallocate = 1;
+
+       /* reallocate fluid if needed*/
+       if (reallocate) {
+               sds->active_fields = active_fields | cache_fields;
+               smoke_reallocate_fluid(sds, ch_dx, ch_res, 1);
+               sds->dx = ch_dx;
+               VECCOPY(sds->res, ch_res);
+               sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2];
+               if (sds->flags & MOD_SMOKE_HIGHRES) {
+                       smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1);
+               }
+       }
        
        if (sds->fluid) {
                size_t res = sds->res[0]*sds->res[1]*sds->res[2];
-               float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
+               float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
                unsigned char *obstacles;
                unsigned int out_len = (unsigned int)res * sizeof(float);
                
-               smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
+               smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
 
                ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)densold, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)vx, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)vy, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)vz, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)vxold, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)vyold, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)vzold, out_len);
-               ptcache_file_compressed_read(pf, (unsigned char*)obstacles, (unsigned int)res);
+               ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len);
+               if (cache_fields & SM_ACTIVE_HEAT) {
+                       ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len);
+               }
+               if (cache_fields & SM_ACTIVE_FIRE) {
+                       ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)react, out_len);
+               }
+               if (cache_fields & SM_ACTIVE_COLORS) {
+                       ptcache_file_compressed_read(pf, (unsigned char *)r, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)g, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)b, out_len);
+               }
+               ptcache_file_compressed_read(pf, (unsigned char *)vx, out_len);
+               ptcache_file_compressed_read(pf, (unsigned char *)vy, out_len);
+               ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len);
+               ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res);
                ptcache_file_read(pf, &dt, 1, sizeof(float));
                ptcache_file_read(pf, &dx, 1, sizeof(float));
-
-               if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
+               ptcache_file_read(pf, &sds->p0, 3, sizeof(float));
+               ptcache_file_read(pf, &sds->p1, 3, sizeof(float));
+               ptcache_file_read(pf, &sds->dp0, 3, sizeof(float));
+               ptcache_file_read(pf, &sds->shift, 3, sizeof(int));
+               ptcache_file_read(pf, &sds->obj_shift_f, 3, sizeof(float));
+               ptcache_file_read(pf, &sds->obmat, 16, sizeof(float));
+               ptcache_file_read(pf, &sds->base_res, 3, sizeof(int));
+               ptcache_file_read(pf, &sds->res_min, 3, sizeof(int));
+               ptcache_file_read(pf, &sds->res_max, 3, sizeof(int));
+               ptcache_file_read(pf, &sds->active_color, 3, sizeof(float));
+       }
+
+       if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
                        int res = sds->res[0]*sds->res[1]*sds->res[2];
                        int res_big, res_big_array[3];
-                       float *dens, *densold, *tcu, *tcv, *tcw;
+                       float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
                        unsigned int out_len = sizeof(float)*(unsigned int)res;
                        unsigned int out_len_big;
 
@@ -645,16 +749,24 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
                        res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
                        out_len_big = sizeof(float) * (unsigned int)res_big;
 
-                       smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
+                       smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
 
-                       ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len_big);
-                       ptcache_file_compressed_read(pf, (unsigned char*)densold, out_len_big);
+                       ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big);
+                       if (cache_fields & SM_ACTIVE_FIRE) {
+                               ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len_big);
+                               ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len_big);
+                               ptcache_file_compressed_read(pf, (unsigned char *)react, out_len_big);
+                       }
+                       if (cache_fields & SM_ACTIVE_COLORS) {
+                               ptcache_file_compressed_read(pf, (unsigned char *)r, out_len_big);
+                               ptcache_file_compressed_read(pf, (unsigned char *)g, out_len_big);
+                               ptcache_file_compressed_read(pf, (unsigned char *)b, out_len_big);
+                       }
 
-                       ptcache_file_compressed_read(pf, (unsigned char*)tcu, out_len);
-                       ptcache_file_compressed_read(pf, (unsigned char*)tcv, out_len);
-                       ptcache_file_compressed_read(pf, (unsigned char*)tcw, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)tcu, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)tcv, out_len);
+                       ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len);
                }
-       }
 
        return 1;
 }
@@ -690,14 +802,20 @@ static int  ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
                /* cache type */
                ptcache_file_write(pf, &surface->type, 1, sizeof(int));
 
-               if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
-                       in_len = sizeof(PaintPoint)*total_points;
+               if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
+                       in_len = sizeof(PaintPoint) * total_points;
+               }
                else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
-                                surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
-                       in_len = sizeof(float)*total_points;
-               else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
-                       in_len = sizeof(PaintWavePoint)*total_points;
-               else return 0;
+                        surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+               {
+                       in_len = sizeof(float) * total_points;
+               }
+               else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
+                       in_len = sizeof(PaintWavePoint) * total_points;
+               }
+               else {
+                       return 0;
+               }
 
                out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
 
@@ -714,7 +832,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
        
        /* version header */
        ptcache_file_read(pf, version, 1, sizeof(char)*4);
-       if (strncmp(version, DPAINT_CACHE_VERSION,4)) {printf("Dynamic Paint: Invalid cache version: %s!\n",version); return 0;}
+       if (strncmp(version, DPAINT_CACHE_VERSION, 4)) {printf("Dynamic Paint: Invalid cache version: %s!\n", version); return 0;}
 
        if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
                unsigned int data_len;
@@ -727,16 +845,22 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
                        return 0;
 
                /* read surface data */
-               if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
+               if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
                        data_len = sizeof(PaintPoint);
+               }
                else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
-                                surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+                        surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+               {
                        data_len = sizeof(float);
-               else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
+               }
+               else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
                        data_len = sizeof(PaintWavePoint);
-               else return 0;
+               }
+               else {
+                       return 0;
+               }
 
-               ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points);
+               ptcache_file_compressed_read(pf, (unsigned char *)surface->data->type_data, data_len*surface->data->total_points);
 
        }
        return 1;
@@ -823,7 +947,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
 
                if (psys->part->rotmode != PART_ROT_VEL  ||
                    psys->part->avemode == PART_AVE_RAND ||
-                   psys->part->avefac  != 0.0f)
+                   psys->part->avefac != 0.0f)
                {
                        pid->data_types |= (1 << BPHYS_DATA_AVELOCITY);
                }
@@ -989,8 +1113,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
                }
                else if (md->type == eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData *)md;
-                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
-                       {
+                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
                                pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
                                BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
                                BLI_addtail(lb, pid);
@@ -998,8 +1121,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
                }
                else if (md->type == eModifierType_DynamicPaint) {
                        DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
-                       if (pmd->canvas)
-                       {
+                       if (pmd->canvas) {
                                DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
 
                                for (; surface; surface=surface->next) {
@@ -1014,7 +1136,8 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
        if (scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) {
                ListBase *lb_dupli_ob;
 
-               if ((lb_dupli_ob=object_duplilist(scene, ob))) {
+               /* don't update the dupli groups, we only wan't their pid's */
+               if ((lb_dupli_ob = object_duplilist_ex(scene, ob, FALSE, FALSE))) {
                        DupliObject *dob;
                        for (dob= lb_dupli_ob->first; dob; dob= dob->next) {
                                if (dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */
@@ -1051,8 +1174,9 @@ static int ptcache_path(PTCacheID *pid, char *filename)
        if (pid->cache->flag & PTCACHE_EXTERNAL) {
                strcpy(filename, pid->cache->path);
 
-               if (strncmp(filename, "//", 2)==0)
+               if (BLI_path_is_rel(filename)) {
                        BLI_path_abs(filename, blendfilename);
+               }
 
                return BLI_add_slash(filename); /* new strlen() */
        }
@@ -1112,7 +1236,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
        if (do_ext) {
 
                if (pid->cache->index < 0)
-                       pid->cache->index =  pid->stack_index = object_insert_ptcache(pid->ob);
+                       pid->cache->index =  pid->stack_index = BKE_object_insert_ptcache(pid->ob);
 
                if (pid->cache->flag & PTCACHE_EXTERNAL) {
                        if (pid->cache->index >= 0)
@@ -1205,8 +1329,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
                                r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
 #endif
 #ifdef WITH_LZMA
-                       if (compressed == 2)
-                       {
+                       if (compressed == 2) {
                                size_t sizeOfIt;
                                size_t leni = in_len, leno = len;
                                ptcache_file_read(pf, &size, 1, sizeof(unsigned int));
@@ -1241,7 +1364,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
        if (mode == 1) {
                LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
                
-               r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);  
+               r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
                if (!(r == LZO_E_OK) || (out_len >= in_len))
                        compressed = 0;
                else
@@ -1251,7 +1374,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
 #ifdef WITH_LZMA
        if (mode == 2) {
                
-               r = LzmaCompress(out, &out_len, in, in_len,//assume sizeof(char)==1....
+               r = LzmaCompress(out, &out_len, in, in_len, //assume sizeof(char)==1....
                                                props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2);
 
                if (!(r == SZ_OK) || (out_len >= in_len))
@@ -1270,8 +1393,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
        else
                ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
 
-       if (compressed == 2)
-       {
+       if (compressed == 2) {
                unsigned int size = sizeOfIt;
                ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
                ptcache_file_write(pf, props, size, sizeof(unsigned char));
@@ -1418,7 +1540,7 @@ void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm)
 
        for (i=0; i<BPHYS_TOT_DATA; i++) {
                if (pm->cur[i])
-                       pm->cur[i] = (char*)pm->cur[i] + ptcache_data_size[i];
+                       pm->cur[i] = (char *)pm->cur[i] + ptcache_data_size[i];
        }
 }
 int  BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
@@ -1436,7 +1558,7 @@ int  BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
        }
 
        for (i=0; i<BPHYS_TOT_DATA; i++)
-               pm->cur[i] = data_types & (1<<i) ? (char*)pm->data[i] + index * ptcache_data_size[i] : NULL;
+               pm->cur[i] = data_types & (1<<i) ? (char *)pm->data[i] + index * ptcache_data_size[i] : NULL;
 
        return 1;
 }
@@ -1578,7 +1700,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
                        for (i=0; i<BPHYS_TOT_DATA; i++) {
                                unsigned int out_len = pm->totpoint*ptcache_data_size[i];
                                if (pf->data_types & (1<<i))
-                                       ptcache_file_compressed_read(pf, (unsigned char*)(pm->data[i]), out_len);
+                                       ptcache_file_compressed_read(pf, (unsigned char *)(pm->data[i]), out_len);
                        }
                }
                else {
@@ -1609,7 +1731,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
                        extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Pointcache extradata->data");
 
                        if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS)
-                               ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]);
+                               ptcache_file_compressed_read(pf, (unsigned char *)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]);
                        else
                                ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]);
 
@@ -1666,7 +1788,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
                                if (pm->data[i]) {
                                        unsigned int in_len = pm->totpoint*ptcache_data_size[i];
                                        unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
-                                       ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression);
+                                       ptcache_file_compressed_write(pf, (unsigned char *)(pm->data[i]), in_len, out, pid->cache->compression);
                                        MEM_freeN(out);
                                }
                        }
@@ -1699,7 +1821,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
                        if (pid->cache->compression) {
                                unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type];
                                unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
-                               ptcache_file_compressed_write(pf, (unsigned char*)(extra->data), in_len, out, pid->cache->compression);
+                               ptcache_file_compressed_write(pf, (unsigned char *)(extra->data), in_len, out, pid->cache->compression);
                                MEM_freeN(out);
                        }
                        else {
@@ -1910,18 +2032,16 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra)
                pid->cache->simframe = cfra2;
        }
 
-       if ((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) {
-               cfrai = (int)cfra;
-               /* clear invalid cache frames so that better stuff can be simulated */
-               if (pid->cache->flag & PTCACHE_OUTDATED) {
-                       BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
-               }
-               else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
-                       if (cfra <= pid->cache->last_exact)
-                               pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
+       cfrai = (int)cfra;
+       /* clear invalid cache frames so that better stuff can be simulated */
+       if (pid->cache->flag & PTCACHE_OUTDATED) {
+               BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
+       }
+       else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
+               if (cfra <= pid->cache->last_exact)
+                       pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
 
-                       BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
-               }
+               BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
        }
 
        return ret;
@@ -2152,7 +2272,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
        /* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */
        switch (mode) {
        case PTCACHE_CLEAR_ALL:
-       case PTCACHE_CLEAR_BEFORE:      
+       case PTCACHE_CLEAR_BEFORE:
        case PTCACHE_CLEAR_AFTER:
                if (pid->cache->flag & PTCACHE_DISK_CACHE) {
                        ptcache_path(pid, path);
@@ -2182,8 +2302,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
                                                                BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
                                                                frame = atoi(num);
                                                                
-                                                               if ((mode==PTCACHE_CLEAR_BEFORE && frame < cfra)        || 
-                                                               (mode==PTCACHE_CLEAR_AFTER && frame > cfra)     ) {
+                                                               if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) ||
+                                                                   (mode == PTCACHE_CLEAR_AFTER && frame > cfra))
+                                                               {
                                                                        
                                                                        BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
                                                                        BLI_delete(path_full, 0, 0);
@@ -2218,8 +2339,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
                        }
                        else {
                                while (pm) {
-                                       if ((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra)    || 
-                                       (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) {
+                                       if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
+                                           (mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra))
+                                       {
                                                link = pm;
                                                if (pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end)
                                                        pid->cache->cached_frames[pm->frame-sta] = 0;
@@ -2254,7 +2376,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
                                }
                        }
                }
-               if (pid->cache->cached_frames && cfra>=sta && cfra<=end)
+               if (pid->cache->cached_frames && cfra >= sta && cfra <= end)
                        pid->cache->cached_frames[cfra-sta] = 0;
                break;
        }
@@ -2303,7 +2425,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
         * - simulation time is scaled by result of bsystem_time
         * - for offsetting time only time offset is taken into account, since
         *   that's always the same and can't be animated. a timeoffset which
-        *   varies over time is not simpe to support.
+        *   varies over time is not simple to support.
         * - field and motion blur offsets are currently ignored, proper solution
         *   is probably to interpolate results from two frames for that ..
         */
@@ -2312,8 +2434,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
        cache= pid->cache;
 
        if (timescale) {
-               time= BKE_curframe(scene);
-               nexttime = BKE_frame_to_ctime(scene, CFRA + 1.0f);
+               time= BKE_scene_frame_get(scene);
+               nexttime = BKE_scene_frame_get_from_ctime(scene, CFRA + 1.0f);
                
                *timescale= MAX2(nexttime - time, 0.0f);
        }
@@ -2341,7 +2463,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
                if (MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) {
                        MEM_freeN(cache->cached_frames);
                        cache->cached_frames = NULL;
-               }       
+               }
        }
 
        if (cache->cached_frames==NULL && cache->endframe > cache->startframe) {
@@ -2414,8 +2536,6 @@ int  BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
 
        if (mode == PTCACHE_RESET_DEPSGRAPH) {
                if (!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
-                       if (cache->flag & PTCACHE_QUICK_CACHE)
-                               clear= 1;
 
                        after= 1;
                }
@@ -2449,10 +2569,12 @@ int  BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
                        sbFreeSimulation(pid->calldata);
                else if (pid->type == PTCACHE_TYPE_PARTICLES)
                        psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH);
+#if 0
                else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
                        smokeModifier_reset(pid->calldata);
                else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
                        smokeModifier_reset_turbulence(pid->calldata);
+#endif
                else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
                        dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
        }
@@ -2479,7 +2601,7 @@ int  BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
        }
 
        for (psys=ob->particlesystem.first; psys; psys=psys->next) {
-               /* children or just redo can be calculated without reseting anything */
+               /* children or just redo can be calculated without resetting anything */
                if (psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
                        skip = 1;
                /* Baked cloth hair has to be checked too, because we don't want to reset */
@@ -2505,16 +2627,14 @@ int  BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
                }
                if (md->type == eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData *)md;
-                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
-                       {
+                       if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
                                BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
                                reset |= BKE_ptcache_id_reset(scene, &pid, mode);
                        }
                }
                if (md->type == eModifierType_DynamicPaint) {
                        DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
-                       if (pmd->canvas)
-                       {
+                       if (pmd->canvas) {
                                DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
 
                                for (; surface; surface=surface->next) {
@@ -2648,36 +2768,66 @@ void BKE_ptcache_free_list(ListBase *ptcaches)
        }
 }
 
-static PointCache *ptcache_copy(PointCache *cache)
+static PointCache *ptcache_copy(PointCache *cache, int copy_data)
 {
        PointCache *ncache;
 
        ncache= MEM_dupallocN(cache);
 
-       /* hmm, should these be copied over instead? */
        ncache->mem_cache.first = NULL;
        ncache->mem_cache.last = NULL;
-       ncache->cached_frames = NULL;
-       ncache->edit = NULL;
 
-       ncache->flag= 0;
-       ncache->simframe= 0;
+       if (copy_data == FALSE) {
+               ncache->mem_cache.first = NULL;
+               ncache->mem_cache.last = NULL;
+               ncache->cached_frames = NULL;
+
+               /* flag is a mix of user settings and simulator/baking state */
+               ncache->flag= ncache->flag & (PTCACHE_DISK_CACHE|PTCACHE_EXTERNAL|PTCACHE_IGNORE_LIBPATH);
+               ncache->simframe= 0;
+       }
+       else {
+               PTCacheMem *pm;
+
+               for (pm = cache->mem_cache.first; pm; pm = pm->next) {
+                       PTCacheMem *pmn = MEM_dupallocN(pm);
+                       int i;
+
+                       for (i = 0; i < BPHYS_TOT_DATA; i++) {
+                               if (pmn->data[i])
+                                       pmn->data[i] = MEM_dupallocN(pm->data[i]);
+                       }
+
+                       BKE_ptcache_mem_pointers_init(pm);
+
+                       BLI_addtail(&ncache->mem_cache, pmn);
+               }
+
+               if (ncache->cached_frames)
+                       ncache->cached_frames = MEM_dupallocN(cache->cached_frames);
+       }
+
+       /* hmm, should these be copied over instead? */
+       ncache->edit = NULL;
 
        return ncache;
 }
+
 /* returns first point cache */
-PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old)
+PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old, int copy_data)
 {
        PointCache *cache = ptcaches_old->first;
 
        ptcaches_new->first = ptcaches_new->last = NULL;
 
        for (; cache; cache=cache->next)
-               BLI_addtail(ptcaches_new, ptcache_copy(cache));
+               BLI_addtail(ptcaches_new, ptcache_copy(cache, copy_data));
 
        return ptcaches_new->first;
 }
 
+/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on 
+ * every user action changing stuff, and then it runs a complete bake??? (ton) */
 
 /* Baking */
 void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene)
@@ -2726,7 +2876,7 @@ static void ptcache_dt_to_str(char *str, double dtime)
 
 static void *ptcache_bake_thread(void *ptr)
 {
-       int usetimer = 0, sfra, efra;
+       int use_timer = FALSE, sfra, efra;
        double stime, ptime, ctime, fetd;
        char run[32], cur[32], etd[32];
 
@@ -2737,7 +2887,7 @@ static void *ptcache_bake_thread(void *ptr)
        efra = data->endframe;
 
        for (; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) {
-               scene_update_for_newframe(data->main, data->scene, data->scene->lay);
+               BKE_scene_update_for_newframe(data->main, data->scene, data->scene->lay);
                if (G.background) {
                        printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe);
                }
@@ -2746,8 +2896,8 @@ static void *ptcache_bake_thread(void *ptr)
 
                        fetd = (ctime-ptime)*(efra-*data->cfra_ptr)/data->step;
 
-                       if (usetimer || fetd > 60.0) {
-                               usetimer = 1;
+                       if (use_timer || fetd > 60.0) {
+                               use_timer = TRUE;
 
                                ptcache_dt_to_str(cur, ctime-ptime);
                                ptcache_dt_to_str(run, ctime-stime);
@@ -2759,7 +2909,7 @@ static void *ptcache_bake_thread(void *ptr)
                }
        }
 
-       if (usetimer) {
+       if (use_timer) {
                ptcache_dt_to_str(run, PIL_check_seconds_timer()-stime);
                printf("Bake %s %s (%i frames simulated).\n", (data->break_operation ? "canceled after" : "finished in"), run, *data->cfra_ptr-sfra);
        }
@@ -2793,7 +2943,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
        thread_data.scene = baker->scene;
        thread_data.main = baker->main;
 
-       G.afbreek = 0;
+       G.is_break = FALSE;
 
        /* set caches to baking mode and figure out start frame */
        if (pid) {
@@ -2813,8 +2963,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
                                PTCacheID *pid2;
                                BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
                                for (pid2=pidlist2.first; pid2; pid2=pid2->next) {
-                                       if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) 
-                                       {
+                                       if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
                                                if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
                                                        if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
                                                                BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
@@ -2862,7 +3011,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
                                        }
 
                                        if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) &&
-                                           ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
+                                           (render || bake))
                                        {
                                                BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
                                        }
@@ -2969,7 +3118,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
        CFRA = cfrao;
        
        if (bake) /* already on cfra unless baking */
-               scene_update_for_newframe(bmain, scene, scene->lay);
+               BKE_scene_update_for_newframe(bmain, scene, scene->lay);
 
        if (thread_data.break_operation)
                WM_cursor_wait(0);
@@ -3181,8 +3330,9 @@ void BKE_ptcache_load_external(PTCacheID *pid)
                cache->endframe = end;
                cache->totpoint = 0;
 
-               if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
-                       ; /*necessary info in every file*/
+               if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
+                       /* necessary info in every file */
+               }
                /* read totpoint from info file (frame 0) */
                else if (info) {
                        pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0);
@@ -3230,7 +3380,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
        if (cache->flag & PTCACHE_EXTERNAL) {
                int cfra = cache->startframe;
 
-               for (; cfra<=cache->endframe; cfra++) {
+               for (; cfra <= cache->endframe; cfra++) {
                        if (BKE_ptcache_id_exist(pid, cfra))
                                totframes++;
                }
@@ -3246,8 +3396,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
        }
 
        if (cache->flag & PTCACHE_DISK_CACHE) {
-               if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
-               {
+               if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
                        int totpoint = pid->totpoint(pid->calldata, 0);
 
                        if (cache->totpoint > totpoint)
@@ -3258,7 +3407,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
                else {
                        int cfra = cache->startframe;
 
-                       for (; cfra<=cache->endframe; cfra++) {
+                       for (; cfra <= cache->endframe; cfra++) {
                                if (BKE_ptcache_id_exist(pid, cfra))
                                        totframes++;
                        }
@@ -3267,7 +3416,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
                }
        }
        else {
-               PTCacheMem *pm = cache->mem_cache.first;                
+               PTCacheMem *pm = cache->mem_cache.first;
                float bytes = 0.0f;
                int i, mb;
                
@@ -3288,9 +3437,9 @@ void BKE_ptcache_update_info(PTCacheID *pid)
                mb = (bytes > 1024.0f * 1024.0f);
 
                BLI_snprintf(mem_info, sizeof(mem_info), "%i frames in memory (%.1f %s)",
-                       totframes,
-                       bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
-                       mb ? "Mb" : "kb");
+                            totframes,
+                            bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
+                            mb ? "Mb" : "kb");
        }
 
        if (cache->flag & PTCACHE_OUTDATED) {