Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/pointcache.c')
-rw-r--r--source/blender/blenkernel/intern/pointcache.c445
1 files changed, 117 insertions, 328 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 5a14277d63b..09170d92866 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -59,23 +59,28 @@
#include "BLI_blenlib.h"
-/* both in intern */
#include "smoke_API.h"
-#include "minilzo.h"
-
-#include "LzmaLib.h"
-
/* needed for directory lookup */
-/* untitled blend's need getpid for a unique name */
#ifndef WIN32
#include <dirent.h>
-#include <unistd.h>
#else
-#include <process.h>
#include "BLI_winstuff.h"
#endif
+/* untitled blend's need getpid for a unique name */
+#ifdef WIN32
+#include <process.h>
+#else
+#include <unistd.h>
+#endif
+
+#ifdef _WIN32
+#ifndef snprintf
+#define snprintf _snprintf
+#endif
+#endif
+
static void ptcache_data_to(void **data, int type, int index, void *to);
static void ptcache_data_from(void **data, int type, void *from);
@@ -171,7 +176,6 @@ static int ptcache_write_particle(int index, void *psys_v, void **data)
{
ParticleSystem *psys= psys_v;
ParticleData *pa = psys->particles + index;
- BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL;
float times[3] = {pa->time, pa->dietime, pa->lifetime};
if(data[BPHYS_DATA_INDEX]) {
@@ -189,8 +193,8 @@ static int ptcache_write_particle(int index, void *psys_v, void **data)
ptcache_data_from(data, BPHYS_DATA_SIZE, &pa->size);
ptcache_data_from(data, BPHYS_DATA_TIMES, times);
- if(boid)
- ptcache_data_from(data, BPHYS_DATA_BOIDS, &boid->data);
+ if(pa->boid)
+ ptcache_data_from(data, BPHYS_DATA_TIMES, &pa->boid);
return 1;
}
@@ -206,7 +210,6 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr
{
ParticleSystem *psys= psys_v;
ParticleData *pa = psys->particles + index;
- BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL;
if(cfra > pa->state.time)
memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey));
@@ -230,8 +233,8 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr
pa->lifetime = times[2];
}
- if(boid)
- ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &boid->data);
+ if(pa->boid)
+ ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &pa->boid);
/* determine velocity from previous location */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
@@ -383,6 +386,8 @@ static int ptcache_totpoint_cloth(void *cloth_v)
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
{
ParticleSystemModifierData *psmd;
+ ModifierData *md;
+ int a;
memset(pid, 0, sizeof(PTCacheID));
@@ -408,26 +413,32 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
if(sb->particles) {
psmd= psys_get_modifier(ob, sb->particles);
- // pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); XXX TODO - get other index DG
+ pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd);
+ }
+ else {
+ for(a=0, md=ob->modifiers.first; md; md=md->next, a++) {
+ if(md->type == eModifierType_Softbody) {
+ pid->stack_index = a;
+ break;
+ }
+ }
}
- else
- pid->stack_index = pid->cache->index;
}
void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys)
{
+ ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
+
memset(pid, 0, sizeof(PTCacheID));
pid->ob= ob;
pid->calldata= psys;
pid->type= PTCACHE_TYPE_PARTICLES;
- pid->stack_index= psys->pointcache->index;
+ pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd);
pid->cache= psys->pointcache;
pid->cache_ptr= &psys->pointcache;
pid->ptcaches= &psys->ptcaches;
- pid->flag |= PTCACHE_VEL_PER_SEC;
-
pid->write_elem= ptcache_write_particle;
pid->write_stream = NULL;
pid->read_stream = NULL;
@@ -458,254 +469,76 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
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) {
+ if(sds->fluid)
+ {
return sds->res[0]*sds->res[1]*sds->res[2];
}
else
return 0;
}
-/* Smoke functions */
-static int ptcache_totpoint_smoke_turbulence(void *smoke_v)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
-
- if(sds->wt) {
- return sds->res_wt[0]*sds->res_wt[1]*sds->res_wt[2];
- }
- else
- return 0;
-}
-
// forward decleration
static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size);
-static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode)
-{
- int r = 0;
- unsigned char compressed;
- LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
- unsigned int out_len = LZO_OUT_LEN(in_len);
- unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
- size_t sizeOfIt = 5;
-
- if(mode == 1) {
- 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
- compressed = 1;
- }
- else if(mode == 2) {
-
- r = LzmaCompress(out, (size_t *)&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))
- compressed = 0;
- else
- compressed = 2;
- }
-
- ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char));
- if(compressed) {
- ptcache_file_write(pf, &out_len, 1, sizeof(unsigned int));
- ptcache_file_write(pf, out, out_len, sizeof(unsigned char));
- }
- else
- ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
-
- if(compressed == 2)
- {
- ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
- ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char));
- }
-
- MEM_freeN(props);
-
- return r;
-}
-
static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v)
-{
+{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
- if(sds->fluid) {
+ 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;
- 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");
- int mode = res >= 1000000 ? 2 : 1;
-
- smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
-
- ptcache_compress_write(pf, (unsigned char *)sds->shadow, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)dens, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)densold, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)heat, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)heatold, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)vx, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)vy, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)vz, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)vxold, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)vyold, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)vzold, in_len, out, mode);
- ptcache_compress_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));
-
- MEM_freeN(out);
+ float *dens, *densold, *heat, *heatold, *vx, *vy, *vz;
- return 1;
- }
- return 0;
-}
-
-static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
-
- if(sds->wt) {
- unsigned int res_big_array[3];
- unsigned int res_big;
- unsigned int res = sds->res[0]*sds->res[1]*sds->res[2];
- float *dens, *densold, *tcu, *tcv, *tcw;
- unsigned int in_len = sizeof(float)*(unsigned int)res;
- unsigned int in_len_big;
- unsigned char *out;
- int mode;
-
- smoke_turbulence_get_res(sds->wt, res_big_array);
- res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
- mode = res_big >= 1000000 ? 2 : 1;
- in_len_big = sizeof(float) * (unsigned int)res_big;
-
- smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
-
- out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer");
- ptcache_compress_write(pf, (unsigned char *)dens, in_len_big, out, mode);
- ptcache_compress_write(pf, (unsigned char *)densold, in_len_big, out, mode);
- MEM_freeN(out);
-
- out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
- ptcache_compress_write(pf, (unsigned char *)tcu, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)tcv, in_len, out, mode);
- ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode);
- MEM_freeN(out);
+ 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 int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len)
-{
- int r = 0;
- unsigned char compressed = 0;
- unsigned int in_len;
- unsigned int out_len = len;
- unsigned char *in;
- unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
- size_t sizeOfIt = 5;
-
- ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
- if(compressed) {
- ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int));
- in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
- ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
-
- if(compressed == 1)
- r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
- else if(compressed == 2)
- {
- size_t leni = in_len, leno = out_len;
- ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int));
- ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char));
- r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
- }
-
- MEM_freeN(in);
- }
- else {
- ptcache_file_read(pf, result, len, sizeof(unsigned char));
- }
-
- MEM_freeN(props);
-
- return r;
-}
-
static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
- if(sds->fluid) {
+ 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;
- unsigned char *obstacles;
- unsigned int out_len = (unsigned int)res * sizeof(float);
+ 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));
- smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
-
- ptcache_compress_read(pf, (unsigned char *)sds->shadow, out_len);
- ptcache_compress_read(pf, (unsigned char*)dens, out_len);
- ptcache_compress_read(pf, (unsigned char*)densold, out_len);
- ptcache_compress_read(pf, (unsigned char*)heat, out_len);
- ptcache_compress_read(pf, (unsigned char*)heatold, out_len);
- ptcache_compress_read(pf, (unsigned char*)vx, out_len);
- ptcache_compress_read(pf, (unsigned char*)vy, out_len);
- ptcache_compress_read(pf, (unsigned char*)vz, out_len);
- ptcache_compress_read(pf, (unsigned char*)vxold, out_len);
- ptcache_compress_read(pf, (unsigned char*)vyold, out_len);
- ptcache_compress_read(pf, (unsigned char*)vzold, out_len);
- ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res);
- ptcache_file_read(pf, &dt, 1, sizeof(float));
- ptcache_file_read(pf, &dx, 1, sizeof(float));
- }
-}
-
-static void ptcache_read_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
-
- if(sds->fluid) {
- unsigned int res = sds->res[0]*sds->res[1]*sds->res[2];
- unsigned int res_big, res_big_array[3];
- float *dens, *densold, *tcu, *tcv, *tcw;
- unsigned int out_len = sizeof(float)*(unsigned int)res;
- unsigned int out_len_big;
-
- smoke_turbulence_get_res(sds->wt, res_big_array);
- 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);
-
- ptcache_compress_read(pf, (unsigned char*)dens, out_len_big);
- ptcache_compress_read(pf, (unsigned char*)densold, out_len_big);
-
- ptcache_compress_read(pf, (unsigned char*)tcu, out_len);
- ptcache_compress_read(pf, (unsigned char*)tcv, out_len);
- ptcache_compress_read(pf, (unsigned char*)tcw, out_len);
}
}
-
-void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
+void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num)
{
SmokeDomainSettings *sds = smd->domain;
@@ -714,54 +547,24 @@ 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;
+ // if(num == 0)
+ pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_LOW;
+ // else if(num == 1)
+ // pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_HIGH;
- pid->cache= sds->point_cache[0];
- pid->cache_ptr= &(sds->point_cache[0]);
- pid->ptcaches= &(sds->ptcaches[0]);
+ 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 to make pointcache happy
- pid->info_types= 0;
-}
-
-void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
-{
- SmokeDomainSettings *sds = smd->domain;
-
- memset(pid, 0, sizeof(PTCacheID));
-
- pid->ob= ob;
- pid->calldata= smd;
-
- pid->type= PTCACHE_TYPE_SMOKE_HIGHRES;
- pid->stack_index= sds->point_cache[1]->index;
-
- pid->cache= sds->point_cache[1];
- pid->cache_ptr= &sds->point_cache[1];
- pid->ptcaches= &sds->ptcaches[1];
-
- pid->totpoint= pid->totwrite= ptcache_totpoint_smoke_turbulence;
-
- pid->write_elem= NULL;
- pid->read_elem= NULL;
-
- pid->read_stream = ptcache_read_smoke_turbulence;
- pid->write_stream = ptcache_write_smoke_turbulence;
-
pid->interpolate_elem= NULL;
pid->write_header= ptcache_write_basic_header;
@@ -770,6 +573,7 @@ void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, str
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)
{
@@ -778,7 +582,7 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl
pid->ob= ob;
pid->calldata= clmd;
pid->type= PTCACHE_TYPE_CLOTH;
- pid->stack_index= clmd->point_cache->index;
+ pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd);
pid->cache= clmd->point_cache;
pid->cache_ptr= &clmd->point_cache;
pid->ptcaches= &clmd->ptcaches;
@@ -812,16 +616,14 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob)
}
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- if(psys->part) {
+ pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
+ BKE_ptcache_id_from_particles(pid, ob, psys);
+ BLI_addtail(lb, pid);
+
+ if(psys->soft) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_particles(pid, ob, psys);
+ BKE_ptcache_id_from_softbody(pid, ob, psys->soft);
BLI_addtail(lb, pid);
-
- if(psys->soft) {
- pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_softbody(pid, ob, psys->soft);
- BLI_addtail(lb, pid);
- }
}
}
@@ -831,19 +633,18 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob)
BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md);
BLI_addtail(lb, pid);
}
+ /*
+ // enabled on next commit
if(md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
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);
-
- pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_smoke_turbulence(pid, ob, (SmokeModifierData*)md);
+ BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md, 0);
BLI_addtail(lb, pid);
}
}
+ */
}
}
@@ -927,10 +728,6 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho
}
if (do_ext) {
-
- if(pid->cache->index < 0)
- pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob);
-
if(pid->cache->flag & PTCACHE_EXTERNAL) {
if(pid->cache->index >= 0)
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
@@ -1105,7 +902,7 @@ static void ptcache_file_init_pointers(PTCacheFile *pf)
pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<<BPHYS_DATA_BOIDS) ? &pf->data.boids : NULL;
}
-void BKE_ptcache_mem_init_pointers(PTCacheMem *pm)
+static void ptcache_mem_init_pointers(PTCacheMem *pm)
{
int data_types = pm->data_types;
int i;
@@ -1114,7 +911,7 @@ void BKE_ptcache_mem_init_pointers(PTCacheMem *pm)
pm->cur[i] = data_types & (1<<i) ? pm->data[i] : NULL;
}
-void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm)
+static void ptcache_mem_incr_pointers(PTCacheMem *pm)
{
int i;
@@ -1180,7 +977,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
int cfra1 = 0, cfra2 = 0;
int totpoint = 0, totpoint2 = 0;
int *index = &i, *index2 = &i;
- int use_old = 0, old_frame = 0;
+ int use_old = 0, old_frame;
int ret = 0, error = 0;
@@ -1267,12 +1064,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
return 0;
if(pm) {
- BKE_ptcache_mem_init_pointers(pm);
+ ptcache_mem_init_pointers(pm);
totpoint = pm->totpoint;
index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i;
}
if(pm2) {
- BKE_ptcache_mem_init_pointers(pm2);
+ ptcache_mem_init_pointers(pm2);
totpoint2 = pm2->totpoint;
index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i;
}
@@ -1343,18 +1140,18 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
if(use_old) {
if(pid->read_elem && ptcache_file_read(pf, (void*)old_data1, 1, old_elemsize))
pid->read_elem(i, pid->calldata, NULL, frs_sec, cfra, old_data1);
- else if(pid->read_elem)
+ else
{ error = 1; break; }
}
else {
if(pid->read_elem && (pm || ptcache_file_read_data(pf)))
pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL);
- else if(pid->read_elem)
+ else
{ error = 1; break; }
}
if(pm) {
- BKE_ptcache_mem_incr_pointers(pm);
+ ptcache_mem_incr_pointers(pm);
index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i;
}
}
@@ -1388,7 +1185,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
else
{ error = 1; break; }
}
- else if(pid->read_elem)
+ else
{ error = 1; break; }
}
else {
@@ -1400,12 +1197,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
else
{ error = 1; break; }
}
- else if(pid->read_elem)
+ else
{ error = 1; break; }
}
if(pm2) {
- BKE_ptcache_mem_incr_pointers(pm2);
+ ptcache_mem_incr_pointers(pm2);
index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i;
}
}
@@ -1577,11 +1374,11 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra)
pm->data_types = cfra ? pid->data_types : pid->info_types;
ptcache_alloc_data(pm);
- BKE_ptcache_mem_init_pointers(pm);
+ ptcache_mem_init_pointers(pm);
for(i=0; i<totpoint; i++) {
if(pid->write_elem && pid->write_elem(i, pid->calldata, pm->cur))
- BKE_ptcache_mem_incr_pointers(pm);
+ ptcache_mem_incr_pointers(pm);
}
//ptcache_make_index_array(pm, pid->totpoint(pid->calldata));
@@ -1682,8 +1479,6 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra)
PTCacheMem *pm= pid->cache->mem_cache.first;
PTCacheMem *link= NULL;
- pm= pid->cache->mem_cache.first;
-
if(mode == PTCACHE_CLEAR_ALL) {
pid->cache->last_exact = 0;
for(; pm; pm=pm->next)
@@ -1844,10 +1639,8 @@ 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)
+ else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN_LOW)
smokeModifier_reset(pid->calldata);
- else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
- smokeModifier_reset_turbulence(pid->calldata);
}
if(clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
@@ -1885,7 +1678,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
skip = 1;
- if(skip == 0 && psys->part) {
+ if(skip == 0) {
BKE_ptcache_id_from_particles(&pid, ob, psys);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
@@ -1896,17 +1689,17 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
+ /*
+ // enabled on next commit
if(md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
- BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
- reset |= BKE_ptcache_id_reset(scene, &pid, mode);
-
- BKE_ptcache_id_from_smoke_turbulence(&pid, ob, (SmokeModifierData*)md);
+ BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md, 0);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
+ */
}
return reset;
@@ -1966,7 +1759,7 @@ void BKE_ptcache_set_continue_physics(Scene *scene, int enable)
if(CONTINUE_PHYSICS == 0) {
for(ob=G.main->object.first; ob; ob=ob->id.next)
if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED))
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
}
@@ -1986,16 +1779,15 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches)
cache->startframe= 1;
cache->endframe= 250;
cache->step= 10;
- cache->index = -1;
BLI_addtail(ptcaches, cache);
return cache;
}
-void BKE_ptcache_free_mem(ListBase *mem_cache)
+void BKE_ptache_free_mem(PointCache *cache)
{
- PTCacheMem *pm = mem_cache->first;
+ PTCacheMem *pm = cache->mem_cache.first;
if(pm) {
for(; pm; pm=pm->next) {
@@ -2004,25 +1796,22 @@ void BKE_ptcache_free_mem(ListBase *mem_cache)
MEM_freeN(pm->index_array);
}
- BLI_freelistN(mem_cache);
+ BLI_freelistN(&cache->mem_cache);
}
}
void BKE_ptcache_free(PointCache *cache)
{
- BKE_ptcache_free_mem(&cache->mem_cache);
- if(cache->edit && cache->free_edit)
- cache->free_edit(cache->edit);
+ BKE_ptache_free_mem(cache);
MEM_freeN(cache);
}
void BKE_ptcache_free_list(ListBase *ptcaches)
{
PointCache *cache = ptcaches->first;
- while(cache) {
- BLI_remlink(ptcaches, cache);
- BKE_ptcache_free(cache);
- cache = ptcaches->first;
- }
+ for(; cache; cache=cache->next)
+ BKE_ptache_free_mem(cache);
+
+ BLI_freelistN(ptcaches);
}
static PointCache *ptcache_copy(PointCache *cache)
@@ -2112,7 +1901,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
Base *base;
ListBase pidlist;
PTCacheID *pid = baker->pid;
- PointCache *cache = NULL;
+ PointCache *cache;
float frameleno = scene->r.framelen;
int cfrao = CFRA;
int startframe = MAXFRAME;
@@ -2286,7 +2075,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid)
pm->frame = cfra;
ptcache_alloc_data(pm);
- BKE_ptcache_mem_init_pointers(pm);
+ ptcache_mem_init_pointers(pm);
ptcache_file_init_pointers(pf);
for(i=0; i<pm->totpoint; i++) {
@@ -2302,7 +2091,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid)
return;
}
ptcache_copy_data(pf->cur, pm->cur);
- BKE_ptcache_mem_incr_pointers(pm);
+ ptcache_mem_incr_pointers(pm);
}
//ptcache_make_index_array(pm, pid->totpoint(pid->calldata));
@@ -2333,7 +2122,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
pf->totpoint = pm->totpoint;
pf->type = pid->type;
- BKE_ptcache_mem_init_pointers(pm);
+ ptcache_mem_init_pointers(pm);
ptcache_file_init_pointers(pf);
if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) {
@@ -2353,7 +2142,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
ptcache_file_close(pf);
return;
}
- BKE_ptcache_mem_incr_pointers(pm);
+ ptcache_mem_incr_pointers(pm);
}
ptcache_file_close(pf);