From 0f2ca0f115731bf4136e427bd909132f27eb8027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaj=20Gr=C3=B6nholm?= Date: Tue, 8 Oct 2019 08:19:29 +0300 Subject: [PATCH] Quick3d: Updirection change as postprocessing step Requires corresponding patch for assimp. Task-number: QTBUG-78975 Change-Id: Ib48d78e430b06416f51af961d13acac789a86bad --- src/3rdparty/assimp/assimp.pri | 6 ++++-- src/3rdparty/assimp/config.h | 8 ++++++++ src/plugins/assetimporters/assimp/assimpimporter.cpp | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/assimp/assimp.pri b/src/3rdparty/assimp/assimp.pri index dee1601..d2f1ff0 100644 --- a/src/3rdparty/assimp/assimp.pri +++ b/src/3rdparty/assimp/assimp.pri @@ -285,7 +285,8 @@ HEADERS += \ $$ASSIMP_SRC/code/glTF2Asset.h \ $$ASSIMP_SRC/code/glTF2Asset.inl \ $$ASSIMP_SRC/code/glTF2AssetWriter.inl \ - $$ASSIMP_SRC/code/glTF2Importer.h + $$ASSIMP_SRC/code/glTF2Importer.h \ + $$ASSIMP_SRC/code/UpDirectionProcess.h SOURCES += \ $$ASSIMP_SRC/code/Assimp.cpp \ @@ -371,7 +372,8 @@ SOURCES += \ $$ASSIMP_SRC/code/MakeVerboseFormat.cpp \ $$ASSIMP_SRC/code/ScaleProcess.cpp \ $$ASSIMP_SRC/code/glTFImporter.cpp \ - $$ASSIMP_SRC/code/glTF2Importer.cpp + $$ASSIMP_SRC/code/glTF2Importer.cpp \ + $$ASSIMP_SRC/code/UpDirectionProcess.cpp # IrrXML (needed for DAE/Collada support) HEADERS += \ diff --git a/src/3rdparty/assimp/config.h b/src/3rdparty/assimp/config.h index c75a419..8a9b263 100644 --- a/src/3rdparty/assimp/config.h +++ b/src/3rdparty/assimp/config.h @@ -506,6 +506,14 @@ enum aiComponent #define AI_CONFIG_PP_FID_IGNORE_TEXTURECOORDS \ "PP_FID_IGNORE_TEXTURECOORDS" +// --------------------------------------------------------------------------- +/** @brief Input parameter to the #aiProcess_UpDirection step: + * Set to 1 to convert UP_X -> Y_UP. Set to 2 to convert UP_Z -> Y_UP. + * Default value is 0, meaning no conversion is required. + */ +#define AI_CONFIG_PP_UP_DIRECTION \ + "PP_UP_DIRECTION" + // TransformUVCoords evaluates UV scalings #define AI_UVTRAFO_SCALING 0x1 diff --git a/src/plugins/assetimporters/assimp/assimpimporter.cpp b/src/plugins/assetimporters/assimp/assimpimporter.cpp index dd7a159..cc76002 100644 --- a/src/plugins/assetimporters/assimp/assimpimporter.cpp +++ b/src/plugins/assetimporters/assimp/assimpimporter.cpp @@ -1285,6 +1285,9 @@ void AssimpImporter::processOptions(const QVariantMap &options) // We always need to triangulate and remove non triangles m_postProcessSteps = aiPostProcessSteps(aiProcess_Triangulate | aiProcess_SortByPType); + // Process updirection change if requested + m_postProcessSteps = aiPostProcessSteps(m_postProcessSteps | aiProcess_UpDirection); + if (checkBooleanOption(QStringLiteral("calculateTangentSpace"), optionsObject)) m_postProcessSteps = aiPostProcessSteps(m_postProcessSteps | aiProcess_CalcTangentSpace); -- 2.15.1.windows.2