Working on making Material Editor able to open materials that have missing textures.

Made it a warning instead of an error when MaterialAssetCreator can't find a texture.
Updated the Material Editor's MaterialDocument class to not elevate warnings to errors.
Material Editor uses new features in TraceRecorder to show a message dialog when warnings are detected so the user is notified of the missing texture.

Next I will work on making MaterialAssetCreator put a "missing" texture in place of the requested one.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
monroegm-disable-blank-issue-2
santorac 4 years ago
parent 87c7023e3c
commit cd28d210ab

@ -329,7 +329,7 @@ namespace AZ
}
else
{
materialAssetCreator.ReportError(
materialAssetCreator.ReportWarning(
"Material property '%s': Could not find the image '%s'", propertyId.GetFullName().GetCStr(),
property.second.m_value.GetValue<AZStd::string>().data());
}

@ -26,6 +26,21 @@ namespace AtomToolsFramework
//! Get the combined output of all messages
AZStd::string GetDump() const;
//! Return the number of OnAssert calls
size_t GetAssertCount() const;
//! Return the number of OnException calls
size_t GetExceptionCount() const;
//! Return the number of OnError calls, and includes OnAssert and OnException if @includeHigher is true
size_t GetErrorCount(bool includeHigher = false) const;
//! Return the number of OnWarning calls, and includes higher categories if @includeHigher is true
size_t GetWarningCount(bool includeHigher = false) const;
//! Return the number of OnPrintf calls, and includes higher categories if @includeHigher is true
size_t GetPrintfCount(bool includeHigher = false) const;
private:
//////////////////////////////////////////////////////////////////////////
// AZ::Debug::TraceMessageBus::Handler overrides...
@ -38,5 +53,11 @@ namespace AtomToolsFramework
size_t m_maxMessageCount = std::numeric_limits<size_t>::max();
AZStd::list<AZStd::string> m_messages;
size_t m_assertCount = 0;
size_t m_exceptionCount = 0;
size_t m_errorCount = 0;
size_t m_warningCount = 0;
size_t m_printfCount = 0;
};
} // namespace AtomToolsFramework

@ -31,6 +31,7 @@ namespace AtomToolsFramework
bool TraceRecorder::OnAssert(const char* message)
{
++m_assertCount;
if (m_messages.size() < m_maxMessageCount)
{
m_messages.push_back(AZStd::string::format("Assert: %s", message));
@ -40,6 +41,7 @@ namespace AtomToolsFramework
bool TraceRecorder::OnException(const char* message)
{
++m_exceptionCount;
if (m_messages.size() < m_maxMessageCount)
{
m_messages.push_back(AZStd::string::format("Exception: %s", message));
@ -49,6 +51,7 @@ namespace AtomToolsFramework
bool TraceRecorder::OnError(const char* /*window*/, const char* message)
{
++m_errorCount;
if (m_messages.size() < m_maxMessageCount)
{
m_messages.push_back(AZStd::string::format("Error: %s", message));
@ -58,6 +61,7 @@ namespace AtomToolsFramework
bool TraceRecorder::OnWarning(const char* /*window*/, const char* message)
{
++m_warningCount;
if (m_messages.size() < m_maxMessageCount)
{
m_messages.push_back(AZStd::string::format("Warning: %s", message));
@ -67,11 +71,58 @@ namespace AtomToolsFramework
bool TraceRecorder::OnPrintf(const char* /*window*/, const char* message)
{
++m_printfCount;
if (m_messages.size() < m_maxMessageCount)
{
m_messages.push_back(AZStd::string::format("%s", message));
}
return false;
}
size_t TraceRecorder::GetAssertCount() const
{
return m_assertCount;
}
size_t TraceRecorder::GetExceptionCount() const
{
return m_exceptionCount;
}
size_t TraceRecorder::GetErrorCount(bool includeHigher) const
{
if (includeHigher)
{
return m_errorCount + GetAssertCount() + GetExceptionCount();
}
else
{
return m_errorCount;
}
}
size_t TraceRecorder::GetWarningCount(bool includeHigher) const
{
if (includeHigher)
{
return m_warningCount + GetErrorCount(true);
}
else
{
return m_warningCount;
}
}
size_t TraceRecorder::GetPrintfCount(bool includeHigher) const
{
if (includeHigher)
{
return m_printfCount + GetWarningCount(true);
}
else
{
return m_printfCount;
}
}
} // namespace AtomToolsFramework

@ -495,8 +495,6 @@ namespace AtomToolsFramework
return AZ::Uuid::CreateNull();
}
traceRecorder.GetDump().clear();
bool openResult = false;
AtomToolsDocumentRequestBus::EventResult(openResult, documentId, &AtomToolsDocumentRequestBus::Events::Open, requestedPath);
if (!openResult)
@ -507,6 +505,12 @@ namespace AtomToolsFramework
AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::DestroyDocument, documentId);
return AZ::Uuid::CreateNull();
}
else if (traceRecorder.GetWarningCount(true) > 0)
{
QMessageBox::warning(
QApplication::activeWindow(), QString("Document opened with warnings"),
QString("Warnings encountered: \n%1\n\n%2").arg(requestedPath.c_str()).arg(traceRecorder.GetDump().c_str()));
}
return documentId;
}

@ -714,6 +714,8 @@ namespace MaterialEditor
AZ_Error("MaterialDocument", false, "Material document extension not supported: '%s'.", m_absolutePath.c_str());
return false;
}
const bool elevateWarnings = false;
// In order to support automation, general usability, and 'save as' functionality, the user must not have to wait
// for their JSON file to be cooked by the asset processor before opening or editing it.
@ -722,7 +724,7 @@ namespace MaterialEditor
// Long term, the material document should not be concerned with assets at all. The viewport window should be the
// only thing concerned with assets or instances.
auto materialAssetResult =
m_materialSourceData.CreateMaterialAssetFromSourceData(Uuid::CreateRandom(), m_absolutePath, true, true, &m_sourceDependencies);
m_materialSourceData.CreateMaterialAssetFromSourceData(Uuid::CreateRandom(), m_absolutePath, elevateWarnings, true, &m_sourceDependencies);
if (!materialAssetResult)
{
AZ_Error("MaterialDocument", false, "Material asset could not be created from source data: '%s'.", m_absolutePath.c_str());
@ -761,9 +763,9 @@ namespace MaterialEditor
AZ_Error("MaterialDocument", false, "Material parent asset ID could not be created: '%s'.", parentMaterialFilePath.c_str());
return false;
}
auto parentMaterialAssetResult = parentMaterialSourceData.CreateMaterialAssetFromSourceData(
parentMaterialAssetIdResult.GetValue(), parentMaterialFilePath, true, true);
parentMaterialAssetIdResult.GetValue(), parentMaterialFilePath, elevateWarnings, true);
if (!parentMaterialAssetResult)
{
AZ_Error("MaterialDocument", false, "Material parent asset could not be created from source data: '%s'.", parentMaterialFilePath.c_str());

Loading…
Cancel
Save