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

Function flatten

physx/source/physxcooking/src/BVHStructureBuilder.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void flatten(const NodeAllocator& nodeAllocator, BVHNode* dest)
62{
63 // PT: gathers all build nodes allocated so far and flatten them to a linear destination array of smaller runtime nodes
64 PxU32 offset = 0;
65 const PxU32 nbSlabs = nodeAllocator.mSlabs.size();
66 for(PxU32 s=0;s<nbSlabs;s++)
67 {
68 const NodeAllocator::Slab& currentSlab = nodeAllocator.mSlabs[s];
69
70 AABBTreeBuildNode* pool = currentSlab.mPool;
71 for(PxU32 i=0;i<currentSlab.mNbUsedNodes;i++)
72 {
73 dest[offset].mBV = pool[i].mBV;
74 if(pool[i].isLeaf())
75 {
76 const PxU32 index = pool[i].mNodeIndex;
77
78 const PxU32 nbPrims = pool[i].getNbPrimitives();
79 PX_ASSERT(nbPrims<=16);
80
81 dest[offset].mData = (index<<5)|((nbPrims&15)<<1)|1;
82 }
83 else
84 {
85 PX_ASSERT(pool[i].mPos);
86 PxU32 localNodeIndex = 0xffffffff;
87 PxU32 nodeBase = 0;
88 for(PxU32 j=0;j<nbSlabs;j++)
89 {
90 if(pool[i].mPos>= nodeAllocator.mSlabs[j].mPool && pool[i].mPos < nodeAllocator.mSlabs[j].mPool + nodeAllocator.mSlabs[j].mNbUsedNodes)
91 {
92 localNodeIndex = PxU32(pool[i].mPos - nodeAllocator.mSlabs[j].mPool);
93 break;
94 }
95 nodeBase += nodeAllocator.mSlabs[j].mNbUsedNodes;
96 }
97 const PxU32 nodeIndex = nodeBase + localNodeIndex;
98 dest[offset].mData = nodeIndex<<1;
99 }
100 offset++;
101 }
102 }
103}
104
105BVHStructureBuilder::BVHStructureBuilder():
106 mBounds(NULL),

Callers 1

loadFromDescMethod · 0.70

Calls 3

sizeMethod · 0.45
isLeafMethod · 0.45
getNbPrimitivesMethod · 0.45

Tested by

no test coverage detected