From 274a6ce1ff1cc11d8c463f69efe8a9c8872dc1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Wed, 21 May 2014 15:59:13 +0200 Subject: [PATCH 01/12] Fixed space --- code/fast_atof.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/fast_atof.h b/code/fast_atof.h index 5e6f5e4a5..b7aca3837 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -227,7 +227,7 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* // If you find any bugs, please send them to me, niko (at) irrlicht3d.org. // ------------------------------------------------------------------------------------ template -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; From b367d9b390fb70120cc6ec70692c9777e48e0993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Thu, 18 Dec 2014 11:01:16 +0100 Subject: [PATCH 02/12] Fixed some warnings related to empty statement when using assert & building in release mode --- code/ColladaParser.cpp | 2 +- include/assimp/ai_assert.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 9e68c9332..fb7cd298a 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1952,7 +1952,7 @@ void ColladaParser::ReadIndexData( Mesh* pMesh) // small sanity check if (primType != Prim_TriFans && primType != Prim_TriStrips) - ai_assert(actualPrimitives == numPrimitives); + ai_assert(actualPrimitives == numPrimitives) // only when we're done reading all

tags (and thus know the final vertex count) can we commit the submesh subgroup.mNumFaces = actualPrimitives; diff --git a/include/assimp/ai_assert.h b/include/assimp/ai_assert.h index 1f946d6ec..eb6bf8e89 100644 --- a/include/assimp/ai_assert.h +++ b/include/assimp/ai_assert.h @@ -5,7 +5,7 @@ #ifdef ASSIMP_BUILD_DEBUG # include -# define ai_assert(expression) assert(expression) +# define ai_assert(expression) assert(expression); #else # define ai_assert(expression) #endif From d9a22934912e2e0aff20b073332b82fe2547a2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Wed, 18 Feb 2015 17:20:03 +0100 Subject: [PATCH 03/12] Improved handling of transparency in collada importer + started preliminary support for RGB_ZERO collada transparency mode + added option to manually invert transparency values to deal with broken exporters that don't follow the specs --- code/ColladaHelper.h | 6 +++++- code/ColladaLoader.cpp | 25 ++++++++++++++++++++----- code/ColladaLoader.h | 1 + code/ColladaParser.cpp | 8 ++++++++ include/assimp/config.h | 2 ++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h index f249a28d5..200e9f8fc 100644 --- a/code/ColladaHelper.h +++ b/code/ColladaHelper.h @@ -502,6 +502,8 @@ struct Effect // Scalar factory float mShininess, mRefractIndex, mReflectivity; float mTransparency; + bool mHasTransparency; + bool mRGBTransparency; // local params referring to each other by their SID typedef std::map ParamLibrary; @@ -522,7 +524,9 @@ struct Effect , mShininess (10.0f) , mRefractIndex (1.f) , mReflectivity (1.f) - , mTransparency (0.f) + , mTransparency (1.f) + , mHasTransparency (false) + , mRGBTransparency(false) , mDoubleSided (false) , mWireframe (false) , mFaceted (false) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index aa4826fc9..d42293490 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -109,6 +109,7 @@ void ColladaLoader::SetupProperties(const Importer* pImp) { noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0; + invertTransparency = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY,0) != 0; } @@ -1289,11 +1290,25 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI); // transparency, a very hard one. seemingly not all files are following the - // specification here .. but we can trick. - if (effect.mTransparency >= 0.f && effect.mTransparency < 1.f) { - effect.mTransparency = 1.f- effect.mTransparency; - mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY ); - mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT ); + // specification here (1.0 transparency => completly opaque)... + // therefore, we let the opportunity for the user to manually invert + // the transparency if necessary and we add preliminary support for RGB_ZERO mode + if(effect.mTransparency >= 0.f && effect.mTransparency <= 1.f) { + // Trying some support for RGB_ZERO mode + if(effect.mRGBTransparency) { + effect.mTransparency = 1.f - effect.mTransparent.a; + } + + // Global option + if(invertTransparency) { + effect.mTransparency = 1.f - effect.mTransparency; + } + + // Is the material finally transparent ? + if (effect.mHasTransparency || effect.mTransparency < 1.f) { + mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY ); + mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT ); + } } // add textures, if given diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index 392c8f359..46e6c8710 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -235,6 +235,7 @@ protected: bool noSkeletonMesh; bool ignoreUpDirection; + bool invertTransparency; /** Used by FindNameForNode() to generate unique node names */ unsigned int mNodeNameCounter; diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index fb7cd298a..bb2bc1777 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1199,6 +1199,14 @@ void ColladaParser::ReadEffectProfileCommon( Collada::Effect& pEffect) ReadEffectColor( pEffect.mReflective, pEffect.mTexReflective); } else if( IsElement( "transparent")) { + pEffect.mHasTransparency = true; + + // In RGB_ZERO mode, the transparency is interpreted in reverse, go figure... + if(::strcmp(mReader->getAttributeValueSafe("opaque"), "RGB_ZERO") == 0) { + // TODO: handle RGB_ZERO mode completely + pEffect.mRGBTransparency = true; + } + ReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent); } else if( IsElement( "shininess")) diff --git a/include/assimp/config.h b/include/assimp/config.h index 56ef8f3b5..8b70fd653 100644 --- a/include/assimp/config.h +++ b/include/assimp/config.h @@ -878,4 +878,6 @@ enum aiComponent #define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" +#define AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY "IMPORT_COLLADA_INVERT_TRANSPARENCY" + #endif // !! AI_CONFIG_H_INC From 8ae9e2b555c7c27562d39dbf3bdbd97f973aa84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 10 Mar 2015 09:20:00 +0100 Subject: [PATCH 04/12] In Collada: Added missing description of importer specific options --- include/assimp/config.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/assimp/config.h b/include/assimp/config.h index 3ecbfc6e6..ab32a8ba3 100644 --- a/include/assimp/config.h +++ b/include/assimp/config.h @@ -877,8 +877,23 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" +// --------------------------------------------------------------------------- +/** @brief Specifies whether the Collada loader will ignore the provided up direction. + * + * If this property is set to true, the up direction provided in the file header will + * be ignored and the file will be loaded as is. + * Property type: Bool. Default value: false. + */ #define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" +// --------------------------------------------------------------------------- +/** @brief Specifies whether the Collada loader will invert the transparency value. + * + * If this property is set to true, the transparency value will be interpreted as the + * inverse of the usual transparency. This is useful because lots of exporters does + * not respect the standard and do the opposite of what is normally expected. + * Property type: Bool. Default value: false. + */ #define AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY "IMPORT_COLLADA_INVERT_TRANSPARENCY" #endif // !! AI_CONFIG_H_INC From 18e6a8fbdb492e7553591b9de8d129b71725d5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 10 Mar 2015 15:39:27 +0100 Subject: [PATCH 05/12] improved handling of commas in fast_atof --- code/fast_atof.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/fast_atof.h b/code/fast_atof.h index 58ec14948..a81c53f25 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -260,14 +260,14 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma } if (!(c[0] >= '0' && c[0] <= '9') && - !(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 != '.') + if (*c != '.' && (! check_comma || c[0] != ',')) { f = static_cast( strtoul10_64 ( c, &c) ); } From 454b85a0adb32895ff246884da2707f3e9817dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Fri, 27 Mar 2015 10:56:03 +0100 Subject: [PATCH 06/12] Improved prototype of Importer & Exporter SetProperty* functions for better integration with tools such as SWIG --- code/Assimp.cpp | 8 ++++---- code/Exporter.cpp | 20 ++++++++------------ code/GenericProperty.h | 11 ++++------- code/Importer.cpp | 36 ++++++++++++++++++++---------------- code/MD3Loader.cpp | 2 +- include/assimp/Exporter.hpp | 21 ++++++++------------- include/assimp/Importer.hpp | 21 ++++++++------------- 7 files changed, 53 insertions(+), 66 deletions(-) diff --git a/code/Assimp.cpp b/code/Assimp.cpp index 89b62d110..ef5b0d9bc 100644 --- a/code/Assimp.cpp +++ b/code/Assimp.cpp @@ -483,7 +483,7 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam { ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->ints,szName,value,NULL); + SetGenericProperty(pp->ints,szName,value); ASSIMP_END_EXCEPTION_REGION(void); } @@ -493,7 +493,7 @@ ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, { ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->floats,szName,value,NULL); + SetGenericProperty(pp->floats,szName,value); ASSIMP_END_EXCEPTION_REGION(void); } @@ -507,7 +507,7 @@ ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName } ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->strings,szName,std::string(st->C_Str()),NULL); + SetGenericProperty(pp->strings,szName,std::string(st->C_Str())); ASSIMP_END_EXCEPTION_REGION(void); } @@ -521,7 +521,7 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName } ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->matrices,szName,*mat,NULL); + SetGenericProperty(pp->matrices,szName,*mat); ASSIMP_END_EXCEPTION_REGION(void); } diff --git a/code/Exporter.cpp b/code/Exporter.cpp index c6fea8856..a0488e0f3 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -507,34 +507,30 @@ ExportProperties::ExportProperties(const ExportProperties &other) // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue) { - SetGenericProperty(mIntProperties, szName,iValue,bWasExisting); + return SetGenericProperty(mIntProperties, szName,iValue); } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyFloat(const char* szName, float iValue, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyFloat(const char* szName, float iValue) { - SetGenericProperty(mFloatProperties, szName,iValue,bWasExisting); + return SetGenericProperty(mFloatProperties, szName,iValue); } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyString(const char* szName, const std::string& value, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyString(const char* szName, const std::string& value) { - SetGenericProperty(mStringProperties, szName,value,bWasExisting); + return SetGenericProperty(mStringProperties, szName,value); } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) { - SetGenericProperty(mMatrixProperties, szName,value,bWasExisting); + return SetGenericProperty(mMatrixProperties, szName,value); } // ------------------------------------------------------------------------------------------------ diff --git a/code/GenericProperty.h b/code/GenericProperty.h index 0e89015ab..06e6f7ca1 100644 --- a/code/GenericProperty.h +++ b/code/GenericProperty.h @@ -46,22 +46,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ------------------------------------------------------------------------------------------------ template -inline void SetGenericProperty(std::map< unsigned int, T >& list, - const char* szName, const T& value, bool* bWasExisting = NULL) +inline bool SetGenericProperty(std::map< unsigned int, T >& list, + const char* szName, const T& value) { ai_assert(NULL != szName); const uint32_t hash = SuperFastHash(szName); typename std::map::iterator it = list.find(hash); if (it == list.end()) { - if (bWasExisting) - *bWasExisting = false; list.insert(std::pair( hash, value )); - return; + return false; } (*it).second = value; - if (bWasExisting) - *bWasExisting = true; + return true; } // ------------------------------------------------------------------------------------------------ diff --git a/code/Importer.cpp b/code/Importer.cpp index a9173cddc..1c45ff978 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -919,42 +919,46 @@ void Importer::GetExtensionList(aiString& szOut) const // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyInteger(const char* szName, int iValue) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mIntProperties, szName,iValue,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mIntProperties, szName,iValue); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyFloat(const char* szName, float iValue, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyFloat(const char* szName, float iValue) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mFloatProperties, szName,iValue,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mFloatProperties, szName,iValue); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyString(const char* szName, const std::string& value, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyString(const char* szName, const std::string& value) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mStringProperties, szName,value,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mStringProperties, szName,value); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mMatrixProperties, szName,value,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mMatrixProperties, szName,value); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 49cecd1bf..701f8db81 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -556,7 +556,7 @@ bool MD3Importer::ReadMultipartFile() // ensure we won't try to load ourselves recursively BatchLoader::PropertyMap props; - SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0, NULL); + SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0); // now read these three files BatchLoader batch(mIOHandler); diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 692830f02..fb890129e 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -348,16 +348,14 @@ public: * are defined in the aiConfig.g header (all constants share the * prefix AI_CONFIG_XXX and are simple strings). * @param iValue New value of the property - * @param bWasExisting Optional pointer to receive true if the - * property was set before. The new value replaces the previous value - * in this case. + * @return true if the property was set before. The new value replaces + * the previous value in this case. * @note Property of different types (float, int, string ..) are kept * on different stacks, so calling SetPropertyInteger() for a * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - void SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting = NULL); + bool SetPropertyInteger(const char* szName, int iValue); // ------------------------------------------------------------------- /** Set a boolean configuration property. Boolean properties @@ -366,30 +364,27 @@ public: * #GetPropertyBool and vice versa. * @see SetPropertyInteger() */ - void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) { - SetPropertyInteger(szName,value,bWasExisting); + bool SetPropertyBool(const char* szName, bool value) { + return SetPropertyInteger(szName,value); } // ------------------------------------------------------------------- /** Set a floating-point configuration property. * @see SetPropertyInteger() */ - void SetPropertyFloat(const char* szName, float fValue, - bool* bWasExisting = NULL); + bool SetPropertyFloat(const char* szName, float fValue); // ------------------------------------------------------------------- /** Set a string configuration property. * @see SetPropertyInteger() */ - void SetPropertyString(const char* szName, const std::string& sValue, - bool* bWasExisting = NULL); + bool SetPropertyString(const char* szName, const std::string& sValue); // ------------------------------------------------------------------- /** Set a matrix configuration property. * @see SetPropertyInteger() */ - void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue, - bool* bWasExisting = NULL); + bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); // ------------------------------------------------------------------- /** Get a configuration property. diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index 8aa9e5ae5..8d9141aeb 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -194,16 +194,14 @@ public: * are defined in the aiConfig.g header (all constants share the * prefix AI_CONFIG_XXX and are simple strings). * @param iValue New value of the property - * @param bWasExisting Optional pointer to receive true if the - * property was set before. The new value replaces the previous value - * in this case. + * @return true if the property was set before. The new value replaces + * the previous value in this case. * @note Property of different types (float, int, string ..) are kept * on different stacks, so calling SetPropertyInteger() for a * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - void SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting = NULL); + bool SetPropertyInteger(const char* szName, int iValue); // ------------------------------------------------------------------- /** Set a boolean configuration property. Boolean properties @@ -212,30 +210,27 @@ public: * #GetPropertyBool and vice versa. * @see SetPropertyInteger() */ - void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) { - SetPropertyInteger(szName,value,bWasExisting); + bool SetPropertyBool(const char* szName, bool value) { + return SetPropertyInteger(szName,value); } // ------------------------------------------------------------------- /** Set a floating-point configuration property. * @see SetPropertyInteger() */ - void SetPropertyFloat(const char* szName, float fValue, - bool* bWasExisting = NULL); + bool SetPropertyFloat(const char* szName, float fValue); // ------------------------------------------------------------------- /** Set a string configuration property. * @see SetPropertyInteger() */ - void SetPropertyString(const char* szName, const std::string& sValue, - bool* bWasExisting = NULL); + bool SetPropertyString(const char* szName, const std::string& sValue); // ------------------------------------------------------------------- /** Set a matrix configuration property. * @see SetPropertyInteger() */ - void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue, - bool* bWasExisting = NULL); + bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); // ------------------------------------------------------------------- /** Get a configuration property. From 91c751a03aecca0d948e71e4cc85029095f79933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 28 Apr 2015 12:29:39 +0200 Subject: [PATCH 07/12] Added missing header --- code/ColladaParser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index aaa705593..05a756ed4 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER +#include #include "ColladaParser.h" #include "fast_atof.h" #include "ParsingUtils.h" From d809ca98c14e3c1a15c8cf80d0996943793af8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 28 Apr 2015 15:16:53 +0200 Subject: [PATCH 08/12] Fixed compilation issues with mingw --- tools/assimp_view/assimp_view.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/assimp_view/assimp_view.h b/tools/assimp_view/assimp_view.h index 7ae21aed4..d18148dc5 100644 --- a/tools/assimp_view/assimp_view.h +++ b/tools/assimp_view/assimp_view.h @@ -72,12 +72,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp // in order for std::min and std::max to behave properly -/*#ifdef min -#undef min +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif // max +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) #endif // min -#ifdef max -#undef max -#endif // min*/ #include From 07f3f4b487df16b4ce3d08c89e514d77a8c9b982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 28 Apr 2015 17:27:20 +0200 Subject: [PATCH 09/12] Updated unit tests to use new SetProperty interface --- test/unit/utImporter.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp index 44a7e1b0b..c7094229a 100644 --- a/test/unit/utImporter.cpp +++ b/test/unit/utImporter.cpp @@ -131,21 +131,19 @@ TEST_F(ImporterTest, testMemoryRead) // ------------------------------------------------------------------------------------------------ TEST_F(ImporterTest, testIntProperty) { - bool b; - pImp->SetPropertyInteger("quakquak",1503,&b); + bool b = pImp->SetPropertyInteger("quakquak",1503); EXPECT_FALSE(b); EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0)); EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159)); - pImp->SetPropertyInteger("quakquak",1504,&b); + b = pImp->SetPropertyInteger("quakquak",1504); EXPECT_TRUE(b); } // ------------------------------------------------------------------------------------------------ TEST_F(ImporterTest, testFloatProperty) { - bool b; - pImp->SetPropertyFloat("quakquak",1503.f,&b); + bool b = pImp->SetPropertyFloat("quakquak",1503.f); EXPECT_TRUE(!b); EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f)); EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f)); @@ -154,8 +152,7 @@ TEST_F(ImporterTest, testFloatProperty) // ------------------------------------------------------------------------------------------------ TEST_F(ImporterTest, testStringProperty) { - bool b; - pImp->SetPropertyString("quakquak","test",&b); + bool b = pImp->SetPropertyString("quakquak","test"); EXPECT_TRUE(!b); EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg")); EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou")); From 825a58803d1d348c3bfc6adab0ee0ab6c98aa921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 28 Apr 2015 17:30:15 +0200 Subject: [PATCH 10/12] Removed some warning about const char* used as char* (not our choice, it depends of some external API) --- tools/assimp_view/Display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 37c22962b..c0d6c4f9e 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -693,7 +693,7 @@ int CDisplay::FillDisplayList(void) // fill in the first entry TVITEMEX tvi; TVINSERTSTRUCT sNew; - tvi.pszText = "Model"; + tvi.pszText = (char*) "Model"; tvi.cchTextMax = (int)strlen(tvi.pszText); tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_STATE; tvi.state = TVIS_EXPANDED; From ca2e47b2050a122cb3955eaa8def358a6a0e6076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Wed, 29 Apr 2015 09:26:11 +0200 Subject: [PATCH 11/12] Fixed some typos --- code/Importer.cpp | 6 +++--- include/assimp/ai_assert.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/Importer.cpp b/code/Importer.cpp index 876746445..ead61402c 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -927,11 +927,11 @@ void Importer::GetExtensionList(aiString& szOut) const // Set a configuration property bool Importer::SetPropertyInteger(const char* szName, int iValue) { - bool exising; + bool existing; ASSIMP_BEGIN_EXCEPTION_REGION(); - exising = SetGenericProperty(pimpl->mIntProperties, szName,iValue); + existing = SetGenericProperty(pimpl->mIntProperties, szName,iValue); ASSIMP_END_EXCEPTION_REGION(bool); - return exising; + return existing; } // ------------------------------------------------------------------------------------------------ diff --git a/include/assimp/ai_assert.h b/include/assimp/ai_assert.h index d753ea01d..202446009 100644 --- a/include/assimp/ai_assert.h +++ b/include/assimp/ai_assert.h @@ -5,7 +5,7 @@ #ifdef ASSIMP_BUILD_DEBUG # include -# define ai_assert(expression) assert(expression); +# define ai_assert(expression) assert(expression) #else # define ai_assert(expression) #endif From c99bd9825ade9a3285fcf97dc8e9433411b46589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Wed, 29 Apr 2015 18:13:16 +0200 Subject: [PATCH 12/12] Fixed bug introduced by misleading names in materials properties between "type" parameters of function referring to the "semantic" field of properties (and NOT the type field...) --- code/SceneCombiner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index eaca35cd6..b46354214 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -920,7 +920,7 @@ void SceneCombiner::MergeMaterials(aiMaterial** dest, // Test if we already have a matching property const aiMaterialProperty* prop_exist; - if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mType, sprop->mIndex, &prop_exist) != AI_SUCCESS) { + if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mSemantic, sprop->mIndex, &prop_exist) != AI_SUCCESS) { // If not, we add it to the new material aiMaterialProperty* prop = out->mProperties[out->mNumProperties] = new aiMaterialProperty();