diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/module/clothing/embedded/LowLevelCloth/src/SwClothData.cpp | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'APEX_1.4/module/clothing/embedded/LowLevelCloth/src/SwClothData.cpp')
| -rw-r--r-- | APEX_1.4/module/clothing/embedded/LowLevelCloth/src/SwClothData.cpp | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/APEX_1.4/module/clothing/embedded/LowLevelCloth/src/SwClothData.cpp b/APEX_1.4/module/clothing/embedded/LowLevelCloth/src/SwClothData.cpp new file mode 100644 index 00000000..bc09612f --- /dev/null +++ b/APEX_1.4/module/clothing/embedded/LowLevelCloth/src/SwClothData.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#include "SwClothData.h" +#include "SwCloth.h" +#include "SwFabric.h" +#include "Simd4f.h" +#include "PsUtilities.h" + +using namespace nvidia; + +cloth::SwClothData::SwClothData(SwCloth& cloth, const SwFabric& fabric) +{ + mNumParticles = uint32_t(cloth.mCurParticles.size()); + mCurParticles = array(cloth.mCurParticles.front()); + mPrevParticles = array(cloth.mPrevParticles.front()); + + const float* center = array(cloth.mParticleBoundsCenter); + const float* extent = array(cloth.mParticleBoundsHalfExtent); + for(uint32_t i = 0; i < 3; ++i) + { + mCurBounds[i] = center[i] - extent[i]; + mCurBounds[i + 3] = center[i] + extent[i]; + } + + // avoid reading uninitialized data into mCurBounds, even though it's never used. + mPrevBounds[0] = 0.0f; + + mConfigBegin = cloth.mPhaseConfigs.empty() ? 0 : &cloth.mPhaseConfigs.front(); + mConfigEnd = mConfigBegin + cloth.mPhaseConfigs.size(); + + mPhases = &fabric.mPhases.front(); + mNumPhases = uint32_t(fabric.mPhases.size()); + + mSets = &fabric.mSets.front(); + mNumSets = uint32_t(fabric.mSets.size()); + + mRestvalues = &fabric.mRestvalues.front(); + mNumRestvalues = uint32_t(fabric.mRestvalues.size()); + + mIndices = &fabric.mIndices.front(); + mNumIndices = uint32_t(fabric.mIndices.size()); + + float stiffnessExponent = cloth.mStiffnessFrequency * cloth.mPrevIterDt * 0.69314718055994531f; // logf(2.0f); + + mTethers = fabric.mTethers.begin(); + mNumTethers = uint32_t(fabric.mTethers.size()); + mTetherConstraintStiffness = 1.0f - exp(stiffnessExponent * cloth.mTetherConstraintLogStiffness); + mTetherConstraintScale = cloth.mTetherConstraintScale * fabric.mTetherLengthScale; + + mStartMotionConstraints = cloth.mMotionConstraints.mStart.size() ? array(cloth.mMotionConstraints.mStart.front()) : 0; + mTargetMotionConstraints = + !cloth.mMotionConstraints.mTarget.empty() ? array(cloth.mMotionConstraints.mTarget.front()) : 0; + mMotionConstraintStiffness = 1.0f - exp(stiffnessExponent * cloth.mMotionConstraintLogStiffness); + + mStartSeparationConstraints = + cloth.mSeparationConstraints.mStart.size() ? array(cloth.mSeparationConstraints.mStart.front()) : 0; + mTargetSeparationConstraints = + !cloth.mSeparationConstraints.mTarget.empty() ? array(cloth.mSeparationConstraints.mTarget.front()) : 0; + + mParticleAccelerations = cloth.mParticleAccelerations.size() ? array(cloth.mParticleAccelerations.front()) : 0; + + mStartCollisionSpheres = cloth.mStartCollisionSpheres.empty() ? 0 : array(cloth.mStartCollisionSpheres.front()); + mTargetCollisionSpheres = + cloth.mTargetCollisionSpheres.empty() ? mStartCollisionSpheres : array(cloth.mTargetCollisionSpheres.front()); + mNumSpheres = uint32_t(cloth.mStartCollisionSpheres.size()); + + mCapsuleIndices = cloth.mCapsuleIndices.empty() ? 0 : &cloth.mCapsuleIndices.front(); + mNumCapsules = uint32_t(cloth.mCapsuleIndices.size()); + + mStartCollisionPlanes = cloth.mStartCollisionPlanes.empty() ? 0 : array(cloth.mStartCollisionPlanes.front()); + mTargetCollisionPlanes = + cloth.mTargetCollisionPlanes.empty() ? mStartCollisionPlanes : array(cloth.mTargetCollisionPlanes.front()); + mNumPlanes = uint32_t(cloth.mStartCollisionPlanes.size()); + + mConvexMasks = cloth.mConvexMasks.empty() ? 0 : &cloth.mConvexMasks.front(); + mNumConvexes = uint32_t(cloth.mConvexMasks.size()); + + mStartCollisionTriangles = cloth.mStartCollisionTriangles.empty() ? 0 : array(cloth.mStartCollisionTriangles.front()); + mTargetCollisionTriangles = cloth.mTargetCollisionTriangles.empty() ? mStartCollisionTriangles + : array(cloth.mTargetCollisionTriangles.front()); + mNumTriangles = uint32_t(cloth.mStartCollisionTriangles.size()) / 3; + + mVirtualParticlesBegin = cloth.mVirtualParticleIndices.empty() ? 0 : array(cloth.mVirtualParticleIndices.front()); + mVirtualParticlesEnd = mVirtualParticlesBegin + 4 * cloth.mVirtualParticleIndices.size(); + mVirtualParticleWeights = cloth.mVirtualParticleWeights.empty() ? 0 : array(cloth.mVirtualParticleWeights.front()); + mNumVirtualParticleWeights = uint32_t(cloth.mVirtualParticleWeights.size()); + + mEnableContinuousCollision = cloth.mEnableContinuousCollision; + mCollisionMassScale = cloth.mCollisionMassScale; + mFrictionScale = cloth.mFriction; + + mSelfCollisionDistance = cloth.mSelfCollisionDistance; + mSelfCollisionStiffness = 1.0f - exp(stiffnessExponent * cloth.mSelfCollisionLogStiffness); + + mSelfCollisionIndices = cloth.mSelfCollisionIndices.empty() ? 0 : cloth.mSelfCollisionIndices.begin(); + mNumSelfCollisionIndices = mSelfCollisionIndices ? cloth.mSelfCollisionIndices.size() : mNumParticles; + + mRestPositions = cloth.mRestPositions.size() ? array(cloth.mRestPositions.front()) : 0; + + mSleepPassCounter = cloth.mSleepPassCounter; + mSleepTestCounter = cloth.mSleepTestCounter; +} + +void cloth::SwClothData::reconcile(SwCloth& cloth) const +{ + cloth.setParticleBounds(mCurBounds); + cloth.mSleepTestCounter = mSleepTestCounter; + cloth.mSleepPassCounter = mSleepPassCounter; +} + +void cloth::SwClothData::verify() const +{ + // checks needs to be run after the constructor because + + PX_ASSERT(!mNumCapsules || + mNumSpheres > *nvidia::maxElement(&mCapsuleIndices->first, &(mCapsuleIndices + mNumCapsules)->first)); + + PX_ASSERT(!mNumConvexes || (1u << mNumPlanes) - 1 >= *nvidia::maxElement(mConvexMasks, mConvexMasks + mNumConvexes)); +} |