From eaf0587dd8b8bb2e66a7c83ef142eb5990f3839b Mon Sep 17 00:00:00 2001 From: Malcolm Tyrrell Date: Thu, 30 Jul 2020 14:56:01 +0100 Subject: [PATCH 1/6] FBX Version/Size Check --- code/AssetLib/FBX/FBXBinaryTokenizer.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp index 719b928bc..bbb3e5434 100644 --- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp +++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp @@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include namespace Assimp { namespace FBX { @@ -456,11 +457,21 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length) ASSIMP_LOG_DEBUG_F("FBX version: ", version); const bool is64bits = version >= 7500; const char *end = input + length; - while (cursor < end ) { - if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) { - break; + try + { + while (cursor < end ) { + if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) { + break; + } } } + catch (const DeadlyImportError& e) + { + if ((sizeof(size_t) > 4) && !is64bits && (length > std::numeric_limits::max())) { + throw DeadlyImportError("The FBX is invalid. This may be because the content is too big for this older version (" + to_string(version) + ") of the FBX format. (" + e.what() + ")"); + } + throw; + } } } // !FBX From 301bae3967046ba74b1fd2d2ba8b62f7cb39efac Mon Sep 17 00:00:00 2001 From: Malcolm Tyrrell Date: Thu, 30 Jul 2020 16:37:41 +0100 Subject: [PATCH 2/6] Improve message --- code/AssetLib/FBX/FBXBinaryTokenizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp index bbb3e5434..82c1783cd 100644 --- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp +++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp @@ -468,7 +468,7 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length) catch (const DeadlyImportError& e) { if ((sizeof(size_t) > 4) && !is64bits && (length > std::numeric_limits::max())) { - throw DeadlyImportError("The FBX is invalid. This may be because the content is too big for this older version (" + to_string(version) + ") of the FBX format. (" + e.what() + ")"); + throw DeadlyImportError("The FBX file is invalid. This may be because the content is too big for this older version (" + to_string(version) + ") of the FBX format. (" + e.what() + ")"); } throw; } From 0282f358a4d26adc897288f1a9ee9359c8bb0ac0 Mon Sep 17 00:00:00 2001 From: Malcolm Tyrrell Date: Fri, 31 Jul 2020 12:40:17 +0100 Subject: [PATCH 3/6] Remove unneeded check. --- code/AssetLib/FBX/FBXBinaryTokenizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp index 82c1783cd..78f02ff96 100644 --- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp +++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp @@ -467,7 +467,7 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length) } catch (const DeadlyImportError& e) { - if ((sizeof(size_t) > 4) && !is64bits && (length > std::numeric_limits::max())) { + if (!is64bits && (length > std::numeric_limits::max())) { throw DeadlyImportError("The FBX file is invalid. This may be because the content is too big for this older version (" + to_string(version) + ") of the FBX format. (" + e.what() + ")"); } throw; From 855b47452e8ff1096f8bc093e2bd702cbb963c5a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 4 Aug 2020 17:41:28 +0200 Subject: [PATCH 4/6] Export opacity is 3DS closes https://github.com/assimp/assimp/issues/3291 --- code/AssetLib/3DS/3DSExporter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp index fed96a51f..8c258d899 100644 --- a/code/AssetLib/3DS/3DSExporter.cpp +++ b/code/AssetLib/3DS/3DSExporter.cpp @@ -290,12 +290,17 @@ void Discreet3DSExporter::WriteMaterials() { ChunkWriter curChunk(writer, Discreet3DS::CHUNK_MAT_SPECULAR); WriteColor(color); } - + if (mat.Get(AI_MATKEY_COLOR_AMBIENT, color) == AI_SUCCESS) { ChunkWriter curChunk(writer, Discreet3DS::CHUNK_MAT_AMBIENT); WriteColor(color); } + if (mat.Get(AI_MATKEY_OPACITY, f) == AI_SUCCESS) { + ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_TRANSPARENCY); + WritePercentChunk(1.0f - f); + } + if (mat.Get(AI_MATKEY_COLOR_EMISSIVE, color) == AI_SUCCESS) { ChunkWriter curChunk(writer, Discreet3DS::CHUNK_MAT_SELF_ILLUM); WriteColor(color); From aabf12827ba516d8507793c558a67189744ea282 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 4 Aug 2020 17:52:43 +0200 Subject: [PATCH 5/6] fix typo --- code/AssetLib/3DS/3DSExporter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp index 8c258d899..ab0a5dbd2 100644 --- a/code/AssetLib/3DS/3DSExporter.cpp +++ b/code/AssetLib/3DS/3DSExporter.cpp @@ -296,6 +296,7 @@ void Discreet3DSExporter::WriteMaterials() { WriteColor(color); } + float f; if (mat.Get(AI_MATKEY_OPACITY, f) == AI_SUCCESS) { ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_TRANSPARENCY); WritePercentChunk(1.0f - f); From 1f348c5fc067bebed79fa7a8f2246984a709a1f6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 4 Aug 2020 20:55:29 +0200 Subject: [PATCH 6/6] Remove redundant float f --- code/AssetLib/3DS/3DSExporter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp index ab0a5dbd2..ad8e10afe 100644 --- a/code/AssetLib/3DS/3DSExporter.cpp +++ b/code/AssetLib/3DS/3DSExporter.cpp @@ -339,7 +339,6 @@ void Discreet3DSExporter::WriteMaterials() { writer.PutU2(static_cast(shading_mode_out)); } - float f; if (mat.Get(AI_MATKEY_SHININESS, f) == AI_SUCCESS) { ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SHININESS); WritePercentChunk(f);