Update AssImp to latest version
This commit is contained in:
76
Source/ThirdParty/assimp/SpatialSort.h
vendored
76
Source/ThirdParty/assimp/SpatialSort.h
vendored
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
@@ -41,11 +41,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/** Small helper classes to optimise finding vertizes close to a given location */
|
||||
#pragma once
|
||||
#ifndef AI_SPATIALSORT_H_INC
|
||||
#define AI_SPATIALSORT_H_INC
|
||||
|
||||
#include <vector>
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
@@ -57,10 +63,8 @@ namespace Assimp {
|
||||
* time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen
|
||||
* so that it avoids common planes in usual data sets. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class ASSIMP_API SpatialSort
|
||||
{
|
||||
class ASSIMP_API SpatialSort {
|
||||
public:
|
||||
|
||||
SpatialSort();
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
@@ -71,14 +75,12 @@ public:
|
||||
* @param pNumPositions Number of vectors to expect in that array.
|
||||
* @param pElementOffset Offset in bytes from the beginning of one vector in memory
|
||||
* to the beginning of the next vector. */
|
||||
SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset);
|
||||
SpatialSort(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset);
|
||||
|
||||
/** Destructor */
|
||||
~SpatialSort();
|
||||
|
||||
public:
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
||||
* The new data receives new indices in ascending order.
|
||||
@@ -92,17 +94,15 @@ public:
|
||||
* required in order to use #FindPosition() or #GenerateMappingTable().
|
||||
* If you don't finalize yet, you can use #Append() to add data from
|
||||
* other sources.*/
|
||||
void Fill( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
void Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Same as #Fill(), except the method appends to existing data in the #SpatialSort. */
|
||||
void Append( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
void Append(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Finalize the spatial hash data structure. This can be useful after
|
||||
@@ -118,8 +118,8 @@ public:
|
||||
* @param poResults The container to store the indices of the found positions.
|
||||
* Will be emptied by the call so it may contain anything.
|
||||
* @return An iterator to iterate over all vertices in the given area.*/
|
||||
void FindPositions( const aiVector3D& pPosition, ai_real pRadius,
|
||||
std::vector<unsigned int>& poResults) const;
|
||||
void FindPositions(const aiVector3D &pPosition, ai_real pRadius,
|
||||
std::vector<unsigned int> &poResults) const;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Fills an array with indices of all positions identical to the given position. In
|
||||
@@ -128,8 +128,8 @@ public:
|
||||
* @param pPosition The position to look for vertices.
|
||||
* @param poResults The container to store the indices of the found positions.
|
||||
* Will be emptied by the call so it may contain anything.*/
|
||||
void FindIdenticalPositions( const aiVector3D& pPosition,
|
||||
std::vector<unsigned int>& poResults) const;
|
||||
void FindIdenticalPositions(const aiVector3D &pPosition,
|
||||
std::vector<unsigned int> &poResults) const;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Compute a table that maps each vertex ID referring to a spatially close
|
||||
@@ -139,34 +139,50 @@ public:
|
||||
* @param pRadius Maximal distance from the position a vertex may have to
|
||||
* be counted in.
|
||||
* @return Number of unique vertices (n). */
|
||||
unsigned int GenerateMappingTable(std::vector<unsigned int>& fill,
|
||||
ai_real pRadius) const;
|
||||
unsigned int GenerateMappingTable(std::vector<unsigned int> &fill,
|
||||
ai_real pRadius) const;
|
||||
|
||||
protected:
|
||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
||||
/** Return the distance to the sorting plane. */
|
||||
ai_real CalculateDistance(const aiVector3D &pPosition) const;
|
||||
|
||||
protected:
|
||||
/** Normal of the sorting plane, normalized.
|
||||
*/
|
||||
aiVector3D mPlaneNormal;
|
||||
|
||||
/** The centroid of the positions, which is used as a point on the sorting plane
|
||||
* when calculating distance. This value is calculated in Finalize.
|
||||
*/
|
||||
aiVector3D mCentroid;
|
||||
|
||||
/** An entry in a spatially sorted position array. Consists of a vertex index,
|
||||
* its position and its pre-calculated distance from the reference plane */
|
||||
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 ), mPosition(), mDistance( 99999. ) {
|
||||
// empty
|
||||
: mIndex(std::numeric_limits<unsigned int>::max()),
|
||||
mPosition(),
|
||||
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), mDistance(std::numeric_limits<ai_real>::max()) {
|
||||
// empty
|
||||
}
|
||||
|
||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
||||
bool operator<(const Entry &e) const { return mDistance < e.mDistance; }
|
||||
};
|
||||
|
||||
// all positions, sorted by distance to the sorting plane
|
||||
std::vector<Entry> mPositions;
|
||||
|
||||
/// false until the Finalize method is called.
|
||||
bool mFinalized;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
Reference in New Issue
Block a user