diff options
author | Julian Eisel <julian@blender.org> | 2020-06-05 14:09:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-06-05 14:09:31 +0300 |
commit | 920a58d9b6d667894cf166cbbd25e4c2fbd238ea (patch) | |
tree | 7ca5a9da640753b5e070c439ac3bdd14dfad92cf /extern/mantaflow/preprocessed/particle.h | |
parent | c94b6209861ca7cc3985b53474feed7d94c0221a (diff) | |
parent | a1d55bdd530390e58c51abe9707b8d3b0ae3e861 (diff) |
Merge branch 'master' into wm-drag-drop-rewritewm-drag-drop-rewrite
Diffstat (limited to 'extern/mantaflow/preprocessed/particle.h')
-rw-r--r-- | extern/mantaflow/preprocessed/particle.h | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/extern/mantaflow/preprocessed/particle.h b/extern/mantaflow/preprocessed/particle.h index 2d41397a961..d9dd3f49c38 100644 --- a/extern/mantaflow/preprocessed/particle.h +++ b/extern/mantaflow/preprocessed/particle.h @@ -469,6 +469,7 @@ template<class S> class ParticleSystem : public ParticleBase { const int integrationMode, const bool deleteInObstacle = true, const bool stopInObstacle = true, + const bool skipNew = false, const ParticleDataImpl<int> *ptype = NULL, const int exclude = 0); static PyObject *_W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds) @@ -486,13 +487,20 @@ template<class S> class ParticleSystem : public ParticleBase { const int integrationMode = _args.get<int>("integrationMode", 2, &_lock); const bool deleteInObstacle = _args.getOpt<bool>("deleteInObstacle", 3, true, &_lock); const bool stopInObstacle = _args.getOpt<bool>("stopInObstacle", 4, true, &_lock); + const bool skipNew = _args.getOpt<bool>("skipNew", 5, false, &_lock); const ParticleDataImpl<int> *ptype = _args.getPtrOpt<ParticleDataImpl<int>>( - "ptype", 5, NULL, &_lock); - const int exclude = _args.getOpt<int>("exclude", 6, 0, &_lock); + "ptype", 6, NULL, &_lock); + const int exclude = _args.getOpt<int>("exclude", 7, 0, &_lock); pbo->_args.copy(_args); _retval = getPyNone(); - pbo->advectInGrid( - flags, vel, integrationMode, deleteInObstacle, stopInObstacle, ptype, exclude); + pbo->advectInGrid(flags, + vel, + integrationMode, + deleteInObstacle, + stopInObstacle, + skipNew, + ptype, + exclude); pbo->_args.check(); } pbFinalizePlugin(pbo->getParent(), "ParticleSystem::advectInGrid", !noTiming); @@ -1863,6 +1871,7 @@ template<class S> struct _GridAdvectKernel : public KernelBase { const Real dt, const bool deleteInObstacle, const bool stopInObstacle, + const bool skipNew, const ParticleDataImpl<int> *ptype, const int exclude, std::vector<Vec3> &u) @@ -1873,6 +1882,7 @@ template<class S> struct _GridAdvectKernel : public KernelBase { dt(dt), deleteInObstacle(deleteInObstacle), stopInObstacle(stopInObstacle), + skipNew(skipNew), ptype(ptype), exclude(exclude), u(u) @@ -1885,11 +1895,13 @@ template<class S> struct _GridAdvectKernel : public KernelBase { const Real dt, const bool deleteInObstacle, const bool stopInObstacle, + const bool skipNew, const ParticleDataImpl<int> *ptype, const int exclude, std::vector<Vec3> &u) const { - if ((p[idx].flag & ParticleBase::PDELETE) || (ptype && ((*ptype)[idx] & exclude))) { + if ((p[idx].flag & ParticleBase::PDELETE) || (ptype && ((*ptype)[idx] & exclude)) || + (skipNew && (p[idx].flag & ParticleBase::PNEW))) { u[idx] = 0.; return; } @@ -1910,7 +1922,7 @@ template<class S> struct _GridAdvectKernel : public KernelBase { void operator()(const tbb::blocked_range<IndexInt> &__r) const { for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++) - op(idx, p, vel, flags, dt, deleteInObstacle, stopInObstacle, ptype, exclude, u); + op(idx, p, vel, flags, dt, deleteInObstacle, stopInObstacle, skipNew, ptype, exclude, u); } void run() { @@ -1922,6 +1934,7 @@ template<class S> struct _GridAdvectKernel : public KernelBase { const Real dt; const bool deleteInObstacle; const bool stopInObstacle; + const bool skipNew; const ParticleDataImpl<int> *ptype; const int exclude; std::vector<Vec3> &u; @@ -1933,6 +1946,7 @@ template<class S> struct GridAdvectKernel : public KernelBase { const Real dt, const bool deleteInObstacle, const bool stopInObstacle, + const bool skipNew, const ParticleDataImpl<int> *ptype, const int exclude) : KernelBase(p.size()), @@ -1943,6 +1957,7 @@ template<class S> struct GridAdvectKernel : public KernelBase { dt, deleteInObstacle, stopInObstacle, + skipNew, ptype, exclude, u), @@ -1952,6 +1967,7 @@ template<class S> struct GridAdvectKernel : public KernelBase { dt(dt), deleteInObstacle(deleteInObstacle), stopInObstacle(stopInObstacle), + skipNew(skipNew), ptype(ptype), exclude(exclude), u((size)) @@ -2001,16 +2017,21 @@ template<class S> struct GridAdvectKernel : public KernelBase { return stopInObstacle; } typedef bool type5; - inline const ParticleDataImpl<int> *getArg6() + inline const bool &getArg6() + { + return skipNew; + } + typedef bool type6; + inline const ParticleDataImpl<int> *getArg7() { return ptype; } - typedef ParticleDataImpl<int> type6; - inline const int &getArg7() + typedef ParticleDataImpl<int> type7; + inline const int &getArg8() { return exclude; } - typedef int type7; + typedef int type8; void runMessage() { debMsg("Executing kernel GridAdvectKernel ", 3); @@ -2025,6 +2046,7 @@ template<class S> struct GridAdvectKernel : public KernelBase { const Real dt; const bool deleteInObstacle; const bool stopInObstacle; + const bool skipNew; const ParticleDataImpl<int> *ptype; const int exclude; std::vector<Vec3> u; @@ -2195,6 +2217,7 @@ void ParticleSystem<S>::advectInGrid(const FlagGrid &flags, const int integrationMode, const bool deleteInObstacle, const bool stopInObstacle, + const bool skipNew, const ParticleDataImpl<int> *ptype, const int exclude) { @@ -2208,8 +2231,15 @@ void ParticleSystem<S>::advectInGrid(const FlagGrid &flags, } // update positions - GridAdvectKernel<S> kernel( - mData, vel, flags, getParent()->getDt(), deleteInObstacle, stopInObstacle, ptype, exclude); + GridAdvectKernel<S> kernel(mData, + vel, + flags, + getParent()->getDt(), + deleteInObstacle, + stopInObstacle, + skipNew, + ptype, + exclude); integratePointSet(kernel, integrationMode); if (!deleteInObstacle) { @@ -2438,15 +2468,15 @@ template<class S> void ParticleSystem<S>::compress() //! insert buffered positions as new particles, update additional particle data template<class S> void ParticleSystem<S>::insertBufferedParticles() { + // clear new flag everywhere + for (IndexInt i = 0; i < (IndexInt)mData.size(); ++i) + mData[i].flag &= ~PNEW; + if (mNewBufferPos.size() == 0) return; IndexInt newCnt = mData.size(); resizeAll(newCnt + mNewBufferPos.size()); - // clear new flag everywhere - for (IndexInt i = 0; i < (IndexInt)mData.size(); ++i) - mData[i].flag &= ~PNEW; - for (IndexInt i = 0; i < (IndexInt)mNewBufferPos.size(); ++i) { int flag = (mNewBufferFlag.size() > 0) ? mNewBufferFlag[i] : 0; // note, other fields are not initialized here... |