[Bf-blender-cvs] [4403ca80bda] master: Smoke: expose empty space clipping property to the UI.

Kévin Dietrich noreply at git.blender.org
Sat Feb 24 14:01:13 CET 2018


Commit: 4403ca80bda690c0ac44e4a6db0cddf4b2428006
Author: Kévin Dietrich
Date:   Thu Feb 22 16:26:50 2018 +0100
Branches: master
https://developer.blender.org/rB4403ca80bda690c0ac44e4a6db0cddf4b2428006

Smoke: expose empty space clipping property to the UI.

This is used to determine which voxels are to be considered empty space.

Previously it was hardcoded for converting dense grids to OpenVDB grids
to reduce disk space usage.

This value is also useful for rendering engines to know, i.e. to
optimize ray marching.

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

M	intern/openvdb/intern/openvdb_dense_convert.cc
M	intern/openvdb/intern/openvdb_dense_convert.h
M	intern/openvdb/openvdb_capi.cc
M	intern/openvdb/openvdb_capi.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

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

diff --git a/intern/openvdb/intern/openvdb_dense_convert.cc b/intern/openvdb/intern/openvdb_dense_convert.cc
index 10d5fb6402a..76fbbf88079 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.cc
+++ b/intern/openvdb/intern/openvdb_dense_convert.cc
@@ -79,7 +79,8 @@ openvdb::GridBase *OpenVDB_export_vector_grid(
         const int res[3],
         float fluid_mat[4][4],
         openvdb::VecType vec_type,
-        const bool is_color,
+		const bool is_color,
+		const float clipping,
         const openvdb::FloatGrid *mask)
 {
 	using namespace openvdb;
@@ -92,15 +93,15 @@ openvdb::GridBase *OpenVDB_export_vector_grid(
 
 	grid[0] = FloatGrid::create(0.0f);
 	tools::Dense<const float, tools::LayoutXYZ> dense_grid_x(bbox, data_x);
-	tools::copyFromDense(dense_grid_x, grid[0]->tree(), TOLERANCE);
+	tools::copyFromDense(dense_grid_x, grid[0]->tree(), clipping);
 
 	grid[1] = FloatGrid::create(0.0f);
 	tools::Dense<const float, tools::LayoutXYZ> dense_grid_y(bbox, data_y);
-	tools::copyFromDense(dense_grid_y, grid[1]->tree(), TOLERANCE);
+	tools::copyFromDense(dense_grid_y, grid[1]->tree(), clipping);
 
 	grid[2] = FloatGrid::create(0.0f);
 	tools::Dense<const float, tools::LayoutXYZ> dense_grid_z(bbox, data_z);
-	tools::copyFromDense(dense_grid_z, grid[2]->tree(), TOLERANCE);
+	tools::copyFromDense(dense_grid_z, grid[2]->tree(), clipping);
 
 	Vec3SGrid::Ptr vecgrid = Vec3SGrid::create(Vec3s(0.0f));
 
diff --git a/intern/openvdb/intern/openvdb_dense_convert.h b/intern/openvdb/intern/openvdb_dense_convert.h
index 7882cafa06e..e5e2965e708 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.h
+++ b/intern/openvdb/intern/openvdb_dense_convert.h
@@ -36,8 +36,6 @@
 
 #include <cstdio>
 
-#define TOLERANCE 1e-3f
-
 namespace internal {
 
 /* Verify that the name does not correspond to the old format, in which case we
@@ -52,7 +50,8 @@ GridType *OpenVDB_export_grid(
         const openvdb::Name &name,
         const T *data,
         const int res[3],
-        float fluid_mat[4][4],
+		float fluid_mat[4][4],
+		const float clipping,
         const openvdb::FloatGrid *mask)
 {
 	using namespace openvdb;
@@ -64,7 +63,7 @@ GridType *OpenVDB_export_grid(
 	typename GridType::Ptr grid = GridType::create(T(0));
 
 	tools::Dense<const T, openvdb::tools::LayoutXYZ> dense_grid(bbox, data);
-	tools::copyFromDense(dense_grid, grid->tree(), (T)TOLERANCE);
+	tools::copyFromDense(dense_grid, grid->tree(), static_cast<T>(clipping));
 
 	grid->setTransform(transform);
 
@@ -119,15 +118,15 @@ void OpenVDB_import_grid(
 	}
 }
 
-openvdb::GridBase *OpenVDB_export_vector_grid(
-        OpenVDBWriter *writer,
-        const openvdb::Name &name,
-        const float *data_x, const float *data_y, const float *data_z,
-        const int res[3],
-        float fluid_mat[4][4],
-        openvdb::VecType vec_type,
-        const bool is_color,
-        const openvdb::FloatGrid *mask);
+openvdb::GridBase *OpenVDB_export_vector_grid(OpenVDBWriter *writer,
+		const openvdb::Name &name,
+		const float *data_x, const float *data_y, const float *data_z,
+		const int res[3],
+		float fluid_mat[4][4],
+		openvdb::VecType vec_type,
+		const bool is_color,
+		const float clipping,
+		const openvdb::FloatGrid *mask);
 
 
 void OpenVDB_import_grid_vector(
diff --git a/intern/openvdb/openvdb_capi.cc b/intern/openvdb/openvdb_capi.cc
index ef4f8c8820f..1c8b51a23c4 100644
--- a/intern/openvdb/openvdb_capi.cc
+++ b/intern/openvdb/openvdb_capi.cc
@@ -39,7 +39,7 @@ int OpenVDB_getVersionHex()
 OpenVDBFloatGrid *OpenVDB_export_grid_fl(
         OpenVDBWriter *writer,
         const char *name, float *data,
-        const int res[3], float matrix[4][4],
+		const int res[3], float matrix[4][4], const float clipping,
         OpenVDBFloatGrid *mask)
 {
 	Timer(__func__);
@@ -53,6 +53,7 @@ OpenVDBFloatGrid *OpenVDB_export_grid_fl(
 	        data,
 	        res,
 	        matrix,
+			clipping,
 	        mask_grid);
 
 	return reinterpret_cast<OpenVDBFloatGrid *>(grid);
@@ -61,7 +62,7 @@ OpenVDBFloatGrid *OpenVDB_export_grid_fl(
 OpenVDBIntGrid *OpenVDB_export_grid_ch(
         OpenVDBWriter *writer,
         const char *name, unsigned char *data,
-        const int res[3], float matrix[4][4],
+		const int res[3], float matrix[4][4], const float clipping,
         OpenVDBFloatGrid *mask)
 {
 	Timer(__func__);
@@ -76,17 +77,17 @@ OpenVDBIntGrid *OpenVDB_export_grid_ch(
 	        data,
 	        res,
 	        matrix,
+			clipping,
 	        mask_grid);
 
 	return reinterpret_cast<OpenVDBIntGrid *>(grid);
 }
 
-OpenVDBVectorGrid *OpenVDB_export_grid_vec(
-        struct OpenVDBWriter *writer,
-        const char *name,
-        const float *data_x, const float *data_y, const float *data_z,
-        const int res[3], float matrix[4][4], short vec_type,
-        const bool is_color, OpenVDBFloatGrid *mask)
+OpenVDBVectorGrid *OpenVDB_export_grid_vec(struct OpenVDBWriter *writer,
+		const char *name,
+		const float *data_x, const float *data_y, const float *data_z,
+		const int res[3], float matrix[4][4], short vec_type, const float clipping,
+		const bool is_color, OpenVDBFloatGrid *mask)
 {
 	Timer(__func__);
 
@@ -105,6 +106,7 @@ OpenVDBVectorGrid *OpenVDB_export_grid_vec(
 	        matrix,
 	        static_cast<VecType>(vec_type),
 	        is_color,
+			clipping,
 	        mask_grid);
 
 	return reinterpret_cast<OpenVDBVectorGrid *>(grid);
diff --git a/intern/openvdb/openvdb_capi.h b/intern/openvdb/openvdb_capi.h
index 2d2feeadcf1..fe7af82769b 100644
--- a/intern/openvdb/openvdb_capi.h
+++ b/intern/openvdb/openvdb_capi.h
@@ -49,22 +49,20 @@ enum {
 struct OpenVDBFloatGrid *OpenVDB_export_grid_fl(
         struct OpenVDBWriter *writer,
         const char *name, float *data,
-        const int res[3], float matrix[4][4],
+		const int res[3], float matrix[4][4], const float clipping,
         struct OpenVDBFloatGrid *mask);
 
-struct OpenVDBIntGrid *OpenVDB_export_grid_ch(
-        struct OpenVDBWriter *writer,
-        const char *name, unsigned char *data,
-        const int res[3], float matrix[4][4],
-        struct OpenVDBFloatGrid *mask);
+struct OpenVDBIntGrid *OpenVDB_export_grid_ch(struct OpenVDBWriter *writer,
+		const char *name, unsigned char *data,
+		const int res[3], float matrix[4][4], const float clipping,
+		struct OpenVDBFloatGrid *mask);
 
-struct OpenVDBVectorGrid *OpenVDB_export_grid_vec(
-        struct OpenVDBWriter *writer,
-        const char *name,
-        const float *data_x, const float *data_y, const float *data_z,
-        const int res[3], float matrix[4][4], short vec_type,
-        const bool is_color,
-        struct OpenVDBFloatGrid *mask);
+struct OpenVDBVectorGrid *OpenVDB_export_grid_vec(struct OpenVDBWriter *writer,
+		const char *name,
+		const float *data_x, const float *data_y, const float *data_z,
+		const int res[3], float matrix[4][4], short vec_type, const float clipping,
+		const bool is_color,
+		struct OpenVDBFloatGrid *mask);
 
 void OpenVDB_import_grid_fl(
         struct OpenVDBReader *reader,
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 01144fa9307..9489fb71e15 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -68,6 +68,8 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
             col.prop(domain, "time_scale", text="Scale")
             col.label(text="Border Collisions:")
             col.prop(domain, "collision_extents", text="")
+            col.label(text="Empty Space:")
+            col.prop(domain, "clipping")
 
             col = split.column()
             col.label(text="Behavior:")
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index c99da724794..6cd93e19e95 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         279
-#define BLENDER_SUBVERSION      2
+#define BLENDER_SUBVERSION      3
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   6
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index a84dc056015..5b36b0f9f84 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -972,20 +972,20 @@ static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke
 
 		smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
 
-		wt_density_grid = OpenVDB_export_grid_fl(writer, "density", dens, sds->res_wt, sds->fluidmat_wt, NULL);
+		wt_density_grid = OpenVDB_export_grid_fl(writer, "density", dens, sds->res_wt, sds->fluidmat_wt, sds->clipping, NULL);
 		clip_grid = wt_density_grid;
 
 		if (fluid_fields & SM_ACTIVE_FIRE) {
-			OpenVDB_export_grid_fl(writer, "flame", flame, sds->res_wt, sds->fluidmat_wt, wt_density_grid);
-			OpenVDB_export_grid_fl(writer, "fuel", fuel, sds->res_wt, sds->fluidmat_wt, wt_density_grid);
-			OpenVDB_export_grid_fl(writer, "react", react, sds->res_wt, sds->fluidmat_wt, wt_density_grid);
+			OpenVDB_export_grid_fl(writer, "flame", flame, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid);
+			OpenVDB_export_grid_fl(writer, "fuel", fuel, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid);
+			OpenVDB_export_grid_fl(writer, "react", react, sds->res_wt, sds->fluidmat_wt, sds->clipping, wt_density_grid);
 		}
 
 		if (fluid_fields & SM_ACTIVE_COLORS) {
-			OpenVDB_export_grid_vec(writer, "color", r, g, b, sds->res_wt, sds->fluidmat_wt, VEC_INVARIANT, true, wt_density_grid);
+			OpenVDB_export_grid_vec(writer, "color", r, g, b, sds->res_wt, sds->fluidmat_wt, VEC_INVARIANT, true, sds->clipping, wt_density_grid);
 		}
 
-		OpenVDB_export_grid_vec(writer, "texture coordinates", tcu, tcv, tcw, sds->res, sds->fluidmat, VEC_INVARIANT, false, wt_density_grid);
+		OpenVDB_export_grid_vec(writer, "texture coordinate

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list