diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2020-11-26 01:17:47 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2020-11-26 01:18:12 +0300 |
commit | e09d0c0d077cff79b55ce32ec5124d5faa73e2e7 (patch) | |
tree | 74dd76ecf5016e4b34ffb42b42b7eaae980b44d4 /extern/mantaflow/preprocessed/grid.cpp | |
parent | f7223d5f722ac430041a748248b45c8590c3ffad (diff) |
Fluid: Updated Mantaflow source files
This update introduces two improvements from the Mantaflow repository:
(1) Improved particle sampling:
- Liquid and secondary particles are sampled more predictably. With all parameters being equal, baked particles will be computed at the exact same position during every bake.
- Before, this was not guaranteed.
(2) Sparse grid caching:
- While saving grid data to disk, grids will from now on be saved in a sparse structure whenever possible (e.g. density, flame but not levelsets).
- With the sparse optimization grid cells with a value under the 'Empty Space' value (already present in domain settings) will not be cached.
- The main benefits of this optimization are: Smaller cache sizes and faster playback of simulation data in the viewport.
- This optimization works 'out-of-the-box'. There is no option in the UI to enable it.
- For now, only smoke simulation grids will take advantage of this optimization.
Diffstat (limited to 'extern/mantaflow/preprocessed/grid.cpp')
-rw-r--r-- | extern/mantaflow/preprocessed/grid.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/extern/mantaflow/preprocessed/grid.cpp b/extern/mantaflow/preprocessed/grid.cpp index cf8e4635462..61672129f37 100644 --- a/extern/mantaflow/preprocessed/grid.cpp +++ b/extern/mantaflow/preprocessed/grid.cpp @@ -60,7 +60,7 @@ template<> inline GridBase::GridType typeList<Vec3>() } template<class T> -Grid<T>::Grid(FluidSolver *parent, bool show) : GridBase(parent), externalData(false) +Grid<T>::Grid(FluidSolver *parent, bool show, bool sparse) : GridBase(parent), mExternalData(false) { mType = typeList<T>(); mSize = parent->getGridSize(); @@ -70,22 +70,23 @@ Grid<T>::Grid(FluidSolver *parent, bool show) : GridBase(parent), externalData(f mDx = 1.0 / mSize.max(); clear(); setHidden(!show); + +#if OPENVDB == 1 + mSaveSparse = sparse; +#else + if (sparse) + debMsg("Cannot enable sparse save option without OpenVDB", 1); + mSaveSparse = false; +#endif } template<class T> -Grid<T>::Grid(FluidSolver *parent, T *data, bool show) - : GridBase(parent), mData(data), externalData(true) +Grid<T>::Grid(FluidSolver *parent, T *data, bool show) : Grid<T>::Grid(parent, show) { - mType = typeList<T>(); - mSize = parent->getGridSize(); - - mStrideZ = parent->is2D() ? 0 : (mSize.x * mSize.y); - mDx = 1.0 / mSize.max(); - - setHidden(!show); + mData = data; } -template<class T> Grid<T>::Grid(const Grid<T> &a) : GridBase(a.getParent()), externalData(false) +template<class T> Grid<T>::Grid(const Grid<T> &a) : GridBase(a.getParent()), mExternalData(false) { mSize = a.mSize; mType = a.mType; @@ -98,7 +99,7 @@ template<class T> Grid<T>::Grid(const Grid<T> &a) : GridBase(a.getParent()), ext template<class T> Grid<T>::~Grid() { - if (!externalData) { + if (!mExternalData) { mParent->freeGridPointer<T>(mData); } } @@ -114,8 +115,8 @@ template<class T> void Grid<T>::swap(Grid<T> &other) other.getSizeZ() != getSizeZ()) errMsg("Grid::swap(): Grid dimensions mismatch."); - if (externalData || other.externalData) - errMsg("Grid::swap(): Cannot swap if one grid stores externalData."); + if (mExternalData || other.mExternalData) + errMsg("Grid::swap(): Cannot swap if one grid stores mExternalData."); T *dswap = other.mData; other.mData = mData; |