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.
This commit is contained in:
Kévin Dietrich
2018-02-22 16:26:50 +01:00
parent 6d8a4c10b6
commit 4403ca80bd
11 changed files with 88 additions and 55 deletions

View File

@@ -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));

View File

@@ -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(

View File

@@ -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);

View File

@@ -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,