Merge branch 'master' into issue_1781

pull/1789/head
Kim Kulling 2018-02-13 13:11:03 +01:00 committed by GitHub
commit 5ac415ff62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 117 deletions

View File

@ -190,7 +190,7 @@ Importer::~Importer()
delete pimpl->mIOHandler; delete pimpl->mIOHandler;
delete pimpl->mProgressHandler; delete pimpl->mProgressHandler;
// Kill imported scene. Destructors should do that recursivly // Kill imported scene. Destructor's should do that recursively
delete pimpl->mScene; delete pimpl->mScene;
// Delete shared post-processing data // Delete shared post-processing data
@ -200,18 +200,6 @@ Importer::~Importer()
delete pimpl; delete pimpl;
} }
// ------------------------------------------------------------------------------------------------
// Copy constructor - copies the config of another Importer, not the scene
Importer::Importer(const Importer &other)
: pimpl(NULL) {
new(this) Importer();
pimpl->mIntProperties = other.pimpl->mIntProperties;
pimpl->mFloatProperties = other.pimpl->mFloatProperties;
pimpl->mStringProperties = other.pimpl->mStringProperties;
pimpl->mMatrixProperties = other.pimpl->mMatrixProperties;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Register a custom post-processing step // Register a custom post-processing step
aiReturn Importer::RegisterPPStep(BaseProcess* pImp) aiReturn Importer::RegisterPPStep(BaseProcess* pImp)

View File

@ -137,7 +137,7 @@ public:
* If this Importer owns a scene it won't be copied. * If this Importer owns a scene it won't be copied.
* Call ReadFile() to start the import process. * Call ReadFile() to start the import process.
*/ */
Importer(const Importer& other); Importer(const Importer& other)=delete;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Assignment operator has been deleted /** Assignment operator has been deleted

View File

@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector> #include <vector>
#include <assimp/types.h> #include <assimp/types.h>
namespace Assimp namespace Assimp {
{
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
/** A little helper class to quickly find all vertices in the epsilon environment of a given /** A little helper class to quickly find all vertices in the epsilon environment of a given
@ -148,17 +147,20 @@ protected:
aiVector3D mPlaneNormal; aiVector3D mPlaneNormal;
/** An entry in a spatially sorted position array. Consists of a vertex index, /** An entry in a spatially sorted position array. Consists of a vertex index,
* its position and its precalculated distance from the reference plane */ * its position and its pre-calculated distance from the reference plane */
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 ai_real mDistance; ///< Distance of this vertex to the sorting plane
Entry() { /** intentionally not initialized.*/ } Entry()
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
// empty
}
Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance) Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance)
: mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) : mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) {
{ } // empty
}
bool operator < (const Entry& e) const { return mDistance < e.mDistance; } bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
}; };

View File

@ -59,69 +59,65 @@ const double fast_atof_table[16] = { // we write [16] here instead of [] to wo
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Convert a string in decimal format to a number // Convert a string in decimal format to a number
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline unsigned int strtoul10( const char* in, const char** out=0) inline
{ unsigned int strtoul10( const char* in, const char** out=0) {
unsigned int value = 0; unsigned int value = 0;
bool running = true; for ( ;; ) {
while ( running )
{
if ( *in < '0' || *in > '9' ) if ( *in < '0' || *in > '9' )
break; break;
value = ( value * 10 ) + ( *in - '0' ); value = ( value * 10 ) + ( *in - '0' );
++in; ++in;
} }
if (out)*out = in; if ( out ) {
*out = in;
}
return value; return value;
} }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Convert a string in octal format to a number // Convert a string in octal format to a number
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline unsigned int strtoul8( const char* in, const char** out=0) inline
{ unsigned int strtoul8( const char* in, const char** out=0) {
unsigned int value = 0; unsigned int value( 0 );
for ( ;; ) {
bool running = true; if ( *in < '0' || *in > '7' ) {
while ( running )
{
if ( *in < '0' || *in > '7' )
break; break;
}
value = ( value << 3 ) + ( *in - '0' ); value = ( value << 3 ) + ( *in - '0' );
++in; ++in;
} }
if (out)*out = in; if ( out ) {
*out = in;
}
return value; return value;
} }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Convert a string in hex format to a number // Convert a string in hex format to a number
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline unsigned int strtoul16( const char* in, const char** out=0) inline
{ unsigned int strtoul16( const char* in, const char** out=0) {
unsigned int value = 0; unsigned int value( 0 );
for ( ;; ) {
bool running = true; if ( *in >= '0' && *in <= '9' ) {
while ( running )
{
if ( *in >= '0' && *in <= '9' )
{
value = ( value << 4u ) + ( *in - '0' ); value = ( value << 4u ) + ( *in - '0' );
} } else if (*in >= 'A' && *in <= 'F') {
else if (*in >= 'A' && *in <= 'F')
{
value = ( value << 4u ) + ( *in - 'A' ) + 10; value = ( value << 4u ) + ( *in - 'A' ) + 10;
} } else if (*in >= 'a' && *in <= 'f') {
else if (*in >= 'a' && *in <= 'f')
{
value = ( value << 4u ) + ( *in - 'a' ) + 10; value = ( value << 4u ) + ( *in - 'a' ) + 10;
} }
else break; else {
break;
}
++in; ++in;
} }
if (out)*out = in; if ( out ) {
*out = in;
}
return value; return value;
} }
@ -129,17 +125,16 @@ inline unsigned int strtoul16( const char* in, const char** out=0)
// Convert just one hex digit // Convert just one hex digit
// Return value is UINT_MAX if the input character is not a hex digit. // Return value is UINT_MAX if the input character is not a hex digit.
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline unsigned int HexDigitToDecimal(char in) inline
{ unsigned int HexDigitToDecimal(char in) {
unsigned int out = UINT_MAX; unsigned int out( UINT_MAX );
if (in >= '0' && in <= '9') if ( in >= '0' && in <= '9' ) {
out = in - '0'; out = in - '0';
} else if ( in >= 'a' && in <= 'f' ) {
else if (in >= 'a' && in <= 'f')
out = 10u + in - 'a'; out = 10u + in - 'a';
} else if ( in >= 'A' && in <= 'F' ) {
else if (in >= 'A' && in <= 'F')
out = 10u + in - 'A'; out = 10u + in - 'A';
}
// return value is UINT_MAX if the input is not a hex digit // return value is UINT_MAX if the input is not a hex digit
return out; return out;
@ -148,8 +143,8 @@ inline unsigned int HexDigitToDecimal(char in)
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Convert a hex-encoded octet (2 characters, i.e. df or 1a). // Convert a hex-encoded octet (2 characters, i.e. df or 1a).
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline uint8_t HexOctetToDecimal(const char* in) inline
{ uint8_t HexOctetToDecimal(const char* in) {
return ((uint8_t)HexDigitToDecimal(in[0])<<4)+(uint8_t)HexDigitToDecimal(in[1]); return ((uint8_t)HexDigitToDecimal(in[0])<<4)+(uint8_t)HexDigitToDecimal(in[1]);
} }
@ -157,11 +152,12 @@ inline uint8_t HexOctetToDecimal(const char* in)
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// signed variant of strtoul10 // signed variant of strtoul10
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline int strtol10( const char* in, const char** out=0) inline
{ int strtol10( const char* in, const char** out=0) {
bool inv = (*in=='-'); bool inv = (*in=='-');
if (inv || *in=='+') if ( inv || *in == '+' ) {
++in; ++in;
}
int value = strtoul10(in,out); int value = strtoul10(in,out);
if (inv) { if (inv) {
@ -176,10 +172,9 @@ inline int strtol10( const char* in, const char** out=0)
// 0NNN - oct // 0NNN - oct
// NNN - dec // NNN - dec
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline unsigned int strtoul_cppstyle( const char* in, const char** out=0) inline
{ unsigned int strtoul_cppstyle( const char* in, const char** out=0) {
if ('0' == in[0]) if ('0' == in[0]) {
{
return 'x' == in[1] ? strtoul16(in+2,out) : strtoul8(in+1,out); return 'x' == in[1] ? strtoul16(in+2,out) : strtoul8(in+1,out);
} }
return strtoul10(in, out); return strtoul10(in, out);
@ -189,19 +184,19 @@ inline unsigned int strtoul_cppstyle( const char* in, const char** out=0)
// Special version of the function, providing higher accuracy and safety // Special version of the function, providing higher accuracy and safety
// It is mainly used by fast_atof to prevent ugly and unwanted integer overflows. // It is mainly used by fast_atof to prevent ugly and unwanted integer overflows.
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_inout=0) inline
{ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_inout=0) {
unsigned int cur = 0; unsigned int cur = 0;
uint64_t value = 0; uint64_t value = 0;
if ( *in < '0' || *in > '9' ) if ( *in < '0' || *in > '9' ) {
throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value."); throw std::invalid_argument( std::string( "The string \"" ) + in + "\" cannot be converted into a value." );
}
bool running = true; for ( ;; ) {
while ( running ) if ( *in < '0' || *in > '9' ) {
{
if ( *in < '0' || *in > '9' )
break; break;
}
const uint64_t new_value = ( value * 10 ) + ( *in - '0' ); const uint64_t new_value = ( value * 10 ) + ( *in - '0' );
@ -240,11 +235,12 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// signed variant of strtoul10_64 // signed variant of strtoul10_64
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
inline int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* max_inout = 0) inline
{ int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* max_inout = 0) {
bool inv = (*in == '-'); bool inv = (*in == '-');
if (inv || *in == '+') if (inv || *in == '+') {
++in; ++in;
}
int64_t value = strtoul10_64(in, out, max_inout); int64_t value = strtoul10_64(in, out, max_inout);
if (inv) { if (inv) {
@ -263,8 +259,8 @@ inline int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* m
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org. // If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
template <typename Real> template <typename Real>
inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true) inline
{ const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true) {
Real f = 0; Real f = 0;
bool inv = (*c == '-'); bool inv = (*c == '-');
@ -272,42 +268,36 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma
++c; ++c;
} }
if ((c[0] == 'N' || c[0] == 'n') && ASSIMP_strincmp(c, "nan", 3) == 0) if ((c[0] == 'N' || c[0] == 'n') && ASSIMP_strincmp(c, "nan", 3) == 0) {
{
out = std::numeric_limits<Real>::quiet_NaN(); out = std::numeric_limits<Real>::quiet_NaN();
c += 3; c += 3;
return c; return c;
} }
if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inf", 3) == 0) if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inf", 3) == 0) {
{
out = std::numeric_limits<Real>::infinity(); out = std::numeric_limits<Real>::infinity();
if (inv) { if (inv) {
out = -out; out = -out;
} }
c += 3; c += 3;
if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inity", 5) == 0) if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inity", 5) == 0) {
{
c += 5; c += 5;
} }
return c; return c;
} }
if (!(c[0] >= '0' && c[0] <= '9') && if (!(c[0] >= '0' && c[0] <= '9') &&
!((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) !((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) {
{
throw std::invalid_argument("Cannot parse string " throw std::invalid_argument("Cannot parse string "
"as real number: does not start with digit " "as real number: does not start with digit "
"or decimal point followed by digit."); "or decimal point followed by digit.");
} }
if (*c != '.' && (! check_comma || c[0] != ',')) if (*c != '.' && (! check_comma || c[0] != ',')) {
{
f = static_cast<Real>( strtoul10_64 ( c, &c) ); f = static_cast<Real>( strtoul10_64 ( c, &c) );
} }
if ((*c == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9') if ((*c == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9') {
{
++c; ++c;
// NOTE: The original implementation is highly inaccurate here. The precision of a single // NOTE: The original implementation is highly inaccurate here. The precision of a single
@ -358,30 +348,30 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// The same but more human. // The same but more human.
inline ai_real fast_atof(const char* c) inline
{ ai_real fast_atof(const char* c) {
ai_real ret(0.0); ai_real ret(0.0);
fast_atoreal_move<ai_real>(c, ret); fast_atoreal_move<ai_real>(c, ret);
return ret; return ret;
} }
inline ai_real fast_atof( const char* c, const char** cout) inline
{ ai_real fast_atof( const char* c, const char** cout) {
ai_real ret(0.0); ai_real ret(0.0);
*cout = fast_atoreal_move<ai_real>(c, ret); *cout = fast_atoreal_move<ai_real>(c, ret);
return ret; return ret;
} }
inline ai_real fast_atof( const char** inout) inline
{ ai_real fast_atof( const char** inout) {
ai_real ret(0.0); ai_real ret(0.0);
*inout = fast_atoreal_move<ai_real>(*inout, ret); *inout = fast_atoreal_move<ai_real>(*inout, ret);
return ret; return ret;
} }
} // end of namespace Assimp } //! namespace Assimp
#endif #endif // __FAST_A_TO_F_H_INCLUDED__

View File

@ -200,8 +200,7 @@ struct aiFace
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief A single influence of a bone on a vertex. /** @brief A single influence of a bone on a vertex.
*/ */
struct aiVertexWeight struct aiVertexWeight {
{
//! Index of the vertex which is influenced by the bone. //! Index of the vertex which is influenced by the bone.
unsigned int mVertexId; unsigned int mVertexId;
@ -214,15 +213,26 @@ struct aiVertexWeight
//! Default constructor //! Default constructor
aiVertexWeight() aiVertexWeight()
: mVertexId(0) : mVertexId(0)
, mWeight(0.0f) , mWeight(0.0f) {
{ } // empty
}
//! Initialisation from a given index and vertex weight factor //! Initialisation from a given index and vertex weight factor
//! \param pID ID //! \param pID ID
//! \param pWeight Vertex weight factor //! \param pWeight Vertex weight factor
aiVertexWeight( unsigned int pID, float pWeight) aiVertexWeight( unsigned int pID, float pWeight )
: mVertexId( pID), mWeight( pWeight) : mVertexId( pID )
{ /* nothing to do here */ } , mWeight( pWeight ) {
// empty
}
bool operator == ( const aiVertexWeight &rhs ) const {
return ( mVertexId == rhs.mVertexId && mWeight == rhs.mWeight );
}
bool operator != ( const aiVertexWeight &rhs ) const {
return ( *this == rhs );
}
#endif // __cplusplus #endif // __cplusplus
}; };
@ -235,8 +245,7 @@ struct aiVertexWeight
* which it can be addressed by animations. In addition it has a number of * which it can be addressed by animations. In addition it has a number of
* influences on vertices. * influences on vertices.
*/ */
struct aiBone struct aiBone {
{
//! The name of the bone. //! The name of the bone.
C_STRUCT aiString mName; C_STRUCT aiString mName;
@ -254,10 +263,10 @@ struct aiBone
//! Default constructor //! Default constructor
aiBone() aiBone()
: mName() : mName()
, mNumWeights( 0 ) , mNumWeights( 0 )
, mWeights( NULL ) , mWeights( nullptr ) {
{ // empty
} }
//! Copy constructor //! Copy constructor
@ -298,7 +307,19 @@ struct aiBone
return *this; return *this;
} }
bool operator == ( const aiBone &rhs ) const {
if ( mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
return false;
}
for ( size_t i = 0; i < mNumWeights; ++i ) {
if ( mWeights[ i ] != rhs.mWeights[ i ] ) {
return false;
}
}
return true;
}
//! Destructor - deletes the array of vertex weights //! Destructor - deletes the array of vertex weights
~aiBone() ~aiBone()
{ {