[Bf-blender-cvs] [ae8f0385c51] fluid-mantaflow: implemented new caching approach

Sebastián Barschkis noreply at git.blender.org
Wed Jun 14 16:00:33 CEST 2017


Commit: ae8f0385c510e244be2f4eaea443251f3dabbcce
Author: Sebastián Barschkis
Date:   Wed Jun 14 15:59:57 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBae8f0385c510e244be2f4eaea443251f3dabbcce

implemented new caching approach

caching is now divided into two parts: surface and volume caching. the reasooning behind this is that for some setups (e.g. liquid + particles) there needs to be a way to cache both the mesh (surface caching) and particles (volumetric caching). Also, smoke scenes might use meshes in the future (e.g. vortex sheets)

===================================================================

M	release/scripts/startup/bl_operators/object_quick_effects.py
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/BKE_pointcache.h
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

===================================================================

diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py
index d16a9563e32..6d05822b044 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -363,7 +363,12 @@ class QuickSmoke(Operator):
         if self.style == 'FIRE' or self.style == 'BOTH':
             obj.modifiers[-1].domain_settings.use_high_resolution = True
 
-        # Setup material
+        # set correct cache file format for smoke
+        obj.modifiers[-1].domain_settings.use_surface_cache = False
+        obj.modifiers[-1].domain_settings.use_volume_cache = True
+        obj.modifiers[-1].domain_settings.cache_volume_format = 'POINTCACHE'
+
+		# Setup material
 
         # Cycles
         if context.scene.render.use_shading_nodes:
@@ -709,7 +714,9 @@ class QuickLiquid(Operator):
         obj.modifiers[-1].domain_settings.use_collision_border_bottom = True
 
         # set correct cache file format for liquid
-        obj.modifiers[-1].domain_settings.cache_file_format = 'OBJECT'
+        obj.modifiers[-1].domain_settings.use_surface_cache = True
+        obj.modifiers[-1].domain_settings.use_volume_cache = False
+        obj.modifiers[-1].domain_settings.cache_surface_format = 'OBJECT'
 		
         # make domain solid so that liquid becomes better visible
         obj.draw_type = 'SOLID'
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 9f8f44b0e57..d04248cbebf 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -386,14 +386,29 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
         layout = self.layout
 
         domain = context.smoke.domain_settings
-        cache_file_format = domain.cache_file_format
+        cache_surface_format = domain.cache_surface_format
+        cache_volume_format = domain.cache_volume_format
 
-        layout.prop(domain, "cache_file_format")
+        split = layout.split()
+
+        col = split.column()
+        col.prop(domain, "use_surface_cache", text="Surface format:")
+        sub = col.column()
+        sub.active = domain.use_surface_cache
+        sub.prop(domain, "cache_surface_format", text="")
+
+        col = split.column()
+        col.prop(domain, "use_volume_cache", text="Volumetric format:")
+        sub = col.column()
+        sub.active = domain.use_volume_cache
+        sub.prop(domain, "cache_volume_format", text="")
+
+        split = layout.split()
 
-        if cache_file_format == 'POINTCACHE':
+        if cache_volume_format == 'POINTCACHE':
             layout.label(text="Compression:")
             layout.prop(domain, "point_cache_compress_type", expand=True)
-        elif cache_file_format == 'OPENVDB':
+        elif cache_volume_format == 'OPENVDB':
             if not bpy.app.build_options.openvdb:
                 layout.label("Built without OpenVDB support")
                 return
@@ -403,9 +418,6 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
             row = layout.row()
             row.label("Data Depth:")
             row.prop(domain, "data_depth", expand=True, text="Data Depth")
-        elif cache_file_format == 'OBJECT':
-            layout.label(text="Compression:")
-            layout.prop(domain, "liquid_cache_compress_type", expand=True)
 
         cache = domain.point_cache
         point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 98ecc413531..c2cbc5100fb 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -123,11 +123,13 @@ typedef struct PTCacheFile {
 #define PTCACHE_VEL_PER_SEC     1
 
 enum {
-	PTCACHE_FILE_PTCACHE = 0,
-	PTCACHE_FILE_OPENVDB = 1,
-	PTCACHE_FILE_LIQUID = 2,
-	PTCACHE_FILE_FLIP = 3,
-	PTCACHE_FILE_LIQUIDFLIP = 4,
+	/* Volumetric file formats */
+	PTCACHE_FILE_PTCACHE = (1 << 0),
+	PTCACHE_FILE_OPENVDB = (1 << 1),
+	PTCACHE_FILE_UNI = (1 << 2),
+
+	/* Surface file formats */
+	PTCACHE_FILE_OBJECT = (1 << 3),
 };
 
 typedef struct PTCacheID {
@@ -163,15 +165,15 @@ typedef struct PTCacheID {
 	/* copies cache data to point data */
 	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, bool save_liquid_data);
+	/* copies mesh data to cache data */
+	int (*write_mesh_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, bool load_liquid_data);
+	int (*read_mesh_stream)(void *calldata, char *filename, char *pathname, bool load_liquid_data);
 
 	/* copies point data to cache data */
-	int (*write_flip_stream)(void *calldata, char *filename, char *pathname, bool save_liquid_data);
+	int (*write_uni_stream)(void *calldata, char *filename, char *pathname, bool save_liquid_data);
 	/* copies cache data to point data */
-	int (*read_flip_stream)(void *calldata, char *filename, char *pathname, bool load_liquid_data);
+	int (*read_uni_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 d1f3fd6343a..fc5fb48e220 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -583,6 +583,11 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
 {	
 	SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 	SmokeDomainSettings *sds = smd->domain;
+
+	if (!(sds->flags & MOD_SMOKE_USE_VOLUME_CACHE)) {
+		return 0;
+	}
+
 	int ret = 0;
 	int fluid_fields = smoke_get_data_flags(sds);
 
@@ -711,7 +716,11 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v)
 {
 	SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 	SmokeDomainSettings *sds = smd->domain;
-	
+
+	if (!(sds->flags & MOD_SMOKE_USE_VOLUME_CACHE)) {
+		return 0;
+	}
+
 	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);
@@ -802,6 +811,11 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
 {
 	SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 	SmokeDomainSettings *sds = smd->domain;
+
+	if (!(sds->flags & MOD_SMOKE_USE_VOLUME_CACHE)) {
+		return 0;
+	}
+
 	char version[4];
 	int ch_res[3];
 	float ch_dx;
@@ -1001,6 +1015,10 @@ static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke
 	SmokeModifierData *smd = (SmokeModifierData *)smoke_v;
 	SmokeDomainSettings *sds = smd->domain;
 
+	if (!(sds->flags & MOD_SMOKE_USE_VOLUME_CACHE)) {
+		return 0;
+	}
+
 	OpenVDBWriter_set_flags(writer, sds->openvdb_comp, (sds->data_depth == 16));
 
 	OpenVDBWriter_add_meta_int(writer, "blender/smoke/active_fields", sds->active_fields);
@@ -1105,6 +1123,10 @@ static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_
 
 	SmokeDomainSettings *sds = smd->domain;
 
+	if (!(sds->flags & MOD_SMOKE_USE_VOLUME_CACHE)) {
+		return 0;
+	}
+
 	int fluid_fields = smoke_get_data_flags(sds);
 	int active_fields, cache_fields = 0;
 	int cache_res[3];
@@ -1227,7 +1249,7 @@ 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, bool load_liquid_data)
+static int ptcache_mesh_read(void *smoke_v, char *filename, char *pathname, bool load_liquid_data)
 {
 	SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
 	int i;
@@ -1237,6 +1259,10 @@ static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname, bo
 	}
 
 	SmokeDomainSettings *sds = smd->domain;
+	if (!(sds->flags & MOD_SMOKE_USE_SURFACE_CACHE)) {
+		return 0;
+	}
+
 	bool high_res      = sds->flags & MOD_SMOKE_HIGHRES;
 	bool high_res_view = sds->viewport_display_mode == SM_VIEWPORT_FINAL;
 
@@ -1253,7 +1279,7 @@ static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname, bo
 		liquid_update_mesh_data(sds->fluid, filename);
 		if (high_res && high_res_view) {
 			i = strlen(filename);
-			if (i > 8) filename[i-8] = '\0';   // strip low-res extension
+			if (i > 8) filename[i-8] = '\0';   // strip .bobj.gz extension
 			strcat(filename, "_HIGH.bobj.gz"); // add high-res extension
 
 			liquid_update_mesh_data(sds->fluid, filename);
@@ -1263,7 +1289,7 @@ static int ptcache_liquid_read(void *smoke_v, char *filename, char *pathname, bo
 	return 0;
 }
 
-static int ptcache_flip_read(void *smoke_v, char *filename, char *pathname, bool load_liquid_data)
+static int ptcache_uni_read(void *smoke_v, char *filename, char *pathname, bool load_liquid_data)
 {
 	SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
 
@@ -1272,6 +1298,9 @@ static int ptcache_flip_read(void *smoke_v, char *filename, char *pathname, bool
 	}
 
 	SmokeDomainSettings *sds = smd->domain;
+	if (!(sds->flags & MOD_SMOKE_USE_VOLUME_CACHE)) {
+		return 0;
+	}
 
 	if (sds->fluid) {
 		/* Mantaflow internal data loading */
@@ -1286,7 +1315,7 @@ static int ptcache_flip_read(void *smoke_v, char *filename, char *pathname, bool
 	return 0;
 }
 
-static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname, bool save_liquid_data)
+static int ptcache_mesh_write(void *smoke_v, char *filename, char* pathname, bool save_liquid_data)
 {
 	SmokeModifierData *smd = (SmokeModifierData *) smoke_v;
 	int i;
@@ -1297,6 +1326,10 @@ static int ptcache_liquid_write(void *smoke_v, char *filename, char* pathname, b
 	}
 
 	SmokeDomainSettings *sds = smd->domain;
+	if (!(sds->flags & MOD_SMOKE_USE_SURFACE_CACHE)) {
+		return 0;
+	}
+
 	bool high_res      = sds->flags & MOD_SMOKE_HIGHR

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list