Merge branch 'master' into pbrmaterial_h

pull/1795/head
Kim Kulling 2018-02-13 19:17:18 +01:00 committed by GitHub
commit cdfe33e3f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 121 additions and 120 deletions

View File

@ -190,7 +190,7 @@ Importer::~Importer()
delete pimpl->mIOHandler;
delete pimpl->mProgressHandler;
// Kill imported scene. Destructors should do that recursivly
// Kill imported scene. Destructor's should do that recursively
delete pimpl->mScene;
// Delete shared post-processing data
@ -200,18 +200,6 @@ Importer::~Importer()
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
aiReturn Importer::RegisterPPStep(BaseProcess* pImp)

View File

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

View File

@ -99,19 +99,19 @@ public:
// Seek specific position
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) {
if (aiOrigin_SET == pOrigin) {
if (pOffset >= length) {
if (pOffset > length) {
return AI_FAILURE;
}
pos = pOffset;
}
else if (aiOrigin_END == pOrigin) {
if (pOffset >= length) {
if (pOffset > length) {
return AI_FAILURE;
}
pos = length-pOffset;
}
else {
if (pOffset+pos >= length) {
if (pOffset+pos > length) {
return AI_FAILURE;
}
pos += pOffset;

View File

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

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
// ------------------------------------------------------------------------------------
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;
bool running = true;
while ( running )
{
for ( ;; ) {
if ( *in < '0' || *in > '9' )
break;
value = ( value * 10 ) + ( *in - '0' );
++in;
}
if (out)*out = in;
if ( out ) {
*out = in;
}
return value;
}
// ------------------------------------------------------------------------------------
// Convert a string in octal format to a number
// ------------------------------------------------------------------------------------
inline unsigned int strtoul8( const char* in, const char** out=0)
{
unsigned int value = 0;
bool running = true;
while ( running )
{
if ( *in < '0' || *in > '7' )
inline
unsigned int strtoul8( const char* in, const char** out=0) {
unsigned int value( 0 );
for ( ;; ) {
if ( *in < '0' || *in > '7' ) {
break;
}
value = ( value << 3 ) + ( *in - '0' );
++in;
}
if (out)*out = in;
if ( out ) {
*out = in;
}
return value;
}
// ------------------------------------------------------------------------------------
// Convert a string in hex format to a number
// ------------------------------------------------------------------------------------
inline unsigned int strtoul16( const char* in, const char** out=0)
{
unsigned int value = 0;
bool running = true;
while ( running )
{
if ( *in >= '0' && *in <= '9' )
{
inline
unsigned int strtoul16( const char* in, const char** out=0) {
unsigned int value( 0 );
for ( ;; ) {
if ( *in >= '0' && *in <= '9' ) {
value = ( value << 4u ) + ( *in - '0' );
}
else if (*in >= 'A' && *in <= 'F')
{
} else if (*in >= 'A' && *in <= 'F') {
value = ( value << 4u ) + ( *in - 'A' ) + 10;
}
else if (*in >= 'a' && *in <= 'f')
{
} else if (*in >= 'a' && *in <= 'f') {
value = ( value << 4u ) + ( *in - 'a' ) + 10;
}
else break;
else {
break;
}
++in;
}
if (out)*out = in;
if ( out ) {
*out = in;
}
return value;
}
@ -129,17 +125,16 @@ inline unsigned int strtoul16( const char* in, const char** out=0)
// Convert just one hex digit
// Return value is UINT_MAX if the input character is not a hex digit.
// ------------------------------------------------------------------------------------
inline unsigned int HexDigitToDecimal(char in)
{
unsigned int out = UINT_MAX;
if (in >= '0' && in <= '9')
inline
unsigned int HexDigitToDecimal(char in) {
unsigned int out( UINT_MAX );
if ( in >= '0' && in <= '9' ) {
out = in - '0';
else if (in >= 'a' && in <= 'f')
} else if ( in >= 'a' && in <= 'f' ) {
out = 10u + in - 'a';
else if (in >= 'A' && in <= 'F')
} else if ( in >= 'A' && in <= 'F' ) {
out = 10u + in - 'A';
}
// return value is UINT_MAX if the input is not a hex digit
return out;
@ -148,8 +143,8 @@ inline unsigned int HexDigitToDecimal(char in)
// ------------------------------------------------------------------------------------
// 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]);
}
@ -157,11 +152,12 @@ inline uint8_t HexOctetToDecimal(const char* in)
// ------------------------------------------------------------------------------------
// 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=='-');
if (inv || *in=='+')
if ( inv || *in == '+' ) {
++in;
}
int value = strtoul10(in,out);
if (inv) {
@ -176,10 +172,9 @@ inline int strtol10( const char* in, const char** out=0)
// 0NNN - oct
// NNN - dec
// ------------------------------------------------------------------------------------
inline unsigned int strtoul_cppstyle( const char* in, const char** out=0)
{
if ('0' == in[0])
{
inline
unsigned int strtoul_cppstyle( const char* in, const char** out=0) {
if ('0' == in[0]) {
return 'x' == in[1] ? strtoul16(in+2,out) : strtoul8(in+1,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
// 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;
uint64_t value = 0;
if ( *in < '0' || *in > '9' )
throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value.");
if ( *in < '0' || *in > '9' ) {
throw std::invalid_argument( std::string( "The string \"" ) + in + "\" cannot be converted into a value." );
}
bool running = true;
while ( running )
{
if ( *in < '0' || *in > '9' )
for ( ;; ) {
if ( *in < '0' || *in > '9' ) {
break;
}
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
// ------------------------------------------------------------------------------------
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 == '-');
if (inv || *in == '+')
if (inv || *in == '+') {
++in;
}
int64_t value = strtoul10_64(in, out, max_inout);
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.
// ------------------------------------------------------------------------------------
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;
bool inv = (*c == '-');
@ -272,42 +268,36 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma
++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();
c += 3;
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();
if (inv) {
out = -out;
}
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;
}
return c;
}
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 "
"as real number: does not start with 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) );
}
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;
// 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.
inline ai_real fast_atof(const char* c)
{
inline
ai_real fast_atof(const char* c) {
ai_real ret(0.0);
fast_atoreal_move<ai_real>(c, 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);
*cout = fast_atoreal_move<ai_real>(c, ret);
return ret;
}
inline ai_real fast_atof( const char** inout)
{
inline
ai_real fast_atof( const char** inout) {
ai_real ret(0.0);
*inout = fast_atoreal_move<ai_real>(*inout, 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.
*/
struct aiVertexWeight
{
struct aiVertexWeight {
//! Index of the vertex which is influenced by the bone.
unsigned int mVertexId;
@ -214,15 +213,26 @@ struct aiVertexWeight
//! Default constructor
aiVertexWeight()
: mVertexId(0)
, mWeight(0.0f)
{ }
, mWeight(0.0f) {
// empty
}
//! Initialisation from a given index and vertex weight factor
//! \param pID ID
//! \param pWeight Vertex weight factor
aiVertexWeight( unsigned int pID, float pWeight)
: mVertexId( pID), mWeight( pWeight)
{ /* nothing to do here */ }
aiVertexWeight( unsigned int pID, float pWeight )
: mVertexId( pID )
, 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
};
@ -235,8 +245,7 @@ struct aiVertexWeight
* which it can be addressed by animations. In addition it has a number of
* influences on vertices.
*/
struct aiBone
{
struct aiBone {
//! The name of the bone.
C_STRUCT aiString mName;
@ -256,8 +265,8 @@ struct aiBone
aiBone()
: mName()
, mNumWeights( 0 )
, mWeights( NULL )
{
, mWeights( nullptr ) {
// empty
}
//! Copy constructor
@ -298,7 +307,19 @@ struct aiBone
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
~aiBone()
{