aboutsummaryrefslogtreecommitdiff
path: root/NvCloth/src/SwSolver.cpp
diff options
context:
space:
mode:
authorMarijn Tamis <[email protected]>2017-04-28 14:19:07 +0200
committerMarijn Tamis <[email protected]>2017-04-28 14:19:07 +0200
commitb350eb5f4d44e8448115796144375d79438d74ae (patch)
tree8e102e8c28f45a1b87bd335ceee4f33c3d4ee7c2 /NvCloth/src/SwSolver.cpp
parentAdd visual samples. (diff)
downloadnvcloth-b350eb5f4d44e8448115796144375d79438d74ae.tar.xz
nvcloth-b350eb5f4d44e8448115796144375d79438d74ae.zip
NvCloth 1.1.0 Release. (22041545)
Diffstat (limited to 'NvCloth/src/SwSolver.cpp')
-rw-r--r--NvCloth/src/SwSolver.cpp48
1 files changed, 38 insertions, 10 deletions
diff --git a/NvCloth/src/SwSolver.cpp b/NvCloth/src/SwSolver.cpp
index c83eed8..c7437e1 100644
--- a/NvCloth/src/SwSolver.cpp
+++ b/NvCloth/src/SwSolver.cpp
@@ -93,29 +93,57 @@ void sortTasks(shdfnd::Array<T, cloth::NonTrackingAllocator>& tasks)
void cloth::SwSolver::addCloth(Cloth* cloth)
{
- SwCloth& swCloth = static_cast<SwClothImpl&>(*cloth).mCloth;
+ SwCloth& swCloth = *static_cast<SwCloth*>(cloth);
mSimulatedCloths.pushBack(SimulatedCloth(swCloth, this));
sortTasks(mSimulatedCloths);
+
+ mCloths.pushBack(&swCloth);
}
void cloth::SwSolver::removeCloth(Cloth* cloth)
{
- SwCloth& swCloth = static_cast<SwClothImpl&>(*cloth).mCloth;
+ SwCloth& swCloth = *static_cast<SwCloth*>(cloth);
- Vector<SimulatedCloth>::Type::Iterator tIt = mSimulatedCloths.begin();
- Vector<SimulatedCloth>::Type::Iterator tEnd = mSimulatedCloths.end();
- while (tIt != tEnd && tIt->mCloth != &swCloth)
- ++tIt;
+ //Remove from mSimulatedCloths
+ {
+ Vector<SimulatedCloth>::Type::Iterator tIt = mSimulatedCloths.begin();
+ Vector<SimulatedCloth>::Type::Iterator tEnd = mSimulatedCloths.end();
+ while(tIt != tEnd && tIt->mCloth != &swCloth)
+ ++tIt;
+
+ if(tIt != tEnd)
+ {
+ NV_CLOTH_FREE(tIt->mScratchMemory);
+ mSimulatedCloths.replaceWithLast(tIt);
+ sortTasks(mSimulatedCloths);
+ }
+ }
- if (tIt != tEnd)
+ //Remove from mCloths
{
- NV_CLOTH_FREE(tIt->mScratchMemory);
- mSimulatedCloths.replaceWithLast(tIt);
- sortTasks(mSimulatedCloths);
+ ClothVector::Iterator tEnd = mCloths.end();
+ ClothVector::Iterator it = mCloths.find(&swCloth);
+
+ if(it != tEnd)
+ {
+ mCloths.replaceWithLast(it);
+ }
}
}
+int cloth::SwSolver::getNumCloths() const
+{
+ return mCloths.size();
+}
+cloth::Cloth * const * cloth::SwSolver::getClothList() const
+{
+ if(getNumCloths())
+ return reinterpret_cast<Cloth* const*>(&mCloths[0]);
+ else
+ return nullptr;
+}
+
bool cloth::SwSolver::beginSimulation(float dt)
{
if (mSimulatedCloths.empty())