From ce11aa51f5085e76303ad5c26318cad7a7cbbd62 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 7 May 2018 00:07:41 +0200 Subject: [PATCH 01/28] add win32-based make script. --- code/ObjFileImporter.cpp | 29 ++++++++++++----------------- tools/make/make_all_win32_x64.bat | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 tools/make/make_all_win32_x64.bat diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index dd0733caa..cbf2363a4 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -76,41 +76,36 @@ using namespace std; // ------------------------------------------------------------------------------------------------ // Default constructor -ObjFileImporter::ObjFileImporter() : - m_Buffer(), - m_pRootObject( NULL ), - m_strAbsPath( "" ) -{ +ObjFileImporter::ObjFileImporter() +: m_Buffer() +, m_pRootObject( nullptr ) +, m_strAbsPath( "" ) { DefaultIOSystem io; m_strAbsPath = io.getOsSeparator(); } // ------------------------------------------------------------------------------------------------ // Destructor. -ObjFileImporter::~ObjFileImporter() -{ +ObjFileImporter::~ObjFileImporter() { delete m_pRootObject; - m_pRootObject = NULL; + m_pRootObject = nullptr; } // ------------------------------------------------------------------------------------------------ // Returns true, if file is an obj file. -bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler , bool checkSig ) const -{ - if(!checkSig) //Check File Extension - { +bool ObjFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler , bool checkSig ) const { + if(!checkSig) { + //Check File Extension return SimpleExtensionCheck(pFile,"obj"); - } - else //Check file Header - { + } else { + // Check file Header static const char *pTokens[] = { "mtllib", "usemtl", "v ", "vt ", "vn ", "o ", "g ", "s ", "f " }; return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 9 ); } } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* ObjFileImporter::GetInfo () const -{ +const aiImporterDesc* ObjFileImporter::GetInfo () const { return &desc; } diff --git a/tools/make/make_all_win32_x64.bat b/tools/make/make_all_win32_x64.bat new file mode 100644 index 000000000..d4561df0d --- /dev/null +++ b/tools/make/make_all_win32_x64.bat @@ -0,0 +1,16 @@ +rem @echo off +call build_env_win32.bat + +set BUILD_CONFIG=release +set PLATFORM_CONFIG=x64 +set MAX_CPU_CONFIG=4 + +set CONFIG_PARAMETER=/p:Configuration="%BUILD_CONFIG%" +set PLATFORM_PARAMETER=/p:Platform="%PLATFORM_CONFIG%" +set CPU_PARAMETER=/maxcpucount:%MAX_CPU_CONFIG% +set PLATFORM_TOOLSET=/p:PlatformToolset=%PLATFORM_VER% + +pushd ..\..\ +cmake CMakeLists.txt -G "Visual Studio 15 2017 Win64" +%MSBUILD% assimp.sln %CONFIG_PARAMETER% %PLATFORM_PARAMETER% %CPU_PARAMETER% %PLATFORM_TOOLSET% +popd From a9dcbedefb46664a09fb723465652726eb7377ee Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 7 May 2018 22:07:19 +0200 Subject: [PATCH 02/28] Make: save environment during make. --- tools/make/make_all_win32_x64.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/make/make_all_win32_x64.bat b/tools/make/make_all_win32_x64.bat index d4561df0d..4a1e663e6 100644 --- a/tools/make/make_all_win32_x64.bat +++ b/tools/make/make_all_win32_x64.bat @@ -1,4 +1,5 @@ rem @echo off +setlocal call build_env_win32.bat set BUILD_CONFIG=release @@ -14,3 +15,4 @@ pushd ..\..\ cmake CMakeLists.txt -G "Visual Studio 15 2017 Win64" %MSBUILD% assimp.sln %CONFIG_PARAMETER% %PLATFORM_PARAMETER% %CPU_PARAMETER% %PLATFORM_TOOLSET% popd +endlocal From d441dcd5230989581ba1bc3ebbc48cc28ed816ba Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 9 May 2018 19:15:42 +0200 Subject: [PATCH 03/28] addmissing file. --- tools/make/build_env_win32.bat | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tools/make/build_env_win32.bat diff --git a/tools/make/build_env_win32.bat b/tools/make/build_env_win32.bat new file mode 100644 index 000000000..cef217b70 --- /dev/null +++ b/tools/make/build_env_win32.bat @@ -0,0 +1,58 @@ +@echo off + +set "initialdir=%cd%" +goto:main + +:exitsucc +cd /d "%initialdir%" +set initialdir= + +set MSBUILD_15="C:\Program Files (x86)\Microsoft Visual Studio\2018\Professional\MSBuild\15.0\Bin\msbuild.exe" +set MSBUILD_14="C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe" + +if not "%VS150%"=="" set MSBUILD_15="%VS150%\MSBuild\15.0\Bin\msbuild.exe" + +if /i %VS_VERSION%==2017 ( + set MS_BUILD_EXE=%MSBUILD_15% + set PLATFORM_VER=v141 +) else ( + set MS_BUILD_EXE=%MSBUILD_14% + set PLATFORM_VER=v140 +) + +set MSBUILD=%MS_BUILD_EXE% + +exit /b 0 + +:main +if not defined PLATFORM set "PLATFORM=x64" + +::my work here is done? + +set PATH_VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\ +REM set PATH_STUDIO="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" + +for /f "usebackq tokens=*" %%i in (`"%PATH_VSWHERE%vswhere" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do ( + set InstallDir=%%i +) + +IF EXIST "%InstallDir%\VC\Auxiliary\Build\vcvarsall.bat" set VS150=%InstallDir%\ + +set "CMAKE_GENERATOR=Visual Studio 15 2017 Win64" +if not "%VS150%"=="" call "%VS150%\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM% && echo found VS 2o17 && set PLATFORM_VER=v141 && set VS_VERSION=2017 && goto:exitsucc + +set "CMAKE_GENERATOR=Visual Studio 14 2015 Win64" +if defined VS140COMNTOOLS call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o15 && set PLATFORM_VER=v140 && set VS_VERSION=2015 && goto:exitsucc + +if defined VS130COMNTOOLS echo call ghostbusters... found lost VS version + +set "CMAKE_GENERATOR=Visual Studio 12 2013 Win64" +if defined VS120COMNTOOLS call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o13 && set PLATFORM_VER=v120 && set VS_VERSION=2013 && goto:exitsucc + +set "CMAKE_GENERATOR=Visual Studio 11 2012 Win64" +if defined VS110COMNTOOLS call "%VS110COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o12 && set PLATFORM_VER=v110 && set VS_VERSION=2012 && goto:exitsucc + +set "CMAKE_GENERATOR=Visual Studio 10 2010 Win64" +if defined VS100COMNTOOLS call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o1o && set PLATFORM_VER=v100 && set VS_VERSION=2010 && goto:exitsucc + +goto:exitsucc \ No newline at end of file From a5a4da89008198c54095e26ee7075170a81ef59d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 10 May 2018 09:19:53 +0200 Subject: [PATCH 04/28] Appveyor: adapt install script. --- appveyor.yml | 1 + packaging/windows-innosetup/script.iss | 38 +++++++++++++------------- tools/make/build_env_win32.bat | 1 - 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1b87286f6..3b4b3144e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,6 +32,7 @@ install: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64 - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" + - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: - code\assimp.dir\%CONFIGURATION% diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index f301bc4eb..8056e31ac 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -2,7 +2,7 @@ [Setup] AppName=Open Asset Import Library - SDK -AppVerName=Open Asset Import Library - SDK (v3.3.1) +AppVerName=Open Asset Import Library - SDK (v4.1.0) DefaultDirName={pf}\Assimp DefaultGroupName=Assimp UninstallDisplayIcon={app}\bin\x86\assimp.exe @@ -12,9 +12,9 @@ SetupIconFile=..\..\tools\shared\assimp_tools_icon.ico WizardImageFile=compiler:WizModernImage-IS.BMP WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP LicenseFile=License.rtf -OutputBaseFileName=assimp-sdk-3.3.1-setup -VersionInfoVersion=3.3.1.0 -VersionInfoTextVersion=3.3.1 +OutputBaseFileName=assimp-sdk-4.1.0-setup +VersionInfoVersion=4.1.0.0 +VersionInfoTextVersion=4.1.0 VersionInfoCompany=Assimp Development Team ArchitecturesInstallIn64BitMode=x64 @@ -35,15 +35,15 @@ Name: "dassimp"; Description: "D Bindings"; Types: full Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full [Run] -Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2015 redistributable package (32 Bit)"; Check: not IsWin64 -Filename: "{app}\stub\vc_redist.x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2015 redistributable package (64 Bit)"; Check: IsWin64 +;Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (32 Bit)"; Check: not IsWin64 +Filename: "{app}\stub\vc_redist.x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (64 Bit)"; Check: IsWin64 [Files] Source: "readme_installer.txt"; DestDir: "{app}"; Flags: isreadme ; Installer stub -Source: "vc_redist.x86.exe"; DestDir: "{app}\stub\"; Check: not IsWin64 +;Source: "vc_redist.x86.exe"; DestDir: "{app}\stub\"; Check: not IsWin64 Source: "vc_redist.x64.exe"; DestDir: "{app}\stub\"; Check: IsWin64 ; Common stuff @@ -55,18 +55,18 @@ Source: "WEB"; DestDir: "{app}" Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries -Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" -Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" +;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries -Source: "..\..\bin\release\x64\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" -Source: "..\..\bin\release\x64\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "D3DCompiler_42_x64.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "D3DX9_42_x64.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools -Source: "..\..\bin\release\x64\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools +Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" +Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools +Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help @@ -74,8 +74,8 @@ Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Co Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries -Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" -Source: "..\..\lib\release\x64\assimp.lib"; DestDir: "{app}\lib\x64" +;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" +Source: "..\..\lib\release\assimp-vc140-mt.lib"; DestDir: "{app}\lib\x64" ; Samples Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Components: samples diff --git a/tools/make/build_env_win32.bat b/tools/make/build_env_win32.bat index cef217b70..4b8b4674b 100644 --- a/tools/make/build_env_win32.bat +++ b/tools/make/build_env_win32.bat @@ -1,5 +1,4 @@ @echo off - set "initialdir=%cd%" goto:main From 5f820fb6d6bbf55d33292f6719c9083c10d915c3 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 3 Jun 2018 17:21:46 +0200 Subject: [PATCH 05/28] Update appveyor.yml Add Inno setup path to PATH variable. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 3b4b3144e..d574dafa6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,6 +32,7 @@ install: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64 - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" + - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5" - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: From 90549e9680ced21beea680525a93aadfabb948b6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 3 Jun 2018 21:29:23 +0200 Subject: [PATCH 06/28] Update script.iss Adapt names of dll only for VS2017 --- packaging/windows-innosetup/script.iss | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 8056e31ac..8debcb494 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -30,16 +30,12 @@ Name: "help"; Description: "Help Files"; Types: full compact Name: "samples"; Description: "Samples"; Types: full Name: "test"; Description: "Test Models (BSD-licensed)"; Types: full Name: "test_nonbsd"; Description: "Test Models (other (free) licenses)"; Types: full -Name: "pyassimp"; Description: "Python Bindings"; Types: full -Name: "dassimp"; Description: "D Bindings"; Types: full -Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full [Run] ;Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (32 Bit)"; Check: not IsWin64 Filename: "{app}\stub\vc_redist.x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (64 Bit)"; Check: IsWin64 [Files] - Source: "readme_installer.txt"; DestDir: "{app}"; Flags: isreadme ; Installer stub @@ -55,15 +51,15 @@ Source: "WEB"; DestDir: "{app}" Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries -;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" -;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "..\..\bin\release\x86\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x86" +;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries -Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" -Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools +Source: "..\..\bin\release\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x64" +Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools @@ -75,7 +71,7 @@ Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries ;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" -Source: "..\..\lib\release\assimp-vc140-mt.lib"; DestDir: "{app}\lib\x64" +Source: "..\..\lib\release\assimp-vc141-mt.lib"; DestDir: "{app}\lib\x64" ; Samples Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Components: samples From 24d49b0cc764e489dae5e9a4985c58cf683681a7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 09:01:17 +0200 Subject: [PATCH 07/28] Update appveyor.yml Add download request for the redistributables. --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index d574dafa6..aa2d8bc10 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,6 +33,8 @@ install: - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64 - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5" + - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\packaging\windows-innosetup\vc_redist.x64.exe + - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/1/d/8/1d8137db-b5bb-4925-8c5d-927424a2e4de/vc_redist.x86.exe -OutFile .\packaging\windows-innosetup\vc_redist.x86.exe - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: From 20bfb3662f55decd0cc7b0186b9c65b7db26d60f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 11:53:44 +0200 Subject: [PATCH 08/28] Update script.iss FIx buggy names of dlls. --- packaging/windows-innosetup/script.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 8debcb494..8364e51e2 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -51,14 +51,14 @@ Source: "WEB"; DestDir: "{app}" Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries -;Source: "..\..\bin\release\x86\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x86" +;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries -Source: "..\..\bin\release\assimp-vc141-mt.dll"; DestDir: "{app}\bin\x64" +Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools From 37ed614b70bc29a00d08dcb97a0ce79317458b1c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 15:02:37 +0200 Subject: [PATCH 09/28] Update appveyor.yml Run inno script after build. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index aa2d8bc10..2b5f212f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,7 +35,6 @@ install: - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5" - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\packaging\windows-innosetup\vc_redist.x64.exe - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/1/d/8/1d8137db-b5bb-4925-8c5d-927424a2e4de/vc_redist.x86.exe -OutFile .\packaging\windows-innosetup\vc_redist.x86.exe - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss cache: - code\assimp.dir\%CONFIGURATION% @@ -54,6 +53,7 @@ build: project: Assimp.sln after_build: + - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss - 7z a assimp.7z bin\%CONFIGURATION%\* lib\%CONFIGURATION%\* test_script: From c46008055c2f0a29126d64fffbc21f7cd60f93fc Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 21:41:58 +0200 Subject: [PATCH 10/28] Update script.iss Directx: Use install path on appyevor image. --- packaging/windows-innosetup/script.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 8364e51e2..471c3a53d 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,8 +53,8 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries From ab301c1acc687945fc7bc6fa35dc991d4c3f8083 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 22:08:20 +0200 Subject: [PATCH 11/28] Update script.iss - Fix x64-folders shwing to DirectX dlls - Remove dead code - Put doc copy ops for installer into brackets. --- packaging/windows-innosetup/script.iss | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 471c3a53d..33fadb57b 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -60,18 +60,18 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation -Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help -Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Components: help -Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help +;Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help +;Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Components: help +:Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries ;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" -Source: "..\..\lib\release\assimp-vc141-mt.lib"; DestDir: "{app}\lib\x64" +Source: "..\..\lib\release\assimp-vc140-mt.lib"; DestDir: "{app}\lib\x64" ; Samples Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Components: samples @@ -93,15 +93,6 @@ Source: "..\..\port\dAssimp\*"; DestDir: "{app}\port\D"; Flags: recursesubdirs; ;Source: "..\..\test\regression\*"; DestDir: "{app}\test\regression"; Flags: recursesubdirs; Components: test ;Source: "..\..\test\models-nonbsd\*"; DestDir: "{app}\test\models-nonbsd"; Flags: recursesubdirs; Components: test_nonbsd -; Source Code & Workspaces -;Source: "..\..\code\*"; Excludes: "*.o"; DestDir: "{app}\code"; Flags: recursesubdirs; Components: wsource -;Source: "..\..\workspaces\vc8\*.sln"; DestDir: "{app}\workspaces\vc8"; Components: wsource and vc8 -;Source: "..\..\workspaces\vc8\*.vcproj"; DestDir: "{app}\workspaces\vc8"; Components: wsource and vc8 -;Source: "..\..\workspaces\vc9\*.sln"; DestDir: "{app}\workspaces\vc9"; Components: wsource and vc9 -;Source: "..\..\workspaces\vc9\*.vcproj"; DestDir: "{app}\workspaces\vc9"; Components: wsource and vc9 - -; Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme - [Icons] Name: "{group}\Assimp Manual"; Filename: "{app}\doc\AssimpDoc.chm" ; Components: help Name: "{group}\Assimp Command Line Manual"; Filename: "{app}\doc\AssimpCmdDoc.chm"; Components: help From 12438bcdb2ae185c5487bcc3496b4c2cefe5ad9a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 4 Jun 2018 22:37:05 +0200 Subject: [PATCH 12/28] Update script.iss Typ fix --- packaging/windows-innosetup/script.iss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 33fadb57b..132054e88 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,15 +53,15 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK)\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation From d55525d16b9f0f929c4689eaab899d32fec4324b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 5 Jun 2018 10:25:35 +0200 Subject: [PATCH 13/28] Update script.iss Fix folders to DX-dlls. --- packaging/windows-innosetup/script.iss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 132054e88..bed974f70 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,15 +53,15 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation From c313d5a3e9ad56cf50a446ea2a06ee142fc30217 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 5 Jun 2018 10:55:51 +0200 Subject: [PATCH 14/28] Update script.iss Fix folders ... again --- packaging/windows-innosetup/script.iss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index bed974f70..136b828c3 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -53,15 +53,15 @@ Source: "..\..\scripts\*"; DestDir: "{app}\scripts"; Flags: recursesubdirs ; x86 binaries ;Source: "..\..\bin\release\x86\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x86" ;Source: "..\..\bin\release\x86\assimp_viewer.exe"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools -;Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x86\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Windows\SysWOW64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x86"; Components: tools +;Source: "C:\Windows\SysWOW64\D3DX9_42.dll"; DestDir: "{app}\bin\x86"; Components: tools ;Source: "..\..\bin\release\x86\assimp.exe"; DestDir: "{app}\bin\x86"; Components: tools ; x64 binaries Source: "..\..\bin\release\assimp-vc140-mt.dll"; DestDir: "{app}\bin\x64" Source: "..\..\bin\release\assimp_viewer.exe"; DestDir: "{app}\bin\x64"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools -Source: "C:\Program Files (x86)\Microsoft DirectX SDK\Developer Runtime\x64\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools +Source: "C:\Windows\SysWOW64\D3DCompiler_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DCompiler_42.dll"; Components: tools +Source: "C:\Windows\SysWOW64\D3DX9_42.dll"; DestDir: "{app}\bin\x64"; DestName: "D3DX9_42.dll"; Components: tools Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Components: tools ; Documentation From de088328aad6b9397989b49537790f3df0f93d17 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Tue, 5 Jun 2018 11:27:24 +0200 Subject: [PATCH 15/28] replace typo by comment statement. --- packaging/windows-innosetup/script.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 136b828c3..6c4b9cd37 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -67,7 +67,7 @@ Source: "..\..\bin\release\assimp.exe"; DestDir: "{app}\bin\x64"; Comp ; Documentation ;Source: "..\..\doc\AssimpDoc_Html\AssimpDoc.chm"; DestDir: "{app}\doc"; Components: help ;Source: "..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm"; DestDir: "{app}\doc"; Components: help -:Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help +;Source: "..\..\doc\datastructure.xml"; DestDir: "{app}\doc"; Components: help ; Import libraries ;Source: "..\..\lib\release\x86\assimp.lib"; DestDir: "{app}\lib\x86" From e07aedac9e24eb8164043ab56da7b044b0ca1b0a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 6 Jun 2018 10:39:17 +0200 Subject: [PATCH 16/28] Update script.iss add missing components andput the into brackets. --- packaging/windows-innosetup/script.iss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index 6c4b9cd37..695740679 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -30,6 +30,9 @@ Name: "help"; Description: "Help Files"; Types: full compact Name: "samples"; Description: "Samples"; Types: full Name: "test"; Description: "Test Models (BSD-licensed)"; Types: full Name: "test_nonbsd"; Description: "Test Models (other (free) licenses)"; Types: full +;Name: "pyassimp"; Description: "Python Bindings"; Types: full +;Name: "dassimp"; Description: "D Bindings"; Types: full +;Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full [Run] ;Filename: "{app}\stub\vc_redist.x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2017 redistributable package (32 Bit)"; Check: not IsWin64 @@ -80,7 +83,7 @@ Source: "..\..\samples\*"; DestDir: "{app}\samples"; Flags: recursesubdirs; Comp Source: "..\..\include\*"; DestDir: "{app}\include"; Flags: recursesubdirs ; dAssimp -Source: "..\..\port\dAssimp\*"; DestDir: "{app}\port\D"; Flags: recursesubdirs; Components: dassimp +;Source: "..\..\port\dAssimp\*"; DestDir: "{app}\port\D"; Flags: recursesubdirs; Components: dassimp ; Assimp.NET ;Source: "..\..\port\Assimp.NET\*"; DestDir: "{app}\port\C#"; Flags: recursesubdirs; Components: assimp_net From 85b0026c922460dac3ccf39f2a5e8b3d175ac6cc Mon Sep 17 00:00:00 2001 From: CwTCwT Date: Sat, 9 Jun 2018 15:45:09 +0200 Subject: [PATCH 17/28] issue_1973 added support for CustomData(Layer) to support multiple (texture) UV mappings added unittest with sample model --- code/BlenderCustomData.cpp | 212 ++++++++++++++++++ code/BlenderCustomData.h | 101 +++++++++ code/BlenderDNA.h | 22 ++ code/BlenderDNA.inl | 118 ++++++++++ code/BlenderLoader.cpp | 78 ++++++- code/BlenderScene.cpp | 45 ++++ code/BlenderScene.h | 83 ++++++- code/BlenderSceneGen.h | 11 + code/CMakeLists.txt | 2 + code/STLLoader.cpp | 25 ++- .../plane_2_textures_2_texcoords_279.blend | Bin 0 -> 512624 bytes test/unit/utBlendImportMaterials.cpp | 27 +++ 12 files changed, 707 insertions(+), 17 deletions(-) create mode 100644 code/BlenderCustomData.cpp create mode 100644 code/BlenderCustomData.h create mode 100644 test/models/BLEND/plane_2_textures_2_texcoords_279.blend diff --git a/code/BlenderCustomData.cpp b/code/BlenderCustomData.cpp new file mode 100644 index 000000000..7f518b782 --- /dev/null +++ b/code/BlenderCustomData.cpp @@ -0,0 +1,212 @@ +#pragma once + +#include "BlenderCustomData.h" +#include + +namespace Assimp { + namespace Blender + { + /** + * @brief read/convert of Structure array to memory + */ + template + bool read(const Structure &s, T *p, const size_t cnt, const FileDatabase &db) { + for (size_t i = 0; i < cnt; ++i) { + T read; + s.Convert(read, db); + *p = read; + p++; + } + return true; + } + + /** + * @brief pointer to function read memory for n CustomData types + */ + typedef bool(*PRead)(void *pOut, const size_t cnt, const FileDatabase &db); + /** + * @brief pointer to function read memory for cnt CustomData types + */ + typedef void *(*PAlloc)(const size_t cnt); + + /** + * @brief helper macro to define Structure specific read function + * for ex: when used like + * + * IMPL_STRUCT_READ(MLoop) + * + * following function is implemented + * + * bool readMLoop(void *v, const size_t cnt, const FileDatabase &db) { + * return read(db.dna["MLoop"], static_cast(v), cnt, db); + * } + */ +#define IMPL_STRUCT_READ(ty) \ + bool read##ty(void *v, const size_t cnt, const FileDatabase &db) { \ + return read(db.dna[#ty], static_cast(v), cnt, db); \ + } + + /** + * @brief helper macro to define Structure specific alloc function + * for ex: when used like + * + * IMPL_STRUCT_ALLOC(MLoop) + * + * following function is implemented + * + * void * allocMLoop(const size_t cnt) { + * return new uint8_t[cnt * sizeof MLoop]; + * } + */ +#define IMPL_STRUCT_ALLOC(ty) \ + void *alloc##ty(const size_t cnt) { \ + return new uint8_t[cnt * sizeof ty]; \ + } + + /** + * @brief helper macro to define Structure functions + */ +#define IMPL_STRUCT(ty) \ + IMPL_STRUCT_ALLOC(ty) \ + IMPL_STRUCT_READ(ty) + + // supported structures for CustomData + IMPL_STRUCT(MVert) + IMPL_STRUCT(MEdge) + IMPL_STRUCT(MFace) + IMPL_STRUCT(MTFace) + IMPL_STRUCT(MTexPoly) + IMPL_STRUCT(MLoopUV) + IMPL_STRUCT(MLoopCol) + IMPL_STRUCT(MPoly) + IMPL_STRUCT(MLoop) + + /** + * @brief describes the size of data and the read function to be used for single CustomerData.type + */ + struct CustomDataTypeDescription + { + PRead Read; ///< function to read one CustomData type element + PAlloc Alloc; ///< function to allocate n type elements + }; + + /** + * @brief shortcut for array of CustomDataTypeDescription + */ + typedef std::array CustomDataTypeDescriptions; + + /** + * @brief helper macro to define Structure type specific CustomDataTypeDescription + * @note IMPL_STRUCT_READ for same ty must be used earlier to implement the typespecific read function + */ +#define DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(ty) \ + CustomDataTypeDescription{ &read##ty, &alloc##ty } + + /** + * @brief helper macro to define CustomDataTypeDescription for UNSUPPORTED type + */ +#define DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION \ + CustomDataTypeDescription{ nullptr, nullptr } + + /** + * @brief descriptors for data pointed to from CustomDataLayer.data + * @note some of the CustomData uses already well defined Structures + * other (like CD_ORCO, ...) uses arrays of rawtypes or even arrays of Structures + * use a special readfunction for that cases + */ + CustomDataTypeDescriptions customDataTypeDescriptions = + { + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MVert), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MEdge), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MFace), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MTFace), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MTexPoly), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoopUV), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoopCol), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MPoly), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoop), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION + }; + + + bool isValidCustomDataType(const int cdtype) + { + return cdtype >= 0 && cdtype < CD_NUMTYPES; + } + + bool readCustomData(std::shared_ptr &out, const CustomDataType cdtype, const size_t cnt, const FileDatabase &db) + { + if (!isValidCustomDataType(cdtype)) + { + throw Error((Formatter::format(), "CustomData.type ", cdtype, " out of index")); + } + + const CustomDataTypeDescription cdtd = customDataTypeDescriptions[cdtype]; + if (cdtd.Read && cdtd.Alloc) + { + // allocate cnt elements and parse them from file + out.reset(cdtd.Alloc(cnt)); + return cdtd.Read(out.get(), cnt, db); + } + return false; + } + + std::shared_ptr getCustomDataLayer(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) + { + for (auto it = customdata.layers.begin(); it != customdata.layers.end(); ++it) + { + if (it->get()->type == cdtype && name == it->get()->name) + { + return *it; + } + } + return nullptr; + } + + const void * getCustomDataLayerData(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) + { + const std::shared_ptr pLayer = getCustomDataLayer(customdata, cdtype, name); + if (pLayer && pLayer->data) + { + return pLayer->data.get(); + } + return nullptr; + } + } +} diff --git a/code/BlenderCustomData.h b/code/BlenderCustomData.h new file mode 100644 index 000000000..b6f3641f1 --- /dev/null +++ b/code/BlenderCustomData.h @@ -0,0 +1,101 @@ +#pragma once + +#include "BlenderDNA.h" +#include "BlenderScene.h" +#include + +namespace Assimp { + namespace Blender + { + /* CustomData.type from Blender (2.79b) */ + enum CustomDataType + { + CD_AUTO_FROM_NAME = -1, + CD_MVERT = 0, +#ifdef DNA_DEPRECATED + CD_MSTICKY = 1, /* DEPRECATED */ +#endif + CD_MDEFORMVERT = 2, + CD_MEDGE = 3, + CD_MFACE = 4, + CD_MTFACE = 5, + CD_MCOL = 6, + CD_ORIGINDEX = 7, + CD_NORMAL = 8, + /* CD_POLYINDEX = 9, */ + CD_PROP_FLT = 10, + CD_PROP_INT = 11, + CD_PROP_STR = 12, + CD_ORIGSPACE = 13, /* for modifier stack face location mapping */ + CD_ORCO = 14, + CD_MTEXPOLY = 15, + CD_MLOOPUV = 16, + CD_MLOOPCOL = 17, + CD_TANGENT = 18, + CD_MDISPS = 19, + CD_PREVIEW_MCOL = 20, /* for displaying weightpaint colors */ + /* CD_ID_MCOL = 21, */ + CD_TEXTURE_MLOOPCOL = 22, + CD_CLOTH_ORCO = 23, + CD_RECAST = 24, + + /* BMESH ONLY START */ + CD_MPOLY = 25, + CD_MLOOP = 26, + CD_SHAPE_KEYINDEX = 27, + CD_SHAPEKEY = 28, + CD_BWEIGHT = 29, + CD_CREASE = 30, + CD_ORIGSPACE_MLOOP = 31, + CD_PREVIEW_MLOOPCOL = 32, + CD_BM_ELEM_PYPTR = 33, + /* BMESH ONLY END */ + + CD_PAINT_MASK = 34, + CD_GRID_PAINT_MASK = 35, + CD_MVERT_SKIN = 36, + CD_FREESTYLE_EDGE = 37, + CD_FREESTYLE_FACE = 38, + CD_MLOOPTANGENT = 39, + CD_TESSLOOPNORMAL = 40, + CD_CUSTOMLOOPNORMAL = 41, + + CD_NUMTYPES = 42 + }; + + /** + * @brief check if given cdtype is valid (ie >= 0 and < CD_NUMTYPES) + * @param[in] cdtype to check + * @return true when valid + */ + bool isValidCustomDataType(const int cdtype); + + /** + * @brief read CustomData's data to ptr to mem + * @param[out] out memory ptr to set + * @param[in] cdtype to read + * @param[in] cnt cnt of elements to read + * @param[in] db to read elements from + * @return true when ok + */ + bool readCustomData(std::shared_ptr &out, CustomDataType cdtype, size_t cnt, const FileDatabase &db); + + /** + * @brief returns CustomDataLayer ptr for given cdtype and name + * @param[in] customdata CustomData to search for wanted layer + * @param[in] cdtype to search for + * @param[in] name to search for + * @return CustomDataLayer * or nullptr if not found + */ + std::shared_ptr getCustomDataLayer(const CustomData &customdata, CustomDataType cdtype, const std::string &name); + + /** + * @brief returns CustomDataLayer data ptr for given cdtype and name + * @param[in] customdata CustomData to search for wanted layer + * @param[in] cdtype to search for + * @param[in] name to search for + * @return CustomDataLayer * or nullptr if not found + */ + const void * getCustomDataLayerData(const CustomData &customdata, CustomDataType cdtype, const std::string &name); + } +} diff --git a/code/BlenderDNA.h b/code/BlenderDNA.h index 6a18fe9fa..d2b897d3a 100644 --- a/code/BlenderDNA.h +++ b/code/BlenderDNA.h @@ -309,6 +309,28 @@ public: void ReadField(T& out, const char* name, const FileDatabase& db) const; + // -------------------------------------------------------- + /** + * @brief field parsing for dynamic vectors + * @param[in] out vector of struct to be filled + * @param[in] name of field + * @param[in] db to access the file, dna, ... + * @return true when read was successful + */ + template class TOUT, typename T> + bool ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const; + + /** + * @brief parses raw customdata + * @param[in] out shared_ptr to be filled + * @param[in] cdtype customdata type to read + * @param[in] name of field ptr + * @param[in] db to access the file, dna, ... + * @return true when read was successful + */ + template + bool ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const; + private: // -------------------------------------------------------- diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index e43d15d38..ae48a5896 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -307,6 +307,124 @@ void Structure :: ReadField(T& out, const char* name, const FileDatabase& db) co } +//-------------------------------------------------------------------------------- +// field parsing for raw untyped data (like CustomDataLayer.data) +template +bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const +{ + if (!isValidCustomDataType(cdtype)) + { + ASSIMP_LOG_ERROR("given rawtype out of index"); + return false; + } + + const StreamReaderAny::pos old = db.reader->GetCurrentPos(); + + Pointer ptrval; + const Field* f; + try + { + f = &(*this)[name]; + + // sanity check, should never happen if the genblenddna script is right + if (!(f->flags & FieldFlag_Pointer)) + { + throw Error((Formatter::format(), "Field `", name, "` of structure `", + this->name, "` ought to be a pointer")); + } + + db.reader->IncPtr(f->offset); + Convert(ptrval, db); + // actually it is meaningless on which Structure the Convert is called + // because the `Pointer` argument triggers a special implementation. + } + catch (const Error& e) + { + _defaultInitializer()(out, e.what()); + out.reset(); + } + + bool readOk = true; + if (ptrval.val) + { + // get block for ptr + const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); + db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); + // read block->num instances of given type to out + readOk = readCustomData(out, static_cast(cdtype), block->num, db); + } + + // and recover the previous stream position + db.reader->SetCurrentPos(old); + +#ifndef ASSIMP_BUILD_BLENDER_NO_STATS + ++db.stats().fields_read; +#endif + + return readOk; +} + +//-------------------------------------------------------------------------------- +template class TOUT, typename T> +bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const +{ + out.clear(); + + const StreamReaderAny::pos old = db.reader->GetCurrentPos(); + + Pointer ptrval; + const Field* f; + try + { + f = &(*this)[name]; + + // sanity check, should never happen if the genblenddna script is right + if (!(f->flags & FieldFlag_Pointer)) + { + throw Error((Formatter::format(), "Field `", name, "` of structure `", + this->name, "` ought to be a pointer")); + } + + db.reader->IncPtr(f->offset); + Convert(ptrval, db); + // actually it is meaningless on which Structure the Convert is called + // because the `Pointer` argument triggers a special implementation. + } + catch (const Error& e) + { + _defaultInitializer()(out, e.what()); + out.clear(); + return false; + } + + + if (ptrval.val) + { + // find the file block the pointer is pointing to + const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); + db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); + // FIXME: basically, this could cause problems with 64 bit pointers on 32 bit systems. + // I really ought to improve StreamReader to work with 64 bit indices exclusively. + + const Structure& s = db.dna[f->type]; + for (size_t i = 0; i < block->num; ++i) + { + TOUT p(new T); + s.Convert(*p, db); + out.push_back(p); + } + } + + db.reader->SetCurrentPos(old); + +#ifndef ASSIMP_BUILD_BLENDER_NO_STATS + ++db.stats().fields_read; +#endif + + return false; +} + + //-------------------------------------------------------------------------------- template