void PtrTable::exportExtraData(PxSerializationContext& stream) { if(mCount>1) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mList, sizeof(void*)*mCount); } }
void RevoluteJoint::exportExtraData(PxSerializationContext& stream) { if(mData) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mData, sizeof(RevoluteJointData)); } stream.writeName(mName); }
// PX_SERIALIZATION void Gu::ConvexMesh::exportExtraData(PxSerializationContext& stream) { stream.alignData(PX_SERIAL_ALIGN); const PxU32 bufferSize = computeBufferSize(mHullData, getNb()); stream.writeData(mHullData.mPolygons, bufferSize); if(mBigConvexData) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mBigConvexData, sizeof(BigConvexData)); mBigConvexData->exportExtraData(stream); } }
void PxSerializerDefaultAdapter<NpRigidDynamic>::exportData(PxBase& obj, PxSerializationContext& s) const { PxU32 classSize = sizeof(NpRigidDynamic); NpRigidDynamic& dynamic = static_cast<NpRigidDynamic&>(obj); PxsBodyCore serialCore; size_t address = dynamic.getScbBodyFast().getScBody().getSerialCore(serialCore); PxU32 offset = PxU32(address - reinterpret_cast<size_t>(&dynamic)); PX_ASSERT(offset + sizeof(serialCore) <= classSize); s.writeData(&dynamic, offset); s.writeData(&serialCore, sizeof(serialCore)); void* tail = reinterpret_cast<PxU8*>(&dynamic) + offset + sizeof(serialCore); s.writeData(tail, classSize - offset - sizeof(serialCore)); }
void PxSerializerDefaultAdapter<NpShape>::registerReferences(PxBase& obj, PxSerializationContext& s) const { NpShape& shape = static_cast<NpShape&>(obj); s.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE, size_t(&obj)); struct RequiresCallback : public PxProcessPxBaseCallback { RequiresCallback(physx::PxSerializationContext& c) : context(c) {} RequiresCallback &operator=(const RequiresCallback&) { PX_ASSERT(0); return *this; } //PX_NOCOPY doesn't work for local classes void process(PxBase& base) { PxMaterial* pxMaterial = base.is<PxMaterial>(); if (!pxMaterial) { context.registerReference(base, PX_SERIAL_REF_KIND_PXBASE, size_t(&base)); } else { //ideally we would move this part to ScShapeCore but we don't yet have a MaterialManager available there. PxU32 index = static_cast<NpMaterial*>(pxMaterial)->getHandle(); context.registerReference(base, PX_SERIAL_REF_KIND_MATERIAL_IDX, size_t(index)); } } PxSerializationContext& context; }; RequiresCallback callback(s); shape.requires(callback); }
// PX_SERIALIZATION void BigConvexData::exportExtraData(PxSerializationContext& stream) { if(mData.mSamples) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mData.mSamples, sizeof(PxU8)*mData.mNbSamples*2); } if(mData.mValencies) { stream.alignData(PX_SERIAL_ALIGN); PxU32 numVerts = (mData.mNbVerts+3)&~3; const PxU32 TotalSize = sizeof(Gu::Valency)*numVerts + sizeof(PxU8)*mData.mNbAdjVerts; stream.writeData(mData.mValencies, TotalSize); } }
void Sc::ClothCore::exportExtraData(PxSerializationContext& stream) { PX_ALLOCA(buf, ClothBulkData, 1); Cm::markSerializedMem(buf, sizeof(ClothBulkData)); ClothBulkData* bulkData = PX_PLACEMENT_NEW(buf, ClothBulkData); updateBulkData(*bulkData); stream.writeData(bulkData, sizeof(ClothBulkData)); bulkData->exportExtraData(stream); bulkData->~ClothBulkData(); }
void PxSerializerDefaultAdapter<NpRigidDynamic>::registerReferences(PxBase& obj, PxSerializationContext& s) const { NpRigidDynamic& dynamic = static_cast<NpRigidDynamic&>(obj); s.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE, size_t(&obj)); struct RequiresCallback : public PxProcessPxBaseCallback { RequiresCallback(physx::PxSerializationContext& c) : context(c) {} RequiresCallback& operator=(const RequiresCallback&) { PX_ASSERT(0); return *this; } //PX_NOCOPY doesn't work for local classes void process(PxBase& base) { context.registerReference(base, PX_SERIAL_REF_KIND_PXBASE, size_t(&base)); } PxSerializationContext& context; }; RequiresCallback callback(s); dynamic.requires(callback); }
void Gu::TriangleMesh::exportExtraData(PxSerializationContext& stream) { //PX_DEFINE_DYNAMIC_ARRAY(TriangleMesh, mVertices, PxField::eVEC3, mNbVertices, Ps::PxFieldFlag::eSERIALIZE), if(mVertices) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mVertices, mNbVertices * sizeof(PxVec3)); } if(mTriangles) { const PxU32 triangleSize = mFlags & PxTriangleMeshFlag::e16_BIT_INDICES ? sizeof(PxU16) : sizeof(PxU32); stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mTriangles, mNbTriangles * 3 * triangleSize); } //PX_DEFINE_DYNAMIC_ARRAY(TriangleMesh, mExtraTrigData, PxField::eBYTE, mNbTriangles, Ps::PxFieldFlag::eSERIALIZE), if(mExtraTrigData) { // PT: it might not be needed to 16-byte align this array of PxU8.... stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mExtraTrigData, mNbTriangles * sizeof(PxU8)); } if(mMaterialIndices) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mMaterialIndices, mNbTriangles * sizeof(PxU16)); } if(mFaceRemap) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mFaceRemap, mNbTriangles * sizeof(PxU32)); } if(mAdjacencies) { stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mAdjacencies, mNbTriangles * sizeof(PxU32) * 3); } }
// PX_SERIALIZATION ///////////////////////////////////////////////////////////////////////// void RTree::exportExtraData(PxSerializationContext& stream) { stream.alignData(128); stream.writeData(mPages, mTotalPages*sizeof(RTreePage)); }