summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2019-08-29 07:21:35 +0300
committerTomi Korpipaa <tomi.korpipaa@qt.io>2019-08-29 10:58:18 +0300
commit7acb8e646e3dbb884b0d379fe9f4f6e4aae417d0 (patch)
tree17a0e6835bd54949dd65854c3ed3fb54f34d8567
parentd5dfb26d046de1a062a9b41fdcc0277465cbf608 (diff)
Fix showing warning if non-triangle geometries
Also unify the warning message for missing material. Task-number: QT3DS-3907 Change-Id: Ia8748bc9a141f30bafecdbe0a64872431bf3f313 Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp3
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp33
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h31
3 files changed, 35 insertions, 32 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index af008129..cd8c0425 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -5442,6 +5442,9 @@ void IDocumentEditor::DisplayImportErrors(const QString &inImportSource,
case ESceneGraphWarningCode_VertexBufferTooLarge:
formatStr = L"A single mesh exceeds the maximum vertex count of 65535";
break;
+ case ESceneGraphWarningCode_MissingMaterial:
+ formatStr = L"Materials are missing from mesh %ls, it was not created";
+ break;
default:
break;
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
index 2bf58a85..16b0ebc0 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
@@ -40,8 +40,6 @@
#include "Qt3DSImportTranslationCommon.h"
#include "Qt3DSImportSceneGraphTranslation.h"
#include "Qt3DSImportTranslation.h"
-#include "Dialogs.h"
-#include "StudioApp.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qfileinfo.h>
@@ -88,7 +86,8 @@ protected:
void ProcessGeometry(const domGeometry *inGeometry, TFaceIndicies &ioIndicies);
void ProcessTriangle(const domTrianglesRef inTrianglesRef, TFaceIndicies &ioFaceIndicies,
bool &outHasNormals, bool &outHasTexCoords, bool &outHasTexCoords2,
- bool &outHasTexTangents, bool &outHasTexBinormals, bool &outHasColors);
+ bool &outHasTexTangents, bool &outHasTexBinormals, bool &outHasColors,
+ const char *meshName);
void GenerateMeshTangents(const domTrianglesRef inTrianglesRef,
const SSourceArrayInfo &inVertexArrayInfo,
const SSourceArrayInfo &inNormalArrayInfo,
@@ -775,7 +774,15 @@ void ColladaDOMWalker::ProcessGeometry(const domGeometry *inGeometry, TFaceIndic
long theTriangleArrayCount = (long)theTriangles.getCount();
for (long theIndex = 0; theIndex < theTriangleArrayCount; ++theIndex) {
ProcessTriangle(theTriangles[theIndex], ioFaceIndicies, theHasNormals, theHasTexCoords,
- theHasTexCoords2, theHasTexTangents, theHasTexBinormals, theHasColors);
+ theHasTexCoords2, theHasTexTangents, theHasTexBinormals, theHasColors,
+ GetNameOrIDOrSid(inGeometry));
+ }
+
+ // Pop up warning message if model contains non-triangles geometry
+ if (theMesh->getPolylist_array().getCount() || theMesh->getPolygons_array().getCount()
+ || theMesh->getLines_array().getCount() || theMesh->getLinestrips_array().getCount()
+ || theMesh->getTrifans_array().getCount() || theMesh->getTristrips_array().getCount()) {
+ LogWarning(ESceneGraphWarningCode_OnlySupportTriangles, GetNameOrIDOrSid(inGeometry));
}
// Prepare arrays for population
@@ -832,13 +839,6 @@ void ColladaDOMWalker::ProcessGeometry(const domGeometry *inGeometry, TFaceIndic
m_Translator->SetGeometry(theVertices, theNormals, theTexCoords, theTexCoords2, theTexTangents,
theTexBinormals, theWeights, theBoneIndex, theColors,
theEntireFaceIndiciesList);
-
- // Pop up warning message if model contains non-triangles geometry
- if (theMesh->getPolylist_array().getCount() || theMesh->getPolygons_array().getCount()
- || theMesh->getLines_array().getCount() || theMesh->getLinestrips_array().getCount()
- || theMesh->getTrifans_array().getCount() || theMesh->getTristrips_array().getCount()) {
- LogWarning(ESceneGraphWarningCode_OnlySupportTriangles, GetNameOrIDOrSid(inGeometry));
- }
}
//==============================================================================
@@ -849,7 +849,7 @@ void ColladaDOMWalker::ProcessTriangle(const domTrianglesRef inTrianglesRef,
TFaceIndicies &ioFaceIndicies, bool &outHasNormals,
bool &outHasTexCoords, bool &outHasTexCoords2,
bool &outHasTexTangents, bool &outHasTexBinormals,
- bool &outHasColors)
+ bool &outHasColors, const char *meshName)
{
SSourceArrayInfo theVertexArrayInfo;
SSourceArrayInfo theNormalArrayInfo;
@@ -1014,13 +1014,10 @@ void ColladaDOMWalker::ProcessTriangle(const domTrianglesRef inTrianglesRef,
// Set the face indicies used by this particular material
const xsNCName theMaterialName =
inTrianglesRef->getMaterial(); // TODO: Handle the material settings for this face
- if (theMaterialName != nullptr) {
+ if (theMaterialName != nullptr)
ioFaceIndicies.second.push_back(std::make_pair(theMaterialName, theMaterialFaceIndicies));
- } else {
- g_StudioApp.GetDialogs()->DisplayKnownErrorDialog(
- QObject::tr("The mesh files could not be created.\n"
- "Materials are missing from the imported model."));
- }
+ else
+ LogWarning(ESceneGraphWarningCode_MissingMaterial, meshName);
}
/**
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
index 5ecd9d64..5bcf2dcf 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
@@ -39,19 +39,22 @@ namespace qt3dsimp {
class Import;
typedef enum _ESceneGraphWarningCode {
- ESceneGraphWarningCode_OnlySupportTriangles, ///< Model contains geometric elements other than
- ///triangles (note that this won't throw exception,
- ///just pop up warning)
- ESceneGraphWarningCode_TrianglesDuplicateSemantic, ///< Triangle contains duplicate semantics,
- ///ex: 1 triangle has multiple TEXCOORD
- ///(multiple UV maps)
- ESceneGraphWarningCode_VertexBufferTooLarge, ///< Triangle contains duplicate semantics, ex: 1
- ///triangle has multiple TEXCOORD (multiple UV
- ///maps)
- ESceneGraphWarningCode_MissingSourceFile, ///< Couldn't find a source image file
- ESceneGraphWarningCode_LockedDestFile, ///< An image or mesh file we need to write to is not
- ///writeable.
- ESceneGraphWarningCode_Generic, ///< For generic warnings
+ // Model contains geometric elements other than triangles (note that this won't throw exception,
+ // just pop up warning).
+ ESceneGraphWarningCode_OnlySupportTriangles,
+ // Triangle contains duplicate semantics, ex: 1 triangle has multiple TEXCOORD (multiple UV
+ // maps).
+ ESceneGraphWarningCode_TrianglesDuplicateSemantic,
+ // A single mesh exceeds the maximum vertex count of 65535.
+ ESceneGraphWarningCode_VertexBufferTooLarge,
+ // Couldn't find a source image file
+ ESceneGraphWarningCode_MissingSourceFile,
+ // An image or mesh file we need to write to is not writeable.
+ ESceneGraphWarningCode_LockedDestFile,
+ // Mesh is missing a material.
+ ESceneGraphWarningCode_MissingMaterial,
+ // For generic warnings.
+ ESceneGraphWarningCode_Generic
} ESceneGraphWarningCode;
class ISGTranslationLog
@@ -89,7 +92,7 @@ struct STranslationLog : public qt3dsimp::ISGTranslationLog
{
vector<pair<qt3dsimp::ESceneGraphWarningCode, Q3DStudio::CString>> m_Warnings;
void OnWarning(qt3dsimp::ESceneGraphWarningCode inWarningCode,
- const wchar_t *inAssociatedName) override
+ const wchar_t *inAssociatedName) override
{
m_Warnings.push_back(std::make_pair(inWarningCode, inAssociatedName));
}