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

Function split

physx/source/geomutils/src/GuAABBTreeBuild.cpp:109–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static PxU32 split(const PxBounds3& box, PxU32 nb, PxU32* const PX_RESTRICT prims, PxU32 axis, const AABBTreeBuildParams& params)
110{
111 // Get node split value
112 const float splitValue = getSplittingValue(box, axis);
113
114 PxU32 nbPos = 0;
115 // Loop through all node-related primitives. Their indices range from "mNodePrimitives[0]" to "mNodePrimitives[mNbPrimitives-1]",
116 // with mNodePrimitives = mIndices + mNodeIndex (i.e. those indices map the global list in the tree params).
117
118 // PT: to avoid calling the unsafe [] operator
119 const size_t ptrValue = size_t(params.mCache) + axis * sizeof(float);
120 const PxVec3* /*PX_RESTRICT*/ cache = reinterpret_cast<const PxVec3*>(ptrValue);
121
122 for (PxU32 i = 0; i<nb; i++)
123 {
124 // Get index in global list
125 const PxU32 index = prims[i];
126
127 // Test against the splitting value. The primitive value is tested against the enclosing-box center.
128 // [We only need an approximate partition of the enclosing box here.]
129 const float primitiveValue = cache[index].x;
130 PX_ASSERT(primitiveValue == params.mCache[index][axis]);
131
132 // Reorganize the list of indices in this order: positive - negative.
133 if (primitiveValue > splitValue)
134 {
135 // Swap entries
136 prims[i] = prims[nbPos];
137 prims[nbPos] = index;
138 // Count primitives assigned to positive space
139 nbPos++;
140 }
141 }
142 return nbPos;
143}
144
145void AABBTreeBuildNode::subdivide(const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices)
146{

Callers 2

sort4Method · 0.85
subdivideMethod · 0.85

Calls 1

getSplittingValueFunction · 0.85

Tested by

no test coverage detected