From b350eb5f4d44e8448115796144375d79438d74ae Mon Sep 17 00:00:00 2001 From: Marijn Tamis Date: Fri, 28 Apr 2017 14:19:07 +0200 Subject: NvCloth 1.1.0 Release. (22041545) --- NvCloth/src/SwCloth.cpp | 113 +++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 64 deletions(-) (limited to 'NvCloth/src/SwCloth.cpp') diff --git a/NvCloth/src/SwCloth.cpp b/NvCloth/src/SwCloth.cpp index f409ad6..6077ada 100644 --- a/NvCloth/src/SwCloth.cpp +++ b/NvCloth/src/SwCloth.cpp @@ -174,116 +174,101 @@ namespace nv namespace cloth { -template <> -Cloth* ClothImpl::clone(Factory& factory) const +Cloth* SwCloth::clone(Factory& factory) const { return factory.clone(*this); } -template <> -uint32_t ClothImpl::getNumParticles() const +uint32_t SwCloth::getNumParticles() const { - return uint32_t(mCloth.mCurParticles.size()); + return uint32_t(mCurParticles.size()); } -template <> -void ClothImpl::lockParticles() const +void SwCloth::lockParticles() const { } -template <> -void ClothImpl::unlockParticles() const +void SwCloth::unlockParticles() const { } -template <> -MappedRange ClothImpl::getCurrentParticles() +MappedRange SwCloth::getCurrentParticles() { - return getMappedParticles(&mCloth.mCurParticles.front()); + return getMappedParticles(&mCurParticles.front()); } -template <> -MappedRange ClothImpl::getCurrentParticles() const +MappedRange SwCloth::getCurrentParticles() const { - return getMappedParticles(&mCloth.mCurParticles.front()); + return getMappedParticles(&mCurParticles.front()); } -template <> -MappedRange ClothImpl::getPreviousParticles() +MappedRange SwCloth::getPreviousParticles() { - return getMappedParticles(&mCloth.mPrevParticles.front()); + return getMappedParticles(&mPrevParticles.front()); } -template <> -MappedRange ClothImpl::getPreviousParticles() const +MappedRange SwCloth::getPreviousParticles() const { - return getMappedParticles(&mCloth.mPrevParticles.front()); + return getMappedParticles(&mPrevParticles.front()); } -template <> -GpuParticles ClothImpl::getGpuParticles() +GpuParticles SwCloth::getGpuParticles() { GpuParticles result = { 0, 0, 0 }; return result; } -template <> -void ClothImpl::setPhaseConfig(Range configs) +void SwCloth::setPhaseConfig(Range configs) { - mCloth.mPhaseConfigs.resize(0); + mPhaseConfigs.resize(0); // transform phase config to use in solver for (; !configs.empty(); configs.popFront()) if (configs.front().mStiffness > 0.0f) - mCloth.mPhaseConfigs.pushBack(transform(configs.front())); + mPhaseConfigs.pushBack(transform(configs.front())); - mCloth.wakeUp(); + wakeUp(); } -template <> -void ClothImpl::setSelfCollisionIndices(Range indices) +void SwCloth::setSelfCollisionIndices(Range indices) { - ContextLockType lock(mCloth.mFactory); - mCloth.mSelfCollisionIndices.assign(indices.begin(), indices.end()); - mCloth.notifyChanged(); - mCloth.wakeUp(); + ContextLockType lock(mFactory); + mSelfCollisionIndices.assign(indices.begin(), indices.end()); + notifyChanged(); + wakeUp(); } -template <> -uint32_t ClothImpl::getNumVirtualParticles() const +uint32_t SwCloth::getNumVirtualParticles() const { - return uint32_t(mCloth.mNumVirtualParticles); + return uint32_t(mNumVirtualParticles); } -template <> -Range ClothImpl::getParticleAccelerations() +Range SwCloth::getParticleAccelerations() { - if (mCloth.mParticleAccelerations.empty()) + if (mParticleAccelerations.empty()) { - uint32_t n = uint32_t(mCloth.mCurParticles.size()); - mCloth.mParticleAccelerations.resize(n, PxVec4(0.0f)); + uint32_t n = uint32_t(mCurParticles.size()); + mParticleAccelerations.resize(n, PxVec4(0.0f)); } - mCloth.wakeUp(); + wakeUp(); - PxVec4* data = &mCloth.mParticleAccelerations.front(); - return Range(data, data + mCloth.mParticleAccelerations.size()); + PxVec4* data = &mParticleAccelerations.front(); + return Range(data, data + mParticleAccelerations.size()); } -template <> -void ClothImpl::clearParticleAccelerations() +void SwCloth::clearParticleAccelerations() { - Vector::Type().swap(mCloth.mParticleAccelerations); - mCloth.wakeUp(); + Vector::Type().swap(mParticleAccelerations); + wakeUp(); } -template <> -void ClothImpl::setVirtualParticles(Range indices, Range weights) +void SwCloth::setVirtualParticles(Range indices, Range weights) { - mCloth.mNumVirtualParticles = 0; + mNumVirtualParticles = 0; // shuffle indices to form independent SIMD sets - uint16_t numParticles = uint16_t(mCloth.mCurParticles.size()); + uint16_t numParticles = uint16_t(mCurParticles.size()); TripletScheduler scheduler(indices); scheduler.simd(numParticles, 4); @@ -292,29 +277,29 @@ void ClothImpl::setVirtualParticles(Range indices, R Vector::Type::ConstIterator sIt = scheduler.mSetSizes.begin(); Vector::Type::ConstIterator sEnd = scheduler.mSetSizes.end(); TripletScheduler::ConstTripletIter tIt = scheduler.mTriplets.begin(), tLast; - mCloth.mVirtualParticleIndices.resize(0); - mCloth.mVirtualParticleIndices.reserve(indices.size() + 3 * uint32_t(sEnd - sIt)); + mVirtualParticleIndices.resize(0); + mVirtualParticleIndices.reserve(indices.size() + 3 * uint32_t(sEnd - sIt)); for (; sIt != sEnd; ++sIt) { uint32_t setSize = *sIt; - for (tLast = tIt + setSize; tIt != tLast; ++tIt, ++mCloth.mNumVirtualParticles) - mCloth.mVirtualParticleIndices.pushBack(Vec4us(*tIt)); - mCloth.mVirtualParticleIndices.resize((mCloth.mVirtualParticleIndices.size() + 3) & ~3, dummy); + for (tLast = tIt + setSize; tIt != tLast; ++tIt, ++mNumVirtualParticles) + mVirtualParticleIndices.pushBack(Vec4us(*tIt)); + mVirtualParticleIndices.resize((mVirtualParticleIndices.size() + 3) & ~3, dummy); } - Vector::Type(mCloth.mVirtualParticleIndices.begin(), mCloth.mVirtualParticleIndices.end()) - .swap(mCloth.mVirtualParticleIndices); + Vector::Type(mVirtualParticleIndices.begin(), mVirtualParticleIndices.end()) + .swap(mVirtualParticleIndices); // precompute 1/dot(w,w) - Vector::Type().swap(mCloth.mVirtualParticleWeights); - mCloth.mVirtualParticleWeights.reserve(weights.size()); + Vector::Type().swap(mVirtualParticleWeights); + mVirtualParticleWeights.reserve(weights.size()); for (; !weights.empty(); weights.popFront()) { PxVec3 w = weights.front(); float scale = 1 / w.magnitudeSquared(); - mCloth.mVirtualParticleWeights.pushBack(PxVec4( w.x, w.y, w.z, scale )); + mVirtualParticleWeights.pushBack(PxVec4( w.x, w.y, w.z, scale )); } - mCloth.notifyChanged(); + notifyChanged(); } } // namespace cloth -- cgit v1.2.3