32#include "foundation/PxVec3.h"
33#include "foundation/PxMat33.h"
34#include "foundation/PxBounds3.h"
35#include "common/PxBase.h"
36#include "foundation/PxInlineArray.h"
37#include "foundation/PxArray.h"
38#include "foundation/PxAllocator.h"
39#include "foundation/PxMemory.h"
46template<
class DstType,
class SrcType>
49 const PxU32 remainder = PxU32(PxMax<PxI32>(PxI32(size - startIndex), 0));
50 const PxU32 writeCount =
PxMin(remainder, bufferSize);
52 for(PxU32 i=0;i<writeCount;i++)
53 userBuffer[i] =
static_cast<DstType*
>(src[i]);
57PX_CUDA_CALLABLE
PX_INLINE void transformInertiaTensor(
const PxVec3& invD,
const PxMat33& M, PxMat33& mIInv)
59 const float axx = invD.x*M(0,0), axy = invD.x*M(1,0), axz = invD.x*M(2,0);
60 const float byx = invD.y*M(0,1), byy = invD.y*M(1,1), byz = invD.y*M(2,1);
61 const float czx = invD.z*M(0,2), czy = invD.z*M(1,2), czz = invD.z*M(2,2);
63 mIInv(0,0) = axx*M(0,0) + byx*M(0,1) + czx*M(0,2);
64 mIInv(1,1) = axy*M(1,0) + byy*M(1,1) + czy*M(1,2);
65 mIInv(2,2) = axz*M(2,0) + byz*M(2,1) + czz*M(2,2);
67 mIInv(0,1) = mIInv(1,0) = axx*M(1,0) + byx*M(1,1) + czx*M(1,2);
68 mIInv(0,2) = mIInv(2,0) = axx*M(2,0) + byx*M(2,1) + czx*M(2,2);
69 mIInv(1,2) = mIInv(2,1) = axy*M(2,0) + byy*M(2,1) + czy*M(2,2);
73PX_FORCE_INLINE PxVec3 basisExtent(
const PxVec3& basis0,
const PxVec3& basis1,
const PxVec3& basis2,
const PxVec3& extent)
76 const PxVec3 c0 = basis0 * extent.x;
77 const PxVec3 c1 = basis1 * extent.y;
78 const PxVec3 c2 = basis2 * extent.z;
86PX_FORCE_INLINE PxBounds3 basisExtent(
const PxVec3& center,
const PxVec3& basis0,
const PxVec3& basis1,
const PxVec3& basis2,
const PxVec3& extent)
88 const PxVec3 w = basisExtent(basis0, basis1, basis2, extent);
89 return PxBounds3(center - w, center + w);
94 return (c.isFinite() && e.isFinite() && (((e.x >= 0.0f) && (e.y >= 0.0f) && (e.z >= 0.0f)) ||
95 ((e.x == -PX_MAX_BOUNDS_EXTENTS) &&
96 (e.y == -PX_MAX_BOUNDS_EXTENTS) &&
97 (e.z == -PX_MAX_BOUNDS_EXTENTS))));
103 PX_ASSERT(isValid(c, e));
114 void (Owner::*realloc)(T*& currentMem, IndexType& currentCapacity, IndexType size, IndexType requiredMinCapacity)>
126 PX_ASSERT(mCapacity==0);
129 void pushBack(T& element, Owner& owner)
134 PX_ASSERT(&element<mData || &element>=mData+mSize);
136 (owner.*realloc)(mData, mCapacity, mSize, IndexType(mSize+1));
138 PX_ASSERT(mData && mSize<mCapacity);
139 mData[mSize++] = element;
142 IndexType size()
const
147 void replaceWithLast(IndexType index)
149 PX_ASSERT(index<mSize);
150 mData[index] = mData[--mSize];
163 T& operator [](IndexType index)
165 PX_ASSERT(index<mSize);
169 const T& operator [](IndexType index)
const
171 PX_ASSERT(index<mSize);
175 void reserve(IndexType capacity, Owner &owner)
177 if(capacity>=mCapacity)
178 (owner.*realloc)(mData, mCapacity, mSize, capacity);
181 void releaseMem(Owner &owner)
184 (owner.*realloc)(mData, mCapacity, 0, 0);
210 if(object->getBaseFlags() & PxBaseFlag::eOWNS_MEMORY)
218#define PX_PADDING_8 0xcd
219#define PX_PADDING_16 0xcdcd
220#define PX_PADDING_32 0xcdcdcdcd
227 #define PX_NEW_SERIALIZED(v,T) \
228 void* _buf = physx::PxReflectionAllocator<T>().allocate(sizeof(T),__FILE__,__LINE__); \
229 PxMarkSerializedMemory(_buf, sizeof(T)); \
230 v = PX_PLACEMENT_NEW(_buf, T)
233 #define PX_NEW_SERIALIZED(v,T) v = PX_NEW(T)
236template<
typename T,
class Alloc>
241 if(this->mData && (this->mSize || this->capacity()))
242 context.writeData(this->mData, this->capacity()*
sizeof(T));
247 if(this->mData && (this->mSize || this->capacity()))
248 this->mData =
context.readExtraData<T>(this->capacity());
252template<
typename T,
typename Alloc>
258template<
typename T,
typename Alloc>
264template<
typename T, PxU32 N,
typename Alloc>
265void exportInlineArray(
const PxInlineArray<T, N, Alloc>& a, PxSerializationContext&
context)
271template<
typename T, PxU32 N,
typename Alloc>
272void importInlineArray(PxInlineArray<T, N, Alloc>& a, PxDeserializationContext&
context)
279static PX_INLINE T* reserveContainerMemory(PxArray<T>& container, PxU32 nb)
281 const PxU32 maxNbEntries = container.capacity();
282 const PxU32 requiredSize = container.size() + nb;
284 if(requiredSize>maxNbEntries)
286 const PxU32 naturalGrowthSize = maxNbEntries ? maxNbEntries*2 : 2;
287 const PxU32 newSize =
PxMax(requiredSize, naturalGrowthSize);
288 container.reserve(newSize);
291 T* buf = container.end();
292 container.forceSize_Unsafe(requiredSize);
Binary deserialization context class.
Definition PxSerialFramework.h:174
Binary serialization context class.
Definition PxSerialFramework.h:99
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMax(T a, T b)
The return value is the greater of the two specified values.
Definition PxMath.h:72
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88