------------------------------------------------------------------------------------------------
| 308 | |
| 309 | // ------------------------------------------------------------------------------------------------ |
| 310 | unsigned int SpatialSort::GenerateMappingTable(std::vector<unsigned int> &fill, ai_real pRadius) const { |
| 311 | ai_assert(mFinalized && "The SpatialSort object must be finalized before GenerateMappingTable can be called."); |
| 312 | fill.resize(mPositions.size(), UINT_MAX); |
| 313 | ai_real dist, maxDist; |
| 314 | |
| 315 | unsigned int t = 0; |
| 316 | const ai_real pSquared = pRadius * pRadius; |
| 317 | for (size_t i = 0; i < mPositions.size();) { |
| 318 | dist = (mPositions[i].mPosition - mCentroid) * mPlaneNormal; |
| 319 | maxDist = dist + pRadius; |
| 320 | |
| 321 | fill[mPositions[i].mIndex] = t; |
| 322 | const aiVector3D &oldpos = mPositions[i].mPosition; |
| 323 | for (++i; i < fill.size() && mPositions[i].mDistance < maxDist && (mPositions[i].mPosition - oldpos).SquareLength() < pSquared; ++i) { |
| 324 | fill[mPositions[i].mIndex] = t; |
| 325 | } |
| 326 | ++t; |
| 327 | } |
| 328 | |
| 329 | #ifdef ASSIMP_BUILD_DEBUG |
| 330 | |
| 331 | // debug invariant: mPositions[i].mIndex values must range from 0 to mPositions.size()-1 |
| 332 | for (size_t i = 0; i < fill.size(); ++i) { |
| 333 | ai_assert(fill[i] < mPositions.size()); |
| 334 | } |
| 335 | |
| 336 | #endif |
| 337 | return t; |
| 338 | } |
no test coverage detected