Commit: e189fe46e1b9e9e045fa6eda830558b2c5df0704
Author: Kévin Dietrich
Date:   Wed May 27 22:22:20 2015 +0200
Branches: openvdb
https://developer.blender.org/rBe189fe46e1b9e9e045fa6eda830558b2c5df0704

Set vector type when converting a grid.

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

M       intern/openvdb/intern/openvdb_dense_convert.cpp
M       intern/openvdb/intern/openvdb_dense_convert.h
M       intern/openvdb/openvdb_capi.cpp
M       intern/openvdb/openvdb_capi.h
M       source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/openvdb/intern/openvdb_dense_convert.cpp 
b/intern/openvdb/intern/openvdb_dense_convert.cpp
index d38b4b5..e095d46 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.cpp
+++ b/intern/openvdb/intern/openvdb_dense_convert.cpp
@@ -66,7 +66,8 @@ void OpenVDB_export_vector_grid(OpenVDBWriter *writer,
                                 const std::string &name,
                                 const float *data_x, const float *data_y, 
const float *data_z,
                                 const int res[3],
-                                float fluid_mat[4][4])
+                                float fluid_mat[4][4],
+                                VecType vec_type)
 {
 
        math::CoordBBox bbox(Coord(0), Coord(res[0] - 1, res[1] - 1, res[2] - 
1));
@@ -107,6 +108,7 @@ void OpenVDB_export_vector_grid(OpenVDBWriter *writer,
        vecgrid->setName(name);
        vecgrid->setTransform(transform);
        vecgrid->setIsInWorldSpace(false);
+       vecgrid->setVectorType(vec_type);
 
        writer->insert(vecgrid);
 }
diff --git a/intern/openvdb/intern/openvdb_dense_convert.h 
b/intern/openvdb/intern/openvdb_dense_convert.h
index d7747c8..4102498 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.h
+++ b/intern/openvdb/intern/openvdb_dense_convert.h
@@ -102,7 +102,8 @@ void OpenVDB_export_vector_grid(OpenVDBWriter *writer,
                                 const std::string &name,
                                 const float *data_x, const float *data_y, 
const float *data_z,
                                 const int res[3],
-                                float fluid_mat[4][4]);
+                                float fluid_mat[4][4],
+                                openvdb::VecType vec_type);
 
 
 void OpenVDB_import_grid_vector(OpenVDBReader *reader,
diff --git a/intern/openvdb/openvdb_capi.cpp b/intern/openvdb/openvdb_capi.cpp
index b3d9aa8..dc1ea07 100644
--- a/intern/openvdb/openvdb_capi.cpp
+++ b/intern/openvdb/openvdb_capi.cpp
@@ -110,9 +110,11 @@ void OpenVDB_export_grid_ch(OpenVDBWriter *writer,
 void 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])
+                             const int res[3], float matrix[4][4], short 
vec_type)
 {
-       internal::OpenVDB_export_vector_grid(writer, name, data_x, data_y, 
data_z, res, matrix);
+       internal::OpenVDB_export_vector_grid(writer, name,
+                                            data_x, data_y, data_z, res, 
matrix,
+                                            
static_cast<openvdb::VecType>(vec_type));
 }
 
 void OpenVDB_import_grid_fl(OpenVDBReader *reader,
diff --git a/intern/openvdb/openvdb_capi.h b/intern/openvdb/openvdb_capi.h
index be2d49d..62e43e9 100644
--- a/intern/openvdb/openvdb_capi.h
+++ b/intern/openvdb/openvdb_capi.h
@@ -54,6 +54,14 @@ enum {
        OPENVDB_UNKNOWN_ERROR = 11,
 };
 
+enum {
+       VEC_INVARIANT = 0,
+       VEC_COVARIANT = 1,
+       VEC_COVARIANT_NORMALIZE = 2,
+       VEC_CONTRAVARIANT_RELATIVE = 3,
+       VEC_CONTRAVARIANT_ABSOLUTE = 4,
+};
+
 void OpenVDB_update_fluid_transform(const char *filename,
                                     float matrix[4][4],
                                     float matrix_high[4][4]);
@@ -69,7 +77,7 @@ void OpenVDB_export_grid_ch(struct OpenVDBWriter *writer,
 void 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]);
+                             const int res[3], float matrix[4][4], short 
vec_type);
 
 void OpenVDB_import_grid_fl(struct OpenVDBReader *reader,
                             const char *name, float **data,
diff --git a/source/blender/blenkernel/intern/smoke.c 
b/source/blender/blenkernel/intern/smoke.c
index 72d9beb..942f90e 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -3165,13 +3165,13 @@ static void OpenVDB_export_smoke(SmokeDomainSettings 
*sds, struct OpenVDBWriter
 //                     OpenVDB_export_grid_fl(writer, "Red", r, sds->res, 
sds->fluidmat);
 //                     OpenVDB_export_grid_fl(writer, "Green", g, sds->res, 
sds->fluidmat);
 //                     OpenVDB_export_grid_fl(writer, "Blue", b, sds->res, 
sds->fluidmat);
-                       OpenVDB_export_grid_vec(writer, "Color", r, g, b, 
sds->res, sds->fluidmat);
+                       OpenVDB_export_grid_vec(writer, "Color", r, g, b, 
sds->res, sds->fluidmat, VEC_INVARIANT);
                }
 
 //             OpenVDB_export_grid_fl(writer, "Velocity X", vx, sds->res, 
sds->fluidmat);
 //             OpenVDB_export_grid_fl(writer, "Velocity Y", vy, sds->res, 
sds->fluidmat);
 //             OpenVDB_export_grid_fl(writer, "Velocity Z", vz, sds->res, 
sds->fluidmat);
-               OpenVDB_export_grid_vec(writer, "Velocity", vx, vy, vz, 
sds->res, sds->fluidmat);
+               OpenVDB_export_grid_vec(writer, "Velocity", vx, vy, vz, 
sds->res, sds->fluidmat, VEC_CONTRAVARIANT_RELATIVE);
 
                OpenVDB_export_grid_ch(writer, "Obstacles", obstacles, 
sds->res, sds->fluidmat);
        }
@@ -3193,13 +3193,13 @@ static void OpenVDB_export_smoke(SmokeDomainSettings 
*sds, struct OpenVDBWriter
 //                     OpenVDB_export_grid_fl(writer, "Red High", r, sds->res, 
sds->fluidmat_wt);
 //                     OpenVDB_export_grid_fl(writer, "Green High", g, 
sds->res, sds->fluidmat_wt);
 //                     OpenVDB_export_grid_fl(writer, "Blue High", b, 
sds->res, sds->fluidmat_wt);
-                       OpenVDB_export_grid_vec(writer, "Color High", r, g, b, 
sds->res_wt, sds->fluidmat_wt);
+                       OpenVDB_export_grid_vec(writer, "Color High", r, g, b, 
sds->res_wt, sds->fluidmat_wt, VEC_INVARIANT);
                }
 
 //             OpenVDB_export_grid_fl(writer, "Texture Coordinates U", tcu, 
sds->res, sds->fluidmat);
 //             OpenVDB_export_grid_fl(writer, "Texture Coordinates V", tcv, 
sds->res, sds->fluidmat);
 //             OpenVDB_export_grid_fl(writer, "Texture Coordinates W", tcw, 
sds->res, sds->fluidmat);
-               OpenVDB_export_grid_vec(writer, "Texture Coordinates", tcu, 
tcv, tcw, sds->res, sds->fluidmat);
+               OpenVDB_export_grid_vec(writer, "Texture Coordinates", tcu, 
tcv, tcw, sds->res, sds->fluidmat, VEC_INVARIANT);
        }
 }
 
@@ -3287,6 +3287,11 @@ void smokeModifier_OpenVDB_export(SmokeModifierData 
*smd, Scene *scene, Object *
        orig_frame = scene->r.cfra;
 
        cache = BKE_openvdb_get_current_cache(sds);
+
+       if (cache->writer == NULL) {
+               cache->writer = OpenVDBWriter_create();
+       }
+
        OpenVDBWriter_set_compression(cache->writer, cache->compression);
 
        for (fr = cache->startframe; fr <= cache->endframe; fr++) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to