MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / addCompound

Method addCompound

physx/source/scenequery/src/SqCompoundPruningPool.cpp:199–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197///////////////////////////////////////////////////////////////////////////////////////////////
198
199PoolIndex CompoundTreePool::addCompound(PrunerHandle* results, const BVHStructure& bvhStructure, const PxBounds3& compoundBounds, const PxTransform& transform,
200 CompoundFlag::Enum flags, const PrunerPayload* userData)
201{
202 if(mNbObjects==mMaxNbObjects) // increase the capacity on overflow
203 {
204 if(!resize(PxMax<PxU32>(mMaxNbObjects*2, 32)))
205 {
206 // pool can return an invalid handle if memory alloc fails
207 Ps::getFoundation().error(PxErrorCode::eOUT_OF_MEMORY, __FILE__, __LINE__, "CompoundTreePool::addCompound memory allocation in resize failed.");
208 return INVALID_PRUNERHANDLE;
209 }
210 }
211 PX_ASSERT(mNbObjects!=mMaxNbObjects);
212
213 const PoolIndex index = mNbObjects++;
214
215 mCompoundBounds[index] = compoundBounds;
216
217 const PxU32 nbObjects = bvhStructure.getNbBounds();
218
219 CompoundTree& tree = mCompoundTrees[index];
220 PX_ASSERT(tree.mPruningPool == NULL);
221 PX_ASSERT(tree.mTree == NULL);
222 PX_ASSERT(tree.mUpdateMap == NULL);
223
224 tree.mGlobalPose = transform;
225 tree.mFlags = flags;
226
227 // prepare the pruning pool
228 PruningPool* pool = PX_PLACEMENT_NEW(PX_ALLOC(sizeof(PruningPool), PX_DEBUG_EXP("Pruning pool")), PruningPool);
229 pool->preallocate(nbObjects);
230 pool->addObjects(results, bvhStructure.getBounds(), userData, nbObjects);
231 tree.mPruningPool = pool;
232
233 // prepare update map
234 UpdateMap* map = PX_PLACEMENT_NEW(PX_ALLOC(sizeof(UpdateMap), PX_DEBUG_EXP("Update map")), UpdateMap);
235 map->resizeUninitialized(nbObjects);
236 tree.mUpdateMap = map;
237
238 IncrementalAABBTree* iTree = PX_NEW(IncrementalAABBTree)();
239 iTree->copy(bvhStructure, *map);
240 tree.mTree = iTree;
241
242 return index;
243}
244
245///////////////////////////////////////////////////////////////////////////////////////////////
246

Callers

nothing calls this directly

Calls 8

resizeFunction · 0.85
errorMethod · 0.80
getNbBoundsMethod · 0.80
resizeUninitializedMethod · 0.80
preallocateMethod · 0.45
addObjectsMethod · 0.45
getBoundsMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected