[Bf-blender-cvs] [4a08eb0707f] blender-v2.82-release: Fluid: Updated manta pp files

Sebastián Barschkis noreply at git.blender.org
Sun Feb 9 17:28:22 CET 2020


Commit: 4a08eb0707fc17e4e97430ffa33eb7d3e36db712
Author: Sebastián Barschkis
Date:   Sun Feb 9 17:09:00 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB4a08eb0707fc17e4e97430ffa33eb7d3e36db712

Fluid: Updated manta pp files

Includes the OpenVDB read/write functions for int grids. This essential for the resume bake functionality in modular fluid caches.

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

M	extern/mantaflow/preprocessed/fileio/iogrids.cpp
M	extern/mantaflow/preprocessed/fileio/ioparticles.cpp
M	extern/mantaflow/preprocessed/fluidsolver.cpp
M	extern/mantaflow/preprocessed/gitinfo.h
M	extern/mantaflow/preprocessed/plugin/flip.cpp
M	extern/mantaflow/preprocessed/plugin/fluidguiding.cpp
M	extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp

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

diff --git a/extern/mantaflow/preprocessed/fileio/iogrids.cpp b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
index 2f6cdaa6209..2b8ee905f99 100644
--- a/extern/mantaflow/preprocessed/fileio/iogrids.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
@@ -954,6 +954,79 @@ template<class T> void readGridVDB(const string &name, Grid<T> *grid)
          1);
 }
 
+template<> void writeGridVDB(const string &name, Grid<int> *grid)
+{
+  debMsg("Writing int grid " << grid->getName() << " to vdb file " << name, 1);
+
+  // Create an empty int32-point grid with background value 0.
+  openvdb::initialize();
+  openvdb::Int32Grid::Ptr gridVDB = openvdb::Int32Grid::create();
+  gridVDB->setTransform(
+      openvdb::math::Transform::createLinearTransform(1. / grid->getSizeX()));  // voxel size
+
+  // Get an accessor for coordinate-based access to voxels.
+  openvdb::Int32Grid::Accessor accessor = gridVDB->getAccessor();
+
+  gridVDB->setGridClass(openvdb::GRID_UNKNOWN);
+
+  // Name the grid "density".
+  gridVDB->setName(grid->getName());
+
+  openvdb::io::File file(name);
+
+  FOR_IJK(*grid)
+  {
+    openvdb::Coord xyz(i, j, k);
+    accessor.setValue(xyz, (*grid)(i, j, k));
+  }
+
+  // Add the grid pointer to a container.
+  openvdb::GridPtrVec gridsVDB;
+  gridsVDB.push_back(gridVDB);
+
+  // Write out the contents of the container.
+  file.write(gridsVDB);
+  file.close();
+}
+
+template<> void readGridVDB(const string &name, Grid<int> *grid)
+{
+  debMsg("Reading int grid " << grid->getName() << " from vdb file " << name, 1);
+
+  openvdb::initialize();
+  openvdb::io::File file(name);
+  file.open();
+
+  openvdb::GridBase::Ptr baseGrid;
+  for (openvdb::io::File::NameIterator nameIter = file.beginName(); nameIter != file.endName();
+       ++nameIter) {
+#  ifndef BLENDER
+    // Read in only the grid we are interested in.
+    if (nameIter.gridName() == grid->getName()) {
+      baseGrid = file.readGrid(nameIter.gridName());
+    }
+    else {
+      debMsg("skipping grid " << nameIter.gridName(), 1);
+    }
+#  else
+    // For Blender, skip name check and pick first grid from loop
+    baseGrid = file.readGrid(nameIter.gridName());
+    break;
+#  endif
+  }
+  file.close();
+  openvdb::Int32Grid::Ptr gridVDB = openvdb::gridPtrCast<openvdb::Int32Grid>(baseGrid);
+
+  openvdb::Int32Grid::Accessor accessor = gridVDB->getAccessor();
+
+  FOR_IJK(*grid)
+  {
+    openvdb::Coord xyz(i, j, k);
+    int v = accessor.getValue(xyz);
+    (*grid)(i, j, k) = v;
+  }
+}
+
 template<> void writeGridVDB(const string &name, Grid<Real> *grid)
 {
   debMsg("Writing real grid " << grid->getName() << " to vdb file " << name, 1);
diff --git a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
index 432cbc9f100..a6cc7583327 100644
--- a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
+++ b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
@@ -310,6 +310,8 @@ template<class T> void readPdataUni(const std::string &name, ParticleDataImpl<T>
     UniPartHeader head;
     assertMsg(gzread(gzf, &head, sizeof(UniPartHeader)) == sizeof(UniPartHeader),
               "can't read file, no header present");
+    pdata->resize(head.dim);
+
     assertMsg(head.dim == pdata->size(), "pdata size doesn't match");
 #  if FLOATINGPOINT_PRECISION != 1
     ParticleDataImpl<T> temp(pdata->getParent());
diff --git a/extern/mantaflow/preprocessed/fluidsolver.cpp b/extern/mantaflow/preprocessed/fluidsolver.cpp
index 814d5444b15..8c48e60760b 100644
--- a/extern/mantaflow/preprocessed/fluidsolver.cpp
+++ b/extern/mantaflow/preprocessed/fluidsolver.cpp
@@ -136,9 +136,9 @@ FluidSolver::FluidSolver(Vec3i gridsize, int dim, int fourthDim)
       mDtMin(1.),
       mDtMax(1.),
       mFrameLength(1.),
+      mTimePerFrame(0.),
       mGridSize(gridsize),
       mDim(dim),
-      mTimePerFrame(0.),
       mLockDt(false),
       mFourthDim(fourthDim)
 {
diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h
index 6d3abd1e88e..943840958f6 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 3f5c7989fd82920f0c509844a06e97dd1069191c"
+#define MANTA_GIT_VERSION "commit abfff159b5ea8cee93d858f4b8be2a308b58b51d"
diff --git a/extern/mantaflow/preprocessed/plugin/flip.cpp b/extern/mantaflow/preprocessed/plugin/flip.cpp
index f6d082900b5..4dfeff1d0ac 100644
--- a/extern/mantaflow/preprocessed/plugin/flip.cpp
+++ b/extern/mantaflow/preprocessed/plugin/flip.cpp
@@ -1407,7 +1407,6 @@ struct correctLevelset : public KernelBase {
   {
     if (rAcc(i, j, k) <= VECTOR_EPSILON)
       return;  // outside nothing happens
-    Real x = pAcc(i, j, k).x;
 
     // create jacobian of pAcc via central differences
     Matrix3x3f jacobian = Matrix3x3f(0.5 * (pAcc(i + 1, j, k).x - pAcc(i - 1, j, k).x),
diff --git a/extern/mantaflow/preprocessed/plugin/fluidguiding.cpp b/extern/mantaflow/preprocessed/plugin/fluidguiding.cpp
index 13383581123..18a5a37771f 100644
--- a/extern/mantaflow/preprocessed/plugin/fluidguiding.cpp
+++ b/extern/mantaflow/preprocessed/plugin/fluidguiding.cpp
@@ -381,7 +381,6 @@ void getSpiralVelocity(const FlagGrid &flags,
     nz = flags.getSizeZ();
   Real midX = 0.5 * (Real)(nx - 1);
   Real midY = 0.5 * (Real)(ny - 1);
-  Real midZ = 0.5 * (Real)(nz - 1);
   for (int i = 0; i < nx; i++) {
     for (int j = 0; j < ny; j++) {
       for (int k = 0; k < nz; k++) {
diff --git a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
index 281e12ef04b..18582d57e64 100644
--- a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
+++ b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
@@ -1099,7 +1099,7 @@ void PbRegister_flipSampleSecondaryParticles()
 // evaluates cubic spline with radius h and distance l in dim dimensions
 Real cubicSpline(const Real h, const Real l, const int dim)
 {
-  const Real h2 = square(h), h3 = h2 * h, h4 = h3 * h, h5 = h4 * h;
+  const Real h2 = square(h), h3 = h2 * h;
   const Real c[] = {
       Real(2e0 / (3e0 * h)), Real(10e0 / (7e0 * M_PI * h2)), Real(1e0 / (M_PI * h3))};
   const Real q = l / h;
@@ -1175,9 +1175,6 @@ struct knFlipUpdateSecondaryParticlesLinear : public KernelBase {
     }
 
     Vec3i gridpos = toVec3i(pts_sec[idx].pos);
-    int i = gridpos.x;
-    int j = gridpos.y;
-    int k = gridpos.z;
 
     // spray particle
     if (neighborRatio(gridpos) < c_s) {



More information about the Bf-blender-cvs mailing list