Commenting out code from commit 22457 by Genscher for PointCache.
authorJoshua Leung <aligorith@gmail.com>
Sat, 15 Aug 2009 00:40:44 +0000 (00:40 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 15 Aug 2009 00:40:44 +0000 (00:40 +0000)
There was some missing code or something causing compiling problems.

1  2 
source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/intern/pointcache.c

  
  /* Structs */
  struct Object;
 +struct Scene;
  struct SoftBody;
  struct ParticleSystem;
 +struct ParticleKey;
  struct ClothModifierData;
++struct SmokeModifierData;
  struct PointCache;
  struct ListBase;
  
@@@ -436,143 -116,8 +436,145 @@@ void BKE_ptcache_id_from_particles(PTCa
        pid->type= PTCACHE_TYPE_PARTICLES;
        pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd);
        pid->cache= psys->pointcache;
 +      pid->cache_ptr= &psys->pointcache;
 +      pid->ptcaches= &psys->ptcaches;
 +
 +      pid->write_elem= ptcache_write_particle;
 +      pid->write_stream = NULL;
 +      pid->read_stream = NULL;
 +      pid->read_elem= ptcache_read_particle;
 +      pid->interpolate_elem= ptcache_interpolate_particle;
 +
 +      pid->totpoint= ptcache_totpoint_particle;
 +      pid->totwrite= ptcache_totwrite_particle;
 +
 +      pid->write_header= ptcache_write_basic_header;
 +      pid->read_header= ptcache_read_basic_header;
 +
 +      pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY);
 +
 +      /* TODO for later */
 +      //if((psys->part->flag & (PART_UNBORN|PART_DIED))==0)
 +      //      pid->data_types|= (1<<BPHYS_DATA_INDEX);
 +
 +      if(psys->part->phystype == PART_PHYS_BOIDS)
 +              pid->data_types|= (1<<BPHYS_DATA_AVELOCITY) | (1<<BPHYS_DATA_ROTATION) | (1<<BPHYS_DATA_BOIDS);
 +
 +      if(psys->part->rotmode || psys->part->avemode)
 +              pid->data_types|= (1<<BPHYS_DATA_AVELOCITY) | (1<<BPHYS_DATA_ROTATION);
 +
 +      if(psys->part->flag & PART_ROT_DYN)
 +              pid->data_types|= (1<<BPHYS_DATA_ROTATION);
 +
 +      pid->info_types= (1<<BPHYS_DATA_TIMES);
 +}
 +
++#if 0 // XXX smoke pointcache stuff breaks compiling now
 +/* Smoke functions */
 +static int ptcache_totpoint_smoke(void *smoke_v)
 +{
 +      SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 +      SmokeDomainSettings *sds = smd->domain;
 +      
 +      if(sds->fluid)
 +      {
 +              return sds->res[0]*sds->res[1]*sds->res[2];
 +      }
 +      else
 +              return 0;
  }
  
 +// forward decleration
 +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size);
 +
 +static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v)
 +{
 +      SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 +      SmokeDomainSettings *sds = smd->domain;
 +      
 +      if(sds->fluid)
 +      {
 +              size_t res = sds->res[0]*sds->res[1]*sds->res[2];
 +              float *dens, *densold, *heat, *heatold, *vx, *vy, *vz;
 +              
 +              smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz);
 +              
 +              ptcache_file_write(pf, dens, res, sizeof(float));
 +              ptcache_file_write(pf, densold, res, sizeof(float));
 +              ptcache_file_write(pf, heat, res, sizeof(float));
 +              ptcache_file_write(pf, heatold, res, sizeof(float));
 +              ptcache_file_write(pf, vx, res, sizeof(float));
 +              ptcache_file_write(pf, vy, res, sizeof(float));
 +              ptcache_file_write(pf, vz, res, sizeof(float));
 +              
 +              return 1;
 +      }
 +
 +      return 0;
 +}
 +
 +// forward decleration
 +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size);
 +
 +static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v)
 +{
 +      SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 +      SmokeDomainSettings *sds = smd->domain;
 +      
 +      if(sds->fluid)
 +      {
 +              size_t res = sds->res[0]*sds->res[1]*sds->res[2];
 +              float *dens, *densold, *heat, *heatold, *vx, *vy, *vz;
 +              
 +              smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz);
 +
 +              ptcache_file_read(pf, dens, res, sizeof(float));
 +              ptcache_file_read(pf, densold, res, sizeof(float));
 +              ptcache_file_read(pf, heat, res, sizeof(float));
 +              ptcache_file_read(pf, heatold, res, sizeof(float));
 +              ptcache_file_read(pf, vx, res, sizeof(float));
 +              ptcache_file_read(pf, vy, res, sizeof(float));
 +              ptcache_file_read(pf, vz, res, sizeof(float));
 +              
 +      }
 +}
 +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num)
 +{
 +      SmokeDomainSettings *sds = smd->domain;
 +
 +      memset(pid, 0, sizeof(PTCacheID));
 +
 +      pid->ob= ob;
 +      pid->calldata= smd;
 +      
 +      // if(num == 0)
 +      pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_LOW;
 +      // else if(num == 1)
 +      //      pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_HIGH;
 +
 +      pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)smd);
 +
 +      pid->cache= sds->point_cache;
 +      pid->cache_ptr= &sds->point_cache;
 +      pid->ptcaches= &sds->ptcaches;
 +
 +      
 +      pid->totpoint= pid->totwrite= ptcache_totpoint_smoke;
 +
 +      pid->write_elem= NULL;
 +      pid->read_elem= NULL;
 +      pid->read_stream = ptcache_read_smoke;
 +      pid->write_stream = ptcache_write_smoke;
 +      pid->interpolate_elem= NULL;
 +
 +      pid->write_header= ptcache_write_basic_header;
 +      pid->read_header= ptcache_read_basic_header;
 +
 +      pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy
 +      pid->info_types= 0;
 +}
++#endif // XXX smoke poitcache stuff breaks compiling
 +
  void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd)
  {
        memset(pid, 0, sizeof(PTCacheID));
@@@ -1828,512 -602,4 +1830,512 @@@ static PointCache *ptcache_copy(PointCa
  
        return ncache;
  }
 +/* returns first point cache */
 +PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old)
 +{
 +      PointCache *cache = ptcaches_old->first;
 +
 +      ptcaches_new->first = ptcaches_new->last = NULL;
 +
 +      for(; cache; cache=cache->next)
 +              BLI_addtail(ptcaches_new, ptcache_copy(cache));
 +
 +      return ptcaches_new->first;
 +}
 +
 +
 +/* Baking */
 +static int count_quick_cache(Scene *scene, int *quick_step)
 +{
 +      Base *base = scene->base.first;
 +      PTCacheID *pid;
 +      ListBase pidlist;
 +      int autocache_count= 0;
 +
 +      for(base = scene->base.first; base; base = base->next) {
 +              if(base->object) {
 +                      BKE_ptcache_ids_from_object(&pidlist, base->object);
 +
 +                      for(pid=pidlist.first; pid; pid=pid->next) {
 +                              if((pid->cache->flag & PTCACHE_BAKED)
 +                                      || (pid->cache->flag & PTCACHE_QUICK_CACHE)==0)
 +                                      continue;
 +
 +                              if(pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) {
 +                                      if(!autocache_count)
 +                                              *quick_step = pid->cache->step;
 +                                      else
 +                                              *quick_step = MIN2(*quick_step, pid->cache->step);
 +
 +                                      autocache_count++;
 +                              }
 +                      }
 +
 +                      BLI_freelistN(&pidlist);
 +              }
 +      }
 +
 +      return autocache_count;
 +}
 +void BKE_ptcache_quick_cache_all(Scene *scene)
 +{
 +      PTCacheBaker baker;
 +
 +      baker.bake=0;
 +      baker.break_data=NULL;
 +      baker.break_test=NULL;
 +      baker.pid=NULL;
 +      baker.progressbar=NULL;
 +      baker.progresscontext=NULL;
 +      baker.render=0;
 +      baker.anim_init = 0;
 +      baker.scene=scene;
 +
 +      if(count_quick_cache(scene, &baker.quick_step))
 +              BKE_ptcache_make_cache(&baker);
 +}
 +
 +/* if bake is not given run simulations to current frame */
 +void BKE_ptcache_make_cache(PTCacheBaker* baker)
 +{
 +      Scene *scene = baker->scene;
 +      Base *base;
 +      ListBase pidlist;
 +      PTCacheID *pid = baker->pid;
 +      PointCache *cache;
 +      float frameleno = scene->r.framelen;
 +      int cfrao = CFRA;
 +      int startframe = MAXFRAME;
 +      int endframe = baker->anim_init ? scene->r.sfra : CFRA;
 +      int bake = baker->bake;
 +      int render = baker->render;
 +      int step = baker->quick_step;
 +
 +      G.afbreek = 0;
 +
 +      /* set caches to baking mode and figure out start frame */
 +      if(pid) {
 +              /* cache/bake a single object */
 +              cache = pid->cache;
 +              if((cache->flag & PTCACHE_BAKED)==0) {
 +                      if(pid->type==PTCACHE_TYPE_PARTICLES)
 +                              psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
 +
 +                      if(bake || cache->flag & PTCACHE_REDO_NEEDED)
 +                              BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
 +
 +                      startframe = MAX2(cache->last_exact, cache->startframe);
 +
 +                      if(bake) {
 +                              endframe = cache->endframe;
 +                              cache->flag |= PTCACHE_BAKING;
 +                      }
 +                      else {
 +                              endframe = MIN2(endframe, cache->endframe);
 +                      }
 +
 +                      cache->flag &= ~PTCACHE_BAKED;
 +              }
 +      }
 +      else for(base=scene->base.first; base; base= base->next) {
 +              /* cache/bake everything in the scene */
 +              BKE_ptcache_ids_from_object(&pidlist, base->object);
 +
 +              for(pid=pidlist.first; pid; pid=pid->next) {
 +                      cache = pid->cache;
 +                      if((cache->flag & PTCACHE_BAKED)==0) {
 +                              if(pid->type==PTCACHE_TYPE_PARTICLES) {
 +                                      ParticleSystem *psys = (ParticleSystem*)pid->calldata;
 +                                      /* skip hair & keyed particles */
 +                                      if(psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
 +                                              continue;
 +
 +                                      psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
 +                              }
 +
 +                              if((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0)
 +                                      && ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
 +                                      BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
 +
 +                              startframe = MIN2(startframe, cache->startframe);
 +
 +                              if(bake || render) {
 +                                      cache->flag |= PTCACHE_BAKING;
 +
 +                                      if(bake)
 +                                              endframe = MAX2(endframe, cache->endframe);
 +                              }
 +
 +                              cache->flag &= ~PTCACHE_BAKED;
 +
 +                      }
 +              }
 +              BLI_freelistN(&pidlist);
 +      }
 +
 +      CFRA= startframe;
 +      scene->r.framelen = 1.0;
 +
 +      for(; CFRA <= endframe; CFRA+=step) {
 +              int prog;
 +
 +              if(bake)
 +                      prog = (int)(100.0f * (float)(CFRA - startframe)/(float)(endframe-startframe));
 +              else
 +                      prog = CFRA;
 +
 +              /* NOTE: baking should not redraw whole ui as this slows things down */
 +              if(baker->progressbar)
 +                      baker->progressbar(baker->progresscontext, prog);
 +              
 +              scene_update_for_newframe(scene, scene->lay);
 +
 +              /* NOTE: breaking baking should leave calculated frames in cache, not clear it */
 +              if(baker->break_test && baker->break_test(baker->break_data))
 +                      break;
 +      }
 +
 +      /* clear baking flag */
 +      if(pid) {
 +              cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
 +              cache->flag |= PTCACHE_SIMULATION_VALID;
 +              if(bake) {
 +                      cache->flag |= PTCACHE_BAKED;
 +                      /* write info file */
 +                      if(cache->flag & PTCACHE_DISK_CACHE)
 +                              BKE_ptcache_write_cache(pid, 0);
 +              }
 +      }
 +      else for(base=scene->base.first; base; base= base->next) {
 +              BKE_ptcache_ids_from_object(&pidlist, base->object);
 +
 +              for(pid=pidlist.first; pid; pid=pid->next) {
 +                      /* skip hair particles */
 +                      if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR)
 +                              continue;
 +              
 +                      cache = pid->cache;
 +
 +                      if(step > 1)
 +                              cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
 +                      else
 +                              cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
 +
 +                      cache->flag |= PTCACHE_SIMULATION_VALID;
 +
 +                      if(bake) {
 +                              cache->flag |= PTCACHE_BAKED;
 +                              if(cache->flag & PTCACHE_DISK_CACHE)
 +                                      BKE_ptcache_write_cache(pid, 0);
 +                      }
 +              }
 +              BLI_freelistN(&pidlist);
 +      }
 +
 +      scene->r.framelen = frameleno;
 +      CFRA = cfrao;
 +
 +      if(bake) /* already on cfra unless baking */
 +              scene_update_for_newframe(scene, scene->lay);
 +
 +      /* TODO: call redraw all windows somehow */
 +}
 +/* Helpers */
 +void BKE_ptcache_disk_to_mem(PTCacheID *pid)
 +{
 +      PointCache *cache = pid->cache;
 +      PTCacheFile *pf;
 +      PTCacheMem *pm;
 +
 +      int cfra, sfra = cache->startframe, efra = cache->endframe;
 +      int i;
 +
 +      BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
 +
 +      for(cfra=sfra; cfra <= efra; cfra++) {
 +              pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
 +
 +              if(pf) {
 +                      if(!ptcache_file_read_header_begin(pf)) {
 +                              printf("Can't yet convert old cache format\n");
 +                              cache->flag |= PTCACHE_DISK_CACHE;
 +                              ptcache_file_close(pf);
 +                              return;
 +                      }
 +
 +                      if(pf->type != pid->type || !pid->read_header(pf)) {
 +                              cache->flag |= PTCACHE_DISK_CACHE;
 +                              ptcache_file_close(pf);
 +                              return;
 +                      }
 +                      
 +                      pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
 +
 +                      pm->totpoint = pf->totpoint;
 +                      pm->data_types = pf->data_types;
 +                      pm->frame = cfra;
 +
 +                      ptcache_alloc_data(pm);
 +                      ptcache_mem_init_pointers(pm);
 +                      ptcache_file_init_pointers(pf);
 +
 +                      for(i=0; i<pm->totpoint; i++) {
 +                              if(!ptcache_file_read_data(pf)) {
 +                                      printf("Error reading from disk cache\n");
 +                                      
 +                                      cache->flag |= PTCACHE_DISK_CACHE;
 +                                      
 +                                      ptcache_free_data(pm->data);
 +                                      MEM_freeN(pm);
 +                                      ptcache_file_close(pf);
 +
 +                                      return;
 +                              }
 +                              ptcache_copy_data(pf->cur, pm->cur);
 +                              ptcache_mem_incr_pointers(pm);
 +                      }
 +
 +                      //ptcache_make_index_array(pm, pid->totpoint(pid->calldata));
 +
 +                      BLI_addtail(&pid->cache->mem_cache, pm);
 +
 +                      ptcache_file_close(pf);
 +              }
 +      }
 +
 +}
 +void BKE_ptcache_mem_to_disk(PTCacheID *pid)
 +{
 +      PointCache *cache = pid->cache;
 +      PTCacheFile *pf;
 +      PTCacheMem *pm;
 +      int i;
 +
 +      pm = cache->mem_cache.first;
 +
 +      BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
 +
 +      for(; pm; pm=pm->next) {
 +              pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
 +
 +              if(pf) {
 +                      pf->data_types = pm->data_types;
 +                      pf->totpoint = pm->totpoint;
 +                      pf->type = pid->type;
 +
 +                      ptcache_mem_init_pointers(pm);
 +                      ptcache_file_init_pointers(pf);
 +
 +                      if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) {
 +                              printf("Error writing to disk cache\n");
 +                              cache->flag &= ~PTCACHE_DISK_CACHE;
 +
 +                              ptcache_file_close(pf);
 +                              return;
 +                      }
 +
 +                      for(i=0; i<pm->totpoint; i++) {
 +                              ptcache_copy_data(pm->cur, pf->cur);
 +                              if(!ptcache_file_write_data(pf)) {
 +                                      printf("Error writing to disk cache\n");
 +                                      cache->flag &= ~PTCACHE_DISK_CACHE;
 +
 +                                      ptcache_file_close(pf);
 +                                      return;
 +                              }
 +                              ptcache_mem_incr_pointers(pm);
 +                      }
 +
 +                      ptcache_file_close(pf);
 +
 +                      /* write info file */
 +                      if(cache->flag & PTCACHE_BAKED)
 +                              BKE_ptcache_write_cache(pid, 0);
 +              }
 +              else
 +                      printf("Error creating disk cache file\n");
 +      }
 +}
 +void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
 +{
 +      PointCache *cache = pid->cache;
 +      int last_exact = cache->last_exact;
 +
 +      if (!G.relbase_valid){
 +              cache->flag &= ~PTCACHE_DISK_CACHE;
 +              printf("File must be saved before using disk cache!\n");
 +              return;
 +      }
 +
 +      if(cache->flag & PTCACHE_DISK_CACHE)
 +              BKE_ptcache_mem_to_disk(pid);
 +      else
 +              BKE_ptcache_disk_to_mem(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_update_info(pid);
 +}
 +
 +void BKE_ptcache_load_external(PTCacheID *pid)
 +{
 +      /*todo*/
 +      PointCache *cache = pid->cache;
 +      int len; /* store the length of the string */
 +      int info = 0;
 +
 +      /* mode is same as fopen's modes */
 +      DIR *dir; 
 +      struct dirent *de;
 +      char path[MAX_PTCACHE_PATH];
 +      char filename[MAX_PTCACHE_FILE];
 +      char ext[MAX_PTCACHE_PATH];
 +
 +      if(!cache)
 +              return;
 +
 +      cache->startframe = MAXFRAME;
 +      cache->endframe = -1;
 +      cache->totpoint = 0;
 +
 +      ptcache_path(pid, path);
 +      
 +      len = BKE_ptcache_id_filename(pid, filename, 1, 0, 0); /* no path */
 +      
 +      dir = opendir(path);
 +      if (dir==NULL)
 +              return;
 +
 +      if(cache->index >= 0)
 +              snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, cache->index);
 +      else
 +              strcpy(ext, PTCACHE_EXT);
 +      
 +      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 */
 +                              /* read the number of the file */
 +                              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(frame) {
 +                                              cache->startframe = MIN2(cache->startframe, frame);
 +                                              cache->endframe = MAX2(cache->endframe, frame);
 +                                      }
 +                                      else
 +                                              info = 1;
 +                              }
 +                      }
 +              }
 +      }
 +      closedir(dir);
 +
 +      if(cache->startframe != MAXFRAME) {
 +              PTCacheFile *pf;
 +
 +              /* read totpoint from info file (frame 0) */
 +              if(info) {
 +                      pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0);
 +
 +                      if(pf) {
 +                              if(ptcache_file_read_header_begin(pf)) {
 +                                      if(pf->type == pid->type && pid->read_header(pf)) {
 +                                              cache->totpoint = pf->totpoint;
 +                                              cache->flag |= PTCACHE_READ_INFO;
 +                                      }
 +                                      else {
 +                                              cache->totpoint = 0;
 +                                      }
 +                              }
 +                              ptcache_file_close(pf);
 +                      }
 +              }
 +              /* or from any old format cache file */
 +              else {
 +                      float old_data[14];
 +                      int elemsize = ptcache_pid_old_elemsize(pid);
 +                      pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe);
 +
 +                      if(pf) {
 +                              while(ptcache_file_read(pf, old_data, 1, elemsize))
 +                                      cache->totpoint++;
 +                              
 +                              ptcache_file_close(pf);
 +                      }
 +              }
 +      }
 +
 +      cache->flag &= ~(PTCACHE_OUTDATED|PTCACHE_FRAMES_SKIPPED);
 +
 +      BKE_ptcache_update_info(pid);
 +}
 +
 +void BKE_ptcache_update_info(PTCacheID *pid)
 +{
 +      PointCache *cache = pid->cache;
 +      int totframes = 0;
 +      char mem_info[64];
 +
 +      if(cache->flag & PTCACHE_EXTERNAL) {
 +              int cfra = cache->startframe;
 +
 +              for(; cfra<=cache->endframe; cfra++) {
 +                      if(BKE_ptcache_id_exist(pid, cfra))
 +                              totframes++;
 +              }
 +
 +              if(totframes && cache->totpoint)
 +                      sprintf(cache->info, "%i points found!", cache->totpoint);
 +              else
 +                      sprintf(cache->info, "No valid data to read!");
 +              return;
 +      }
 +
 +      if(cache->flag & PTCACHE_DISK_CACHE) {
 +              int cfra = cache->startframe;
 +
 +              for(; cfra<=cache->endframe; cfra++) {
 +                      if(BKE_ptcache_id_exist(pid, cfra))
 +                              totframes++;
 +              }
 +
 +              sprintf(mem_info, "%i frames on disk", totframes);
 +      }
 +      else {
 +              PTCacheMem *pm = cache->mem_cache.first;                
 +              float framesize = 0.0f, bytes = 0.0f;
 +              int mb;
 +
 +              if(pm)
 +                      framesize = (float)ptcache_pid_old_elemsize(pid) * (float)pm->totpoint;
 +              
 +              for(; pm; pm=pm->next)
 +                      totframes++;
 +
 +              bytes = totframes * framesize;
 +
 +              mb = (bytes > 1024.0f * 1024.0f);
 +
 +              sprintf(mem_info, "%i frames in memory (%.1f %s)",
 +                      totframes,
 +                      bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
 +                      mb ? "Mb" : "kb");
 +      }
  
- }
 +      if(cache->flag & PTCACHE_OUTDATED) {
 +              sprintf(cache->info, "%s, cache is outdated!", mem_info);
 +      }
 +      else if(cache->flag & PTCACHE_FRAMES_SKIPPED) {
 +              sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact);
 +      }
 +      else
 +              sprintf(cache->info, "%s.", mem_info);
++}