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 /PhysX_3.4/Source/LowLevel/common/include/pipeline | |
| 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 'PhysX_3.4/Source/LowLevel/common/include/pipeline')
12 files changed, 1283 insertions, 0 deletions
diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcCCDStateStreamPair.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcCCDStateStreamPair.h new file mode 100644 index 00000000..cf29bad0 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcCCDStateStreamPair.h @@ -0,0 +1,29 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcConstraintBlockStream.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcConstraintBlockStream.h new file mode 100644 index 00000000..37c0ba8e --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcConstraintBlockStream.h @@ -0,0 +1,166 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + + +#ifndef PXC_CONSTRAINTBLOCKPOOL_H +#define PXC_CONSTRAINTBLOCKPOOL_H + +#include "PxvConfig.h" +#include "PsArray.h" +#include "PsMutex.h" +#include "PxcNpMemBlockPool.h" + +namespace physx +{ + +class PxsConstraintBlockManager +{ +public: + PxsConstraintBlockManager(PxcNpMemBlockPool & blockPool): + mBlockPool(blockPool) + { + } + + + PX_FORCE_INLINE void reset() + { + mBlockPool.releaseConstraintBlocks(mTrackingArray); + } + + + PxcNpMemBlockArray mTrackingArray; + PxcNpMemBlockPool& mBlockPool; + +private: + PxsConstraintBlockManager& operator=(const PxsConstraintBlockManager&); +}; + +class PxcConstraintBlockStream +{ + PX_NOCOPY(PxcConstraintBlockStream) +public: + PxcConstraintBlockStream(PxcNpMemBlockPool & blockPool): + mBlockPool(blockPool), + mBlock(NULL), + mUsed(0) + { + } + + PX_FORCE_INLINE PxU8* reserve(PxU32 size, PxsConstraintBlockManager& manager) + { + size = (size+15)&~15; + if(size>PxcNpMemBlock::SIZE) + return mBlockPool.acquireExceptionalConstraintMemory(size); + + if(mBlock == NULL || size+mUsed>PxcNpMemBlock::SIZE) + { + mBlock = mBlockPool.acquireConstraintBlock(manager.mTrackingArray); + PX_ASSERT(0==mBlock || mBlock->data == reinterpret_cast<PxU8*>(mBlock)); + mUsed = size; + return reinterpret_cast<PxU8*>(mBlock); + } + PX_ASSERT(mBlock && mBlock->data == reinterpret_cast<PxU8*>(mBlock)); + PxU8* PX_RESTRICT result = mBlock->data+mUsed; + mUsed += size; + return result; + } + + PX_FORCE_INLINE void reset() + { + mBlock = NULL; + mUsed = 0; + } + + PX_FORCE_INLINE PxcNpMemBlockPool& getMemBlockPool() + { + return mBlockPool; + } + +private: + PxcNpMemBlockPool& mBlockPool; + PxcNpMemBlock* mBlock; // current constraint block + PxU32 mUsed; // number of bytes used in constraint block + //Tracking peak allocations + PxU32 mPeakUsed; +}; + +class PxcContactBlockStream +{ + PX_NOCOPY(PxcContactBlockStream) +public: + PxcContactBlockStream(PxcNpMemBlockPool & blockPool): + mBlockPool(blockPool), + mBlock(NULL), + mUsed(0) + { + } + + PX_FORCE_INLINE PxU8* reserve(PxU32 size) + { + size = (size+15)&~15; + + if(size>PxcNpMemBlock::SIZE) + return mBlockPool.acquireExceptionalConstraintMemory(size); + + PX_ASSERT(size <= PxcNpMemBlock::SIZE); + + if(mBlock == NULL || size+mUsed>PxcNpMemBlock::SIZE) + { + mBlock = mBlockPool.acquireContactBlock(); + PX_ASSERT(0==mBlock || mBlock->data == reinterpret_cast<PxU8*>(mBlock)); + mUsed = size; + return reinterpret_cast<PxU8*>(mBlock); + } + PX_ASSERT(mBlock && mBlock->data == reinterpret_cast<PxU8*>(mBlock)); + PxU8* PX_RESTRICT result = mBlock->data+mUsed; + mUsed += size; + return result; + } + + PX_FORCE_INLINE void reset() + { + mBlock = NULL; + mUsed = 0; + } + + PX_FORCE_INLINE PxcNpMemBlockPool& getMemBlockPool() + { + return mBlockPool; + } + +private: + PxcNpMemBlockPool& mBlockPool; + PxcNpMemBlock* mBlock; // current constraint block + PxU32 mUsed; // number of bytes used in constraint block +}; + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcContactCache.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcContactCache.h new file mode 100644 index 00000000..34174b35 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcContactCache.h @@ -0,0 +1,64 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PXC_CONTACT_CACHE_H +#define PXC_CONTACT_CACHE_H + +#include "foundation/PxTransform.h" +#include "PxvConfig.h" +#include "PxcContactMethodImpl.h" + +namespace physx +{ + bool PxcCacheLocalContacts( PxcNpThreadContext& context, Gu::Cache& pairContactCache, + const PxTransform& tm0, const PxTransform& tm1, + const PxcContactMethod conMethod, + const Gu::GeometryUnion& shape0, const Gu::GeometryUnion& shape1); + + struct PxcLocalContactsCache + { + PxTransform mTransform0; + PxTransform mTransform1; + PxU16 mNbCachedContacts; + bool mUseFaceIndices; + bool mSameNormal; + + PX_FORCE_INLINE void operator = (const PxcLocalContactsCache& other) + { + mTransform0 = other.mTransform0; + mTransform1 = other.mTransform1; + mNbCachedContacts = other.mNbCachedContacts; + mUseFaceIndices = other.mUseFaceIndices; + mSameNormal = other.mSameNormal; + } + }; + +} + +#endif // PXC_CONTACT_CACHE_H diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcMaterialMethodImpl.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcMaterialMethodImpl.h new file mode 100644 index 00000000..b7260aa4 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcMaterialMethodImpl.h @@ -0,0 +1,69 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PXC_MATERIALMETHOD_H +#define PXC_MATERIALMETHOD_H + +#include "CmPhysXCommon.h" +#include "PxGeometry.h" + +namespace physx +{ + +struct PxsShapeCore; +struct PxsMaterialInfo; +class PxcNpThreadContext; + +#define MATERIAL_METHOD_ARGS \ + const PxsShapeCore* shape0, \ + const PxsShapeCore* shape1, \ + PxcNpThreadContext& pairContext, \ + PxsMaterialInfo* materialInfo + + +#define SINGLE_MATERIAL_METHOD_ARGS \ + const PxsShapeCore* shape, \ + const PxU32 index, \ + PxcNpThreadContext& pairContext, \ + PxsMaterialInfo* materialInfo + +/*! +Method prototype for fetch material routines +*/ +typedef bool (*PxcGetMaterialMethod) (MATERIAL_METHOD_ARGS); + +typedef bool (*PxcGetSingleMaterialMethod) (SINGLE_MATERIAL_METHOD_ARGS); + +extern PxcGetMaterialMethod g_GetMaterialMethodTable[][PxGeometryType::eGEOMETRY_COUNT]; + +extern PxcGetSingleMaterialMethod g_GetSingleMaterialMethodTable[PxGeometryType::eGEOMETRY_COUNT]; + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpBatch.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpBatch.h new file mode 100644 index 00000000..fe243aed --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpBatch.h @@ -0,0 +1,65 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PXC_NP_BATCH_H +#define PXC_NP_BATCH_H + +#include "PxvConfig.h" + +namespace physx +{ + struct PxcNpWorkUnit; + class PxcNpThreadContext; + +struct PxcNpWorkUnit; +class PxsContactManager; +struct PxsContactManagerOutput; + +namespace Gu +{ + struct Cache; +} + +namespace Cm +{ + class FlushPool; +} + +class PxLightCpuTask; + +namespace Gu +{ + class PxgGpuNarrowphaseCoreInterface; +} + +void PxcDiscreteNarrowPhase(PxcNpThreadContext& context, PxcNpWorkUnit& cmInput, Gu::Cache& cache, PxsContactManagerOutput& output); +void PxcDiscreteNarrowPhasePCM(PxcNpThreadContext& context, PxcNpWorkUnit& cmInput, Gu::Cache& cache, PxsContactManagerOutput& output); +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpCache.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpCache.h new file mode 100644 index 00000000..2ac7dde8 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpCache.h @@ -0,0 +1,154 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PXC_NPCACHE_H +#define PXC_NPCACHE_H + +#include "foundation/PxMemory.h" + +#include "PsIntrinsics.h" +#include "PxcNpCacheStreamPair.h" + +#include "PsPool.h" +#include "PsFoundation.h" +#include "GuContactMethodImpl.h" +#include "PsUtilities.h" + +namespace physx +{ + +template <typename T> +void PxcNpCacheWrite(PxcNpCacheStreamPair& streams, + Gu::Cache& cache, + const T& payload, + PxU32 bytes, + const PxU8* data) +{ + const PxU32 payloadSize = (sizeof(payload)+3)&~3; + cache.mCachedSize = Ps::to16((payloadSize + 4 + bytes + 0xF)&~0xF); + + PxU8* ls = streams.reserve(cache.mCachedSize); + cache.mCachedData = ls; + if(ls==NULL || (reinterpret_cast<PxU8*>(-1))==ls) + { + if(ls==NULL) + { + PX_WARN_ONCE( + "Reached limit set by PxSceneDesc::maxNbContactDataBlocks - ran out of buffer space for narrow phase. " + "Either accept dropped contacts or increase buffer size allocated for narrow phase by increasing PxSceneDesc::maxNbContactDataBlocks."); + return; + } + else + { + PX_WARN_ONCE( + "Attempting to allocate more than 16K of contact data for a single contact pair in narrowphase. " + "Either accept dropped contacts or simplify collision geometry."); + cache.mCachedData = NULL; + ls = NULL; + return; + } + } + + *reinterpret_cast<T*>(ls) = payload; + *reinterpret_cast<PxU32*>(ls+payloadSize) = bytes; + if(data) + PxMemCopy(ls+payloadSize+sizeof(PxU32), data, bytes); +} + + +template <typename T> +PxU8* PxcNpCacheWriteInitiate(PxcNpCacheStreamPair& streams, Gu::Cache& cache, const T& payload, PxU32 bytes) +{ + PX_UNUSED(payload); + + const PxU32 payloadSize = (sizeof(payload)+3)&~3; + cache.mCachedSize = Ps::to16((payloadSize + 4 + bytes + 0xF)&~0xF); + + PxU8* ls = streams.reserve(cache.mCachedSize); + cache.mCachedData = ls; + if(NULL==ls || reinterpret_cast<PxU8*>(-1)==ls) + { + if(NULL==ls) + { + PX_WARN_ONCE( + "Reached limit set by PxSceneDesc::maxNbContactDataBlocks - ran out of buffer space for narrow phase. " + "Either accept dropped contacts or increase buffer size allocated for narrow phase by increasing PxSceneDesc::maxNbContactDataBlocks."); + } + else + { + PX_WARN_ONCE( + "Attempting to allocate more than 16K of contact data for a single contact pair in narrowphase. " + "Either accept dropped contacts or simplify collision geometry."); + cache.mCachedData = NULL; + ls = NULL; + } + } + return ls; +} + +template <typename T> +PX_FORCE_INLINE void PxcNpCacheWriteFinalize(PxU8* ls, const T& payload, PxU32 bytes, const PxU8* data) +{ + const PxU32 payloadSize = (sizeof(payload)+3)&~3; + *reinterpret_cast<T*>(ls) = payload; + *reinterpret_cast<PxU32*>(ls+payloadSize) = bytes; + if(data) + PxMemCopy(ls+payloadSize+sizeof(PxU32), data, bytes); +} + + +template <typename T> +PX_FORCE_INLINE PxU8* PxcNpCacheRead(Gu::Cache& cache, T*& payload) +{ + PxU8* ls = cache.mCachedData; + payload = reinterpret_cast<T*>(ls); + const PxU32 payloadSize = (sizeof(T)+3)&~3; + return reinterpret_cast<PxU8*>(ls+payloadSize+sizeof(PxU32)); +} + +template <typename T> +const PxU8* PxcNpCacheRead2(Gu::Cache& cache, T& payload, PxU32& bytes) +{ + const PxU8* ls = cache.mCachedData; + if(ls==NULL) + { + bytes = 0; + return NULL; + } + + const PxU32 payloadSize = (sizeof(payload)+3)&~3; + payload = *reinterpret_cast<const T*>(ls); + bytes = *reinterpret_cast<const PxU32*>(ls+payloadSize); + PX_ASSERT(cache.mCachedSize == ((payloadSize + 4 + bytes+0xF)&~0xF)); + return reinterpret_cast<const PxU8*>(ls+payloadSize+sizeof(PxU32)); +} + +} + +#endif // #ifndef PXC_NPCACHE_H diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpCacheStreamPair.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpCacheStreamPair.h new file mode 100644 index 00000000..08757b8c --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpCacheStreamPair.h @@ -0,0 +1,63 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + + +#ifndef PXC_NPCACHESTREAMPAIR_H +#define PXC_NPCACHESTREAMPAIR_H + +#include "foundation/PxSimpleTypes.h" +#include "PxvConfig.h" +#include "PxcNpMemBlockPool.h" + +namespace physx +{ + +static const PxU32 PXC_NPCACHE_BLOCK_SIZE = 16384; + + +struct PxcNpCacheStreamPair +{ +public: + PxcNpCacheStreamPair(PxcNpMemBlockPool& blockPool); + + // reserve can fail and return null. + PxU8* reserve(PxU32 byteCount); + void reset(); +private: + PxcNpMemBlockPool& mBlockPool; + PxcNpMemBlock* mBlock; + PxU32 mUsed; +private: + PxcNpCacheStreamPair& operator=(const PxcNpCacheStreamPair&); +}; + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpContactPrepShared.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpContactPrepShared.h new file mode 100644 index 00000000..4fc9c122 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpContactPrepShared.h @@ -0,0 +1,59 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PXC_NPCONTACTPREPSHARED_H +#define PXC_NPCONTACTPREPSHARED_H + +namespace physx +{ +class PxcNpThreadContext; +struct PxsMaterialInfo; +class PxsMaterialManager; +class PxsConstraintBlockManager; +class PxcConstraintBlockStream; +struct PxsContactManagerOutput; + +namespace Gu +{ + struct ContactPoint; +} + +static const PxReal PXC_SAME_NORMAL = 0.999f; //Around 6 degrees + +bool finishContacts(PxcNpWorkUnit& input, PxsContactManagerOutput& npOutput, PxcNpThreadContext& threadContext, PxsMaterialInfo* pMaterialInfo, const bool isMeshType); + +PxU32 writeCompressedContact(const Gu::ContactPoint* const PX_RESTRICT contactPoints, const PxU32 numContactPoints, PxcNpThreadContext* threadContext, + PxU8& writtenContactCount, PxU8*& outContactPatches, PxU8*& outContactPoints, PxU16& compressedContactSize, PxReal*& contactForces, PxU32 contactForceByteSize, + const PxsMaterialManager* materialManager, bool hasModifiableContacts, bool forceNoResponse, PxsMaterialInfo* PX_RESTRICT pMaterial, PxU8& numPatches, + PxU32 additionalHeaderSize = 0, PxsConstraintBlockManager* manager = NULL, PxcConstraintBlockStream* blockStream = NULL, bool insertAveragePoint = false, + PxcDataStreamPool* pool = NULL, PxcDataStreamPool* patchStreamPool = NULL, PxcDataStreamPool* forcePool = NULL, const bool isMeshType = false); + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpMemBlockPool.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpMemBlockPool.h new file mode 100644 index 00000000..8374cfa9 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpMemBlockPool.h @@ -0,0 +1,119 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + + +#ifndef PXC_NP_MEM_BLOCK_POOL_H +#define PXC_NP_MEM_BLOCK_POOL_H + +#include "PxvConfig.h" +#include "PsArray.h" +#include "PxcScratchAllocator.h" + +namespace physx +{ +struct PxcNpMemBlock +{ + enum + { + SIZE = 16384 + }; + PxU8 data[SIZE]; +}; + +typedef Ps::Array<PxcNpMemBlock*> PxcNpMemBlockArray; + +class PxcNpMemBlockPool +{ + PX_NOCOPY(PxcNpMemBlockPool) +public: + PxcNpMemBlockPool(PxcScratchAllocator& allocator); + ~PxcNpMemBlockPool(); + + void init(PxU32 initial16KDataBlocks, PxU32 maxBlocks); + void flush(); + void setBlockCount(PxU32 count); + PxU32 getUsedBlockCount() const; + PxU32 getMaxUsedBlockCount() const; + PxU32 getPeakConstraintBlockCount() const; + void releaseUnusedBlocks(); + + PxcNpMemBlock* acquireConstraintBlock(); + PxcNpMemBlock* acquireConstraintBlock(PxcNpMemBlockArray& memBlocks); + PxcNpMemBlock* acquireContactBlock(); + PxcNpMemBlock* acquireFrictionBlock(); + PxcNpMemBlock* acquireNpCacheBlock(); + + PxU8* acquireExceptionalConstraintMemory(PxU32 size); + + void acquireConstraintMemory(); + void releaseConstraintMemory(); + void releaseConstraintBlocks(PxcNpMemBlockArray& memBlocks); + void releaseContacts(); + void swapFrictionStreams(); + void swapNpCacheStreams(); + + void flushUnused(); + +private: + + + Ps::Mutex mLock; + PxcNpMemBlockArray mConstraints; + PxcNpMemBlockArray mContacts[2]; + PxcNpMemBlockArray mFriction[2]; + PxcNpMemBlockArray mNpCache[2]; + PxcNpMemBlockArray mScratchBlocks; + Ps::Array<PxU8*> mExceptionalConstraints; + + PxcNpMemBlockArray mUnused; + + PxU32 mNpCacheActiveStream; + PxU32 mFrictionActiveStream; + PxU32 mCCDCacheActiveStream; + PxU32 mContactIndex; + PxU32 mAllocatedBlocks; + PxU32 mMaxBlocks; + PxU32 mInitialBlocks; + PxU32 mUsedBlocks; + PxU32 mMaxUsedBlocks; + PxcNpMemBlock* mScratchBlockAddr; + PxU32 mNbScratchBlocks; + PxcScratchAllocator& mScratchAllocator; + + PxU32 mPeakConstraintAllocations; + PxU32 mConstraintAllocations; + + PxcNpMemBlock* acquire(PxcNpMemBlockArray& trackingArray, PxU32* allocationCount = NULL, PxU32* peakAllocationCount = NULL, bool isScratchAllocation = false); + void release(PxcNpMemBlockArray& deadArray, PxU32* allocationCount = NULL); +}; + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpThreadContext.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpThreadContext.h new file mode 100644 index 00000000..ef731066 --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpThreadContext.h @@ -0,0 +1,216 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + +#ifndef PXC_NPTHREADCONTEXT_H +#define PXC_NPTHREADCONTEXT_H + +#include "PxvConfig.h" +#include "CmScaling.h" +#include "CmRenderOutput.h" +#include "PxcNpCacheStreamPair.h" +#include "PxcConstraintBlockStream.h" +#include "GuContactBuffer.h" +#include "PxvContext.h" +#include "PxcThreadCoherentCache.h" +#include "CmBitMap.h" +#include "../pcm/GuPersistentContactManifold.h" + +namespace physx +{ + +class PxsTransformCache; +class PxsMaterialManager; + +namespace Bp +{ + class AABBManagerImpl; +} + +namespace Sc +{ + class BodySim; +} + +/*! +Per-thread context used by contact generation routines. +*/ + +struct PxcDataStreamPool +{ + PxU8* mDataStream; + PxI32 mSharedDataIndex; + PxU32 mDataStreamSize; + PxU32 mSharedDataIndexGPU; + + bool isOverflown() const + { + //FD: my expectaton is that reading those variables is atomic, shared indices are non-decreasing, + //so we can only get a false overflow alert because of concurrency issues, which is not a big deal as it means + //it did overflow a bit later + return mSharedDataIndex + mSharedDataIndexGPU >= mDataStreamSize; + } +}; + +struct PxcNpContext +{ + private: + PX_NOCOPY(PxcNpContext) + public: + + PxcNpContext() : + mNpMemBlockPool (mScratchAllocator), + mMeshContactMargin (0.0f), + mToleranceLength (0.0f), + mCreateContactStream (false), + mContactStreamPool (NULL), + mPatchStreamPool (NULL), + mForceAndIndiceStreamPool(NULL), + mMaterialManager (NULL) + { + } + + PxcScratchAllocator mScratchAllocator; + PxcNpMemBlockPool mNpMemBlockPool; + PxReal mMeshContactMargin; + PxReal mToleranceLength; + Cm::RenderBuffer mRenderBuffer; + bool mCreateContactStream; // flag to enforce that contacts are stored persistently per workunit. Used for PVD. + PxcDataStreamPool* mContactStreamPool; + PxcDataStreamPool* mPatchStreamPool; + PxcDataStreamPool* mForceAndIndiceStreamPool; + PxcDataStreamPool* mConstraintWriteBackStreamPool; + PxsMaterialManager* mMaterialManager; + + PX_FORCE_INLINE PxReal getToleranceLength() const { return mToleranceLength; } + PX_FORCE_INLINE void setToleranceLength(PxReal x) { mToleranceLength = x; } + PX_FORCE_INLINE PxReal getMeshContactMargin() const { return mMeshContactMargin; } + PX_FORCE_INLINE void setMeshContactMargin(PxReal x) { mMeshContactMargin = x; } + PX_FORCE_INLINE bool getCreateContactStream() { return mCreateContactStream; } + + PX_FORCE_INLINE PxcNpMemBlockPool& getNpMemBlockPool() { return mNpMemBlockPool; } + PX_FORCE_INLINE const PxcNpMemBlockPool& getNpMemBlockPool() const { return mNpMemBlockPool; } + PX_FORCE_INLINE void setMaterialManager(PxsMaterialManager* m){ mMaterialManager = m; } + PX_FORCE_INLINE PxsMaterialManager* getMaterialManager() const { return mMaterialManager; } + + Cm::RenderOutput getRenderOutput() { return Cm::RenderOutput(mRenderBuffer); } +}; + +class PxcNpThreadContext : public PxcThreadCoherentCache<PxcNpThreadContext, PxcNpContext>::EntryBase +{ + PX_NOCOPY(PxcNpThreadContext) +public: + PxcNpThreadContext(PxcNpContext* params); + ~PxcNpThreadContext(); + +#if PX_ENABLE_SIM_STATS + void clearStats(); +#endif + + PX_FORCE_INLINE void setCreateContactStream(bool to) { mCreateContactStream = to; } + + PX_FORCE_INLINE void addLocalNewTouchCount(PxU32 newTouchCMCount) { mLocalNewTouchCount += newTouchCMCount; } + PX_FORCE_INLINE void addLocalLostTouchCount(PxU32 lostTouchCMCount) { mLocalLostTouchCount += lostTouchCMCount; } + PX_FORCE_INLINE PxU32 getLocalNewTouchCount() const { return mLocalNewTouchCount; } + PX_FORCE_INLINE PxU32 getLocalLostTouchCount() const { return mLocalLostTouchCount; } + + PX_FORCE_INLINE void addLocalFoundPatchCount(PxU32 foundPatchCount) { mLocalFoundPatchCount += foundPatchCount; } + PX_FORCE_INLINE void addLocalLostPatchCount(PxU32 lostPatchCount) { mLocalLostPatchCount += lostPatchCount; } + PX_FORCE_INLINE PxU32 getLocalFoundPatchCount() const { return mLocalFoundPatchCount; } + PX_FORCE_INLINE PxU32 getLocalLostPatchCount() const { return mLocalLostPatchCount; } + + PX_FORCE_INLINE Cm::BitMap& getLocalChangeTouch() { return mLocalChangeTouch; } + + PX_FORCE_INLINE Cm::BitMap& getLocalPatchChangeMap() { return mLocalPatchCountChange; } + + void reset(PxU32 cmCount); + // debugging + Cm::RenderOutput mRenderOutput; + + // dsequeira: Need to think about this block pool allocation a bit more. Ideally we'd be + // taking blocks from a single pool, except that we want to be able to selectively reclaim + // blocks if the user needs to defragment, depending on which artifacts they're willing + // to tolerate, such that the blocks we don't reclaim are contiguous. +#if PX_ENABLE_SIM_STATS + PxU32 mDiscreteContactPairs [PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT]; + PxU32 mModifiedContactPairs [PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT]; +#endif + PxcContactBlockStream mContactBlockStream; // constraint block pool + PxcNpCacheStreamPair mNpCacheStreamPair; // narrow phase pairwise data cache + + // Everything below here is scratch state. Most of it can even overlap. + + // temporary contact buffer + Gu::ContactBuffer mContactBuffer; + + PX_ALIGN(16, Gu::MultiplePersistentContactManifold mTempManifold); + + Gu::NarrowPhaseParams mNarrowPhaseParams; + + // DS: this stuff got moved here from the PxcNpPairContext. As Pierre says: + ////////// PT: those members shouldn't be there in the end, it's not necessary + Ps::Array<Sc::BodySim*> mBodySimPool; + PxsTransformCache* mTransformCache; + PxReal* mContactDistance; + bool mPCM; + bool mContactCache; + bool mCreateContactStream; // flag to enforce that contacts are stored persistently per workunit. Used for PVD. + bool mCreateAveragePoint; // flag to enforce whether we create average points +#if PX_ENABLE_SIM_STATS + PxU32 mCompressedCacheSize; + PxU32 mNbDiscreteContactPairsWithCacheHits; + PxU32 mNbDiscreteContactPairsWithContacts; +#endif + PxReal mDt; // AP: still needed for ccd + PxU32 mCCDPass; + PxU32 mCCDFaceIndex; + + PxU32 mMaxPatches; + //PxU32 mTotalContactCount; + PxU32 mTotalCompressedCacheSize; + //PxU32 mTotalPatchCount; + + PxcDataStreamPool* mContactStreamPool; + PxcDataStreamPool* mPatchStreamPool; + PxcDataStreamPool* mForceAndIndiceStreamPool; //this stream is used to store the force buffer and triangle index if we are performing mesh/heightfield contact gen + PxcDataStreamPool* mConstraintWriteBackStreamPool; + PxsMaterialManager* mMaterialManager; +private: + // change touch handling. + Cm::BitMap mLocalChangeTouch; + Cm::BitMap mLocalPatchCountChange; + PxU32 mLocalNewTouchCount; + PxU32 mLocalLostTouchCount; + PxU32 mLocalFoundPatchCount; + PxU32 mLocalLostPatchCount; +}; + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpWorkUnit.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpWorkUnit.h new file mode 100644 index 00000000..bfc4f0da --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcNpWorkUnit.h @@ -0,0 +1,162 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + + +#ifndef PXC_NPWORKUNIT_H +#define PXC_NPWORKUNIT_H + +#include "PxcNpThreadContext.h" +#include "PxcMaterialMethodImpl.h" +#include "PxcNpCache.h" + +namespace physx +{ + +class PxvContact; + +struct PxsRigidCore; +struct PxsShapeCore; + +class PxsMaterialManager; + +struct PxcNpWorkUnitFlag +{ + enum Enum + { + eOUTPUT_CONTACTS = 1, + eOUTPUT_CONSTRAINTS = 2, + eDISABLE_STRONG_FRICTION = 4, + eARTICULATION_BODY0 = 8, + eARTICULATION_BODY1 = 16, + eDYNAMIC_BODY0 = 32, + eDYNAMIC_BODY1 = 64, + eMODIFIABLE_CONTACT = 128, + eFORCE_THRESHOLD = 256, + eDETECT_DISCRETE_CONTACT = 512, + eHAS_KINEMATIC_ACTOR = 1024, + eDISABLE_RESPONSE = 2048, + eDETECT_CCD_CONTACTS = 4096 + }; +}; + +struct PxcNpWorkUnitStatusFlag +{ + enum Enum + { + eHAS_NO_TOUCH = (1 << 0), + eHAS_TOUCH = (1 << 1), + //eHAS_SOLVER_CONSTRAINTS = (1 << 2), + eREQUEST_CONSTRAINTS = (1 << 3), + eHAS_CCD_RETOUCH = (1 << 4), // Marks pairs that are touching at a CCD pass and were touching at discrete collision or at a previous CCD pass already + // but we can not tell whether they lost contact in a pass before. We send them as pure eNOTIFY_TOUCH_CCD events to the + // contact report callback if requested. + eDIRTY_MANAGER = (1 << 5), + eREFRESHED_WITH_TOUCH = (1 << 6), + eTOUCH_KNOWN = eHAS_NO_TOUCH | eHAS_TOUCH // The touch status is known (if narrowphase never ran for a pair then no flag will be set) + }; +}; + +/* + * A struct to record the number of work units a particular constraint pointer references. + * This is created at the beginning of the constriant data and is used to bypass constraint preparation when the + * bodies are not moving a lot. In this case, we can recycle the constraints and save ourselves some cycles. +*/ +struct PxcNpWorkUnit; +struct PxcNpWorkUnitBatch +{ + PxcNpWorkUnit* mUnits[4]; + PxU32 mSize; +}; + +struct PxcNpWorkUnit +{ + + const PxsRigidCore* rigidCore0; // INPUT //4 //8 + const PxsRigidCore* rigidCore1; // INPUT //8 //16 + + const PxsShapeCore* shapeCore0; // INPUT //12 //24 + const PxsShapeCore* shapeCore1; // INPUT //16 //32 + + PxU8* ccdContacts; // OUTPUT //20 //40 + + PxU8* frictionDataPtr; // INOUT //24 //48 + + PxU16 flags; // INPUT //26 //50 + PxU8 frictionPatchCount; // INOUT //27 //51 + PxU8 statusFlags; // OUTPUT (see PxcNpWorkUnitStatusFlag) //28 //52 + + PxU8 dominance0; // INPUT //29 //53 + PxU8 dominance1; // INPUT //30 //54 + PxU8 geomType0; // INPUT //31 //55 + PxU8 geomType1; // INPUT //32 //56 + + PxU32 index; // INPUT //36 //60 + + PxReal restDistance; // INPUT //40 //64 + + PxU32 mTransformCache0; // //44 //68 + PxU32 mTransformCache1; // //48 //72 + + PxU32 mEdgeIndex; //inout the island gen edge index //52 //76 + PxU32 mNpIndex; //INPUT //56 //80 + +}; + +//#if !defined(PX_P64) +//PX_COMPILE_TIME_ASSERT(0 == (sizeof(PxcNpWorkUnit) & 0x0f)); +//#endif + +PX_FORCE_INLINE void PxcNpWorkUnitClearContactState(PxcNpWorkUnit& n) +{ + n.ccdContacts = NULL; +} + + +PX_FORCE_INLINE void PxcNpWorkUnitClearCachedState(PxcNpWorkUnit& n) +{ + n.frictionDataPtr = 0; + n.frictionPatchCount = 0; + n.ccdContacts = NULL; +} + +PX_FORCE_INLINE void PxcNpWorkUnitClearFrictionCachedState(PxcNpWorkUnit& n) +{ + n.frictionDataPtr = 0; + n.frictionPatchCount = 0; + n.ccdContacts = NULL; +} + +#if !defined(PX_P64) +//PX_COMPILE_TIME_ASSERT(sizeof(PxcNpWorkUnit)==128); +#endif + +} + +#endif diff --git a/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcRigidBody.h b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcRigidBody.h new file mode 100644 index 00000000..03870e4f --- /dev/null +++ b/PhysX_3.4/Source/LowLevel/common/include/pipeline/PxcRigidBody.h @@ -0,0 +1,117 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and 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. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + +#ifndef PXC_RIGIDBODY_H +#define PXC_RIGIDBODY_H + +#include "foundation/PxVec3.h" +#include "foundation/PxTransform.h" +#include "PxvDynamics.h" +#include "CmSpatialVector.h" + +namespace physx +{ + +class PxsContactManager; +struct PxsCCDPair; +struct PxsCCDBody; + +#define PX_INTERNAL_LOCK_FLAG_START 7 + +PX_ALIGN_PREFIX(16) +class PxcRigidBody +{ +public: + + enum PxcRigidBodyFlag + { + eFROZEN = 1 << 0, //This flag indicates that the stabilization is enabled and the body is + //"frozen". By "frozen", we mean that the body's transform is unchanged + //from the previous frame. This permits various optimizations. + eFREEZE_THIS_FRAME = 1 << 1, + eUNFREEZE_THIS_FRAME = 1 << 2, + eACTIVATE_THIS_FRAME = 1 << 3, + eDEACTIVATE_THIS_FRAME = 1 << 4, + eDISABLE_GRAVITY = 1 << 5, + eSPECULATIVE_CCD = 1 << 6, + //KS - copied here for GPU simulation to avoid needing to pass another set of flags around. + eLOCK_LINEAR_X = 1 << (PX_INTERNAL_LOCK_FLAG_START), + eLOCK_LINEAR_Y = 1 << (PX_INTERNAL_LOCK_FLAG_START + 1), + eLOCK_LINEAR_Z = 1 << (PX_INTERNAL_LOCK_FLAG_START + 2), + eLOCK_ANGULAR_X = 1 << (PX_INTERNAL_LOCK_FLAG_START + 3), + eLOCK_ANGULAR_Y = 1 << (PX_INTERNAL_LOCK_FLAG_START + 4), + eLOCK_ANGULAR_Z = 1 << (PX_INTERNAL_LOCK_FLAG_START + 5) + + }; + + PX_FORCE_INLINE PxcRigidBody(PxsBodyCore* core) + : mLastTransform(core->body2World), + mCCD(NULL), + mCore(core) + { + } + + void adjustCCDLastTransform(); + +protected: + + ~PxcRigidBody() + { + } + +public: + + PxTransform mLastTransform; //28 (28) + + PxU16 mInternalFlags; //30 (30) + PxU16 solverIterationCounts; //32 (32) + + PxsCCDBody* mCCD; //36 (40) // only valid during CCD + + PxsBodyCore* mCore; //40 (48) + +#if !PX_P64_FAMILY + PxU32 alignmentPad[2]; //48 (48) +#endif + + PxVec3 sleepLinVelAcc; //60 (60) + PxReal freezeCount; //64 (64) + + PxVec3 sleepAngVelAcc; //76 (76) + PxReal accelScale; //80 (80) + + +} +PX_ALIGN_SUFFIX(16); +PX_COMPILE_TIME_ASSERT(0 == (sizeof(PxcRigidBody) & 0x0f)); + +} + +#endif //PXC_RIGIDBODY_H |