void VisualDebugger::updatePvdProperties(const PxHeightField* heightField) { PVD::PvdCommLayerError error; mPvdConnectionHelper.addPropertyGroupProperty(HeightFieldProp::NumRows, heightField->getNbRows()); mPvdConnectionHelper.addPropertyGroupProperty(HeightFieldProp::NumColumns, heightField->getNbColumns()); mPvdConnectionHelper.addPropertyGroupProperty(HeightFieldProp::HeightFieldFormat, PVD::createEnumerationValue(heightField->getFormat())); mPvdConnectionHelper.addPropertyGroupProperty(HeightFieldProp::Thickness, heightField->getThickness()); mPvdConnectionHelper.addPropertyGroupProperty(HeightFieldProp::ConvexEdgeThreshold, heightField->getConvexEdgeThreshold()); mPvdConnectionHelper.addPropertyGroupProperty(HeightFieldProp::Flags, PVD::createBitflag(heightField->getFlags())); error = mPvdConnectionHelper.sendSinglePropertyGroup(mPvdConnection, PX_PROFILE_POINTER_TO_U64(heightField), PvdClassKeys::HeightField); // samples array { PxU32 nbRows = heightField->getNbRows(); PxU32 nbCols = heightField->getNbColumns(); PxU8* samplesPtr = (PxU8*)PX_ALLOC(nbCols*nbRows*sizeof(PxHeightFieldSample)); heightField->saveCells(samplesPtr, nbRows*nbCols*sizeof(PxHeightFieldSample)); PxU32 sampleStride = heightField->getSampleStride(); PxU32 numSamples = nbCols * nbRows; error = PvdConnectionHelper::sendSingleElementArrayProperty(mPvdConnection, PX_PROFILE_POINTER_TO_U64(heightField), HeightFieldProp::Samples , HeightFieldSampleArrayProp::Element, PVD::PvdCommLayerDatatype::HeightFieldSample , samplesPtr, sampleStride, numSamples); PX_FREE_AND_RESET(samplesPtr); } PX_ASSERT(error == PVD::PvdCommLayerError::None); }
void PxsFluidDynamics::adjustTempBuffers(PxU32 count) { PX_ASSERT(count <= PXS_FLUID_MAX_PARALLEL_TASKS_SPH); PX_ASSERT(mNumTempBuffers <= PXS_FLUID_MAX_PARALLEL_TASKS_SPH); Ps::AlignedAllocator<16, Ps::ReflectionAllocator<char> > align16; // shrink for (PxU32 i = count; i < mNumTempBuffers; ++i) { PxsFluidDynamicsTempBuffers& tempBuffers = mTempBuffers[i]; if (tempBuffers.indexStream) PX_FREE_AND_RESET(tempBuffers.indexStream); if (tempBuffers.hashKeys) PX_FREE_AND_RESET(tempBuffers.hashKeys); if (tempBuffers.mergedIndices) PX_FREE_AND_RESET(tempBuffers.mergedIndices); if (tempBuffers.indicesSubpacketA) PX_FREE_AND_RESET(tempBuffers.indicesSubpacketA); if (tempBuffers.indicesSubpacketB) PX_FREE_AND_RESET(tempBuffers.indicesSubpacketB); if (tempBuffers.cellHashTableSubpacketB) PX_FREE_AND_RESET(tempBuffers.cellHashTableSubpacketB); if (tempBuffers.cellHashTableSubpacketA) PX_FREE_AND_RESET(tempBuffers.cellHashTableSubpacketA); if (tempBuffers.simdPositionsSubpacket) { align16.deallocate(tempBuffers.simdPositionsSubpacket); tempBuffers.simdPositionsSubpacket = NULL; } if (tempBuffers.mergedHaloRegions) { align16.deallocate(tempBuffers.mergedHaloRegions); tempBuffers.mergedHaloRegions = NULL; } } // growing for (PxU32 i = mNumTempBuffers; i < count; ++i) { PxsFluidDynamicsTempBuffers& tempBuffers = mTempBuffers[i]; // Make sure the number of hash buckets is a power of 2 (requirement for the used hash function) tempBuffers.cellHashMaxSize = Ps::nextPowerOfTwo((PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY + 1)); // Local hash tables for particle cells (for two subpackets A and B). tempBuffers.cellHashTableSubpacketA = (PxsParticleCell*)PX_ALLOC(tempBuffers.cellHashMaxSize*sizeof(PxsParticleCell), PX_DEBUG_EXP("PxsParticleCell")); tempBuffers.cellHashTableSubpacketB = (PxsParticleCell*)PX_ALLOC(tempBuffers.cellHashMaxSize*sizeof(PxsParticleCell), PX_DEBUG_EXP("PxsParticleCell")); // Particle index lists for local hash of particle cells (for two subpackets A and B). tempBuffers.indicesSubpacketA = (PxU32*)PX_ALLOC(PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY*sizeof(PxU32), PX_DEBUG_EXP("Subpacket indices")); tempBuffers.indicesSubpacketB = (PxU32*)PX_ALLOC(PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY*sizeof(PxU32), PX_DEBUG_EXP("Subpacket indices")); tempBuffers.mergedIndices = (PxU32*)PX_ALLOC(PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY*sizeof(PxU32), PX_DEBUG_EXP("Subpacket merged indices")); tempBuffers.mergedHaloRegions = (PxsFluidParticle*) align16.allocate(PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY*sizeof(PxsFluidParticle), __FILE__, __LINE__); tempBuffers.hashKeys = (PxU16*)PX_ALLOC(PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY*sizeof(PxU16), PX_DEBUG_EXP("Subpacket hashKeys")); // SIMD buffer for storing intermediate particle positions of up to a subpacket size. // Ceil up to multiple of four + 4 for save unrolling. // For 4 particles we need three Vec4V. PxU32 paddedSubPacketMax = ((PXS_FLUID_SUBPACKET_PARTICLE_LIMIT_FORCE_DENSITY + 3) & ~0x3) + 4; tempBuffers.simdPositionsSubpacket = (PxU8*)align16.allocate(3*(paddedSubPacketMax / 4)*sizeof(Vec4V), __FILE__, __LINE__); tempBuffers.indexStream = (PxU32*)PX_ALLOC(MAX_INDEX_STREAM_SIZE*sizeof(PxU32), PX_DEBUG_EXP("indexStream")); tempBuffers.orderedIndicesSubpacket = sOrderedIndexTable.indices; } mNumTempBuffers = count; }
Gu::TriangleMesh::~TriangleMesh() { if(getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) { PX_FREE_AND_RESET(mExtraTrigData); PX_FREE_AND_RESET(mFaceRemap); PX_FREE_AND_RESET(mAdjacencies); PX_FREE_AND_RESET(mMaterialIndices); PX_FREE_AND_RESET(mTriangles); PX_FREE_AND_RESET(mVertices); PX_FREE_AND_RESET(mGRB_triIndices); PX_FREE_AND_RESET(mGRB_triAdjacencies); PX_FREE_AND_RESET(mGRB_vertValency); PX_FREE_AND_RESET(mGRB_adjVertStart); PX_FREE_AND_RESET(mGRB_adjVertices); PX_FREE_AND_RESET(mGRB_faceRemap); BV32Tree* bv32Tree = reinterpret_cast<BV32Tree*>(mGRB_BV32Tree); PX_DELETE_AND_RESET(bv32Tree); } }