Move distance initialization to Finalize.
parent
5b13b97f27
commit
4d10f5d133
|
@ -89,6 +89,9 @@ void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SpatialSort::Finalize() {
|
void SpatialSort::Finalize() {
|
||||||
|
for (unsigned int i = 0; i < mPositions.size(); i++) {
|
||||||
|
mPositions[i].mDistance = mPositions[i].mPosition * mPlaneNormal;
|
||||||
|
}
|
||||||
std::sort(mPositions.begin(), mPositions.end());
|
std::sort(mPositions.begin(), mPositions.end());
|
||||||
mFinalized = true;
|
mFinalized = true;
|
||||||
}
|
}
|
||||||
|
@ -104,10 +107,7 @@ void SpatialSort::Append(const aiVector3D *pPositions, unsigned int pNumPosition
|
||||||
for (unsigned int a = 0; a < pNumPositions; a++) {
|
for (unsigned int a = 0; a < pNumPositions; a++) {
|
||||||
const char *tempPointer = reinterpret_cast<const char *>(pPositions);
|
const char *tempPointer = reinterpret_cast<const char *>(pPositions);
|
||||||
const aiVector3D *vec = reinterpret_cast<const aiVector3D *>(tempPointer + a * pElementOffset);
|
const aiVector3D *vec = reinterpret_cast<const aiVector3D *>(tempPointer + a * pElementOffset);
|
||||||
|
mPositions.push_back(Entry(static_cast<unsigned int>(a + initial), *vec));
|
||||||
// store position by index and distance
|
|
||||||
ai_real distance = *vec * mPlaneNormal;
|
|
||||||
mPositions.push_back(Entry(static_cast<unsigned int>(a + initial), *vec, distance));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFinalize) {
|
if (pFinalize) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
@ -150,16 +151,17 @@ protected:
|
||||||
struct Entry {
|
struct Entry {
|
||||||
unsigned int mIndex; ///< The vertex referred by this entry
|
unsigned int mIndex; ///< The vertex referred by this entry
|
||||||
aiVector3D mPosition; ///< Position
|
aiVector3D mPosition; ///< Position
|
||||||
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
/// Distance of this vertex to the sorting plane. This is set by Finalize.
|
||||||
|
ai_real mDistance;
|
||||||
|
|
||||||
Entry() AI_NO_EXCEPT
|
Entry() AI_NO_EXCEPT
|
||||||
: mIndex(999999999),
|
: mIndex(std::numeric_limits<unsigned int>::max()),
|
||||||
mPosition(),
|
mPosition(),
|
||||||
mDistance(99999.) {
|
mDistance(std::numeric_limits<ai_real>::max()) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
Entry(unsigned int pIndex, const aiVector3D &pPosition, ai_real pDistance) :
|
Entry(unsigned int pIndex, const aiVector3D &pPosition) :
|
||||||
mIndex(pIndex), mPosition(pPosition), mDistance(pDistance) {
|
mIndex(pIndex), mPosition(pPosition) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue