Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastián Barschkis <sebbas@sebbas.org>2020-11-26 01:17:47 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-11-26 01:18:12 +0300
commite09d0c0d077cff79b55ce32ec5124d5faa73e2e7 (patch)
tree74dd76ecf5016e4b34ffb42b42b7eaae980b44d4 /extern/mantaflow/preprocessed/grid.h
parentf7223d5f722ac430041a748248b45c8590c3ffad (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.h')
-rw-r--r--extern/mantaflow/preprocessed/grid.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/extern/mantaflow/preprocessed/grid.h b/extern/mantaflow/preprocessed/grid.h
index 1f3dc2789ac..cf942a19e9a 100644
--- a/extern/mantaflow/preprocessed/grid.h
+++ b/extern/mantaflow/preprocessed/grid.h
@@ -402,7 +402,7 @@ class GridBase : public PbClass {
template<class T> class Grid : public GridBase {
public:
//! init new grid, values are set to zero
- Grid(FluidSolver *parent, bool show = true);
+ Grid(FluidSolver *parent, bool show = true, bool sparse = false);
static int _W_10(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
PbClass *obj = Pb::objFromPy(_self);
@@ -416,7 +416,8 @@ template<class T> class Grid : public GridBase {
ArgLocker _lock;
FluidSolver *parent = _args.getPtr<FluidSolver>("parent", 0, &_lock);
bool show = _args.getOpt<bool>("show", 1, true, &_lock);
- obj = new Grid(parent, show);
+ bool sparse = _args.getOpt<bool>("sparse", 2, false, &_lock);
+ obj = new Grid(parent, show, sparse);
obj->registerObject(_self, &_args);
_args.check();
}
@@ -581,6 +582,16 @@ template<class T> class Grid : public GridBase {
DEBUG_ONLY(checkIndex(idx));
return mData[idx];
}
+ //! raw data access
+ inline T *getData() const
+ {
+ return mData;
+ }
+ //! query if this grid should be saved as a sparse grid
+ inline bool saveSparse()
+ {
+ return mSaveSparse;
+ }
//! set data
inline void set(int i, int j, int k, T &val)
@@ -1290,7 +1301,8 @@ template<class T> class Grid : public GridBase {
protected:
T *mData;
- bool externalData; // True if mData is managed outside of the Fluidsolver
+ bool mExternalData; // True if mData is managed outside of the Fluidsolver
+ bool mSaveSparse; // True if this grid may be cached in a sparse structure
public:
PbArgs _args;
}
@@ -1302,7 +1314,8 @@ template<class T> class Grid : public GridBase {
//! Special function for staggered grids
class MACGrid : public Grid<Vec3> {
public:
- MACGrid(FluidSolver *parent, bool show = true) : Grid<Vec3>(parent, show)
+ MACGrid(FluidSolver *parent, bool show = true, bool sparse = false)
+ : Grid<Vec3>(parent, show, sparse)
{
mType = (GridType)(TypeMAC | TypeVec3);
}
@@ -1319,7 +1332,8 @@ class MACGrid : public Grid<Vec3> {
ArgLocker _lock;
FluidSolver *parent = _args.getPtr<FluidSolver>("parent", 0, &_lock);
bool show = _args.getOpt<bool>("show", 1, true, &_lock);
- obj = new MACGrid(parent, show);
+ bool sparse = _args.getOpt<bool>("sparse", 2, false, &_lock);
+ obj = new MACGrid(parent, show, sparse);
obj->registerObject(_self, &_args);
_args.check();
}
@@ -1425,7 +1439,8 @@ class MACGrid : public Grid<Vec3> {
//! Special functions for FlagGrid
class FlagGrid : public Grid<int> {
public:
- FlagGrid(FluidSolver *parent, int dim = 3, bool show = true) : Grid<int>(parent, show)
+ FlagGrid(FluidSolver *parent, int dim = 3, bool show = true, bool sparse = false)
+ : Grid<int>(parent, show, sparse)
{
mType = (GridType)(TypeFlags | TypeInt);
}
@@ -1443,7 +1458,8 @@ class FlagGrid : public Grid<int> {
FluidSolver *parent = _args.getPtr<FluidSolver>("parent", 0, &_lock);
int dim = _args.getOpt<int>("dim", 1, 3, &_lock);
bool show = _args.getOpt<bool>("show", 2, true, &_lock);
- obj = new FlagGrid(parent, dim, show);
+ bool sparse = _args.getOpt<bool>("sparse", 3, false, &_lock);
+ obj = new FlagGrid(parent, dim, show, sparse);
obj->registerObject(_self, &_args);
_args.check();
}