From 59f732e10d23df3104b161c66efcde3805dade4e Mon Sep 17 00:00:00 2001
From: RichardTea <31507749+RichardTea@users.noreply.github.com>
Date: Thu, 20 Jun 2019 16:30:52 +0100
Subject: [PATCH 01/10] DAE Import: Don't use SkipElement() to skip empty Text
IrrXML doesn't recognise the construction: `` as being an empty element, and so ColladaParser::TestTextContent advances the element stream into the `` element.
Use TestClosing(const char*) instead of SkipElement() to skip an empty text element.
---
code/Collada/ColladaParser.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/code/Collada/ColladaParser.cpp b/code/Collada/ColladaParser.cpp
index 2106bf01c..860ae2ae9 100644
--- a/code/Collada/ColladaParser.cpp
+++ b/code/Collada/ColladaParser.cpp
@@ -323,10 +323,8 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
aiString aistr;
aistr.Set(value_char);
metadata.emplace(camel_key_str, aistr);
- TestClosing(key_str.c_str());
}
- else
- SkipElement();
+ TestClosing(key_str.c_str());
}
else
SkipElement();
From bf252c4452b76f9318b56d8c91f515bc13412a9c Mon Sep 17 00:00:00 2001
From: RichardTea <31507749+RichardTea@users.noreply.github.com>
Date: Thu, 20 Jun 2019 18:11:11 +0100
Subject: [PATCH 02/10] Add configuration of text format precision
Define ASSIMP_AI_REAL_TEXT_PRECISION
8 when ai_real is float
16 when ai_real is double
---
code/Collada/ColladaExporter.cpp | 2 +-
code/Obj/ObjExporter.cpp | 4 ++--
code/Ply/PlyExporter.cpp | 2 +-
code/STL/STLExporter.cpp | 2 +-
code/Step/StepExporter.cpp | 16 ++++++++--------
code/X/XFileExporter.cpp | 4 ++--
include/assimp/defs.h | 6 ++++++
7 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/code/Collada/ColladaExporter.cpp b/code/Collada/ColladaExporter.cpp
index 7c21dde43..639f0e032 100644
--- a/code/Collada/ColladaExporter.cpp
+++ b/code/Collada/ColladaExporter.cpp
@@ -99,7 +99,7 @@ ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, co
, mFile(file) {
// make sure that all formatting happens using the standard, C locale and not the user's current locale
mOutput.imbue( std::locale("C") );
- mOutput.precision(16);
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
mScene = pScene;
mSceneOwned = false;
diff --git a/code/Obj/ObjExporter.cpp b/code/Obj/ObjExporter.cpp
index 08cba43f7..0a0dbd62c 100644
--- a/code/Obj/ObjExporter.cpp
+++ b/code/Obj/ObjExporter.cpp
@@ -126,9 +126,9 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMt
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
- mOutput.precision(16);
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
mOutputMat.imbue(l);
- mOutputMat.precision(16);
+ mOutputMat.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
WriteGeometryFile(noMtl);
if ( !noMtl ) {
diff --git a/code/Ply/PlyExporter.cpp b/code/Ply/PlyExporter.cpp
index 4f9fa6c6f..5e21a88ac 100644
--- a/code/Ply/PlyExporter.cpp
+++ b/code/Ply/PlyExporter.cpp
@@ -111,7 +111,7 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
- mOutput.precision(16);
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
unsigned int faces = 0u, vertices = 0u, components = 0u;
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
diff --git a/code/STL/STLExporter.cpp b/code/STL/STLExporter.cpp
index d56c42835..43bc752ae 100644
--- a/code/STL/STLExporter.cpp
+++ b/code/STL/STLExporter.cpp
@@ -111,7 +111,7 @@ STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool expo
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
- mOutput.precision(16);
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
if (binary) {
char buf[80] = {0} ;
buf[0] = 'A'; buf[1] = 's'; buf[2] = 's'; buf[3] = 'i'; buf[4] = 'm'; buf[5] = 'p';
diff --git a/code/Step/StepExporter.cpp b/code/Step/StepExporter.cpp
index 2b4dbdbac..70035d9ea 100644
--- a/code/Step/StepExporter.cpp
+++ b/code/Step/StepExporter.cpp
@@ -143,15 +143,15 @@ namespace {
// ------------------------------------------------------------------------------------------------
// Constructor for a specific scene to export
StepExporter::StepExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path,
- const std::string& file, const ExportProperties* pProperties):
- mProperties(pProperties),mIOSystem(pIOSystem),mFile(file), mPath(path),
- mScene(pScene), endstr(";\n") {
- CollectTrafos(pScene->mRootNode, trafos);
- CollectMeshes(pScene->mRootNode, meshes);
+ const std::string& file, const ExportProperties* pProperties) :
+ mProperties(pProperties), mIOSystem(pIOSystem), mFile(file), mPath(path),
+ mScene(pScene), endstr(";\n") {
+ CollectTrafos(pScene->mRootNode, trafos);
+ CollectMeshes(pScene->mRootNode, meshes);
// make sure that all formatting happens using the standard, C locale and not the user's current locale
- mOutput.imbue( std::locale("C") );
- mOutput.precision(16);
+ mOutput.imbue(std::locale("C"));
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
// start writing
WriteFile();
@@ -166,7 +166,7 @@ void StepExporter::WriteFile()
mOutput.setf(std::ios::fixed);
// precision for double
// see http://stackoverflow.com/questions/554063/how-do-i-print-a-double-value-with-full-precision-using-cout
- mOutput.precision(16);
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
// standard color
aiColor4D fColor;
diff --git a/code/X/XFileExporter.cpp b/code/X/XFileExporter.cpp
index b2cc51852..ae9fd58fc 100644
--- a/code/X/XFileExporter.cpp
+++ b/code/X/XFileExporter.cpp
@@ -113,7 +113,7 @@ XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const s
{
// make sure that all formatting happens using the standard, C locale and not the user's current locale
mOutput.imbue( std::locale("C") );
- mOutput.precision(16);
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
// start writing
WriteFile();
@@ -134,7 +134,7 @@ void XFileExporter::WriteFile()
{
// note, that all realnumber values must be comma separated in x files
mOutput.setf(std::ios::fixed);
- mOutput.precision(16); // precision for double
+ mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION); // precision for ai_real
// entry of writing the file
WriteHeader();
diff --git a/include/assimp/defs.h b/include/assimp/defs.h
index 2631263f5..1b9a97b6b 100644
--- a/include/assimp/defs.h
+++ b/include/assimp/defs.h
@@ -243,10 +243,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
+#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
+#endif // ASSIMP_AI_REAL_TEXT_PRECISION
#endif // ASSIMP_DOUBLE_PRECISION
//////////////////////////////////////////////////////////////////////////
From 8f43fb144ac07a4dec9ae1e376bed37426951cee Mon Sep 17 00:00:00 2001
From: RichardTea <31507749+RichardTea@users.noreply.github.com>
Date: Mon, 24 Jun 2019 14:55:48 +0100
Subject: [PATCH 03/10] Add "importerIndex" Importer property
This indicates the index of the Importer that was selected, or -1 if did not find one at all.
---
code/Common/Importer.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/code/Common/Importer.cpp b/code/Common/Importer.cpp
index 8931bfa03..91b50859a 100644
--- a/code/Common/Importer.cpp
+++ b/code/Common/Importer.cpp
@@ -590,10 +590,12 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
// Find an worker class which can handle the file
BaseImporter* imp = NULL;
+ SetPropertyInteger("importerIndex", -1);
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, false)) {
imp = pimpl->mImporter[a];
+ SetPropertyInteger("importerIndex", a);
break;
}
}
@@ -606,6 +608,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, true)) {
imp = pimpl->mImporter[a];
+ SetPropertyInteger("importerIndex", a);
break;
}
}
From 6d07473550bfe4a7cee84e1cb59273329a8422d7 Mon Sep 17 00:00:00 2001
From: Mike Samsonov
Date: Thu, 27 Jun 2019 17:59:55 +0100
Subject: [PATCH 04/10] all textures use relative path except embedded, this is
fix for it
---
code/FBX/FBXConverter.cpp | 4 ++--
test/unit/utFBXImporterExporter.cpp | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp
index 5031665a6..ccbfc9b40 100644
--- a/code/FBX/FBXConverter.cpp
+++ b/code/FBX/FBXConverter.cpp
@@ -1642,7 +1642,7 @@ namespace Assimp {
out_tex->pcData = reinterpret_cast(const_cast