Init
This commit is contained in:
@ -0,0 +1,156 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,66 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
{
|
||||
class PxcNpThreadContext;
|
||||
|
||||
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
|
||||
@ -0,0 +1,69 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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 "geometry/PxGeometry.h"
|
||||
#include "CmPhysXCommon.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
|
||||
50
physx/source/lowlevel/common/include/pipeline/PxcNpBatch.h
Normal file
50
physx/source/lowlevel/common/include/pipeline/PxcNpBatch.h
Normal file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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 PxsContactManagerOutput;
|
||||
|
||||
namespace Gu
|
||||
{
|
||||
struct Cache;
|
||||
}
|
||||
|
||||
void PxcDiscreteNarrowPhase(PxcNpThreadContext& context, const PxcNpWorkUnit& cmInput, Gu::Cache& cache, PxsContactManagerOutput& output);
|
||||
void PxcDiscreteNarrowPhasePCM(PxcNpThreadContext& context, const PxcNpWorkUnit& cmInput, Gu::Cache& cache, PxsContactManagerOutput& output);
|
||||
}
|
||||
|
||||
#endif
|
||||
154
physx/source/lowlevel/common/include/pipeline/PxcNpCache.h
Normal file
154
physx/source/lowlevel/common/include/pipeline/PxcNpCache.h
Normal file
@ -0,0 +1,154 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,57 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
|
||||
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
|
||||
@ -0,0 +1,119 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,212 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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 "geometry/PxGeometry.h"
|
||||
#include "geomutils/GuContactBuffer.h"
|
||||
|
||||
#include "PxvConfig.h"
|
||||
#include "CmScaling.h"
|
||||
#include "CmRenderOutput.h"
|
||||
#include "PxcNpCacheStreamPair.h"
|
||||
#include "PxcConstraintBlockStream.h"
|
||||
#include "PxcThreadCoherentCache.h"
|
||||
#include "CmBitMap.h"
|
||||
#include "../pcm/GuPersistentContactManifold.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxsTransformCache;
|
||||
class PxsMaterialManager;
|
||||
|
||||
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
|
||||
155
physx/source/lowlevel/common/include/pipeline/PxcNpWorkUnit.h
Normal file
155
physx/source/lowlevel/common/include/pipeline/PxcNpWorkUnit.h
Normal file
@ -0,0 +1,155 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
{
|
||||
struct PxsRigidCore;
|
||||
struct PxsShapeCore;
|
||||
|
||||
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)
|
||||
};
|
||||
};
|
||||
|
||||
// PT: TODO: fix the inconsistent namings (mXXX) in this class
|
||||
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
|
||||
|
||||
PxReal mTorsionalPatchRadius; //60 //84
|
||||
PxReal mMinTorsionalPatchRadius; //64 //88
|
||||
};
|
||||
|
||||
/*
|
||||
* 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 PxcNpWorkUnitBatch
|
||||
{
|
||||
PxcNpWorkUnit* mUnits[4];
|
||||
PxU32 mSize;
|
||||
};
|
||||
|
||||
//#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
|
||||
Reference in New Issue
Block a user