diff options
Diffstat (limited to 'source/blender/blenkernel/intern/pointcache.c')
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 224 |
1 files changed, 112 insertions, 112 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 10050e5e083..3e8e6a69dd8 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -125,7 +125,7 @@ /* could be made into a pointcache option */ #define DURIAN_POINTCACHE_LIB_OK 1 -static int ptcache_data_size[] = { +static int ptcache_data_size[] = { sizeof(unsigned int), // BPHYS_DATA_INDEX 3 * sizeof(float), // BPHYS_DATA_LOCATION 3 * sizeof(float), // BPHYS_DATA_VELOCITY @@ -155,7 +155,7 @@ static int ptcache_basic_header_read(PTCacheFile *pf) /* Custom functions should read these basic elements too! */ if (!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp)) error = 1; - + if (!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp)) error = 1; @@ -166,7 +166,7 @@ static int ptcache_basic_header_write(PTCacheFile *pf) /* Custom functions should write these basic elements too! */ if (!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp)) return 0; - + if (!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp)) return 0; @@ -244,7 +244,7 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo { PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co); PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel); - + /* 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); @@ -320,7 +320,7 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf if (data[BPHYS_DATA_SIZE]) { PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size); } - + if (data[BPHYS_DATA_TIMES]) { float times[3]; PTCACHE_DATA_TO(data, BPHYS_DATA_TIMES, 0, ×); @@ -498,7 +498,7 @@ static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUS ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; ClothVertex *vert = cloth->verts + index; - + if (old_data) { memcpy(vert->x, data, 3 * sizeof(float)); memcpy(vert->xconst, data + 3, 3 * sizeof(float)); @@ -564,7 +564,7 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; - + if (sds->fluid) { return sds->base_res[0]*sds->base_res[1]*sds->base_res[2]; } @@ -581,7 +581,7 @@ static void ptcache_smoke_error(void *smoke_v, const char *message) #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; @@ -593,7 +593,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) 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, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b; @@ -640,7 +640,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) ptcache_file_write(pf, &sds->active_color, 3, sizeof(float)); MEM_freeN(out); - + ret = 1; } @@ -683,7 +683,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, out, mode); ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, out, mode); MEM_freeN(out); - + ret = 1; } @@ -695,7 +695,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; - + if (sds->fluid) { const size_t res = sds->res[0] * sds->res[1] * sds->res[2]; const unsigned int out_len = (unsigned int)res * sizeof(float); @@ -709,7 +709,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v) sds->active_color[0] = 0.7f; sds->active_color[1] = 0.7f; sds->active_color[2] = 0.7f; - + smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles); ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); @@ -762,7 +762,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v) } } - return 1; + return 1; } static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) @@ -818,13 +818,13 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) 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, *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, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); @@ -1199,7 +1199,7 @@ static void ptcache_dynamicpaint_error(void *UNUSED(sd), const char *UNUSED(mess #define DPAINT_CACHE_VERSION "1.01" static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v) -{ +{ DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v; int cache_compress = 1; @@ -1241,7 +1241,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) { DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v; char version[4]; - + /* version header */ ptcache_file_read(pf, version, 1, sizeof(char) * 4); if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) { @@ -1286,13 +1286,13 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUS { RigidBodyWorld *rbw = rb_v; Object *ob = NULL; - + if (rbw->objects) ob = rbw->objects[index]; - + if (ob && ob->rigidbody_object) { RigidBodyOb *rbo = ob->rigidbody_object; - + if (rbo->type == RBO_TYPE_ACTIVE) { #ifdef WITH_BULLET RB_body_get_position(rbo->physics_object, rbo->pos); @@ -1309,15 +1309,15 @@ static void ptcache_rigidbody_read(int index, void *rb_v, void **data, float UNU { RigidBodyWorld *rbw = rb_v; Object *ob = NULL; - + if (rbw->objects) ob = rbw->objects[index]; - + if (ob && ob->rigidbody_object) { RigidBodyOb *rbo = ob->rigidbody_object; - + if (rbo->type == RBO_TYPE_ACTIVE) { - + if (old_data) { memcpy(rbo->pos, data, 3 * sizeof(float)); memcpy(rbo->orn, data + 3, 4 * sizeof(float)); @@ -1333,23 +1333,23 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl { RigidBodyWorld *rbw = rb_v; Object *ob = NULL; - + if (rbw->objects) ob = rbw->objects[index]; - + if (ob && ob->rigidbody_object) { RigidBodyOb *rbo = ob->rigidbody_object; - + if (rbo->type == RBO_TYPE_ACTIVE) { ParticleKey keys[4]; ParticleKey result; float dfra; - + memset(keys, 0, sizeof(keys)); - + copy_v3_v3(keys[1].co, rbo->pos); copy_qt_qt(keys[1].rot, rbo->orn); - + if (old_data) { memcpy(keys[2].co, data, 3 * sizeof(float)); memcpy(keys[2].rot, data + 3, 4 * sizeof(float)); @@ -1357,13 +1357,13 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl else { BKE_ptcache_make_particle_key(&keys[2], 0, data, cfra2); } - + dfra = cfra2 - cfra1; - + /* note: keys[0] and keys[3] unused for type < 1 (crappy) */ psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &result, true); interp_qt_qtqt(result.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra); - + copy_v3_v3(rbo->pos, result.co); copy_qt_qt(rbo->orn, result.rot); } @@ -1372,7 +1372,7 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl static int ptcache_rigidbody_totpoint(void *rb_v, int UNUSED(cfra)) { RigidBodyWorld *rbw = rb_v; - + return rbw->numbodies; } @@ -1529,7 +1529,7 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->ob= ob; pid->calldata= smd; - + pid->type= PTCACHE_TYPE_SMOKE_DOMAIN; pid->stack_index= sds->point_cache[0]->index; @@ -1613,9 +1613,9 @@ void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSu void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *rbw) { - + memset(pid, 0, sizeof(PTCacheID)); - + pid->ob= ob; pid->calldata= rbw; pid->type= PTCACHE_TYPE_RIGIDBODY; @@ -1624,29 +1624,29 @@ void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *r pid->ptcaches= &rbw->ptcaches; pid->totpoint= pid->totwrite= ptcache_rigidbody_totpoint; pid->error = ptcache_rigidbody_error; - + pid->write_point = ptcache_rigidbody_write; pid->read_point = ptcache_rigidbody_read; pid->interpolate_point = ptcache_rigidbody_interpolate; - + pid->write_stream = NULL; pid->read_stream = NULL; pid->write_openvdb_stream = NULL; pid->read_openvdb_stream = NULL; - + pid->write_extra_data = NULL; pid->read_extra_data = NULL; pid->interpolate_extra_data = NULL; - + pid->write_header = ptcache_basic_header_write; pid->read_header = ptcache_basic_header_read; - + pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_ROTATION); pid->info_types= 0; - + pid->stack_index = pid->cache->index; - + pid->default_step = 1; pid->max_step = 1; pid->file_type = PTCACHE_FILE_PTCACHE; @@ -1688,7 +1688,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup for (psys=ob->particlesystem.first; psys; psys=psys->next) { if (psys->part==NULL) continue; - + /* check to make sure point cache is actually used by the particles */ if (ELEM(psys->part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) continue; @@ -1696,7 +1696,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup /* hair needs to be included in id-list for cache edit mode to work */ /* if (psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DYNAMICS)==0) */ /* continue; */ - + if (psys->part->type == PART_FLUID) continue; @@ -1732,7 +1732,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup } } } - + if (scene && ob->rigidbody_object && scene->rigidbody_world) { pid = MEM_callocN(sizeof(PTCacheID), "PTCacheID"); BKE_ptcache_id_from_rigidbody(pid, ob, scene->rigidbody_world); @@ -1818,20 +1818,20 @@ static int ptcache_path(PTCacheID *pid, char *filename) BLI_split_file_part(blendfilename, file, sizeof(file)); i = strlen(file); - + /* remove .blend */ if (i > 6) file[i-6] = '\0'; - + BLI_snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */ BLI_path_abs(filename, blendfilename); return BLI_add_slash(filename); /* new strlen() */ } - + /* use the temp path. this is weak but better then not using point cache at all */ /* temporary directory is assumed to exist and ALWAYS has a trailing slash */ BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH, BKE_tempdir_session()); - + return BLI_add_slash(filename); /* new strlen() */ } @@ -1842,9 +1842,9 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p char *newname; filename[0] = '\0'; newname = filename; - + if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return 0; /* save blend file before using disk pointcache */ - + /* start with temp dir */ if (do_path) { len = ptcache_path(pid, filename); @@ -1860,8 +1860,8 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p } } else { - int temp = (int)strlen(pid->cache->name); - strcpy(newname, pid->cache->name); + int temp = (int)strlen(pid->cache->name); + strcpy(newname, pid->cache->name); newname+=temp; len += temp; } @@ -1883,7 +1883,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p } len += 16; } - + return len; /* make sure the above string is always 16 chars */ } @@ -1900,7 +1900,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) return NULL; #endif if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */ - + ptcache_filename(pid, filename, cfra, 1, 1); if (mode==PTCACHE_FILE_READ) { @@ -1994,7 +1994,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns out_len= LZO_OUT_LEN(in_len); 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); if (!(r == LZO_E_OK) || (out_len >= in_len)) compressed = 0; @@ -2004,7 +2004,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns #endif #ifdef WITH_LZMA if (mode == 2) { - + r = LzmaCompress(out, &out_len, in, in_len, //assume sizeof(char)==1.... props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); @@ -2014,7 +2014,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns compressed = 2; } #endif - + ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char)); if (compressed) { unsigned int size = out_len; @@ -2050,18 +2050,18 @@ static int ptcache_file_data_read(PTCacheFile *pf) if ((pf->data_types & (1<<i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i])) return 0; } - + return 1; } static int ptcache_file_data_write(PTCacheFile *pf) -{ +{ int i; for (i=0; i<BPHYS_TOT_DATA; i++) { if ((pf->data_types & (1<<i)) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i])) return 0; } - + return 1; } static int ptcache_file_header_begin_read(PTCacheFile *pf) @@ -2069,12 +2069,12 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) unsigned int typeflag=0; int error=0; char bphysics[8]; - + pf->data_types = 0; - + if (fread(bphysics, sizeof(char), 8, pf->fp) != 8) error = 1; - + if (!error && !STREQLEN(bphysics, "BPHYSICS", 8)) error = 1; @@ -2083,7 +2083,7 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK); pf->flag = (typeflag & PTCACHE_TYPEFLAG_FLAGMASK); - + /* if there was an error set file as it was */ if (error) fseek(pf->fp, 0, SEEK_SET); @@ -2094,13 +2094,13 @@ static int ptcache_file_header_begin_write(PTCacheFile *pf) { const char *bphysics = "BPHYSICS"; unsigned int typeflag = pf->type + pf->flag; - + if (fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) return 0; if (!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp)) return 0; - + return 1; } @@ -2381,14 +2381,14 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) if (error && G.debug & G_DEBUG) printf("Error reading from disk cache\n"); - + return pm; } static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) { PTCacheFile *pf = NULL; unsigned int i, error = 0; - + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame); pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); @@ -2403,10 +2403,10 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) pf->totpoint = pm->totpoint; pf->type = pid->type; pf->flag = 0; - + if (pm->extradata.first) pf->flag |= PTCACHE_TYPEFLAG_EXTRADATA; - + if (pid->cache->compression) pf->flag |= PTCACHE_TYPEFLAG_COMPRESS; @@ -2462,7 +2462,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) } ptcache_file_close(pf); - + if (error && G.debug & G_DEBUG) printf("Error writing to disk cache\n"); @@ -2511,7 +2511,7 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra) } ptcache_file_close(pf); - + return error == 0; } @@ -2556,7 +2556,7 @@ static int ptcache_read(PTCacheID *pid, int cfra) } else { pm = pid->cache->mem_cache.first; - + while (pm && pm->frame != cfra) pm = pm->next; } @@ -2581,7 +2581,7 @@ static int ptcache_read(PTCacheID *pid, int cfra) index = pm->cur[BPHYS_DATA_INDEX]; pid->read_point(*index, pid->calldata, pm->cur, (float)pm->frame, NULL); - + BKE_ptcache_mem_pointers_incr(pm); } @@ -2610,7 +2610,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2) } else { pm = pid->cache->mem_cache.first; - + while (pm && pm->frame != cfra2) pm = pm->next; } @@ -2748,7 +2748,7 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint) { PTCacheFile *pf = NULL; int error = 0; - + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, cfra); pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); @@ -2820,7 +2820,7 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra)) fra--; - + pm2 = ptcache_disk_frame_to_mem(pid, fra); } else @@ -2968,7 +2968,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) unsigned int sta, end; /* mode is same as fopen's modes */ - DIR *dir; + DIR *dir; struct dirent *de; char path[MAX_PTCACHE_PATH]; char filename[MAX_PTCACHE_FILE]; @@ -3001,11 +3001,11 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) case PTCACHE_CLEAR_AFTER: if (pid->cache->flag & PTCACHE_DISK_CACHE) { ptcache_path(pid, path); - + dir = opendir(path); if (dir==NULL) return; - + len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */ /* append underscore terminator to ensure we don't match similar names * from objects whose names start with the same prefix @@ -3014,9 +3014,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) BLI_strncpy(filename + len, "_", sizeof(filename) - 2 - len); len += 1; } - + BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext); - + while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ @@ -3033,7 +3033,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int 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) @@ -3062,7 +3062,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) } BLI_freelistN(&pid->cache->mem_cache); - if (pid->cache->cached_frames) + if (pid->cache->cached_frames) memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames)); } else { @@ -3084,7 +3084,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) } } break; - + case PTCACHE_CLEAR_FRAME: if (pid->cache->flag & PTCACHE_DISK_CACHE) { if (BKE_ptcache_id_exist(pid, cfra)) { @@ -3121,10 +3121,10 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) if (pid->cache->cached_frames && pid->cache->cached_frames[cfra-pid->cache->startframe]==0) return 0; - + if (pid->cache->flag & PTCACHE_DISK_CACHE) { char filename[MAX_PTCACHE_FILE]; - + ptcache_filename(pid, filename, cfra, 1, 1); return BLI_exists(filename); @@ -3164,7 +3164,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if (timescale) { time= BKE_scene_frame_get(scene); nexttime = BKE_scene_frame_get_from_ctime(scene, CFRA + 1.0f); - + *timescale= MAX2(nexttime - time, 0.0f); } @@ -3202,7 +3202,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if (pid->cache->flag & PTCACHE_DISK_CACHE) { /* mode is same as fopen's modes */ - DIR *dir; + DIR *dir; struct dirent *de; char path[MAX_PTCACHE_PATH]; char filename[MAX_PTCACHE_FILE]; @@ -3210,9 +3210,9 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra unsigned int len; /* store the length of the string */ ptcache_path(pid, path); - + len = ptcache_filename(pid, filename, (int)cfra, 0, 0); /* no path */ - + dir = opendir(path); if (dir==NULL) return; @@ -3220,7 +3220,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra const char *fext = ptcache_file_extension(pid); BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext); - + while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ @@ -3328,7 +3328,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) /* particles or cloth in that case -jahka */ else if (psys->clmd) { BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd); - if (mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) + if (mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) reset |= BKE_ptcache_id_reset(scene, &pid, mode); else skip = 1; @@ -3386,19 +3386,19 @@ void BKE_ptcache_remove(void) char path[MAX_PTCACHE_PATH]; char path_full[MAX_PTCACHE_PATH]; int rmdir = 1; - + ptcache_path(NULL, path); if (BLI_exists(path)) { /* The pointcache dir exists? - remove all pointcache */ - DIR *dir; + DIR *dir; struct dirent *de; dir = opendir(path); if (dir==NULL) return; - + while ((de = readdir(dir)) != NULL) { if (FILENAME_IS_CURRPAR(de->d_name)) { /* do nothing */ @@ -3417,7 +3417,7 @@ void BKE_ptcache_remove(void) else { rmdir = 0; /* path dosnt exist */ } - + if (rmdir) { BLI_delete(path, true, false); } @@ -3527,7 +3527,7 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcach return ptcaches_new->first; } -/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on +/* 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 */ @@ -3576,7 +3576,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : CFRA; int bake = baker->bake; int render = baker->render; - + G.is_break = false; /* set caches to baking mode and figure out start frame */ @@ -3768,7 +3768,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) scene->r.framelen = frameleno; CFRA = cfrao; - + if (bake) { /* already on cfra unless baking */ BKE_scene_graph_update_for_newframe(depsgraph, bmain); } @@ -3850,7 +3850,7 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) cache->flag ^= PTCACHE_DISK_CACHE; BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); cache->flag ^= PTCACHE_DISK_CACHE; - + cache->last_exact = last_exact; BKE_ptcache_id_time(pid, NULL, 0.0f, NULL, NULL, NULL); @@ -3870,7 +3870,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c char old_name[80]; int len; /* store the length of the string */ /* mode is same as fopen's modes */ - DIR *dir; + DIR *dir; struct dirent *de; char path[MAX_PTCACHE_PATH]; char old_filename[MAX_PTCACHE_FILE]; @@ -3929,7 +3929,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) int end = -1; /* mode is same as fopen's modes */ - DIR *dir; + DIR *dir; struct dirent *de; char path[MAX_PTCACHE_PATH]; char filename[MAX_PTCACHE_FILE]; @@ -3939,9 +3939,9 @@ void BKE_ptcache_load_external(PTCacheID *pid) return; ptcache_path(pid, path); - + len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */ - + dir = opendir(path); if (dir==NULL) return; @@ -3952,7 +3952,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext); else BLI_strncpy(ext, fext, sizeof(ext)); - + while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ @@ -4008,7 +4008,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) if (pf) { while (ptcache_file_read(pf, old_data, 1, elemsize)) cache->totpoint++; - + ptcache_file_close(pf); } } @@ -4086,7 +4086,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) } bytes += sizeof(PTCacheMem); - + totframes++; } |