[Bf-blender-cvs] [f686625d8bd] fluid-mantaflow: added new cache option that supports mesh and FLIP particle export
Sebastián Barschkis
noreply at git.blender.org
Tue Jun 13 15:22:18 CEST 2017
Commit: f686625d8bd06831cc89e78e3a77a8f43d599839
Author: Sebastián Barschkis
Date: Mon Jun 12 17:48:25 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBf686625d8bd06831cc89e78e3a77a8f43d599839
added new cache option that supports mesh and FLIP particle export
===================================================================
M source/blender/blenkernel/BKE_pointcache.h
M source/blender/blenkernel/intern/pointcache.c
M source/blender/makesrna/intern/rna_smoke.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index bbe795c021d..98ecc413531 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -126,7 +126,8 @@ enum {
PTCACHE_FILE_PTCACHE = 0,
PTCACHE_FILE_OPENVDB = 1,
PTCACHE_FILE_LIQUID = 2,
- PTCACHE_FILE_PARTICLE = 3,
+ PTCACHE_FILE_FLIP = 3,
+ PTCACHE_FILE_LIQUIDFLIP = 4,
};
typedef struct PTCacheID {
@@ -163,14 +164,14 @@ typedef struct PTCacheID {
int (*read_openvdb_stream)(struct OpenVDBReader *reader, void *calldata);
/* copies mesj data to cache data */
- int (*write_liquid_stream)(void *calldata, char *filename, char *pathname);
+ int (*write_liquid_stream)(void *calldata, char *filename, char *pathname, bool save_liquid_data);
/* copies cache data to mesh data */
- int (*read_liquid_stream)(void *calldata, char *filename, char *pathname);
+ int (*read_liquid_stream)(void *calldata, char *filename, char *pathname, bool load_liquid_data);
/* copies point data to cache data */
- int (*write_particle_stream)(void *calldata, char *filename, char *pathname);
+ int (*write_flip_stream)(void *calldata, char *filename, char *pathname, bool save_liquid_data);
/* copies cache data to point data */
- int (*read_particle_stream)(void *calldata, char *filename, char *pathname);
+ int (*read_flip_stream)(void *calldata, char *filename, char *pathname, bool load_liquid_data);
/* copies custom extradata to cache data */
void (*write_extra_data)(void *calldata, struct PTCacheMem *pm, int cfra);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index f982a3681bc..581fbfd6ee4 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1227,10 +1227,9 @@ static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_
#endif
#ifdef WITH_MANTA
-static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname)
+static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname, bool load_liquid_data)
{
SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
- int i;
if (!smd) {
return 0;
@@ -1239,8 +1238,9 @@ static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname)
SmokeDomainSettings *sds = smd->domain;
if (sds->fluid) {
- liquid_load_data(sds->fluid, pathname);
-
+ if (load_liquid_data) {
+ liquid_load_data(sds->fluid, pathname);
+ }
if (sds->flags & MOD_SMOKE_HIGHRES) {
liquid_load_data_high(sds->fluid, pathname);
}
@@ -1250,10 +1250,9 @@ static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname)
return 0;
}
-static int ptcache_mantaparticle_read(void *smoke_v, char *filename, char *pathname)
+static int ptcache_flip_read(void *smoke_v, char *filename, char *pathname, bool load_liquid_data)
{
SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
- int i;
if (!smd) {
return 0;
@@ -1262,17 +1261,10 @@ static int ptcache_mantaparticle_read(void *smoke_v, char *filename, char *pathn
SmokeDomainSettings *sds = smd->domain;
if (sds->fluid) {
- liquid_load_data(sds->fluid, pathname);
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
-
- i = strlen(filename);
- /* remove .bobj.gz ...*/
- if (i > 8)
- filename[i-8] = '\0';
- /* ... and add _HIGH.bobj.gz ending */
- strcat(filename, "_HIGH.bobj.gz");
-
+ if (load_liquid_data) {
+ liquid_load_data(sds->fluid, pathname);
+ }
+ if (load_liquid_data && sds->flags & MOD_SMOKE_HIGHRES) {
liquid_load_data_high(sds->fluid, pathname);
}
liquid_update_particle_data(sds->fluid, filename);
@@ -1281,7 +1273,7 @@ static int ptcache_mantaparticle_read(void *smoke_v, char *filename, char *pathn
return 0;
}
-static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname)
+static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname, bool save_liquid_data)
{
SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
int i;
@@ -1294,10 +1286,10 @@ static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname)
if (sds->fluid) {
liquid_save_mesh(sds->fluid, filename);
- liquid_save_data(sds->fluid, pathname);
-
+ if (save_liquid_data) {
+ liquid_save_data(sds->fluid, pathname);
+ }
if (sds->flags & MOD_SMOKE_HIGHRES) {
-
i = strlen(filename);
/* remove .bobj.gz ...*/
if (i > 8)
@@ -1306,7 +1298,9 @@ static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname)
strcat(filename, "_HIGH.bobj.gz");
liquid_save_mesh_high(sds->fluid, filename);
- liquid_save_data_high(sds->fluid, pathname);
+ if (save_liquid_data) {
+ liquid_save_data_high(sds->fluid, pathname);
+ }
}
/* After writing mesh data make sure that fields in fluid object
* are up-to-date (necessary for instant replay functionality) */
@@ -1316,10 +1310,9 @@ static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname)
return 0;
}
-static int ptcache_mantaparticle_write(void *smoke_v, char *filename, char* pathname)
+static int ptcache_flip_write(void *smoke_v, char *filename, char* pathname, bool save_liquid_data)
{
SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
- int i;
if (!smd) {
return 0;
@@ -1329,9 +1322,10 @@ static int ptcache_mantaparticle_write(void *smoke_v, char *filename, char* path
if (sds->fluid) {
liquid_save_particles(sds->fluid, filename);
- liquid_save_data(sds->fluid, pathname);
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
+ if (save_liquid_data) {
+ liquid_save_data(sds->fluid, pathname);
+ }
+ if (save_liquid_data && sds->flags & MOD_SMOKE_HIGHRES) {
liquid_save_data_high(sds->fluid, pathname);
}
/* After writing particle data make sure that fields in fluid object
@@ -1637,8 +1631,8 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
pid->write_liquid_stream = NULL;
pid->read_liquid_stream = NULL;
- pid->write_particle_stream = NULL;
- pid->read_particle_stream = NULL;
+ pid->write_flip_stream = NULL;
+ pid->read_flip_stream = NULL;
pid->write_extra_data = NULL;
pid->read_extra_data = NULL;
@@ -1700,8 +1694,8 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl
pid->write_liquid_stream = NULL;
pid->read_liquid_stream = NULL;
- pid->write_particle_stream = NULL;
- pid->read_particle_stream = NULL;
+ pid->write_flip_stream = NULL;
+ pid->read_flip_stream = NULL;
pid->write_extra_data = NULL;
pid->read_extra_data = NULL;
@@ -1748,8 +1742,8 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->write_liquid_stream = NULL;
pid->read_liquid_stream = NULL;
- pid->write_particle_stream = NULL;
- pid->read_particle_stream = NULL;
+ pid->write_flip_stream = NULL;
+ pid->read_flip_stream = NULL;
}
else if (smd->domain->type == MOD_SMOKE_DOMAIN_TYPE_LIQUID)
{
@@ -1759,8 +1753,8 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->write_liquid_stream = ptcache_liquid_write;
pid->read_liquid_stream = ptcache_liquid_read;
- pid->write_particle_stream = ptcache_mantaparticle_write;
- pid->read_particle_stream = ptcache_mantaparticle_read;
+ pid->write_flip_stream = ptcache_flip_write;
+ pid->read_flip_stream = ptcache_flip_read;
}
pid->write_openvdb_stream = ptcache_smoke_openvdb_write;
@@ -1973,7 +1967,7 @@ static const char *ptcache_file_extension(const PTCacheID *pid)
return ".vdb";
case PTCACHE_FILE_LIQUID:
return ".bobj.gz";
- case PTCACHE_FILE_PARTICLE:
+ case PTCACHE_FILE_FLIP:
return ".uni";
}
}
@@ -2754,7 +2748,7 @@ static int ptcache_read_openvdb_stream(PTCacheID *pid, int cfra)
#endif
}
-static int ptcache_read_liquid_stream(PTCacheID *pid, int cfra)
+static int ptcache_read_liquid_stream(PTCacheID *pid, int cfra, bool load_liquid_data)
{
char filename[FILE_MAX * 2];
char pathname[FILE_MAX * 2];
@@ -2770,14 +2764,14 @@ static int ptcache_read_liquid_stream(PTCacheID *pid, int cfra)
return 0;
}
- if (!pid->read_liquid_stream(pid->calldata, filename, pathname)) {
+ if (!pid->read_liquid_stream(pid->calldata, filename, pathname, load_liquid_data)) {
return 0;
}
return 1;
}
-static int ptcache_read_particle_stream(PTCacheID *pid, int cfra)
+static int ptcache_read_flip_stream(PTCacheID *pid, int cfra, bool load_liquid_data)
{
char filename[FILE_MAX * 2];
char pathname[FILE_MAX * 2];
@@ -2793,7 +2787,7 @@ static int ptcache_read_particle_stream(PTCacheID *pid, int cfra)
return 0;
}
- if (!pid->read_particle_stream(pid->calldata, filename, pathname)) {
+ if (!pid->read_flip_stream(pid->calldata, filename, pathname, load_liquid_data)) {
return 0;
}
@@ -2954,12 +2948,20 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
}
}
else if (pid->file_type == PTCACHE_FILE_LIQUID && pid->read_liquid_stream) {
- if (!ptcache_read_liquid_stream(pid, cfra1)) {
+ if (!ptcache_read_liquid_stream(pid, cfra1, true)) {
return 0;
}
}
- else if (pid->file_type == PTCACHE_FILE_PARTICLE && pid->read_particle_stream) {
- if (!ptcache_read_particle_stream(pid, cfra1)) {
+ else if (pid->file_type == PTCACHE_FILE_FLIP && pid->read_flip_stream) {
+ if (!ptcache_read_flip_stream(pid, cfra1, true)) {
+ return 0;
+ }
+ }
+ else if (pid->file_type == PTCACHE_FILE_LIQUIDFLIP && pid->read_liquid_stream && pid->read_flip_stream) {
+ if (!ptcache_read_liquid_stream(pid, cfra1, true)) {
+ return 0;
+ }
+ if (!ptcache_read_flip_stream(pid, cfra1, false)) { // Do not load liquid data again, was loaded above
return 0;
}
}
@@ -2979,12 +2981,20 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
}
}
else if (pid->file_type == PTCACHE_FILE_LIQUID && pid->read_liquid_stream) {
- if (!ptcache_read_liquid_stream(pid, cfra2)) {
+ if (!ptcache_read_liquid_stream(pid, cfra2, true)) {
+ return 0;
+ }
+ }
+ else if (pid->file_type == PTCACHE_FILE_FLIP && pid->read_flip_stream) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list