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