Merge branch 'development' of https://github.com/o3de/o3de into cgalvan/DraftStreamingImageAssetPixelAPI

This commit is contained in:
Chris Galvan
2022-01-24 16:18:38 -06:00
139 changed files with 2021 additions and 1445 deletions
@@ -27,63 +27,84 @@ namespace AZ
bool MaterialPropertyId::IsValid() const
{
const bool groupNameIsValid = m_groupName.IsEmpty() || IsValidName(m_groupName);
const bool propertyNameIsValid = IsValidName(m_propertyName);
return groupNameIsValid && propertyNameIsValid;
return !m_fullName.IsEmpty();
}
MaterialPropertyId MaterialPropertyId::Parse(AZStd::string_view fullPropertyId)
{
AZStd::vector<AZStd::string> tokens;
AzFramework::StringFunc::Tokenize(fullPropertyId.data(), tokens, '.', true, true);
AzFramework::StringFunc::Tokenize(fullPropertyId, tokens, '.', true, true);
if (tokens.size() == 1)
if (tokens.empty())
{
return MaterialPropertyId{"", tokens[0]};
AZ_Error("MaterialPropertyId", false, "Property ID is empty.", fullPropertyId.data());
return MaterialPropertyId{};
}
else if (tokens.size() == 2)
for (const auto& token : tokens)
{
return MaterialPropertyId{tokens[0], tokens[1]};
if (!IsValidName(token))
{
AZ_Error("MaterialPropertyId", false, "Property ID '%.*s' is not a valid identifier.", AZ_STRING_ARG(fullPropertyId));
return MaterialPropertyId{};
}
}
MaterialPropertyId id;
id.m_fullName = fullPropertyId;
return id;
}
MaterialPropertyId::MaterialPropertyId(AZStd::string_view propertyName)
{
if (!IsValidName(propertyName))
{
AZ_Error("MaterialPropertyId", false, "Property name '%.*s' is not a valid identifier.", AZ_STRING_ARG(propertyName));
}
else
{
AZ_Error("MaterialPropertyId", false, "Property ID '%s' is not a valid identifier.", fullPropertyId.data());
return MaterialPropertyId{};
m_fullName = propertyName;
}
}
MaterialPropertyId::MaterialPropertyId(AZStd::string_view groupName, AZStd::string_view propertyName)
: MaterialPropertyId(Name{groupName}, Name{propertyName})
{
}
MaterialPropertyId::MaterialPropertyId(const Name& groupName, const Name& propertyName)
{
AZ_Error("MaterialPropertyId", groupName.IsEmpty() || IsValidName(groupName), "Group name '%s' is not a valid identifier.", groupName.GetCStr());
AZ_Error("MaterialPropertyId", IsValidName(propertyName), "Property name '%s' is not a valid identifier.", propertyName.GetCStr());
m_groupName = groupName;
m_propertyName = propertyName;
if (groupName.IsEmpty())
if (!IsValidName(groupName))
{
m_fullName = m_propertyName.GetStringView();
AZ_Error("MaterialPropertyId", false, "Group name '%.*s' is not a valid identifier.", AZ_STRING_ARG(groupName));
}
else if (!IsValidName(propertyName))
{
AZ_Error("MaterialPropertyId", false, "Property name '%.*s' is not a valid identifier.", AZ_STRING_ARG(propertyName));
}
else
{
m_fullName = AZStd::string::format("%s.%s", m_groupName.GetCStr(), m_propertyName.GetCStr());
m_fullName = AZStd::string::format("%.*s.%.*s", AZ_STRING_ARG(groupName), AZ_STRING_ARG(propertyName));
}
}
const Name& MaterialPropertyId::GetGroupName() const
MaterialPropertyId::MaterialPropertyId(const Name& groupName, const Name& propertyName)
: MaterialPropertyId(groupName.GetStringView(), propertyName.GetStringView())
{
return m_groupName;
}
MaterialPropertyId::MaterialPropertyId(const AZStd::array_view<AZStd::string> names)
{
for (const auto& name : names)
{
if (!IsValidName(name))
{
AZ_Error("MaterialPropertyId", false, "'%s' is not a valid identifier.", name.c_str());
return;
}
}
AZStd::string fullName; // m_fullName is a Name, not a string, so we have to join into a local variable temporarily.
AzFramework::StringFunc::Join(fullName, names.begin(), names.end(), ".");
m_fullName = fullName;
}
const Name& MaterialPropertyId::GetPropertyName() const
{
return m_propertyName;
}
const Name& MaterialPropertyId::GetFullName() const
MaterialPropertyId::operator const Name&() const
{
return m_fullName;
}
@@ -92,6 +113,11 @@ namespace AZ
{
return m_fullName.GetCStr();
}
AZStd::string_view MaterialPropertyId::GetStringView() const
{
return m_fullName.GetStringView();
}
Name::Hash MaterialPropertyId::GetHash() const
{
@@ -340,16 +340,16 @@ namespace AZ
if (result == MaterialUtils::GetImageAssetResult::Missing)
{
materialAssetCreator.ReportWarning(
"Material property '%s': Could not find the image '%s'", propertyId.GetFullName().GetCStr(),
"Material property '%s': Could not find the image '%s'", propertyId.GetCStr(),
property.second.m_value.GetValue<AZStd::string>().data());
}
imageAsset.SetAutoLoadBehavior(Data::AssetLoadBehavior::PreLoad);
materialAssetCreator.SetPropertyValue(propertyId.GetFullName(), imageAsset);
materialAssetCreator.SetPropertyValue(propertyId, imageAsset);
}
else
{
materialAssetCreator.SetPropertyValue(propertyId.GetFullName(), property.second.m_value);
materialAssetCreator.SetPropertyValue(propertyId, property.second.m_value);
}
}
}
@@ -140,7 +140,7 @@ namespace AZ
{
if (action.m_operation == "rename")
{
if (action.m_renameFrom == propertyId.GetFullName().GetStringView())
if (action.m_renameFrom == propertyId.GetStringView())
{
propertyId = MaterialPropertyId::Parse(action.m_renameTo);
renamed = true;
@@ -177,14 +177,19 @@ namespace AZ
// Do the search again with the new names
groupIter = m_propertyLayout.m_properties.find(propertyId.GetGroupName().GetStringView());
if (groupIter != m_propertyLayout.m_properties.end())
AZStd::vector<AZStd::string> tokens;
AZ::StringFunc::Tokenize(propertyId.GetStringView(), tokens, ".", true, true);
if (tokens.size() == 2)
{
for (const PropertyDefinition& property : groupIter->second)
groupIter = m_propertyLayout.m_properties.find(tokens[0]);
if (groupIter != m_propertyLayout.m_properties.end())
{
if (property.m_name == propertyId.GetPropertyName().GetStringView())
for (const PropertyDefinition& property : groupIter->second)
{
return &property;
if (property.m_name == tokens[1])
{
return &property;
}
}
}
}
@@ -400,7 +405,7 @@ namespace AZ
continue;
}
materialTypeAssetCreator.BeginMaterialProperty(propertyId.GetFullName(), property.m_dataType);
materialTypeAssetCreator.BeginMaterialProperty(propertyId, property.m_dataType);
if (property.m_dataType == MaterialPropertyDataType::Enum)
{
@@ -454,18 +459,18 @@ namespace AZ
if (result == MaterialUtils::GetImageAssetResult::Missing)
{
materialTypeAssetCreator.ReportError(
"Material property '%s': Could not find the image '%s'", propertyId.GetFullName().GetCStr(),
"Material property '%s': Could not find the image '%s'", propertyId.GetCStr(),
property.m_value.GetValue<AZStd::string>().data());
}
else
{
materialTypeAssetCreator.SetPropertyValue(propertyId.GetFullName(), imageAsset);
materialTypeAssetCreator.SetPropertyValue(propertyId, imageAsset);
}
}
break;
case MaterialPropertyDataType::Enum:
{
MaterialPropertyIndex propertyIndex = materialTypeAssetCreator.GetMaterialPropertiesLayout()->FindPropertyIndex(propertyId.GetFullName());
MaterialPropertyIndex propertyIndex = materialTypeAssetCreator.GetMaterialPropertiesLayout()->FindPropertyIndex(propertyId);
const MaterialPropertyDescriptor* propertyDescriptor = materialTypeAssetCreator.GetMaterialPropertiesLayout()->GetPropertyDescriptor(propertyIndex);
AZ::Name enumName = AZ::Name(property.m_value.GetValue<AZStd::string>());
@@ -476,12 +481,12 @@ namespace AZ
}
else
{
materialTypeAssetCreator.SetPropertyValue(propertyId.GetFullName(), enumValue);
materialTypeAssetCreator.SetPropertyValue(propertyId, enumValue);
}
}
break;
default:
materialTypeAssetCreator.SetPropertyValue(propertyId.GetFullName(), property.m_value);
materialTypeAssetCreator.SetPropertyValue(propertyId, property.m_value);
break;
}
}
@@ -322,7 +322,7 @@ namespace AZ
void Scene::RemoveRenderPipeline(const RenderPipelineId& pipelineId)
{
bool removed = false;
[[maybe_unused]] bool removed = false;
for (auto it = m_pipelines.begin(); it != m_pipelines.end(); ++it)
{
if (pipelineId == (*it)->GetId())