From 8f4eff8d95e350b3c38dd599d8f200e97b70d256 Mon Sep 17 00:00:00 2001 From: RichardTea <31507749+RichardTea@users.noreply.github.com> Date: Wed, 20 Jan 2021 17:13:31 +0000 Subject: [PATCH 01/12] Increase ASSIMP_AI_REAL_TEXT_PRECISION 9 for float, 17 for double --- include/assimp/defs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/assimp/defs.h b/include/assimp/defs.h index 1e908afac..d2077d8b4 100644 --- a/include/assimp/defs.h +++ b/include/assimp/defs.h @@ -247,14 +247,14 @@ typedef double ai_real; typedef signed long long int ai_int; typedef unsigned long long int ai_uint; #ifndef ASSIMP_AI_REAL_TEXT_PRECISION -#define ASSIMP_AI_REAL_TEXT_PRECISION 16 +#define ASSIMP_AI_REAL_TEXT_PRECISION 17 #endif // ASSIMP_AI_REAL_TEXT_PRECISION #else // ASSIMP_DOUBLE_PRECISION typedef float ai_real; typedef signed int ai_int; typedef unsigned int ai_uint; #ifndef ASSIMP_AI_REAL_TEXT_PRECISION -#define ASSIMP_AI_REAL_TEXT_PRECISION 8 +#define ASSIMP_AI_REAL_TEXT_PRECISION 9 #endif // ASSIMP_AI_REAL_TEXT_PRECISION #endif // ASSIMP_DOUBLE_PRECISION From dd0facd722b8d84f2f2df606837cdbce98415158 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 24 Jan 2021 18:14:00 +0100 Subject: [PATCH 02/12] Delete appveyor.yml --- appveyor.yml | 81 ---------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4fb79dd69..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,81 +0,0 @@ -# AppVeyor file -# http://www.appveyor.com/docs/appveyor-yml - -# clone directory -clone_folder: c:\projects\assimp - -clone_depth: 1 - -# branches to build -branches: - # whitelist - only: - - master - -matrix: - fast_finish: true - -image: - - Visual Studio 2013 - #- Visual Studio 2015 - #- Visual Studio 2017 - - Visual Studio 2019 - #- MinGW - -platform: - - Win32 - - x64 - -configuration: Release - -install: - - set PATH=C:\Ruby24-x64\bin;%PATH% - - set CMAKE_DEFINES -DASSIMP_WERROR=ON - - if [%COMPILER%]==[MinGW] set PATH=C:\MinGW\bin;%PATH% - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" set CMAKE_GENERATOR_NAME=Visual Studio 12 2013 - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set CMAKE_GENERATOR_NAME=Visual Studio 16 2019 - - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" -A %platform% . - # Rename sh.exe as sh.exe in PATH interferes with MinGW - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 - - - rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe" - - 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 - -cache: - - code\assimp.dir\%CONFIGURATION% - - contrib\zlib\zlibstatic.dir\%CONFIGURATION% - - contrib\zlib\zlib.dir\%CONFIGURATION% - - tools\assimp_cmd\assimp_cmd.dir\%CONFIGURATION% - - tools\assimp_view\assimp_viewer.dir\%CONFIGURATION% - - test\unit.dir\%CONFIGURATION% - - bin\.mtime_cache - -before_build: - - echo NUMBER_OF_PROCESSORS=%NUMBER_OF_PROCESSORS% - - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json - -build_script: - cmake --build . --config Release -- /maxcpucount:2 - -after_build: - - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( - if "%platform%"=="x64" ( - iscc packaging\windows-innosetup\script_x64.iss - ) else ( - iscc packaging\windows-innosetup\script_x86.iss - ) - ) - - 7z a assimp.7z bin\%CONFIGURATION%\* lib\%CONFIGURATION%\* - -test_script: - - cmd: bin\%CONFIGURATION%\unit.exe --gtest_output=xml:testout.xml - -on_finish: - - ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\testout.xml)) - -artifacts: - - path: assimp.7z - name: assimp_lib From 7a706be9206ed4f2b238e99e4dfb8c330e01dfd9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 24 Jan 2021 18:14:36 +0100 Subject: [PATCH 03/12] Delete cacheglobs.txt --- scripts/AppVeyor/cacheglobs.txt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 scripts/AppVeyor/cacheglobs.txt diff --git a/scripts/AppVeyor/cacheglobs.txt b/scripts/AppVeyor/cacheglobs.txt deleted file mode 100644 index 0f5f04a4a..000000000 --- a/scripts/AppVeyor/cacheglobs.txt +++ /dev/null @@ -1,4 +0,0 @@ -code/*.{%{cpp}} -contrib/**/*.{%{cpp}} -include/**/*.{%{cpp}} -test/**/*.{%{cpp}} From e18261953d511468f2edec16aa7f1db068653bac Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 24 Jan 2021 18:14:43 +0100 Subject: [PATCH 04/12] Delete mtime_cache --- scripts/AppVeyor/mtime_cache | 177 ----------------------------------- 1 file changed, 177 deletions(-) delete mode 100644 scripts/AppVeyor/mtime_cache diff --git a/scripts/AppVeyor/mtime_cache b/scripts/AppVeyor/mtime_cache deleted file mode 100644 index e296e3658..000000000 --- a/scripts/AppVeyor/mtime_cache +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env ruby - -# -# mtime_cache -# Copyright (c) 2016 Borislav Stanimirov -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# - -require 'digest/md5' -require 'json' -require 'fileutils' - -VERSION = "1.0.2" - -VERSION_TEXT = "mtime_cache v#{VERSION}" - -USAGE = <] [-g globfile] [-d] [-q|V] [-c cache] -ENDUSAGE - -HELP = < '.mtime_cache.json', :globs => [] } - -ARGV.each do |arg| - case arg - when '-g', '--globfile' then param_arg = :globfile - when '-h', '-?', '--help' then ARGS[:help] = true - when '-v', '--version' then ARGS[:ver] = true - when '-q', '--quiet' then ARGS[:quiet] = true - when '-V', '--verbose' then ARGS[:verbose] = true - when '-d', '--dryrun' then ARGS[:dry] = true - when '-c', '--cache' then param_arg = :cache - else - if param_arg - ARGS[param_arg] = arg - param_arg = nil - else - ARGS[:globs] << arg - end - end -end - -def log(text, level = 0) - return if ARGS[:quiet] - return if level > 0 && !ARGS[:verbose] - puts text -end - -if ARGS[:ver] || ARGS[:help] - log VERSION_TEXT - exit if ARGS[:ver] - log USAGE - log HELP - exit -end - -if ARGS[:globs].empty? && !ARGS[:globfile] - log 'Error: Missing globs' - log USAGE - exit 1 -end - -EXTENSION_PATTERNS = { - :cpp => "c,cc,cpp,cxx,h,hpp,hxx,inl,ipp,inc,ixx" -} - -cache_file = ARGS[:cache] - -cache = {} - -if File.file?(cache_file) - log "Found #{cache_file}" - cache = JSON.parse(File.read(cache_file)) - log "Read #{cache.length} entries" -else - log "#{cache_file} not found. A new one will be created" -end - -globs = ARGS[:globs].map { |g| g % EXTENSION_PATTERNS } - -globfile = ARGS[:globfile] -if globfile - File.open(globfile, 'r').each_line do |line| - line.strip! - next if line.empty? - globs << line % EXTENSION_PATTERNS - end -end - -if globs.empty? - log 'Error: No globs in globfile' - log USAGE - exit 1 -end - -files = {} -num_changed = 0 - -globs.each do |glob| - Dir[glob].each do |file| - next if !File.file?(file) - - mtime = File.mtime(file).to_i - hash = Digest::MD5.hexdigest(File.read(file)) - - cached = cache[file] - - if cached && cached['hash'] == hash && cached['mtime'] < mtime - mtime = cached['mtime'] - - log "mtime_cache: changing mtime of #{file} to #{mtime}", 1 - - File.utime(File.atime(file), Time.at(mtime), file) if !ARGS[:dry] - num_changed += 1 - else - log "mtime_cache: NOT changing mtime of #{file}", 1 - end - - files[file] = { 'mtime' => mtime, 'hash' => hash } - end -end - -log "Changed mtime of #{num_changed} of #{files.length} files" -log "Writing #{cache_file}" - -if !ARGS[:dry] - dirname = File.dirname(cache_file) - unless File.directory?(dirname) - FileUtils.mkdir_p(dirname) - end - File.open(cache_file, 'w').write(JSON.pretty_generate(files)) -end From a2b889ab09fa6b5081c3cacb257d577e12214ea6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 24 Jan 2021 18:21:46 +0100 Subject: [PATCH 05/12] Fix typo in collada parser closes https://github.com/assimp/assimp/issues/3599 --- code/AssetLib/Collada/ColladaParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index d84f76340..126c87db0 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -334,7 +334,7 @@ void ColladaParser::ReadAssetInfo(XmlNode &node) { const std::string ¤tName = currentNode.name(); if (currentName == "unit") { mUnitSize = 1.f; - XmlParser::getFloatAttribute(node, "meter", mUnitSize); + XmlParser::getFloatAttribute(currentNode, "meter", mUnitSize); } else if (currentName == "up_axis") { std::string v; if (!XmlParser::getValueAsString(currentNode, v)) { From 243d017463151b3966d88af86215ee28776a4f1b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 24 Jan 2021 18:47:50 +0100 Subject: [PATCH 06/12] Add missing skip - closes https://github.com/assimp/assimp/issues/3601 - Fix some format issues --- code/AssetLib/Collada/ColladaParser.cpp | 185 +++++++++++++----------- 1 file changed, 100 insertions(+), 85 deletions(-) diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 126c87db0..f78b51047 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -459,7 +459,6 @@ void ColladaParser::PostProcessRootAnimations() { if (animation != mAnimationLibrary.end()) { Animation *pSourceAnimation = animation->second; - pSourceAnimation->CollectChannelsRecursively(clip->mChannels); } } @@ -1738,14 +1737,16 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector indices; - if (expectedPointCount > 0) + if (expectedPointCount > 0) { indices.reserve(expectedPointCount * numOffsets); + } - if (pNumPrimitives > 0) // It is possible to not contain any indices - { + // It is possible to not contain any indices + if (pNumPrimitives > 0) { std::string v; XmlParser::getValueAsString(node, v); const char *content = v.c_str(); + SkipSpacesAndLineEnd(&content); while (*content != 0) { // read a value. // Hack: (thom) Some exporters put negative indices sometimes. We just try to carry on anyways. @@ -1772,21 +1773,24 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) { InputChannel &input = *it; - if (input.mResolved) + if (input.mResolved) { continue; + } // find accessor input.mResolved = &ResolveLibraryReference(mAccessorLibrary, input.mAccessor); // resolve accessor's data pointer as well, if necessary const Accessor *acc = input.mResolved; - if (!acc->mData) + if (!acc->mData) { acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource); + } } // and the same for the per-index channels for (std::vector::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) { InputChannel &input = *it; - if (input.mResolved) + if (input.mResolved) { continue; + } // ignore vertex pointer, it doesn't refer to an accessor if (input.mType == IT_Vertex) { @@ -1801,8 +1805,9 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vectormData) + if (!acc->mData) { acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource); + } } // For continued primitives, the given count does not come all in one

, but only one primitive per

@@ -1884,11 +1889,13 @@ void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t n ai_assert((baseOffset + numOffsets - 1) < indices.size()); // extract per-vertex channels using the global per-vertex offset - for (std::vector::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) + for (std::vector::iterator it = pMesh.mPerVertexData.begin(); it != pMesh.mPerVertexData.end(); ++it) { ExtractDataObjectFromChannel(*it, indices[baseOffset + perVertexOffset], pMesh); + } // and extract per-index channels using there specified offset - for (std::vector::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) + for (std::vector::iterator it = pPerIndexChannels.begin(); it != pPerIndexChannels.end(); ++it) { ExtractDataObjectFromChannel(*it, indices[baseOffset + it->mOffset], pMesh); + } // store the vertex-data index for later assignment of bone vertex weights pMesh.mFacePosIndices.push_back(indices[baseOffset + perVertexOffset]); @@ -1912,8 +1919,9 @@ void ColladaParser::ReadPrimTriStrips(size_t numOffsets, size_t perVertexOffset, // Extracts a single object from an input channel and stores it in the appropriate mesh data array void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, size_t pLocalIndex, Mesh &pMesh) { // ignore vertex referrer - we handle them that separate - if (pInput.mType == IT_Vertex) + if (pInput.mType == IT_Vertex) { return; + } const Accessor &acc = *pInput.mResolved; if (pLocalIndex >= acc.mCount) { @@ -1926,86 +1934,93 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz // assemble according to the accessors component sub-offset list. We don't care, yet, // what kind of object exactly we're extracting here ai_real obj[4]; - for (size_t c = 0; c < 4; ++c) + for (size_t c = 0; c < 4; ++c) { obj[c] = dataObject[acc.mSubOffset[c]]; + } // now we reinterpret it according to the type we're reading here switch (pInput.mType) { - case IT_Position: // ignore all position streams except 0 - there can be only one position - if (pInput.mIndex == 0) - pMesh.mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2])); - else - ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported"); - break; - case IT_Normal: - // pad to current vertex count if necessary - if (pMesh.mNormals.size() < pMesh.mPositions.size() - 1) - pMesh.mNormals.insert(pMesh.mNormals.end(), pMesh.mPositions.size() - pMesh.mNormals.size() - 1, aiVector3D(0, 1, 0)); - - // ignore all normal streams except 0 - there can be only one normal - if (pInput.mIndex == 0) - pMesh.mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2])); - else - ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported"); - break; - case IT_Tangent: - // pad to current vertex count if necessary - if (pMesh.mTangents.size() < pMesh.mPositions.size() - 1) - pMesh.mTangents.insert(pMesh.mTangents.end(), pMesh.mPositions.size() - pMesh.mTangents.size() - 1, aiVector3D(1, 0, 0)); - - // ignore all tangent streams except 0 - there can be only one tangent - if (pInput.mIndex == 0) - pMesh.mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); - else - ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported"); - break; - case IT_Bitangent: - // pad to current vertex count if necessary - if (pMesh.mBitangents.size() < pMesh.mPositions.size() - 1) - pMesh.mBitangents.insert(pMesh.mBitangents.end(), pMesh.mPositions.size() - pMesh.mBitangents.size() - 1, aiVector3D(0, 0, 1)); - - // ignore all bitangent streams except 0 - there can be only one bitangent - if (pInput.mIndex == 0) - pMesh.mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); - else - ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported"); - break; - case IT_Texcoord: - // up to 4 texture coord sets are fine, ignore the others - if (pInput.mIndex < AI_MAX_NUMBER_OF_TEXTURECOORDS) { - // pad to current vertex count if necessary - if (pMesh.mTexCoords[pInput.mIndex].size() < pMesh.mPositions.size() - 1) - pMesh.mTexCoords[pInput.mIndex].insert(pMesh.mTexCoords[pInput.mIndex].end(), - pMesh.mPositions.size() - pMesh.mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0)); - - pMesh.mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2])); - if (0 != acc.mSubOffset[2] || 0 != acc.mSubOffset[3]) /* hack ... consider cleaner solution */ - pMesh.mNumUVComponents[pInput.mIndex] = 3; - } else { - ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping."); - } - break; - case IT_Color: - // up to 4 color sets are fine, ignore the others - if (pInput.mIndex < AI_MAX_NUMBER_OF_COLOR_SETS) { - // pad to current vertex count if necessary - if (pMesh.mColors[pInput.mIndex].size() < pMesh.mPositions.size() - 1) - pMesh.mColors[pInput.mIndex].insert(pMesh.mColors[pInput.mIndex].end(), - pMesh.mPositions.size() - pMesh.mColors[pInput.mIndex].size() - 1, aiColor4D(0, 0, 0, 1)); - - aiColor4D result(0, 0, 0, 1); - for (size_t i = 0; i < pInput.mResolved->mSize; ++i) { - result[static_cast(i)] = obj[pInput.mResolved->mSubOffset[i]]; + case IT_Position: // ignore all position streams except 0 - there can be only one position + if (pInput.mIndex == 0) { + pMesh.mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2])); + } else { + ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported"); } - pMesh.mColors[pInput.mIndex].push_back(result); - } else { - ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping."); - } + break; + case IT_Normal: + // pad to current vertex count if necessary + if (pMesh.mNormals.size() < pMesh.mPositions.size() - 1) + pMesh.mNormals.insert(pMesh.mNormals.end(), pMesh.mPositions.size() - pMesh.mNormals.size() - 1, aiVector3D(0, 1, 0)); - break; - default: - // IT_Invalid and IT_Vertex - ai_assert(false && "shouldn't ever get here"); + // ignore all normal streams except 0 - there can be only one normal + if (pInput.mIndex == 0) { + pMesh.mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2])); + } else { + ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported"); + } + break; + case IT_Tangent: + // pad to current vertex count if necessary + if (pMesh.mTangents.size() < pMesh.mPositions.size() - 1) + pMesh.mTangents.insert(pMesh.mTangents.end(), pMesh.mPositions.size() - pMesh.mTangents.size() - 1, aiVector3D(1, 0, 0)); + + // ignore all tangent streams except 0 - there can be only one tangent + if (pInput.mIndex == 0) { + pMesh.mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); + } else { + ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported"); + } + break; + case IT_Bitangent: + // pad to current vertex count if necessary + if (pMesh.mBitangents.size() < pMesh.mPositions.size() - 1) { + pMesh.mBitangents.insert(pMesh.mBitangents.end(), pMesh.mPositions.size() - pMesh.mBitangents.size() - 1, aiVector3D(0, 0, 1)); + } + + // ignore all bitangent streams except 0 - there can be only one bitangent + if (pInput.mIndex == 0) { + pMesh.mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); + } else { + ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported"); + } + break; + case IT_Texcoord: + // up to 4 texture coord sets are fine, ignore the others + if (pInput.mIndex < AI_MAX_NUMBER_OF_TEXTURECOORDS) { + // pad to current vertex count if necessary + if (pMesh.mTexCoords[pInput.mIndex].size() < pMesh.mPositions.size() - 1) + pMesh.mTexCoords[pInput.mIndex].insert(pMesh.mTexCoords[pInput.mIndex].end(), + pMesh.mPositions.size() - pMesh.mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0)); + + pMesh.mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2])); + if (0 != acc.mSubOffset[2] || 0 != acc.mSubOffset[3]) { + pMesh.mNumUVComponents[pInput.mIndex] = 3; + } + } else { + ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping."); + } + break; + case IT_Color: + // up to 4 color sets are fine, ignore the others + if (pInput.mIndex < AI_MAX_NUMBER_OF_COLOR_SETS) { + // pad to current vertex count if necessary + if (pMesh.mColors[pInput.mIndex].size() < pMesh.mPositions.size() - 1) + pMesh.mColors[pInput.mIndex].insert(pMesh.mColors[pInput.mIndex].end(), + pMesh.mPositions.size() - pMesh.mColors[pInput.mIndex].size() - 1, aiColor4D(0, 0, 0, 1)); + + aiColor4D result(0, 0, 0, 1); + for (size_t i = 0; i < pInput.mResolved->mSize; ++i) { + result[static_cast(i)] = obj[pInput.mResolved->mSubOffset[i]]; + } + pMesh.mColors[pInput.mIndex].push_back(result); + } else { + ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping."); + } + + break; + default: + // IT_Invalid and IT_Vertex + ai_assert(false && "shouldn't ever get here"); } } From d04b1b9e2e58a8d05fe2cfdd17a547c1e7804b82 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 26 Jan 2021 18:08:20 +0100 Subject: [PATCH 07/12] Replace patreon by opencollective --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index e0c2bec9e..35448d4dc 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ patreon: assimp -custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4 +open_collective: assimp From 0244aec0a574debdb11fee9a3d9516094a7dcfe5 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 26 Jan 2021 18:09:25 +0100 Subject: [PATCH 08/12] Update Readme.md --- Readme.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Readme.md b/Readme.md index c6212bcc0..6198d403e 100644 --- a/Readme.md +++ b/Readme.md @@ -105,12 +105,6 @@ Become a financial contributor and help us sustain our community. [[Contribute]( Monthly donations via Patreon:
[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/assimp) -
- -One-off donations via PayPal: -
[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4) - -
#### Organizations From 4471c36c087c0a36a6dfd9aee01cdce520f8df2d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 26 Jan 2021 20:59:21 +0100 Subject: [PATCH 09/12] Fix compiler bug for VS2019 - Check https://developercommunity.visualstudio.com/content/problem/1223143/visual-studio-2019-c-program-crash-with-stdstring.html for more details - closes https://github.com/assimp/assimp/issues/3572 --- code/AssetLib/FBX/FBXMaterial.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 9fe4ce5be..2d727d16e 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -60,12 +60,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { namespace FBX { - using namespace Util; +using namespace Util; // ------------------------------------------------------------------------------------------------ -Material::Material(uint64_t id, const Element& element, const Document& doc, const std::string& name) -: Object(id,element,name) -{ +Material::Material(uint64_t id, const Element& element, const Document& doc, const std::string& name) : + Object(id,element,name) { const Scope& sc = GetRequiredScope(element); const Element* const ShadingModel = sc["ShadingModel"]; @@ -77,8 +76,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con if(ShadingModel) { shading = ParseTokenAsString(GetRequiredToken(*ShadingModel,0)); - } - else { + } else { DOMWarning("shading mode not specified, assuming phong",&element); shading = "phong"; } @@ -86,7 +84,9 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con std::string templateName; // lower-case shading because Blender (for example) writes "Phong" - std::transform(shading.data(), shading.data() + shading.size(), std::addressof(shading[0]), Assimp::ToLower); + for (size_t i = 0; i < shading.length(); ++i) { + shading[i] = tolower(shading[i]); + } if(shading == "phong") { templateName = "Material.FbxSurfacePhong"; } From c02ad323a5f41f3fb37e5fdfc2ef097860a2f426 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 27 Jan 2021 09:22:59 +0100 Subject: [PATCH 10/12] Fix VS compiler warning: convertig int to char --- code/AssetLib/FBX/FBXMaterial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 2d727d16e..8738924ad 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -85,7 +85,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con // lower-case shading because Blender (for example) writes "Phong" for (size_t i = 0; i < shading.length(); ++i) { - shading[i] = tolower(shading[i]); + shading[i] = sttaic_cast(tolower(shading[i]); } if(shading == "phong") { templateName = "Material.FbxSurfacePhong"; From ac0f1f2cabb44adf29cf06da05a1387ec37b4da7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 27 Jan 2021 09:37:35 +0100 Subject: [PATCH 11/12] Update FBXMaterial.cpp --- code/AssetLib/FBX/FBXMaterial.cpp | 126 +++++++++++------------------- 1 file changed, 46 insertions(+), 80 deletions(-) diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 8738924ad..7223f3217 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include // std::transform #include "FBXUtil.h" namespace Assimp { @@ -81,19 +80,16 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con shading = "phong"; } - std::string templateName; - // lower-case shading because Blender (for example) writes "Phong" for (size_t i = 0; i < shading.length(); ++i) { - shading[i] = sttaic_cast(tolower(shading[i]); + shading[i] = static_cast(tolower(shading[i]); } + std::string templateName; if(shading == "phong") { templateName = "Material.FbxSurfacePhong"; - } - else if(shading == "lambert") { + } else if(shading == "lambert") { templateName = "Material.FbxSurfaceLambert"; - } - else { + } else { DOMWarning("shading mode not recognized: " + shading,&element); } @@ -102,20 +98,19 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con // resolve texture links const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID()); for(const Connection* con : conns) { - // texture link to properties, not objects - if (!con->PropertyName().length()) { + if ( 0 == con->PropertyName().length()) { continue; } const Object* const ob = con->SourceObject(); - if(!ob) { + if(nullptr == ob) { DOMWarning("failed to read source object for texture link, ignoring",&element); continue; } const Texture* const tex = dynamic_cast(ob); - if(!tex) { + if(nullptr == tex) { const LayeredTexture* const layeredTexture = dynamic_cast(ob); if(!layeredTexture) { DOMWarning("source object for texture link is not a texture or layered texture, ignoring",&element); @@ -128,9 +123,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con layeredTextures[prop] = layeredTexture; ((LayeredTexture*)layeredTexture)->fillTexture(doc); - } - else - { + } else { const std::string& prop = con->PropertyName(); if (textures.find(prop) != textures.end()) { DOMWarning("duplicate texture link: " + prop,&element); @@ -138,23 +131,20 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con textures[prop] = tex; } - } } // ------------------------------------------------------------------------------------------------ -Material::~Material() -{ +Material::~Material() { + // empty } - // ------------------------------------------------------------------------------------------------ -Texture::Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name) -: Object(id,element,name) -, uvScaling(1.0f,1.0f) -, media(0) -{ +Texture::Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name) : + Object(id,element,name), + uvScaling(1.0f,1.0f), + media(0) { const Scope& sc = GetRequiredScope(element); const Element* const Type = sc["Type"]; @@ -194,8 +184,7 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const crop[1] = ParseTokenAsInt(GetRequiredToken(*Cropping,1)); crop[2] = ParseTokenAsInt(GetRequiredToken(*Cropping,2)); crop[3] = ParseTokenAsInt(GetRequiredToken(*Cropping,3)); - } - else { + } else { // vc8 doesn't support the crop() syntax in initialization lists // (and vc9 WARNS about the new (i.e. compliant) behaviour). crop[0] = crop[1] = crop[2] = crop[3] = 0; @@ -226,7 +215,7 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID()); for(const Connection* con : conns) { const Object* const ob = con->SourceObject(); - if(!ob) { + if (nullptr == ob) { DOMWarning("failed to read source object for texture link, ignoring",&element); continue; } @@ -240,46 +229,38 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const } -Texture::~Texture() -{ - +Texture::~Texture() { + // empty } -LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name) -: Object(id,element,name) -,blendMode(BlendMode_Modulate) -,alpha(1) -{ +LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name) : + Object(id,element,name), + blendMode(BlendMode_Modulate), + alpha(1) { const Scope& sc = GetRequiredScope(element); const Element* const BlendModes = sc["BlendModes"]; const Element* const Alphas = sc["Alphas"]; - - if(BlendModes!=0) - { + if (nullptr != BlendModes) { blendMode = (BlendMode)ParseTokenAsInt(GetRequiredToken(*BlendModes,0)); } - if(Alphas!=0) - { + if (nullptr != Alphas) { alpha = ParseTokenAsFloat(GetRequiredToken(*Alphas,0)); } } -LayeredTexture::~LayeredTexture() -{ - +LayeredTexture::~LayeredTexture() { + // empty } -void LayeredTexture::fillTexture(const Document& doc) -{ +void LayeredTexture::fillTexture(const Document& doc) { const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID()); - for(size_t i = 0; i < conns.size();++i) - { + for(size_t i = 0; i < conns.size();++i) { const Connection* con = conns.at(i); const Object* const ob = con->SourceObject(); - if(!ob) { + if (nullptr == ob) { DOMWarning("failed to read source object for texture link, ignoring",&element); continue; } @@ -290,13 +271,11 @@ void LayeredTexture::fillTexture(const Document& doc) } } - // ------------------------------------------------------------------------------------------------ -Video::Video(uint64_t id, const Element& element, const Document& doc, const std::string& name) -: Object(id,element,name) -, contentLength(0) -, content(0) -{ +Video::Video(uint64_t id, const Element& element, const Document& doc, const std::string& name) : + Object(id,element,name), + contentLength(0), + content(0) { const Scope& sc = GetRequiredScope(element); const Element* const Type = sc["Type"]; @@ -324,52 +303,43 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std if (!token.IsBinary()) { if (*data != '"') { DOMError("embedded content is not surrounded by quotation marks", &element); - } - else { + } else { size_t targetLength = 0; auto numTokens = Content->Tokens().size(); // First time compute size (it could be large like 64Gb and it is good to allocate it once) - for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx) - { + for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx) { const Token& dataToken = GetRequiredToken(*Content, tokenIdx); size_t tokenLength = dataToken.end() - dataToken.begin() - 2; // ignore double quotes const char* base64data = dataToken.begin() + 1; const size_t outLength = Util::ComputeDecodedSizeBase64(base64data, tokenLength); - if (outLength == 0) - { + if (outLength == 0) { DOMError("Corrupted embedded content found", &element); } targetLength += outLength; } - if (targetLength == 0) - { + if (targetLength == 0) { DOMError("Corrupted embedded content found", &element); } content = new uint8_t[targetLength]; contentLength = static_cast(targetLength); size_t dst_offset = 0; - for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx) - { + for (uint32_t tokenIdx = 0; tokenIdx < numTokens; ++tokenIdx) { const Token& dataToken = GetRequiredToken(*Content, tokenIdx); size_t tokenLength = dataToken.end() - dataToken.begin() - 2; // ignore double quotes const char* base64data = dataToken.begin() + 1; dst_offset += Util::DecodeBase64(base64data, tokenLength, content + dst_offset, targetLength - dst_offset); } - if (targetLength != dst_offset) - { + if (targetLength != dst_offset) { delete[] content; contentLength = 0; DOMError("Corrupted embedded content found", &element); } } - } - else if (static_cast(token.end() - data) < 5) { + } else if (static_cast(token.end() - data) < 5) { DOMError("binary data array is too short, need five (5) bytes for type signature and element count", &element); - } - else if (*data != 'R') { + } else if (*data != 'R') { DOMWarning("video content is not raw binary data, ignoring", &element); - } - else { + } else { // read number of elements uint32_t len = 0; ::memcpy(&len, data + 1, sizeof(len)); @@ -380,8 +350,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std content = new uint8_t[len]; ::memcpy(content, data + 5, len); } - } catch (const runtime_error& runtimeError) - { + } catch (const runtime_error& runtimeError) { //we don't need the content data for contents that has already been loaded ASSIMP_LOG_VERBOSE_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ", runtimeError.what()); @@ -392,14 +361,11 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std } -Video::~Video() -{ - if(content) { - delete[] content; - } +Video::~Video() { + delete[] content; } } //!FBX } //!Assimp -#endif +#endif // ASSIMP_BUILD_NO_FBX_IMPORTER From 1e38f84c3a66e429f8cd3f45779bcd6c61fdfff6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 27 Jan 2021 09:40:19 +0100 Subject: [PATCH 12/12] fix typo --- code/AssetLib/FBX/FBXMaterial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 7223f3217..6997388b8 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -82,7 +82,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con // lower-case shading because Blender (for example) writes "Phong" for (size_t i = 0; i < shading.length(); ++i) { - shading[i] = static_cast(tolower(shading[i]); + shading[i] = static_cast(tolower(shading[i])); } std::string templateName; if(shading == "phong") {