32#include "foundation/PxMemory.h"
33#include "foundation/PxIntrinsics.h"
34#include "foundation/PxPool.h"
35#include "foundation/PxUtilities.h"
37#include "PxcNpCacheStreamPair.h"
39#include "GuContactMethodImpl.h"
45void PxcNpCacheWrite(PxcNpCacheStreamPair& streams,
51 const PxU32 payloadSize = (
sizeof(payload)+3)&~3;
52 cache.mCachedSize = PxTo16((payloadSize + 4 +
bytes + 0xF)&~0xF);
54 PxU8* ls = streams.reserve(cache.mCachedSize);
55 cache.mCachedData = ls;
56 if(ls==NULL || (
reinterpret_cast<PxU8*
>(-1))==ls)
61 "Reached limit set by PxSceneDesc::maxNbContactDataBlocks - ran out of buffer space for narrow phase. "
62 "Either accept dropped contacts or increase buffer size allocated for narrow phase by increasing PxSceneDesc::maxNbContactDataBlocks.");
68 "Attempting to allocate more than 16K of contact data for a single contact pair in narrowphase. "
69 "Either accept dropped contacts or simplify collision geometry.");
70 cache.mCachedData = NULL;
76 *
reinterpret_cast<T*
>(ls) = payload;
77 *
reinterpret_cast<PxU32*
>(ls+payloadSize) =
bytes;
84PxU8* PxcNpCacheWriteInitiate(PxcNpCacheStreamPair& streams, Gu::Cache& cache,
const T& payload, PxU32
bytes)
88 const PxU32 payloadSize = (
sizeof(payload)+3)&~3;
89 cache.mCachedSize = PxTo16((payloadSize + 4 +
bytes + 0xF)&~0xF);
91 PxU8* ls = streams.reserve(cache.mCachedSize);
92 cache.mCachedData = ls;
93 if(NULL==ls ||
reinterpret_cast<PxU8*
>(-1)==ls)
98 "Reached limit set by PxSceneDesc::maxNbContactDataBlocks - ran out of buffer space for narrow phase. "
99 "Either accept dropped contacts or increase buffer size allocated for narrow phase by increasing PxSceneDesc::maxNbContactDataBlocks.");
104 "Attempting to allocate more than 16K of contact data for a single contact pair in narrowphase. "
105 "Either accept dropped contacts or simplify collision geometry.");
106 cache.mCachedData = NULL;
114PX_FORCE_INLINE void PxcNpCacheWriteFinalize(PxU8* ls,
const T& payload, PxU32
bytes,
const PxU8* data)
116 const PxU32 payloadSize = (
sizeof(payload)+3)&~3;
117 *
reinterpret_cast<T*
>(ls) = payload;
118 *
reinterpret_cast<PxU32*
>(ls+payloadSize) =
bytes;
127 PxU8* ls = cache.mCachedData;
128 payload =
reinterpret_cast<T*
>(ls);
129 const PxU32 payloadSize = (
sizeof(T)+3)&~3;
130 return reinterpret_cast<PxU8*
>(ls+payloadSize+
sizeof(PxU32));
134const PxU8* PxcNpCacheRead2(Gu::Cache& cache, T& payload, PxU32&
bytes)
136 const PxU8* ls = cache.mCachedData;
143 const PxU32 payloadSize = (
sizeof(payload)+3)&~3;
144 payload = *
reinterpret_cast<const T*
>(ls);
145 bytes = *
reinterpret_cast<const PxU32*
>(ls+payloadSize);
146 PX_ASSERT(cache.mCachedSize == ((payloadSize + 4 +
bytes+0xF)&~0xF));
147 return reinterpret_cast<const PxU8*
>(ls+payloadSize+
sizeof(PxU32));
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemCopy(void *dest, const void *src, PxU32 count)
Copies the bytes of one memory block to another. The memory blocks must not overlap.
Definition PxMemory.h:83