aboutsummaryrefslogtreecommitdiff
path: root/NvCloth/src/dx/DxCloth.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NvCloth/src/dx/DxCloth.cpp')
-rw-r--r--NvCloth/src/dx/DxCloth.cpp137
1 files changed, 61 insertions, 76 deletions
diff --git a/NvCloth/src/dx/DxCloth.cpp b/NvCloth/src/dx/DxCloth.cpp
index f87943e..68c3289 100644
--- a/NvCloth/src/dx/DxCloth.cpp
+++ b/NvCloth/src/dx/DxCloth.cpp
@@ -36,7 +36,6 @@
#include "../TripletScheduler.h"
#include "../ClothBase.h"
#include <foundation/PxMat44.h>
-#include <PsFoundation.h>
#if NV_CLOTH_ENABLE_DX11
@@ -224,7 +223,7 @@ uint32_t cloth::DxCloth::getSharedMemorySize() const
return phaseConfigSize + sizeof(float) * (continuousCollisionSize + std::max(selfCollisionSize, discreteCollisionSize));
}
-void cloth::DxCloth::setPhaseConfig(Range<const PhaseConfig> configs)
+void cloth::DxCloth::setPhaseConfigInternal(Range<const PhaseConfig> configs)
{
mHostPhaseConfigs.assign(configs.begin(), configs.end());
@@ -332,71 +331,62 @@ namespace nv
namespace cloth
{
-// ClothImpl<DxCloth>::clone() implemented in DxClothClone.cpp
+// DxCloth::clone() implemented in DxClothClone.cpp
-template <>
-uint32_t ClothImpl<DxCloth>::getNumParticles() const
+uint32_t DxCloth::getNumParticles() const
{
- return mCloth.mNumParticles;
+ return mNumParticles;
}
-template <>
-void ClothImpl<DxCloth>::lockParticles() const
+void DxCloth::lockParticles() const
{
- const_cast<DxCloth&>(mCloth).mapParticles();
+ const_cast<DxCloth&>(*this).mapParticles();
}
-template <>
-void ClothImpl<DxCloth>::unlockParticles() const
+void DxCloth::unlockParticles() const
{
- const_cast<DxCloth&>(mCloth).unmapParticles();
+ const_cast<DxCloth&>(*this).unmapParticles();
}
-template <>
-MappedRange<PxVec4> ClothImpl<DxCloth>::getCurrentParticles()
+MappedRange<PxVec4> DxCloth::getCurrentParticles()
{
- mCloth.wakeUp();
+ wakeUp();
lockParticles();
- mCloth.mDeviceParticlesDirty = true;
- return getMappedParticles(mCloth.mParticlesMapPointer);
+ mDeviceParticlesDirty = true;
+ return getMappedParticles(mParticlesMapPointer);
}
-template <>
-MappedRange<const PxVec4> ClothImpl<DxCloth>::getCurrentParticles() const
+MappedRange<const PxVec4> DxCloth::getCurrentParticles() const
{
lockParticles();
- const PxVec4* data = mCloth.mParticlesMapPointer;
+ const PxVec4* data = mParticlesMapPointer;
return getMappedParticles(data);
}
-template <>
-MappedRange<PxVec4> ClothImpl<DxCloth>::getPreviousParticles()
+MappedRange<PxVec4> DxCloth::getPreviousParticles()
{
- mCloth.wakeUp();
+ wakeUp();
lockParticles();
- mCloth.mDeviceParticlesDirty = true;
- return getMappedParticles(mCloth.mParticlesMapPointer + mCloth.mNumParticles);
+ mDeviceParticlesDirty = true;
+ return getMappedParticles(mParticlesMapPointer + mNumParticles);
}
-template <>
-MappedRange<const PxVec4> ClothImpl<DxCloth>::getPreviousParticles() const
+MappedRange<const PxVec4> DxCloth::getPreviousParticles() const
{
lockParticles();
- const PxVec4* data = (const PxVec4*)mCloth.mParticlesMapPointer;
- return getMappedParticles(data + mCloth.mNumParticles);
+ const PxVec4* data = (const PxVec4*)mParticlesMapPointer;
+ return getMappedParticles(data + mNumParticles);
}
-template <>
-GpuParticles ClothImpl<DxCloth>::getGpuParticles()
+GpuParticles DxCloth::getGpuParticles()
{
- ID3D11Buffer* buffer = mCloth.mParticles.buffer();
- PxVec4* offset = (PxVec4*)nullptr + mCloth.mParticles.mOffset;
- GpuParticles result = { offset, offset + mCloth.mNumParticles, buffer };
+ ID3D11Buffer* buffer = mParticles.buffer();
+ PxVec4* offset = (PxVec4*)nullptr + mParticles.mOffset;
+ GpuParticles result = { offset, offset + mNumParticles, buffer };
return result;
}
-template <>
-void ClothImpl<DxCloth>::setPhaseConfig(Range<const PhaseConfig> configs)
+void DxCloth::setPhaseConfig(Range<const PhaseConfig> configs)
{
Vector<PhaseConfig>::Type transformedConfigs;
transformedConfigs.reserve(configs.size());
@@ -406,57 +396,53 @@ void ClothImpl<DxCloth>::setPhaseConfig(Range<const PhaseConfig> configs)
if (configs.front().mStiffness > 0.0f)
transformedConfigs.pushBack(transform(configs.front()));
- mCloth.setPhaseConfig(Range<const PhaseConfig>(transformedConfigs.begin(),
+ setPhaseConfigInternal(Range<const PhaseConfig>(transformedConfigs.begin(),
transformedConfigs.begin() + transformedConfigs.size()));
- mCloth.notifyChanged();
- mCloth.wakeUp();
+ notifyChanged();
+ wakeUp();
}
-template <>
-void ClothImpl<DxCloth>::setSelfCollisionIndices(Range<const uint32_t> indices)
+void DxCloth::setSelfCollisionIndices(Range<const uint32_t> indices)
{
- ContextLockType lock(mCloth.mFactory);
- mCloth.mSelfCollisionIndices.assign(indices.begin(), indices.end());
- mCloth.mSelfCollisionIndicesHost.assign(indices.begin(), indices.end());
- mCloth.notifyChanged();
- mCloth.wakeUp();
+ ContextLockType lock(mFactory);
+ mSelfCollisionIndices.assign(indices.begin(), indices.end());
+ mSelfCollisionIndicesHost.assign(indices.begin(), indices.end());
+ notifyChanged();
+ wakeUp();
}
-template <>
-uint32_t ClothImpl<DxCloth>::getNumVirtualParticles() const
+uint32_t DxCloth::getNumVirtualParticles() const
{
- return uint32_t(mCloth.mVirtualParticleIndices.size());
+ return uint32_t(mVirtualParticleIndices.size());
}
-template <>
-Range<PxVec4> ClothImpl<DxCloth>::getParticleAccelerations()
+Range<PxVec4> DxCloth::getParticleAccelerations()
{
- if (mCloth.mParticleAccelerations.empty())
+ if (mParticleAccelerations.empty())
{
- DxContextLock contextLock(mCloth.mFactory);
- mCloth.mParticleAccelerations.resize(mCloth.mNumParticles);
+ DxContextLock contextLock(mFactory);
+ mParticleAccelerations.resize(mNumParticles);
}
- if (!mCloth.mParticleAccelerationsHostCopy.capacity())
+ if (!mParticleAccelerationsHostCopy.capacity())
{
- DxContextLock contextLock(mCloth.mFactory);
- mCloth.mParticleAccelerationsHostCopy.reserve(mCloth.mNumParticles);
+ DxContextLock contextLock(mFactory);
+ mParticleAccelerationsHostCopy.reserve(mNumParticles);
}
- mCloth.mParticleAccelerationsHostCopy.resizeUninitialized(mCloth.mNumParticles);
+ mParticleAccelerationsHostCopy.resizeUninitialized(mNumParticles);
- mCloth.wakeUp();
+ wakeUp();
- PxVec4* data = mCloth.mParticleAccelerationsHostCopy.begin();
- return Range<PxVec4>(data, mCloth.mParticleAccelerationsHostCopy.end());
+ PxVec4* data = mParticleAccelerationsHostCopy.begin();
+ return Range<PxVec4>(data, mParticleAccelerationsHostCopy.end());
}
-template <>
-void ClothImpl<DxCloth>::clearParticleAccelerations()
+void DxCloth::clearParticleAccelerations()
{
- DxContextLock contextLock(mCloth.mFactory);
- mCloth.mParticleAccelerations.clear();
- Vector<PxVec4>::Type().swap(mCloth.mParticleAccelerationsHostCopy);
- mCloth.wakeUp();
+ DxContextLock contextLock(mFactory);
+ mParticleAccelerations.clear();
+ Vector<PxVec4>::Type().swap(mParticleAccelerationsHostCopy);
+ wakeUp();
}
namespace
@@ -488,12 +474,11 @@ uint32_t calculateNumReplays(const Vector<Vec4u>::Type& triplets, const Vector<u
}
}
-template <>
-void ClothImpl<DxCloth>::setVirtualParticles(Range<const uint32_t[4]> indices, Range<const PxVec3> weights)
+void DxCloth::setVirtualParticles(Range<const uint32_t[4]> indices, Range<const PxVec3> weights)
{
// shuffle indices to form independent SIMD sets
TripletScheduler scheduler(indices);
- scheduler.warp(mCloth.mNumParticles, 32);
+ scheduler.warp(mNumParticles, 32);
// convert to 16bit indices
Vector<Vec4us>::Type hostIndices;
@@ -516,15 +501,15 @@ void ClothImpl<DxCloth>::setVirtualParticles(Range<const uint32_t[4]> indices, R
hostWeights.pushBack(PxVec4(w.x, w.y, w.z, scale));
}
- DxContextLock contextLock(mCloth.mFactory);
+ DxContextLock contextLock(mFactory);
// todo: 'swap' these to force reallocation?
- mCloth.mVirtualParticleIndices = hostIndices;
- mCloth.mVirtualParticleSetSizes = scheduler.mSetSizes;
- mCloth.mVirtualParticleWeights = hostWeights;
+ mVirtualParticleIndices = hostIndices;
+ mVirtualParticleSetSizes = scheduler.mSetSizes;
+ mVirtualParticleWeights = hostWeights;
- mCloth.notifyChanged();
- mCloth.wakeUp();
+ notifyChanged();
+ wakeUp();
}
} // namespace cloth