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

Method clone

physx/source/scenequery/src/SqIncrementalAABBTree.cpp:957–1029  ·  view source on GitHub ↗

clone the tree, the tree is computed in the NodeAllocator, similar to AABBTree flatten

Source from the content-addressed store, hash-verified

955
956// clone the tree, the tree is computed in the NodeAllocator, similar to AABBTree flatten
957void IncrementalAABBTree::clone(Ps::Array<IncrementalAABBTreeNode*>& mapping, const PxU32* _indices, IncrementalAABBTreeNode** treeNodes)
958{
959 PxU32 offset = 0;
960 const PxU32 nbSlabs = mNodeAllocator.mSlabs.size();
961 for (PxU32 s = 0; s<nbSlabs; s++)
962 {
963 const NodeAllocator::Slab& currentSlab = mNodeAllocator.mSlabs[s];
964
965 AABBTreeBuildNode* pool = currentSlab.mPool;
966 for (PxU32 i = 0; i < currentSlab.mNbUsedNodes; i++)
967 {
968 IncrementalAABBTreeNode* destNode = treeNodes[offset];
969 if(!destNode)
970 {
971 destNode = reinterpret_cast<IncrementalAABBTreeNode*>(mNodesPool.allocate());
972 treeNodes[offset] = destNode;
973 }
974
975 destNode->mBVMin = V4ClearW(V4LoadU(&pool[i].mBV.minimum.x));
976 destNode->mBVMax = V4ClearW(V4LoadU(&pool[i].mBV.maximum.x));
977
978 if (pool[i].isLeaf())
979 {
980 AABBTreeIndices* indices = mIndicesPool.allocate();
981 destNode->mIndices = indices;
982 destNode->mChilds[1] = NULL;
983 indices->nbIndices = pool[i].getNbPrimitives();
984 PX_ASSERT(indices->nbIndices <= 16);
985 const PxU32* sourceIndices = _indices + pool[i].mNodeIndex;
986 for (PxU32 iIndices = 0; iIndices < indices->nbIndices; iIndices++)
987 {
988 const PxU32 sourceIndex = sourceIndices[iIndices];
989 indices->indices[iIndices] = sourceIndex;
990 PX_ASSERT(sourceIndex < mapping.size());
991 mapping[sourceIndex] = destNode;
992 }
993 }
994 else
995 {
996 PX_ASSERT(pool[i].mPos);
997 PxU32 localNodeIndex = 0xffffffff;
998 PxU32 nodeBase = 0;
999 for (PxU32 j = 0; j<nbSlabs; j++)
1000 {
1001 if (pool[i].mPos >= mNodeAllocator.mSlabs[j].mPool && pool[i].mPos < mNodeAllocator.mSlabs[j].mPool + mNodeAllocator.mSlabs[j].mNbUsedNodes)
1002 {
1003 localNodeIndex = PxU32(pool[i].mPos - mNodeAllocator.mSlabs[j].mPool);
1004 break;
1005 }
1006 nodeBase += mNodeAllocator.mSlabs[j].mNbUsedNodes;
1007 }
1008 const PxU32 nodeIndex = nodeBase + localNodeIndex;
1009
1010 IncrementalAABBTreeNode* child0 = treeNodes[nodeIndex];
1011 IncrementalAABBTreeNode* child1 = treeNodes[nodeIndex + 1];
1012 if(!child0)
1013 {
1014 PX_ASSERT(!child1);

Callers 3

jquery.jsFile · 0.45
jquery.jsFile · 0.45
BFunction · 0.45

Calls 6

V4ClearWFunction · 0.50
V4LoadUFunction · 0.50
sizeMethod · 0.45
allocateMethod · 0.45
isLeafMethod · 0.45
getNbPrimitivesMethod · 0.45

Tested by

no test coverage detected