diff options
| author | Marijn Tamis <[email protected]> | 2017-10-20 14:30:56 +0200 |
|---|---|---|
| committer | Marijn Tamis <[email protected]> | 2017-10-20 14:36:12 +0200 |
| commit | fabb251458f4a2d6d4f87dd36038fac2774b378c (patch) | |
| tree | 68a4a0ecd940dc949e0477d521d8c159968cfcd5 /NvCloth/src/cuda/CuSolver.cpp | |
| parent | NvCloth 1.1.2 Release. (22576033) (diff) | |
| download | nvcloth-fabb251458f4a2d6d4f87dd36038fac2774b378c.tar.xz nvcloth-fabb251458f4a2d6d4f87dd36038fac2774b378c.zip | |
NvCloth 1.1.3 Release. (23014067)v1.1.3
Diffstat (limited to 'NvCloth/src/cuda/CuSolver.cpp')
| -rw-r--r-- | NvCloth/src/cuda/CuSolver.cpp | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/NvCloth/src/cuda/CuSolver.cpp b/NvCloth/src/cuda/CuSolver.cpp index f0e328f..7ef1d32 100644 --- a/NvCloth/src/cuda/CuSolver.cpp +++ b/NvCloth/src/cuda/CuSolver.cpp @@ -302,6 +302,28 @@ cloth::CuSolver::~CuSolver() mFactory.mSolverCount--; } +void cloth::CuSolver::addClothAppend(Cloth* cloth) +{ + CuCloth& cuCloth = *static_cast<CuCloth*>(cloth); + + NV_CLOTH_ASSERT(mCloths.find(&cuCloth) == mCloths.end()); + + mCloths.pushBack(&cuCloth); + // trigger update of mClothData array + cuCloth.notifyChanged(); +} + +void cloth::CuSolver::addClothUpdateData() +{ + CuContextLock contextLock(mFactory); + + // resize containers and update kernel data + mClothDataHostCopy.resize(mCloths.size()); + mClothData.resize(mCloths.size()); + mFrameData.resize(mCloths.size()); + updateKernelData(); +} + void cloth::CuSolver::updateKernelData() { mKernelDataHost.mClothIndex = mClothIndex.get(); @@ -326,24 +348,17 @@ struct ClothSimCostGreater void cloth::CuSolver::addCloth(Cloth* cloth) { - CuCloth& cuCloth = *static_cast<CuCloth*>(cloth); - - NV_CLOTH_ASSERT(mCloths.find(&cuCloth) == mCloths.end()); - - mCloths.pushBack(&cuCloth); - // trigger update of mClothData array - cuCloth.notifyChanged(); - - // sort cloth instances by size - shdfnd::sort(mCloths.begin(), mCloths.size(), ClothSimCostGreater(), NonTrackingAllocator()); - - CuContextLock contextLock(mFactory); + addClothAppend(cloth); + addClothUpdateData(); +} - // resize containers and update kernel data - mClothDataHostCopy.resize(mCloths.size()); - mClothData.resize(mCloths.size()); - mFrameData.resize(mCloths.size()); - updateKernelData(); +void cloth::CuSolver::addCloths(Range<Cloth*> cloths) +{ + for (uint32_t i = 0; i < cloths.size(); ++i) + { + addClothAppend(*(cloths.begin() + i)); + } + addClothUpdateData(); } void cloth::CuSolver::removeCloth(Cloth* cloth) @@ -401,7 +416,8 @@ void cloth::CuSolver::endSimulation() int cloth::CuSolver::getSimulationChunkCount() const { - return 1; + // 0 chunks when no cloth present in the solver, 1 otherwise + return getNumCloths() != 0; } void cloth::CuSolver::beginFrame() |