[Bf-blender-cvs] [9e10e19] alembic_pointcache: Removed mem_cache access in pointcache.c, i.e. assume that the PTCACHE_DISK_CACHE flag is always set.
Lukas Tönne
noreply at git.blender.org
Thu Oct 16 16:53:30 CEST 2014
Commit: 9e10e191c8ad38e1da1d35dccdd9263fdefa4571
Author: Lukas Tönne
Date: Wed Nov 27 13:32:20 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB9e10e191c8ad38e1da1d35dccdd9263fdefa4571
Removed mem_cache access in pointcache.c, i.e. assume that the
PTCACHE_DISK_CACHE flag is always set.
===================================================================
M source/blender/blenkernel/intern/pointcache.c
M source/blender/makesdna/DNA_pointcache_types.h
===================================================================
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 7ece54d..8d9b19f 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1888,54 +1888,27 @@ static int ptcache_old_elemsize(PTCacheID *pid)
static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2)
{
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- int cfra1=frame, cfra2=frame+1;
-
- while (cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
- cfra1--;
-
- if (cfra1 < pid->cache->startframe)
- cfra1 = 0;
-
- while (cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2))
- cfra2++;
-
- if (cfra2 > pid->cache->endframe)
- cfra2 = 0;
-
- if (cfra1 && !cfra2) {
- *fra1 = 0;
- *fra2 = cfra1;
- }
- else {
- *fra1 = cfra1;
- *fra2 = cfra2;
- }
+ int cfra1=frame, cfra2=frame+1;
+
+ while (cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
+ cfra1--;
+
+ if (cfra1 < pid->cache->startframe)
+ cfra1 = 0;
+
+ while (cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2))
+ cfra2++;
+
+ if (cfra2 > pid->cache->endframe)
+ cfra2 = 0;
+
+ if (cfra1 && !cfra2) {
+ *fra1 = 0;
+ *fra2 = cfra1;
}
- else if (pid->cache->mem_cache.first) {
- PTCacheMem *pm = pid->cache->mem_cache.first;
- PTCacheMem *pm2 = pid->cache->mem_cache.last;
-
- while (pm->next && pm->next->frame <= frame)
- pm= pm->next;
-
- if (pm2->frame < frame) {
- pm2 = NULL;
- }
- else {
- while (pm2->prev && pm2->prev->frame > frame) {
- pm2= pm2->prev;
- }
- }
-
- if (!pm2) {
- *fra1 = 0;
- *fra2 = pm->frame;
- }
- else {
- *fra1 = pm->frame;
- *fra2 = pm2->frame;
- }
+ else {
+ *fra1 = cfra1;
+ *fra2 = cfra2;
}
}
@@ -2157,15 +2130,7 @@ static int ptcache_read(PTCacheID *pid, int cfra)
int *index = &i;
/* get a memory cache to read from */
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- pm = ptcache_disk_frame_to_mem(pid, cfra);
- }
- else {
- pm = pid->cache->mem_cache.first;
-
- while (pm && pm->frame != cfra)
- pm = pm->next;
- }
+ pm = ptcache_disk_frame_to_mem(pid, cfra);
/* read the cache */
if (pm) {
@@ -2211,15 +2176,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
int *index = &i;
/* get a memory cache to read from */
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- pm = ptcache_disk_frame_to_mem(pid, cfra2);
- }
- else {
- pm = pid->cache->mem_cache.first;
-
- while (pm && pm->frame != cfra2)
- pm = pm->next;
- }
+ pm = ptcache_disk_frame_to_mem(pid, cfra2);
/* read the cache */
if (pm) {
@@ -2385,16 +2342,12 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
BKE_ptcache_mem_pointers_init(pm);
if (overwrite) {
- if (cache->flag & PTCACHE_DISK_CACHE) {
- int fra = cfra-1;
-
- while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
- fra--;
-
- pm2 = ptcache_disk_frame_to_mem(pid, fra);
- }
- else
- pm2 = cache->mem_cache.last;
+ int fra = cfra-1;
+
+ while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
+ fra--;
+
+ pm2 = ptcache_disk_frame_to_mem(pid, fra);
}
if (pid->write_point) {
@@ -2415,25 +2368,20 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
pm->frame = cfra;
- if (cache->flag & PTCACHE_DISK_CACHE) {
- error += !ptcache_mem_frame_to_disk(pid, pm);
-
- // if (pm) /* pm is always set */
- {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- MEM_freeN(pm);
- }
-
- if (pm2) {
- error += !ptcache_mem_frame_to_disk(pid, pm2);
- ptcache_data_free(pm2);
- ptcache_extra_free(pm2);
- MEM_freeN(pm2);
- }
+ error += !ptcache_mem_frame_to_disk(pid, pm);
+
+ // if (pm) /* pm is always set */
+ {
+ ptcache_data_free(pm);
+ ptcache_extra_free(pm);
+ MEM_freeN(pm);
}
- else {
- BLI_addtail(&cache->mem_cache, pm);
+
+ if (pm2) {
+ error += !ptcache_mem_frame_to_disk(pid, pm2);
+ ptcache_data_free(pm2);
+ ptcache_extra_free(pm2);
+ MEM_freeN(pm2);
}
return error;
@@ -2450,31 +2398,17 @@ static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite)
return 1;
}
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- if (cfra==0 && cache->startframe > 0)
- return 1;
-
- /* find last cached frame */
- while (efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra))
- efra--;
-
- /* find second last cached frame */
- ofra = efra-1;
- while (ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra))
- ofra--;
- }
- else {
- PTCacheMem *pm = cache->mem_cache.last;
- /* don't write info file in memory */
- if (cfra == 0)
- return 0;
-
- if (pm == NULL)
- return 1;
-
- efra = pm->frame;
- ofra = (pm->prev ? pm->prev->frame : efra - cache->step);
- }
+ if (cfra==0 && cache->startframe > 0)
+ return 1;
+
+ /* find last cached frame */
+ while (efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra))
+ efra--;
+
+ /* find second last cached frame */
+ ofra = efra-1;
+ while (ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra))
+ ofra--;
if (efra >= cache->startframe && cfra > efra) {
if (ofra >= cache->startframe && efra - ofra < cache->step) {
@@ -2564,107 +2498,57 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
case PTCACHE_CLEAR_ALL:
case PTCACHE_CLEAR_BEFORE:
case PTCACHE_CLEAR_AFTER:
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- ptcache_path(pid->cache, pid->ob, path);
-
- len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index);
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
- if (mode == PTCACHE_CLEAR_ALL) {
- pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
- BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
- BLI_delete(path_full, false, false);
- }
- else {
- /* read the number of the file */
- unsigned int frame, len2 = (int)strlen(de->d_name);
- char num[7];
-
- if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
- BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
- frame = atoi(num);
+ ptcache_path(pid->cache, pid->ob, path);
+
+ len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
+
+ dir = opendir(path);
+ if (dir==NULL)
+ return;
+
+ BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index);
+
+ while ((de = readdir(dir)) != NULL) {
+ if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
+ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
+ if (mode == PTCACHE_CLEAR_ALL) {
+ pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
+ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
+ BLI_delete(path_full, false, false);
+ }
+ else {
+ /* read the number of the file */
+ unsigned int frame, len2 = (int)strlen(de->d_name);
+ char num[7];
+
+ if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
+ 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, false, false);
- if (pid->cache->cached_frames && frame >=sta && frame <= end)
- pid->cache->cached_frames[frame-sta] = 0;
- }
+ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
+ BLI_delete(path_full, false, false);
+ if (pid->cache->cached_frames && frame >=sta && frame <= end)
+ pid->cache->cached_frames[frame-sta] = 0;
}
}
}
}
}
- closedir(dir);
-
- if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames)
- memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
- }
- else {
- PTCacheMem *pm= pid->cache->mem_cache.first;
- PTCacheMem *link= NULL;
-
- if (mode == PTCACHE_CLEAR_ALL) {
- /*we want startframe if the cache starts before zero*/
- pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
- for (; pm; pm=pm->next) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- }
- BLI_freelistN(&pid->cache->mem_cache);
-
- if (pid->cache->cached_frames)
- memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
- }
- else {
- while (pm) {
- 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;
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- pm = pm->next;
- BLI_freelinkN(&pid->cache->mem_cache, link);
- }
- else
- pm = pm->next;
- }
- }
}
+ closedir(dir);
+
+ if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames)
+ memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
break;
case PTCACHE_CLEAR_FRAME:
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- if (BKE_ptcache_id_exist(pid, cfra)) {
- ptcache_filename(pid, filename, cfra, 1, 1); /* no path */
- BLI_delete(filename, false, false);
- }
- }
- else {
- PTCacheMem *pm = pid->cache->mem_cache.first;
-
- for (; pm; pm=pm->next) {
- if (pm->frame == cfra) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- BLI
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list