diff options
| author | Marijn Tamis <[email protected]> | 2019-04-01 13:09:20 +0200 |
|---|---|---|
| committer | Marijn Tamis <[email protected]> | 2019-04-01 13:09:20 +0200 |
| commit | 2835d138450b20744c3b97e7ae827372ceac5958 (patch) | |
| tree | 8a1a38f613ee18d5bac1d24aa2d40059aadf8b73 /NvCloth/src | |
| parent | Update documentation that was missing from latest release. (diff) | |
| download | nvcloth-1.1.5.tar.xz nvcloth-1.1.5.zip | |
Add new SetSpheres and SetPlanes api's to bring them in line with setTriangles.1.1.5
Diffstat (limited to 'NvCloth/src')
| -rw-r--r-- | NvCloth/src/ClothImpl.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/NvCloth/src/ClothImpl.h b/NvCloth/src/ClothImpl.h index dde7cdd..6686cd7 100644 --- a/NvCloth/src/ClothImpl.h +++ b/NvCloth/src/ClothImpl.h @@ -109,12 +109,14 @@ class ClothImpl : public Cloth virtual uint32_t getAccelerationFilterWidth() const; virtual void setSpheres(Range<const physx::PxVec4>, uint32_t first, uint32_t last); + virtual void setSpheres(Range<const physx::PxVec4> startSpheres, Range<const physx::PxVec4> targetSpheres); virtual uint32_t getNumSpheres() const; virtual void setCapsules(Range<const uint32_t>, uint32_t first, uint32_t last); virtual uint32_t getNumCapsules() const; virtual void setPlanes(Range<const physx::PxVec4>, uint32_t first, uint32_t last); + virtual void setPlanes(Range<const physx::PxVec4> startPlanes, Range<const physx::PxVec4> targetPlanes); virtual uint32_t getNumPlanes() const; virtual void setConvexes(Range<const uint32_t>, uint32_t first, uint32_t last); @@ -617,6 +619,38 @@ inline void ClothImpl<T>::setSpheres(Range<const physx::PxVec4> spheres, uint32_ } template <typename T> +inline void ClothImpl<T>::setSpheres(Range<const physx::PxVec4> startSpheres, Range<const physx::PxVec4> targetSpheres) +{ + NV_CLOTH_ASSERT(startSpheres.size() == targetSpheres.size()); + + //Clamp ranges to the first 32 spheres + startSpheres = Range<const physx::PxVec4>(startSpheres.begin(), std::min(startSpheres.end(), startSpheres.begin() + 32)); + targetSpheres = Range<const physx::PxVec4>(targetSpheres.begin(), std::min(targetSpheres.end(), targetSpheres.begin() + 32)); + + uint32_t oldSize = uint32_t(getChildCloth()->mStartCollisionSpheres.size()); + uint32_t newSize = uint32_t(startSpheres.size()); + + if(newSize > std::min(getChildCloth()->mStartCollisionSpheres.capacity(), getChildCloth()->mTargetCollisionSpheres.capacity())) + { + //context lock only if we are growing the array + ContextLockType contextLock(getChildCloth()->mFactory); + getChildCloth()->mStartCollisionSpheres.assign(startSpheres.begin(), startSpheres.end()); + getChildCloth()->mTargetCollisionSpheres.assign(targetSpheres.begin(), targetSpheres.end()); + getChildCloth()->notifyChanged(); + } + else + { + getChildCloth()->mStartCollisionSpheres.assign(startSpheres.begin(), startSpheres.end()); + getChildCloth()->mTargetCollisionSpheres.assign(targetSpheres.begin(), targetSpheres.end()); + + if(newSize - oldSize) //notify only if the size changed + getChildCloth()->notifyChanged(); + } + + wakeUp(); +} + +template <typename T> inline uint32_t ClothImpl<T>::getNumSpheres() const { return uint32_t(getChildCloth()->mStartCollisionSpheres.size()); @@ -775,6 +809,38 @@ inline void ClothImpl<T>::setPlanes(Range<const physx::PxVec4> planes, uint32_t } template <typename T> +inline void ClothImpl<T>::setPlanes(Range<const physx::PxVec4> startPlanes, Range<const physx::PxVec4> targetPlanes) +{ + NV_CLOTH_ASSERT(startPlanes.size() == targetPlanes.size()); + + //Clamp ranges to the first 32 planes + startPlanes = Range<const physx::PxVec4>(startPlanes.begin(), std::min(startPlanes.end(), startPlanes.begin() + 32)); + targetPlanes = Range<const physx::PxVec4>(targetPlanes.begin(), std::min(targetPlanes.end(), targetPlanes.begin() + 32)); + + uint32_t oldSize = uint32_t(getChildCloth()->mStartCollisionPlanes.size()); + uint32_t newSize = uint32_t(startPlanes.size()); + + if(newSize > std::min(getChildCloth()->mStartCollisionPlanes.capacity(), getChildCloth()->mTargetCollisionPlanes.capacity())) + { + //context lock only if we are growing the array + ContextLockType contextLock(getChildCloth()->mFactory); + getChildCloth()->mStartCollisionPlanes.assign(startPlanes.begin(), startPlanes.end()); + getChildCloth()->mTargetCollisionPlanes.assign(targetPlanes.begin(), targetPlanes.end()); + getChildCloth()->notifyChanged(); + } + else + { + getChildCloth()->mStartCollisionPlanes.assign(startPlanes.begin(), startPlanes.end()); + getChildCloth()->mTargetCollisionPlanes.assign(targetPlanes.begin(), targetPlanes.end()); + + if(newSize - oldSize) //notify only if the size changed + getChildCloth()->notifyChanged(); + } + + wakeUp(); +} + +template <typename T> inline uint32_t ClothImpl<T>::getNumPlanes() const { return uint32_t(getChildCloth()->mStartCollisionPlanes.size()); |