style cleanup
[blender.git] / source / blender / blenkernel / intern / pointcache.c
index e9115ae72e6a1a7912b4d6ed50c8c7845ac8f09c..9c3c1b0e508ce0a00136e798a9e4009b0db2b9b5 100644 (file)
@@ -249,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);
@@ -686,12 +686,12 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 
        /* reallocate fluid if needed*/
        if (reallocate) {
-               sds->active_fields = active_fields;
+               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) {
+               if (sds->flags & MOD_SMOKE_HIGHRES) {
                        smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1);
                }
        }
@@ -755,6 +755,7 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
                        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);
@@ -1363,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
@@ -1539,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)
@@ -1557,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;
 }
@@ -2031,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;
@@ -2273,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);
@@ -2377,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;
        }
@@ -2464,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) {
@@ -2537,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;
                }
@@ -2572,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);
-               /*else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+#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);*/
+                       smokeModifier_reset_turbulence(pid->calldata);
+#endif
                else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
                        dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
        }
@@ -2783,7 +2782,8 @@ static PointCache *ptcache_copy(PointCache *cache, int copy_data)
                ncache->mem_cache.last = NULL;
                ncache->cached_frames = NULL;
 
-               ncache->flag= 0;
+               /* 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 {
@@ -2826,6 +2826,8 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old
        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)
@@ -3009,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);
                                        }
@@ -3378,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++;
                }
@@ -3405,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++;
                        }
@@ -3414,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;