You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.8 KiB
C++
90 lines
2.8 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include <Atom/RPI.Reflect/Material/MaterialNameContext.h>
|
|
#include <AzCore/RTTI/ReflectContext.h>
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
#include <AzCore/Name/Name.h>
|
|
|
|
namespace AZ
|
|
{
|
|
namespace RPI
|
|
{
|
|
void MaterialNameContext::Reflect(ReflectContext* context)
|
|
{
|
|
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
|
{
|
|
serializeContext->Class<MaterialNameContext>()
|
|
->Version(1)
|
|
->Field("propertyIdContext", &MaterialNameContext::m_propertyIdContext)
|
|
->Field("srgInputNameContext", &MaterialNameContext::m_srgInputNameContext)
|
|
->Field("shaderOptionNameContext", &MaterialNameContext::m_shaderOptionNameContext)
|
|
;
|
|
}
|
|
}
|
|
|
|
bool MaterialNameContext::IsDefault() const
|
|
{
|
|
return m_propertyIdContext.empty() && m_srgInputNameContext.empty() && m_shaderOptionNameContext.empty();
|
|
}
|
|
|
|
void MaterialNameContext::ExtendPropertyIdContext(AZStd::string_view nameContext, bool insertDelimiter)
|
|
{
|
|
m_propertyIdContext += nameContext;
|
|
if (insertDelimiter && !nameContext.empty() && !nameContext.ends_with("."))
|
|
{
|
|
m_propertyIdContext += ".";
|
|
}
|
|
}
|
|
|
|
void MaterialNameContext::ExtendSrgInputContext(AZStd::string_view nameContext)
|
|
{
|
|
m_srgInputNameContext += nameContext;
|
|
}
|
|
|
|
void MaterialNameContext::ExtendShaderOptionContext(AZStd::string_view nameContext)
|
|
{
|
|
m_shaderOptionNameContext += nameContext;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeProperty(Name& propertyName) const
|
|
{
|
|
if (m_propertyIdContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
propertyName = m_propertyIdContext + propertyName.GetCStr();
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeSrgInput(Name& srgInputName) const
|
|
{
|
|
if (m_srgInputNameContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
srgInputName = m_srgInputNameContext + srgInputName.GetCStr();
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeShaderOption(Name& shaderOptionName) const
|
|
{
|
|
if (m_shaderOptionNameContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
shaderOptionName = m_shaderOptionNameContext + shaderOptionName.GetCStr();
|
|
return true;
|
|
}
|
|
|
|
} // namespace RPI
|
|
} // namespace AZ
|