|
@@ -87,6 +87,11 @@ void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
|
mFinalized = pFinalize;
|
|
mFinalized = pFinalize;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
|
|
+ai_real SpatialSort::CalculateDistance(const aiVector3D &pPosition) const {
|
|
|
|
+ return (pPosition - mCentroid) * mPlaneNormal;
|
|
|
|
+}
|
|
|
|
+
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
void SpatialSort::Finalize() {
|
|
void SpatialSort::Finalize() {
|
|
const ai_real scale = 1.0f / mPositions.size();
|
|
const ai_real scale = 1.0f / mPositions.size();
|
|
@@ -94,7 +99,7 @@ void SpatialSort::Finalize() {
|
|
mCentroid += scale * mPositions[i].mPosition;
|
|
mCentroid += scale * mPositions[i].mPosition;
|
|
}
|
|
}
|
|
for (unsigned int i = 0; i < mPositions.size(); i++) {
|
|
for (unsigned int i = 0; i < mPositions.size(); i++) {
|
|
- mPositions[i].mDistance = (mPositions[i].mPosition - mCentroid) * mPlaneNormal;
|
|
|
|
|
|
+ mPositions[i].mDistance = CalculateDistance(mPositions[i].mPosition);
|
|
}
|
|
}
|
|
std::sort(mPositions.begin(), mPositions.end());
|
|
std::sort(mPositions.begin(), mPositions.end());
|
|
mFinalized = true;
|
|
mFinalized = true;
|
|
@@ -125,7 +130,7 @@ void SpatialSort::Append(const aiVector3D *pPositions, unsigned int pNumPosition
|
|
void SpatialSort::FindPositions(const aiVector3D &pPosition,
|
|
void SpatialSort::FindPositions(const aiVector3D &pPosition,
|
|
ai_real pRadius, std::vector<unsigned int> &poResults) const {
|
|
ai_real pRadius, std::vector<unsigned int> &poResults) const {
|
|
ai_assert(mFinalized && "The SpatialSort object must be finalized before FindPositions can be called.");
|
|
ai_assert(mFinalized && "The SpatialSort object must be finalized before FindPositions can be called.");
|
|
- const ai_real dist = (pPosition - mCentroid) * mPlaneNormal;
|
|
|
|
|
|
+ const ai_real dist = CalculateDistance(pPosition);
|
|
const ai_real minDist = dist - pRadius, maxDist = dist + pRadius;
|
|
const ai_real minDist = dist - pRadius, maxDist = dist + pRadius;
|
|
|
|
|
|
// clear the array
|
|
// clear the array
|
|
@@ -266,7 +271,7 @@ void SpatialSort::FindIdenticalPositions(const aiVector3D &pPosition, std::vecto
|
|
|
|
|
|
// Convert the plane distance to its signed integer representation so the ULPs tolerance can be
|
|
// Convert the plane distance to its signed integer representation so the ULPs tolerance can be
|
|
// applied. For some reason, VC won't optimize two calls of the bit pattern conversion.
|
|
// applied. For some reason, VC won't optimize two calls of the bit pattern conversion.
|
|
- const BinFloat minDistBinary = ToBinary((pPosition - mCentroid) * mPlaneNormal) - distanceToleranceInULPs;
|
|
|
|
|
|
+ const BinFloat minDistBinary = ToBinary(CalculateDistance(pPosition)) - distanceToleranceInULPs;
|
|
const BinFloat maxDistBinary = minDistBinary + 2 * distanceToleranceInULPs;
|
|
const BinFloat maxDistBinary = minDistBinary + 2 * distanceToleranceInULPs;
|
|
|
|
|
|
// clear the array in this strange fashion because a simple clear() would also deallocate
|
|
// clear the array in this strange fashion because a simple clear() would also deallocate
|