From 50c5f3cb581b729e7914b0825fe710009b1fe6a9 Mon Sep 17 00:00:00 2001 From: "A. Breust" Date: Mon, 7 May 2018 15:16:32 +0200 Subject: [PATCH 1/3] Fixes DXF loader false positive on FBX file A binary FBX file can have an header section `FBXHeaderVersion` which starts around the 70th byte. Therefore, the token check for DXF file was hitting true because the `SearchFileHeaderForToken` is case insensitive. We limit the scope of the token search to the first 32 bytes. --- code/DXFLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index 90270bbd7..d317382dc 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -127,7 +127,7 @@ bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool if ( extension.empty() || checkSig ) { static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" }; - return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4 ); + return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4, 32 ); } return false; From 5a5db25df62d3047029ff915dfe941317bac4125 Mon Sep 17 00:00:00 2001 From: Jean-Louis Date: Tue, 8 May 2018 00:28:53 +0200 Subject: [PATCH 2/3] Fix AssimpView build - Use std::min/max instead of min/max macro in windef.h - Use mmsytem.h instead of timeapi.h with MinGW --- tools/assimp_view/Display.cpp | 2 +- tools/assimp_view/Material.cpp | 2 +- tools/assimp_view/MessageProc.cpp | 9 +++++++-- tools/assimp_view/assimp_view.cpp | 7 ++++++- tools/assimp_view/assimp_view.h | 5 ++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp index 7d986fa9c..cb3d66031 100644 --- a/tools/assimp_view/Display.cpp +++ b/tools/assimp_view/Display.cpp @@ -2251,7 +2251,7 @@ int CDisplay::RenderTextureView() const float ny = (float)sRect.bottom; const float x = (float)sDesc.Width; const float y = (float)sDesc.Height; - float f = min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f); + float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f); float fHalfX = (nx - (f * x)) / 2.0f; float fHalfY = (ny - (f * y)) / 2.0f; diff --git a/tools/assimp_view/Material.cpp b/tools/assimp_view/Material.cpp index f04ea28eb..1fb13f5a8 100644 --- a/tools/assimp_view/Material.cpp +++ b/tools/assimp_view/Material.cpp @@ -275,7 +275,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString) for (unsigned int i = 0; i < iSizeFound;++i) info.cFileName[i] = (CHAR)tolower(info.cFileName[i]); - if (0 == memcmp(info.cFileName,szFile2, min(iSizeFound,iSize))) + if (0 == memcmp(info.cFileName,szFile2, std::min(iSizeFound,iSize))) { // we have it. Build the full path ... char* sz = strrchr(szTempB,'*'); diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp index 71bc5c8bb..88a01fd02 100644 --- a/tools/assimp_view/MessageProc.cpp +++ b/tools/assimp_view/MessageProc.cpp @@ -45,7 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include + +#ifdef __MINGW32__ +#include +#else #include +#endif namespace AssimpView { @@ -1050,9 +1055,9 @@ void DoExport(size_t formatId) ai_assert(strlen(szFileName) <= MAX_PATH); // invent a nice default file name - char* sz = max(strrchr(szFileName,'\\'),strrchr(szFileName,'/')); + char* sz = std::max(strrchr(szFileName,'\\'),strrchr(szFileName,'/')); if (sz) { - strncpy(sz,max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH); + strncpy(sz,std::max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH); } } else { diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index e68b20a00..4d7850cd5 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -43,10 +43,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "assimp_view.h" -#include #include #include +#ifdef __MINGW32__ +#include +#else +#include +#endif + using namespace std; namespace AssimpView { diff --git a/tools/assimp_view/assimp_view.h b/tools/assimp_view/assimp_view.h index 70bce2ce4..9317495c1 100644 --- a/tools/assimp_view/assimp_view.h +++ b/tools/assimp_view/assimp_view.h @@ -46,6 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_SHADER_COMPILE_FLAGS D3DXSHADER_USE_LEGACY_D3DX9_31_DLL +// Because Dx headers include windef.h with min/max redefinition +#define NOMINMAX + // include resource definitions #include "resource.h" @@ -177,7 +180,7 @@ type clamp(intype in) { // for unsigned types only ... intype mask = (0x1u << (sizeof(type)*8))-1; - return (type)max((intype)0,min(in,mask)); + return (type)std::max((intype)0,std::min(in,mask)); } From 700c85bbfbc1de7a7776cd0082ed993e445a7db3 Mon Sep 17 00:00:00 2001 From: Diego Lopes Date: Tue, 8 May 2018 13:01:56 -0400 Subject: [PATCH 3/3] _stat64 doesn't seem to exist. use __stat64! Merely add an extra _ to the type name... --- code/DefaultIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp index afa95d364..58afe475c 100644 --- a/code/DefaultIOSystem.cpp +++ b/code/DefaultIOSystem.cpp @@ -80,7 +80,7 @@ bool DefaultIOSystem::Exists( const char* pFile) const if (isUnicode) { MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, pFile, -1, fileName16, PATHLIMIT); - struct _stat64 filestat; + struct __stat64 filestat; if (0 != _wstat64(fileName16, &filestat)) { return false; }