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

Method loadFromDesc

physx/source/physxcooking/src/BVHStructureBuilder.cpp:121–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121bool BVHStructureBuilder::loadFromDesc(const PxBVHStructureDesc& desc)
122{
123 PX_ASSERT(desc.isValid());
124
125 const PxU32 numPrimitives = desc.bounds.count;
126
127 // allocate one more for safe SIMD vec4 load
128 mBounds = reinterpret_cast<PxBounds3*>(PX_ALLOC((numPrimitives + 1) * sizeof(PxBounds3), "PxBounds3"));
129
130 const PxU8* sB = reinterpret_cast<const PxU8*>(desc.bounds.data);
131
132 for(PxU32 i = 0; i < numPrimitives; i++)
133 {
134 inflateBounds(mBounds[i], *reinterpret_cast<const PxBounds3*>(sB));
135
136 sB += desc.bounds.stride;
137 }
138 mNumVolumes = numPrimitives;
139
140 // build the BVH
141 AABBTreeBuildParams params;
142 params.mNbPrimitives = desc.bounds.count;
143 params.mAABBArray = mBounds;
144 params.mLimit = NB_OBJECTS_PER_NODE;
145 BuildStats stats;
146 NodeAllocator nodeAllocator;
147
148 const bool buildStatus = buildAABBTree(params, nodeAllocator, stats, mIndices);
149 PX_UNUSED(buildStatus);
150 PX_ASSERT(buildStatus);
151
152 // store the computed hierarchy
153 mNumNodes = stats.getCount();
154 mNodes = reinterpret_cast<BVHNode*>(PX_ALLOC(sizeof(BVHNode)*mNumNodes, "AABB tree nodes"));
155 PX_ASSERT(mNumNodes==nodeAllocator.mTotalNbNodes);
156
157 // store the results into BVHNode list
158 flatten(nodeAllocator, mNodes);
159 nodeAllocator.release();
160
161 return true;
162}
163
164// A.B. move to load code
165#define PX_BVH_STRUCTURE_VERSION 1

Callers 7

validateTriangleMeshMethod · 0.45
cookTriangleMeshMethod · 0.45
createTriangleMeshMethod · 0.45
cookHeightFieldMethod · 0.45
createHeightFieldMethod · 0.45
cookBVHStructureMethod · 0.45
createBVHStructureMethod · 0.45

Calls 6

PX_UNUSEDFunction · 0.85
inflateBoundsFunction · 0.70
flattenFunction · 0.70
isValidMethod · 0.45
getCountMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected