[Bf-blender-cvs] [09da26d] openvdb: Expose file compression types.

Kévin Dietrich noreply at git.blender.org
Fri Jun 5 14:07:26 CEST 2015


Commit: 09da26d720a3ee36a473f9654bc77689327c5d3d
Author: Kévin Dietrich
Date:   Fri May 22 20:09:23 2015 +0200
Branches: openvdb
https://developer.blender.org/rB09da26d720a3ee36a473f9654bc77689327c5d3d

Expose file compression types.

By default files are compressed based on their active values, with zip
compression optionnaly added to it. We can as an option, enable blosc
compression, through a build flags. This flag is only to be enbaled if
OpenVDB was built with blosc. Otherwise -> crash.

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

M	CMakeLists.txt
M	build_files/cmake/config/bpy_module.cmake
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/editors/object/object_modifier.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/rna_smoke.c
M	source/blender/openvdb/openvdb_capi.cpp
M	source/blender/openvdb/openvdb_capi.h

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 360b4aa..56bab6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -223,6 +223,7 @@ option(WITH_PLAYER        "Build Player" OFF)
 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
 option(WITH_COMPOSITOR    "Enable the tile based nodal compositor" ON)
 option(WITH_OPENVDB       "Enable features relying on OpenVDB" ON)
+option(WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enble if OpenVDB was built with blosc support" OFF)
 
 # GHOST Windowing Library Options
 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
@@ -1076,6 +1077,7 @@ if(UNIX AND NOT APPLE)
 
 		if(NOT OPENVDB_FOUND)
 			set(WITH_OPENVDB OFF)
+			set(WITH_OPENVDB_BLOSC OFF)
 			message(STATUS "OpenVDB not found")
 		endif()
 	endif()
diff --git a/build_files/cmake/config/bpy_module.cmake b/build_files/cmake/config/bpy_module.cmake
index b5b13b4..4114015 100644
--- a/build_files/cmake/config/bpy_module.cmake
+++ b/build_files/cmake/config/bpy_module.cmake
@@ -31,3 +31,4 @@ set(WITH_INPUT_NDOF          OFF CACHE BOOL "" FORCE)
 set(WITH_OPENCOLLADA         OFF CACHE BOOL "" FORCE)
 set(WITH_INTERNATIONAL       OFF CACHE BOOL "" FORCE)
 set(WITH_BULLET              OFF CACHE BOOL "" FORCE)
+set(WITH_OPENVDB             OFF CACHE BOOL "" FORCE)
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index bf258ff..16e2fa0 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -364,6 +364,7 @@ class PHYSICS_PT_smoke_openvdb(PhysicButtonsPanel, Panel):
 
         if cache:
             layout.prop(cache, "filepath")
+            layout.prop(cache, "compression")
             row = layout.row(align=True)
             row.prop(cache, "frame_start")
             row.prop(cache, "frame_end")
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 17d7c7d..4c4aa06 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -3287,7 +3287,7 @@ void smokeModifier_OpenVDB_export(SmokeModifierData *smd, Scene *scene, Object *
 	orig_frame = scene->r.cfra;
 
 	cache = BKE_openvdb_get_current_cache(sds);
-	OpenVDBWriter_set_compression(cache->writer, 0);
+	OpenVDBWriter_set_compression(cache->writer, cache->compression);
 
 	for (fr = cache->startframe; fr <= cache->endframe; fr++) {
 		/* smd->time is overwritten with scene->r.cfra in smokeModifier_process,
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index fd76eef..43d8f65 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2499,6 +2499,7 @@ static OpenVDBCache *openvdb_cache_new(void)
 	cache->writer = OpenVDBWriter_create();
     cache->startframe = 1;
     cache->endframe = 250;
+	cache->compression = VDB_COMPRESSION_ZIP;
 
 	BLI_strncpy(cache->name, "openvdb_smoke_export_", sizeof(cache->name));
 
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index d2feb45..522b19b 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -164,13 +164,19 @@ typedef struct OpenVDBCache {
 	char path[1024];
 	char name[64];
 	int startframe, endframe;
-	short flag, pad[3];
+	short flag, compression, pad[2];
 } OpenVDBCache;
 
 enum {
 	VDB_CACHE_CURRENT = 1,
 };
 
+enum {
+	VDB_COMPRESSION_ZIP   = 0,
+	VDB_COMPRESSION_BLOSC = 1,
+	VDB_COMPRESSION_NONE  = 2,
+};
+
 /* inflow / outflow */
 
 /* type */
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index e878e08..5bdebf2 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -300,6 +300,10 @@ if(WITH_FREESTYLE)
 	add_definitions(-DWITH_FREESTYLE)
 endif()
 
+if(WITH_OPENVDB_BLOSC)
+	add_definitions(-DWITH_OPENVDB_BLOSC)
+endif()
+
 # Build makesrna executable
 blender_include_dirs(
 	.
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 059b3d1..7ee9ad5 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -321,6 +321,15 @@ static void rna_def_openvdb_cache(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
+	static EnumPropertyItem prop_compression_items[] = {
+		{ VDB_COMPRESSION_ZIP, "ZIP", 0, "Zip", "Slow and effective compression" },
+#if WITH_OPENVDB_BLOSC
+		{ VDB_COMPRESSION_BLOSC, "BLOSC", 0, "Blosc", "Multithreaded compression, almost similar in size and quality as 'Zip'" },
+#endif
+	    { VDB_COMPRESSION_NONE, "NONE", 0, "None", "Do not use any compression" },
+		{ 0, NULL, 0, NULL, NULL }
+	};
+
 	srna = RNA_def_struct(brna, "OpenVDBCache", NULL);
 	RNA_def_struct_ui_text(srna, "OpenVDB cache", "OpenVDB cache");
 
@@ -342,8 +351,15 @@ static void rna_def_openvdb_cache(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "name");
-	RNA_def_property_ui_text(prop, "Name", "Level Set filter name");
+	RNA_def_property_ui_text(prop, "Name", "Cache name");
     RNA_def_struct_name_property(srna, prop);
+
+	prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "compression");
+	RNA_def_property_enum_items(prop, prop_compression_items);
+	RNA_def_property_ui_text(prop, "File Compression",
+	                         "Select what type of compression to use when writing the files");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
 }
 
 static void rna_def_smoke_domain_settings(BlenderRNA *brna)
diff --git a/source/blender/openvdb/openvdb_capi.cpp b/source/blender/openvdb/openvdb_capi.cpp
index d919668..246b312 100644
--- a/source/blender/openvdb/openvdb_capi.cpp
+++ b/source/blender/openvdb/openvdb_capi.cpp
@@ -148,11 +148,21 @@ void OpenVDBWriter_free(OpenVDBWriter *writer)
 	writer = NULL;
 }
 
-void OpenVDBWriter_set_compression(OpenVDBWriter *writer, const int flags)
+void OpenVDBWriter_set_compression(OpenVDBWriter *writer, const int flag)
 {
-	// TODO(kevin)
-	(void)flags;
-	writer->setFileCompression(io::COMPRESS_ACTIVE_MASK | io::COMPRESS_ZIP);
+	int compression_flags = io::COMPRESS_ACTIVE_MASK;
+
+	if (flag == 0) {
+		compression_flags |= io::COMPRESS_ZIP;
+	}
+	else if (flag == 1) {
+		compression_flags |= io::COMPRESS_BLOSC;
+	}
+	else {
+		compression_flags = io::COMPRESS_NONE;
+	}
+
+	writer->setFileCompression(compression_flags);
 }
 
 void OpenVDBWriter_add_meta_fl(OpenVDBWriter *writer, const char *name, const float value)
diff --git a/source/blender/openvdb/openvdb_capi.h b/source/blender/openvdb/openvdb_capi.h
index 812b3f9..2bae96e 100644
--- a/source/blender/openvdb/openvdb_capi.h
+++ b/source/blender/openvdb/openvdb_capi.h
@@ -103,7 +103,7 @@ void OpenVDB_import_grid_vec(struct OpenVDBReader *reader,
 
 struct OpenVDBWriter *OpenVDBWriter_create(void);
 void OpenVDBWriter_free(struct OpenVDBWriter *writer);
-void OpenVDBWriter_set_compression(struct OpenVDBWriter *writer, const int flags);
+void OpenVDBWriter_set_compression(struct OpenVDBWriter *writer, const int flag);
 void OpenVDBWriter_add_meta_fl(struct OpenVDBWriter *writer, const char *name, const float value);
 void OpenVDBWriter_add_meta_int(struct OpenVDBWriter *writer, const char *name, const int value);
 void OpenVDBWriter_add_meta_v3(struct OpenVDBWriter *writer, const char *name, const float value[3]);




More information about the Bf-blender-cvs mailing list