Merge branch 'main' into Atom/santorac/PomHeightOffset-ATOM-14495

This commit is contained in:
Chris Santora
2021-05-06 13:53:58 -07:00
760 changed files with 17129 additions and 36323 deletions
@@ -25,13 +25,24 @@ namespace AWSCore
: AWSCoreInternalRequestBus::Handler
{
public:
static constexpr const char AWSCORE_CONFIGURATION_FILENAME[] = "awscoreconfiguration.setreg";
static constexpr const char AWSCoreConfigurationName[] = "AWSCoreConfiguration";
static constexpr const char AWSCoreConfigurationFileName[] = "awscoreconfiguration.setreg";
static constexpr const char AWSCORE_RESOURCE_MAPPING_CONFIG_FOLDERNAME[] = "Config";
static constexpr const char AWSCORE_RESOURCE_MAPPING_CONFIG_FILENAME_KEY[] = "/AWSCore/ResourceMappingConfigFileName";
static constexpr const char AWSCoreResourceMappingConfigFolderName[] = "Config";
static constexpr const char AWSCoreResourceMappingConfigFileNameKey[] = "/AWSCore/ResourceMappingConfigFileName";
static constexpr const char AWSCoreDefaultProfileName[] = "default";
static constexpr const char AWSCoreProfileNameKey[] = "/AWSCore/ProfileName";
static constexpr const char ProjectSourceFolderNotFoundErrorMessage[] =
"Failed to get project source folder path.";
static constexpr const char ProfileNameNotFoundErrorMessage[] =
"Failed to get profile name, return default value instead.";
static constexpr const char ResourceMappingFileNameNotFoundErrorMessage[] =
"Failed to get resource mapping config file name, return empty value instead.";
static constexpr const char SettingsRegistryLoadFailureErrorMessage[] =
"Failed to load AWSCore settings registry file.";
static constexpr const char AWSCORE_DEFAULT_PROFILE_NAME[] = "default";
static constexpr const char AWSCORE_PROFILENAME_KEY[] = "/AWSCore/ProfileName";
AWSCoreConfiguration();
~AWSCoreConfiguration() = default;
@@ -55,6 +66,9 @@ namespace AWSCore
// Parse values from project .setreg file
void ParseSettingsRegistryValues();
// Reset settings registry data
void ResetSettingsRegistryData();
AZStd::string m_sourceProjectFolder;
AZ::SettingsRegistryImpl m_settingsRegistry;
AZStd::string m_profileName;
@@ -14,20 +14,20 @@
namespace AWSCore
{
static constexpr const char AWS_CHINA_REGION_PREFIX[] = "cn-";
static constexpr const char AWSChinaRegionPrefix[] = "cn-";
static constexpr const char AWS_FEATURE_GEM_RESTAPI_ID_KEYNAME_SUFFIX[] = ".RESTApiId";
static constexpr const char AWS_FEATURE_GEM_RESTAPI_STAGE_KEYNAME_SUFFIX[] = ".RESTApiStage";
static constexpr const char AWSFeatureGemRESTApiIdKeyNameSuffix[] = ".RESTApiId";
static constexpr const char AWSFeatureGemRESTApiStageKeyNameSuffix[] = ".RESTApiStage";
static constexpr const char RESOURCE_MAPPING_ACCOUNTID_KEYNAME[] = "AccountId";
static constexpr const char RESOURCE_MAPPING_RESOURCES_KEYNAME[] = "AWSResourceMappings";
static constexpr const char RESOURCE_MAPPING_NAMEID_KEYNAME[] = "Name/ID";
static constexpr const char RESOURCE_MAPPING_REGION_KEYNAME[] = "Region";
static constexpr const char RESOURCE_MAPPING_TYPE_KEYNAME[] = "Type";
static constexpr const char RESOURCE_MAPPING_VERSION_KEYNAME[] = "Version";
static constexpr const char ResourceMappingAccountIdKeyName[] = "AccountId";
static constexpr const char ResourceMappingResourcesKeyName[] = "AWSResourceMappings";
static constexpr const char ResourceMappingNameIdKeyName[] = "Name/ID";
static constexpr const char ResourceMappingRegionKeyName[] = "Region";
static constexpr const char ResourceMappingTypeKeyName[] = "Type";
static constexpr const char ResourceMappingVersionKeyName[] = "Version";
// TODO: move this into an independent file under AWSCore gem, if resource mapping tool can reuse it
static constexpr const char RESOURCE_MAPPING_JSON_SCHEMA[] =
static constexpr const char ResourceMappingJsonSchema[] =
R"({
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
@@ -45,6 +45,35 @@ namespace AWSCore
};
public:
static constexpr const char AWSResourceMappingManagerName[] = "AWSResourceMappingManager";
static constexpr const char ManagerUnexpectedStatusErrorMessage[] =
"AWSResourceMappingManager is in unexpected status.";
static constexpr const char ResourceMappingFileInvalidPathErrorMessage[] =
"Failed to get resource mapping config file path.";
static constexpr const char ResourceMappingKeyNotFoundErrorMessage[] =
"Failed to find resource mapping key: %s";
static constexpr const char ResourceMappingFileNotLoadedErrorMessage[] =
"Resource mapping config file is not loaded, please confirm %s is setup correctly.";
static constexpr const char ResourceMappingFileLoadFailureErrorMessage[] =
"Resource mapping config file failed to load, please confirm file is present and in correct format.";
static constexpr const char ResourceMappingRESTApiIdAndStageInconsistentErrorMessage[] =
"Resource mapping %s and %s have inconsistent region value, return empty service url.";
static constexpr const char ResourceMappingRESTApiInvalidServiceUrlErrorMessage[] =
"Unable to format REST Api url with RESTApiId=%s, RESTApiRegion=%s, RESTApiStage=%s, return empty service url.";
static constexpr const char ResourceMappingFileInvalidJsonFormatErrorMessage[] =
"Failed to read resource mapping config file: %s";
static constexpr const char ResourceMappingFileInvalidSchemaErrorMessage[] =
"Failed to load resource mapping config file json schema.";
static constexpr const char ResourceMappingFileInvalidContentErrorMessage[] =
"Failed to parse resource mapping config file: %s";
enum class Status : AZ::u8
{
NotLoaded = 0,
Ready = 1,
Error = 2
};
AWSResourceMappingManager();
~AWSResourceMappingManager() = default;
@@ -63,7 +92,12 @@ namespace AWSCore
const AZStd::string& restApiIdKeyName, const AZStd::string& restApiStageKeyName) const override;
void ReloadConfigFile(bool reloadConfigFileName = false) override;
Status GetStatus() const;
private:
// Get resource attribute error message based on the status
AZStd::string GetResourceAttributeErrorMessageByStatus(const AZStd::string& resourceKeyName) const;
// Get resource attribute from resource mappings
AZStd::string GetResourceAttribute(
AZStd::function<AZStd::string(const AWSResourceMappingAttributes&)> getAttributeFunction,
@@ -83,6 +117,7 @@ namespace AWSCore
// Validate JSON document against schema
bool ValidateJsonDocumentAgainstSchema(const rapidjson::Document& jsonDocument);
Status m_status;
// Resource mapping related data
AZStd::string m_defaultAccountId;
AZStd::string m_defaultRegion;
@@ -20,7 +20,7 @@ namespace AWSCore
{
AWSCoreConfiguration::AWSCoreConfiguration()
: m_sourceProjectFolder("")
, m_profileName(AWSCORE_DEFAULT_PROFILE_NAME)
, m_profileName(AWSCoreDefaultProfileName)
, m_resourceMappingConfigFileName("")
{
}
@@ -44,16 +44,16 @@ namespace AWSCore
{
if (m_sourceProjectFolder.empty())
{
AZ_Warning("AWSCoreConfiguration", false, "Failed to get source project folder path.");
AZ_Warning(AWSCoreConfigurationName, false, ProjectSourceFolderNotFoundErrorMessage);
return "";
}
if (m_resourceMappingConfigFileName.empty())
{
AZ_Warning("AWSCoreConfiguration", false, "Failed to get resource mapping config file name.");
AZ_Warning(AWSCoreConfigurationName, false, ResourceMappingFileNameNotFoundErrorMessage);
return "";
}
AZStd::string configFilePath = AZStd::string::format("%s/%s/%s",
m_sourceProjectFolder.c_str(), AWSCORE_RESOURCE_MAPPING_CONFIG_FOLDERNAME, m_resourceMappingConfigFileName.c_str());
m_sourceProjectFolder.c_str(), AWSCoreResourceMappingConfigFolderName, m_resourceMappingConfigFileName.c_str());
AzFramework::StringFunc::Path::Normalize(configFilePath);
return configFilePath;
}
@@ -68,17 +68,17 @@ namespace AWSCore
{
if (m_sourceProjectFolder.empty())
{
AZ_Warning("AWSCoreConfiguration", false, "Failed to get source project folder path.");
AZ_Warning(AWSCoreConfigurationName, false, ProjectSourceFolderNotFoundErrorMessage);
return;
}
AZStd::string settingsRegistryPath = AZStd::string::format("%s/%s/%s",
m_sourceProjectFolder.c_str(), AZ::SettingsRegistryInterface::RegistryFolder, AWSCoreConfiguration::AWSCORE_CONFIGURATION_FILENAME);
m_sourceProjectFolder.c_str(), AZ::SettingsRegistryInterface::RegistryFolder, AWSCoreConfiguration::AWSCoreConfigurationFileName);
AzFramework::StringFunc::Path::Normalize(settingsRegistryPath);
if (!m_settingsRegistry.MergeSettingsFile(settingsRegistryPath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, ""))
{
AZ_Warning("AWSCoreConfiguration", false, "Failed to merge AWS core settings registry.");
AZ_Warning(AWSCoreConfigurationName, false, SettingsRegistryLoadFailureErrorMessage);
return;
}
@@ -90,7 +90,7 @@ namespace AWSCore
auto sourceProjectFolder = AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@");
if (!sourceProjectFolder)
{
AZ_Error("AWSCoreConfiguration", false, "Failed to initialize source project folder path.");
AZ_Error(AWSCoreConfigurationName, false, ProjectSourceFolderNotFoundErrorMessage);
}
else
{
@@ -102,24 +102,38 @@ namespace AWSCore
{
m_resourceMappingConfigFileName.clear();
auto resourceMappingConfigFileNamePath = AZStd::string::format("%s%s",
AZ::SettingsRegistryMergeUtils::OrganizationRootKey, AWSCORE_RESOURCE_MAPPING_CONFIG_FILENAME_KEY);
AZ::SettingsRegistryMergeUtils::OrganizationRootKey, AWSCoreResourceMappingConfigFileNameKey);
if (!m_settingsRegistry.Get(m_resourceMappingConfigFileName, resourceMappingConfigFileNamePath))
{
AZ_Warning("AWSCoreConfiguration", false, "Failed to get resource mapping config file name from settings registry.");
AZ_Warning(AWSCoreConfigurationName, false, ResourceMappingFileNameNotFoundErrorMessage);
}
m_profileName.clear();
auto profileNamePath = AZStd::string::format(
"%s%s", AZ::SettingsRegistryMergeUtils::OrganizationRootKey, AWSCORE_PROFILENAME_KEY);
"%s%s", AZ::SettingsRegistryMergeUtils::OrganizationRootKey, AWSCoreProfileNameKey);
if (!m_settingsRegistry.Get(m_profileName, profileNamePath))
{
AZ_Warning("AWSCoreConfiguration", false, "Failed to get profile name from settings registry, using default value instead.");
m_profileName = AWSCORE_DEFAULT_PROFILE_NAME;
AZ_Warning(AWSCoreConfigurationName, false, ProfileNameNotFoundErrorMessage);
m_profileName = AWSCoreDefaultProfileName;
}
}
void AWSCoreConfiguration::ResetSettingsRegistryData()
{
auto profileNamePath = AZStd::string::format("%s%s",
AZ::SettingsRegistryMergeUtils::OrganizationRootKey, AWSCoreProfileNameKey);
m_settingsRegistry.Remove(profileNamePath);
m_profileName.clear();
auto resourceMappingConfigFileNamePath = AZStd::string::format("%s%s",
AZ::SettingsRegistryMergeUtils::OrganizationRootKey, AWSCoreResourceMappingConfigFileNameKey);
m_settingsRegistry.Remove(resourceMappingConfigFileNamePath);
m_resourceMappingConfigFileName.clear();
}
void AWSCoreConfiguration::ReloadConfiguration()
{
ResetSettingsRegistryData();
InitSettingsRegistry();
}
} // namespace AWSCore
@@ -84,7 +84,7 @@ namespace AWSCore
{
AZ_Warning("AWSDefaultCredentialHandler", false, "Failed to get profile name, use default profile name instead");
SetProfileCredentialsProvider(Aws::MakeShared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>(
AWSDEFAULTCREDENTIALHANDLER_ALLOC_TAG, AWSCoreConfiguration::AWSCORE_DEFAULT_PROFILE_NAME));
AWSDEFAULTCREDENTIALHANDLER_ALLOC_TAG, AWSCoreConfiguration::AWSCoreDefaultProfileName));
}
else
{
@@ -12,12 +12,14 @@
#include <AzCore/IO/Path/Path.h>
#include <AzCore/JSON/schema.h>
#include <AzCore/JSON/prettywriter.h>
#include <AzCore/Settings/SettingsRegistry.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzFramework/FileFunc/FileFunc.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AWSCoreInternalBus.h>
#include <Configuration/AWSCoreConfiguration.h>
#include <ResourceMapping/AWSResourceMappingConstants.h>
#include <ResourceMapping/AWSResourceMappingManager.h>
#include <ResourceMapping/AWSResourceMappingUtils.h>
@@ -25,7 +27,8 @@
namespace AWSCore
{
AWSResourceMappingManager::AWSResourceMappingManager()
: m_defaultAccountId("")
: m_status(Status::NotLoaded)
, m_defaultAccountId("")
, m_defaultRegion("")
, m_resourceMappings()
{
@@ -43,11 +46,27 @@ namespace AWSCore
ResetResourceMappingsData();
}
AZStd::string AWSResourceMappingManager::GetResourceAttributeErrorMessageByStatus(const AZStd::string& resourceKeyName) const
{
switch (m_status)
{
case Status::NotLoaded:
return AZStd::string::format(ResourceMappingFileNotLoadedErrorMessage, AWSCoreConfiguration::AWSCoreConfigurationFileName);
case Status::Ready:
return AZStd::string::format(ResourceMappingKeyNotFoundErrorMessage, resourceKeyName.c_str());
case Status::Error:
return ResourceMappingFileLoadFailureErrorMessage;
default:
return ManagerUnexpectedStatusErrorMessage;
}
}
AZStd::string AWSResourceMappingManager::GetDefaultAccountId() const
{
if (m_defaultAccountId.empty())
{
AZ_Warning("AWSResourceMappingManager", false, "Account Id should not be empty, please make sure config file is valid.");
AZ_Warning(AWSResourceMappingManagerName, false,
GetResourceAttributeErrorMessageByStatus(ResourceMappingAccountIdKeyName).c_str());
}
return m_defaultAccountId;
}
@@ -56,7 +75,8 @@ namespace AWSCore
{
if (m_defaultRegion.empty())
{
AZ_Warning("AWSResourceMappingManager", false, "Region should not be empty, please make sure config file is valid.");
AZ_Warning(AWSResourceMappingManagerName, false,
GetResourceAttributeErrorMessageByStatus(ResourceMappingRegionKeyName).c_str());
}
return m_defaultRegion;
}
@@ -100,8 +120,8 @@ namespace AWSCore
AZStd::string AWSResourceMappingManager::GetServiceUrlByServiceName(const AZStd::string& serviceName) const
{
return GetServiceUrlByRESTApiIdAndStage(
AZStd::string::format("%s%s", serviceName.c_str(), AWS_FEATURE_GEM_RESTAPI_ID_KEYNAME_SUFFIX),
AZStd::string::format("%s%s", serviceName.c_str(), AWS_FEATURE_GEM_RESTAPI_STAGE_KEYNAME_SUFFIX));
AZStd::string::format("%s%s", serviceName.c_str(), AWSFeatureGemRESTApiIdKeyNameSuffix),
AZStd::string::format("%s%s", serviceName.c_str(), AWSFeatureGemRESTApiStageKeyNameSuffix));
}
AZStd::string AWSResourceMappingManager::GetServiceUrlByRESTApiIdAndStage(
@@ -113,16 +133,13 @@ namespace AWSCore
AZStd::string serviceRegion = GetResourceRegion(restApiIdKeyName);
if (serviceRegion != GetResourceRegion(restApiStageKeyName))
{
AZ_Warning(
"AWSResourceMappingManager", false, "%s and %s have inconsistent region value, return empty service url.",
AZ_Warning(AWSResourceMappingManagerName, false, ResourceMappingRESTApiIdAndStageInconsistentErrorMessage,
restApiIdKeyName.c_str(), restApiStageKeyName.c_str());
return "";
}
AZStd::string serviceRESTApiUrl = AWSResourceMappingUtils::FormatRESTApiUrl(serviceRESTApiId, serviceRegion, serviceRESTApiStage);
AZ_Warning(
"AWSResourceMappingManager", !serviceRESTApiUrl.empty(),
"Unable to format REST Api url with RESTApiId=%s, RESTApiRegion=%s, RESTApiStage=%s, return empty service url.",
AZ_Warning(AWSResourceMappingManagerName, !serviceRESTApiUrl.empty(), ResourceMappingRESTApiInvalidServiceUrlErrorMessage,
serviceRESTApiId.c_str(), serviceRegion.c_str(), serviceRESTApiStage.c_str());
return serviceRESTApiUrl;
}
@@ -136,16 +153,21 @@ namespace AWSCore
return getAttributeFunction(iter->second);
}
AZ_Warning("AWSResourceMappingManager", false, "Failed to find resource mapping key: %s.", resourceKeyName.c_str());
AZ_Warning(AWSResourceMappingManagerName, false, GetResourceAttributeErrorMessageByStatus(resourceKeyName).c_str());
return "";
}
AWSResourceMappingManager::Status AWSResourceMappingManager::GetStatus() const
{
return m_status;
}
void AWSResourceMappingManager::ParseJsonDocument(const rapidjson::Document& jsonDocument)
{
m_defaultAccountId = jsonDocument.FindMember(RESOURCE_MAPPING_ACCOUNTID_KEYNAME)->value.GetString();
m_defaultRegion = jsonDocument.FindMember(RESOURCE_MAPPING_REGION_KEYNAME)->value.GetString();
m_defaultAccountId = jsonDocument.FindMember(ResourceMappingAccountIdKeyName)->value.GetString();
m_defaultRegion = jsonDocument.FindMember(ResourceMappingRegionKeyName)->value.GetString();
auto resourceMappings = jsonDocument.FindMember(RESOURCE_MAPPING_RESOURCES_KEYNAME)->value.GetObject();
auto resourceMappings = jsonDocument.FindMember(ResourceMappingResourcesKeyName)->value.GetObject();
for (auto mappingIter = resourceMappings.MemberBegin(); mappingIter != resourceMappings.MemberEnd(); mappingIter++)
{
auto mappingValue = mappingIter->value.GetObject();
@@ -162,16 +184,16 @@ namespace AWSCore
const JsonObject& jsonObject)
{
AWSResourceMappingAttributes attributes;
if (jsonObject.HasMember(RESOURCE_MAPPING_ACCOUNTID_KEYNAME))
if (jsonObject.HasMember(ResourceMappingAccountIdKeyName))
{
attributes.resourceAccountId = jsonObject.FindMember(RESOURCE_MAPPING_ACCOUNTID_KEYNAME)->value.GetString();
attributes.resourceAccountId = jsonObject.FindMember(ResourceMappingAccountIdKeyName)->value.GetString();
}
attributes.resourceNameId = jsonObject.FindMember(RESOURCE_MAPPING_NAMEID_KEYNAME)->value.GetString();
if (jsonObject.HasMember(RESOURCE_MAPPING_REGION_KEYNAME))
attributes.resourceNameId = jsonObject.FindMember(ResourceMappingNameIdKeyName)->value.GetString();
if (jsonObject.HasMember(ResourceMappingRegionKeyName))
{
attributes.resourceRegion = jsonObject.FindMember(RESOURCE_MAPPING_REGION_KEYNAME)->value.GetString();
attributes.resourceRegion = jsonObject.FindMember(ResourceMappingRegionKeyName)->value.GetString();
}
attributes.resourceType = jsonObject.FindMember(RESOURCE_MAPPING_TYPE_KEYNAME)->value.GetString();
attributes.resourceType = jsonObject.FindMember(ResourceMappingTypeKeyName)->value.GetString();
return attributes;
}
@@ -188,7 +210,7 @@ namespace AWSCore
AWSCoreInternalRequestBus::BroadcastResult(configJsonPath, &AWSCoreInternalRequests::GetResourceMappingConfigFilePath);
if (configJsonPath.empty())
{
AZ_Warning("AWSResourceMappingManager", false, "Failed to get resource mapping config file path.");
AZ_Warning(AWSResourceMappingManagerName, false, ResourceMappingFileInvalidPathErrorMessage);
return;
}
@@ -201,20 +223,26 @@ namespace AWSCore
if (!ValidateJsonDocumentAgainstSchema(jsonDocument))
{
// Failed to satisfy the validation against json schema
m_status = Status::Error;
return;
}
ParseJsonDocument(jsonDocument);
}
else
{
AZ_Warning(
"AWSResourceMappingManager", false, "Failed to get read resource mapping config file: %s\n Error: %s",
configJsonPath.c_str(), readJsonOutcome.GetError().c_str());
m_status = Status::Error;
AZ_Warning(AWSResourceMappingManagerName, false,
ResourceMappingFileInvalidJsonFormatErrorMessage, readJsonOutcome.GetError().c_str());
return;
}
// Resource mapping config file gets loaded successfully
m_status = Status::Ready;
}
void AWSResourceMappingManager::ResetResourceMappingsData()
{
m_status = Status::NotLoaded;
m_defaultAccountId = "";
m_defaultRegion = "";
m_resourceMappings.clear();
@@ -223,9 +251,9 @@ namespace AWSCore
bool AWSResourceMappingManager::ValidateJsonDocumentAgainstSchema(const rapidjson::Document& jsonDocument)
{
rapidjson::Document jsonSchemaDocument;
if (jsonSchemaDocument.Parse(RESOURCE_MAPPING_JSON_SCHEMA).HasParseError())
if (jsonSchemaDocument.Parse(ResourceMappingJsonSchema).HasParseError())
{
AZ_Error("AWSResourceMappingManager", false, "Invalid resource mapping json schema.");
AZ_Error(AWSResourceMappingManagerName, false, ResourceMappingFileInvalidSchemaErrorMessage);
return false;
}
@@ -235,12 +263,10 @@ namespace AWSCore
if (!jsonDocument.Accept(validator))
{
rapidjson::StringBuffer error;
validator.GetInvalidSchemaPointer().StringifyUriFragment(error);
AZ_Warning("AWSResourceMappingManager", false, "Failed to load config file, invalid schema: %s.", error.GetString());
AZ_Warning("AWSResourceMappingManager", false, "Failed to load config file, invalid keyword: %s.", validator.GetInvalidSchemaKeyword());
error.Clear();
validator.GetInvalidDocumentPointer().StringifyUriFragment(error);
AZ_Warning("AWSResourceMappingManager", false, "Failed to load config file, invalid document: %s.", error.GetString());
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(error);
validator.GetError().Accept(writer);
AZ_Warning(AWSResourceMappingManagerName, false, ResourceMappingFileInvalidContentErrorMessage, error.GetString());
return false;
}
return true;
@@ -18,8 +18,8 @@ namespace AWSCore
namespace AWSResourceMappingUtils
{
// https://docs.aws.amazon.com/general/latest/gr/apigateway.html
static constexpr char RESTAPI_URL_FORMAT[] = "https://%s.execute-api.%s.amazonaws.com/%s";
static constexpr char RESTAPI_CHINA_URL_FORMAT[] = "https://%s.execute-api.%s.amazonaws.com.cn/%s";
static constexpr char RESTApiUrlFormat[] = "https://%s.execute-api.%s.amazonaws.com/%s";
static constexpr char RESTApiChinaUrlFormat[] = "https://%s.execute-api.%s.amazonaws.com.cn/%s";
AZStd::string FormatRESTApiUrl(
const AZStd::string& restApiId, const AZStd::string& restApiRegion, const AZStd::string& restApiStage)
@@ -27,14 +27,14 @@ namespace AWSCore
// https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-call-api.html
if (!restApiId.empty() && !restApiRegion.empty() && !restApiStage.empty())
{
if (restApiRegion.rfind(AWS_CHINA_REGION_PREFIX, 0) == 0)
if (restApiRegion.rfind(AWSChinaRegionPrefix, 0) == 0)
{
return AZStd::string::format(RESTAPI_CHINA_URL_FORMAT,
return AZStd::string::format(RESTApiChinaUrlFormat,
restApiId.c_str(), restApiRegion.c_str(), restApiStage.c_str());
}
else
{
return AZStd::string::format(RESTAPI_URL_FORMAT,
return AZStd::string::format(RESTApiUrlFormat,
restApiId.c_str(), restApiRegion.c_str(), restApiStage.c_str());
}
}
@@ -46,7 +46,7 @@ public:
void CreateTestSetRegFile(const AZStd::string& setregContent)
{
m_normalizedSetRegFilePath = AZStd::string::format("%s/%s",
m_normalizedSetRegFolderPath.c_str(), AWSCore::AWSCoreConfiguration::AWSCORE_CONFIGURATION_FILENAME);
m_normalizedSetRegFolderPath.c_str(), AWSCore::AWSCoreConfiguration::AWSCoreConfigurationFileName);
AzFramework::StringFunc::Path::Normalize(m_normalizedSetRegFilePath);
CreateTestFile(m_normalizedSetRegFilePath, setregContent);
}
@@ -177,7 +177,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAf
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
auto actualProfileName = m_awsCoreConfiguration->GetProfileName();
EXPECT_TRUE(actualConfigFilePath.empty());
EXPECT_TRUE(actualProfileName == AWSCoreConfiguration::AWSCORE_DEFAULT_PROFILE_NAME);
EXPECT_TRUE(actualProfileName == AWSCoreConfiguration::AWSCoreDefaultProfileName);
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
m_awsCoreConfiguration->ReloadConfiguration();
@@ -185,5 +185,24 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAf
actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
actualProfileName = m_awsCoreConfiguration->GetProfileName();
EXPECT_FALSE(actualConfigFilePath.empty());
EXPECT_TRUE(actualProfileName != AWSCoreConfiguration::AWSCORE_DEFAULT_PROFILE_NAME);
EXPECT_TRUE(actualProfileName != AWSCoreConfiguration::AWSCoreDefaultProfileName);
}
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadInvalidSettingsRegistryAfterValidOne_ReturnEmptyConfigFilePath)
{
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
m_awsCoreConfiguration->InitConfig();
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
auto actualProfileName = m_awsCoreConfiguration->GetProfileName();
EXPECT_FALSE(actualConfigFilePath.empty());
EXPECT_TRUE(actualProfileName != AWSCoreConfiguration::AWSCoreDefaultProfileName);
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
m_awsCoreConfiguration->ReloadConfiguration();
actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
actualProfileName = m_awsCoreConfiguration->GetProfileName();
EXPECT_TRUE(actualConfigFilePath.empty());
EXPECT_TRUE(actualProfileName == AWSCoreConfiguration::AWSCoreDefaultProfileName);
}
@@ -98,7 +98,7 @@ public:
"AWSResourceMappingManager", AZ::Uuid::CreateRandom().ToString<AZStd::string>(false, false).c_str());
AzFramework::StringFunc::Path::Normalize(m_normalizedSourceProjectFolder);
m_normalizedConfigFolderPath = AZStd::string::format("%s/%s/",
m_normalizedSourceProjectFolder.c_str(), AWSCore::AWSCoreConfiguration::AWSCORE_RESOURCE_MAPPING_CONFIG_FOLDERNAME);
m_normalizedSourceProjectFolder.c_str(), AWSCore::AWSCoreConfiguration::AWSCoreResourceMappingConfigFolderName);
AzFramework::StringFunc::Path::Normalize(m_normalizedConfigFolderPath);
AWSCoreInternalRequestBus::Handler::BusConnect();
}
@@ -178,6 +178,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseInvalidConfigFile_Con
EXPECT_EQ(m_reloadConfigurationCounter, 1);
EXPECT_TRUE(actualAccountId.empty());
EXPECT_TRUE(actualRegion.empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Error);
}
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_ConfigDataIsNotEmpty)
@@ -192,6 +193,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_Confi
EXPECT_EQ(m_reloadConfigurationCounter, 1);
EXPECT_FALSE(actualAccountId.empty());
EXPECT_FALSE(actualRegion.empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Ready);
}
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_ConfigDataIsNotEmptyWithMultithreadCalls)
@@ -230,11 +232,13 @@ TEST_F(AWSResourceMappingManagerTest, DeactivateManager_AfterActivatingWithValid
AWSResourceMappingRequestBus::BroadcastResult(actualRegion, &AWSResourceMappingRequests::GetDefaultRegion);
EXPECT_FALSE(actualAccountId.empty());
EXPECT_FALSE(actualRegion.empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Ready);
m_resourceMappingManager->DeactivateManager();
EXPECT_TRUE(m_resourceMappingManager->GetDefaultAccountId().empty());
EXPECT_TRUE(m_resourceMappingManager->GetDefaultRegion().empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::NotLoaded);
}
TEST_F(AWSResourceMappingManagerTest, GetDefaultAccountId_AfterParsingValidConfigFile_GetExpectedDefaultAccountId)
@@ -416,6 +420,7 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ParseValidConfigFileAfter
EXPECT_EQ(m_reloadConfigurationCounter, 1);
EXPECT_TRUE(actualAccountId.empty());
EXPECT_TRUE(actualRegion.empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Error);
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
m_resourceMappingManager->ReloadConfigFile();
@@ -425,6 +430,7 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ParseValidConfigFileAfter
EXPECT_EQ(m_reloadConfigurationCounter, 1);
EXPECT_FALSE(actualAccountId.empty());
EXPECT_FALSE(actualRegion.empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Ready);
}
TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ReloadConfigFileNameAndParseValidConfigFile_ConfigDataGetParsed)
@@ -435,6 +441,7 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ReloadConfigFileNameAndPa
EXPECT_EQ(m_reloadConfigurationCounter, 1);
EXPECT_FALSE(m_resourceMappingManager->GetDefaultAccountId().empty());
EXPECT_FALSE(m_resourceMappingManager->GetDefaultRegion().empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Ready);
}
TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_MissingSetRegFile_ConfigDataIsNotParsed)
@@ -444,4 +451,5 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_MissingSetRegFile_ConfigD
EXPECT_EQ(m_reloadConfigurationCounter, 1);
EXPECT_TRUE(m_resourceMappingManager->GetDefaultAccountId().empty());
EXPECT_TRUE(m_resourceMappingManager->GetDefaultRegion().empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::NotLoaded);
}
@@ -127,11 +127,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<extends>QWidget</extends>
<header>Controls/PreviewModelCtrl.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AzToolsFramework::AspectRatioAwarePixmapWidget</class>
<extends>QWidget</extends>
@@ -10,11 +10,9 @@
*
*/
#ifndef AZ_COLLECTING_PARTIAL_SRGS
#error Do not include this file directly. Include the main .srgi file instead.
#endif
#include <Atom/Features/SrgSemantics.azsli>
partial ShaderResourceGroup RayTracingSceneSrg
ShaderResourceGroup RayTracingSceneSrg : SRG_RayTracingScene
{
RaytracingAccelerationStructure m_scene;
@@ -150,6 +148,4 @@ partial ShaderResourceGroup RayTracingSceneSrg
#define MESH_NORMAL_BUFFER_OFFSET 2
ByteAddressBuffer m_meshBuffers[];
}
}
@@ -1,19 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
// Please review README.md to understand how this file is used in RayTracingSceneSrg.azsrg generation
#ifdef AZ_COLLECTING_PARTIAL_SRGS
#include <Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli>
#endif
@@ -280,8 +280,6 @@ set(FILES
ShaderLib/Atom/Features/Shadow/Shadow.azsli
ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli
ShaderLib/Atom/Features/Vertex/VertexHelper.azsli
ShaderResourceGroups/RayTracingSceneSrg.azsli
ShaderResourceGroups/RayTracingSceneSrgAll.azsli
ShaderResourceGroups/SceneSrg.azsli
ShaderResourceGroups/SceneSrgAll.azsli
ShaderResourceGroups/SceneTimeSrg.azsli
@@ -88,7 +88,10 @@ namespace AZ
//! Sets the transform of the decal
//! Equivalent to calling SetDecalPosition() + SetDecalOrientation() + SetDecalHalfSize()
//! @{
virtual void SetDecalTransform(DecalHandle handle, const AZ::Transform& world) = 0;
virtual void SetDecalTransform(DecalHandle handle, const AZ::Transform& world, const AZ::Vector3& nonUniformScale) = 0;
//! @}
//! Sets the material information for this decal
virtual void SetDecalMaterial(DecalHandle handle, const AZ::Data::AssetId) = 0;
@@ -264,7 +264,12 @@ namespace AZ
void DecalFeatureProcessor::SetDecalTransform(DecalHandle handle, const AZ::Transform& world)
{
// https://jira.agscollab.com/browse/ATOM-4330
SetDecalTransform(handle, world, AZ::Vector3::CreateOne());
}
void DecalFeatureProcessor::SetDecalTransform(DecalHandle handle, const AZ::Transform& world, const AZ::Vector3& nonUniformScale)
{
// ATOM-4330
// Original Open 3D Engine uploads a 4x4 matrix rather than quaternion, rotation, scale.
// That is more memory but less calculation because it is doing a matrix inverse rather than a polar decomposition
// I've done some experiments and uploading a 3x4 transform matrix with 3x3 matrix inverse should be possible
@@ -274,7 +279,7 @@ namespace AZ
if (handle.IsValid())
{
Quaternion orientation = world.GetRotation();
Vector3 scale = world.GetScale();
Vector3 scale = world.GetScale() * nonUniformScale;
SetDecalHalfSize(handle, scale);
SetDecalPosition(handle, world.GetTranslation());
@@ -73,7 +73,10 @@ namespace AZ
//! Sets the transform of the decal
//! Equivalent to calling SetDecalPosition() + SetDecalOrientation() + SetDecalHalfSize()
//! @{
void SetDecalTransform(DecalHandle handle, const AZ::Transform& world) override;
void SetDecalTransform(DecalHandle handle, const AZ::Transform& world, const AZ::Vector3& nonUniformScale) override;
//! @}
//! Sets the material information for this decal
void SetDecalMaterial(DecalHandle handle, const AZ::Data::AssetId) override;
@@ -270,10 +270,16 @@ namespace AZ
}
void DecalTextureArrayFeatureProcessor::SetDecalTransform(DecalHandle handle, const AZ::Transform& world)
{
SetDecalTransform(handle, world, AZ::Vector3::CreateOne());
}
void DecalTextureArrayFeatureProcessor::SetDecalTransform(DecalHandle handle, const AZ::Transform& world,
const AZ::Vector3& nonUniformScale)
{
if (handle.IsValid())
{
SetDecalHalfSize(handle, world.GetScale());
SetDecalHalfSize(handle, nonUniformScale * world.GetScale());
SetDecalPosition(handle, world.GetTranslation());
SetDecalOrientation(handle, world.GetRotation());
@@ -82,7 +82,10 @@ namespace AZ
//! Sets the transform of the decal
//! Equivalent to calling SetDecalPosition() + SetDecalOrientation() + SetDecalHalfSize()
//! @{
void SetDecalTransform(const DecalHandle handle, const AZ::Transform& world) override;
void SetDecalTransform(const DecalHandle handle, const AZ::Transform& world, const AZ::Vector3& nonUniformScale) override;
//! @}
//! Sets the material information for this decal
void SetDecalMaterial(const DecalHandle handle, const AZ::Data::AssetId id) override;
@@ -67,7 +67,7 @@ namespace AZ
// load the RayTracingSceneSrg asset
Data::Asset<RPI::ShaderResourceGroupAsset> rayTracingSceneSrgAsset =
RPI::AssetUtils::LoadAssetByProductPath<RPI::ShaderResourceGroupAsset>("shaderlib/raytracingscenesrg_raytracingscenesrg.azsrg", RPI::AssetUtils::TraceLevel::Error);
RPI::AssetUtils::LoadAssetByProductPath<RPI::ShaderResourceGroupAsset>("shaderlib/atom/features/raytracing/raytracingscenesrg_raytracingscenesrg.azsrg", RPI::AssetUtils::TraceLevel::Error);
AZ_Assert(rayTracingSceneSrgAsset.IsReady(), "Failed to load RayTracingSceneSrg asset");
m_rayTracingSceneSrg = RPI::ShaderResourceGroup::Create(rayTracingSceneSrgAsset);
@@ -40,13 +40,22 @@ namespace AZ
// Dependent asset references aren't guaranteed to finish loading by the time this asset is serialized, only by
// the time this asset load is completed. But since the data is needed here, we will deliberately block until the
// shader asset has finished loading.
shaderVariantReference->m_shaderAsset.QueueLoad();
shaderVariantReference->m_shaderAsset.BlockUntilLoadComplete();
if (shaderVariantReference->m_shaderAsset.QueueLoad())
{
shaderVariantReference->m_shaderAsset.BlockUntilLoadComplete();
}
shaderVariantReference->m_shaderOptionGroup = ShaderOptionGroup{
shaderVariantReference->m_shaderAsset->GetShaderOptionGroupLayout(),
shaderVariantReference->m_shaderVariantId
};
if (shaderVariantReference->m_shaderAsset.IsReady())
{
shaderVariantReference->m_shaderOptionGroup = ShaderOptionGroup{
shaderVariantReference->m_shaderAsset->GetShaderOptionGroupLayout(),
shaderVariantReference->m_shaderVariantId
};
}
else
{
shaderVariantReference->m_shaderOptionGroup = {};
}
}
};
@@ -82,7 +91,7 @@ namespace AZ
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<Item>()
behaviorContext->Class<Item>("ShaderCollectionItem")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Category, "Shader")
->Attribute(AZ::Script::Attributes::Module, "shader")
@@ -15,6 +15,7 @@
#if !defined(Q_MOC_RUN)
#include <AzCore/Memory/SystemAllocator.h>
#include <AzQtComponents/Components/ExtendedLabel.h>
#include <QMouseEvent>
#include <QPaintEvent>
#endif
@@ -31,7 +32,11 @@ namespace AtomToolsFramework
void SetExpanded(bool expanded);
bool IsExpanded() const;
Q_SIGNALS:
void clicked(QMouseEvent* event);
protected:
void mousePressEvent(QMouseEvent* event) override;
void paintEvent(QPaintEvent* event) override;
private:
@@ -55,6 +55,12 @@ namespace AtomToolsFramework
//! Calls Rebuild for all InspectorGroupWidget, allowing for destructive UI changes
virtual void RebuildAll() = 0;
//! Expands all groups and headers
virtual void ExpandAll() = 0;
//! Collapses all groups and headers
virtual void CollapseAll() = 0;
};
using InspectorRequestBus = AZ::EBus<InspectorRequests>;
@@ -29,11 +29,8 @@ namespace Ui
namespace AtomToolsFramework
{
class InspectorPropertyGroupWidget;
}
class InspectorGroupHeaderWidget;
namespace AtomToolsFramework
{
//! Provides controls for viewing and editing object settings.
//! The settings can be divided into groups, with each one showing a subset of properties.
class InspectorWidget
@@ -66,8 +63,15 @@ namespace AtomToolsFramework
void RefreshAll() override;
void RebuildAll() override;
void ExpandAll() override;
void CollapseAll() override;
private:
void OnHeaderClicked(QMouseEvent* event, InspectorGroupHeaderWidget* groupHeader, QWidget* groupWidget);
QVBoxLayout* m_layout = nullptr;
QScopedPointer<Ui::InspectorWidget> m_ui;
AZStd::vector<InspectorGroupHeaderWidget*> m_headers;
AZStd::vector<QWidget*> m_groups;
};
} // namespace AtomToolsFramework
@@ -94,9 +94,10 @@ namespace AtomToolsFramework
bool ShowGrid() override;
bool AngleSnappingEnabled() override;
float AngleStep() override;
QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override;
AZStd::optional<AZ::Vector3> ViewportScreenToWorld(const QPoint& screenPosition, float depth) override;
AZStd::optional<AzToolsFramework::ViewportInteraction::ProjectedViewportRay> ViewportScreenToWorldRay(const QPoint& screenPosition) override;
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override;
AZStd::optional<AZ::Vector3> ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) override;
AZStd::optional<AzToolsFramework::ViewportInteraction::ProjectedViewportRay> ViewportScreenToWorldRay(
const AzFramework::ScreenPoint& screenPosition) override;
// AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler ...
void BeginCursorCapture() override;
@@ -14,10 +14,10 @@
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Components/Widgets/Text.h>
#include <QStyle>
#include <QPainter>
#include <QApplication>
#include <QPainter>
#include <QPixmap>
#include <QStyle>
#include <QStyleOptionViewItem>
namespace AtomToolsFramework
@@ -44,6 +44,11 @@ namespace AtomToolsFramework
return m_expanded;
}
void InspectorGroupHeaderWidget::mousePressEvent(QMouseEvent* event)
{
emit clicked(event);
}
void InspectorGroupHeaderWidget::paintEvent([[maybe_unused]] QPaintEvent* event)
{
QPainter painter(this);
@@ -52,19 +57,10 @@ namespace AtomToolsFramework
auto& icon = m_expanded ? m_iconExpanded : m_iconCollapsed;
const QRect iconRect(5, (geometry().height() / 2) - (iconSize.height() / 2), iconSize.width(), iconSize.height());
style->drawItemPixmap(&painter,
iconRect,
Qt::AlignLeft | Qt::AlignVCenter,
icon.scaledToWidth(iconSize.width()));
style->drawItemPixmap(&painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter, icon.scaledToWidth(iconSize.width()));
const auto textRect = QRect(25, 0, geometry().width() - 21, geometry().height());
style->drawItemText(&painter,
textRect,
Qt::AlignLeft | Qt::AlignVCenter,
QPalette(),
true,
text(),
QPalette::HighlightedText);
style->drawItemText(&painter, textRect, Qt::AlignLeft | Qt::AlignVCenter, QPalette(), true, text(), QPalette::HighlightedText);
}
} // namespace AtomToolsFramework
@@ -10,12 +10,13 @@
*
*/
#include <QMenu>
#include <QScrollArea>
#include <QScrollBar>
#include <QSizePolicy>
#include <AtomToolsFramework/Inspector/InspectorGroupWidget.h>
#include <AtomToolsFramework/Inspector/InspectorGroupHeaderWidget.h>
#include <AtomToolsFramework/Inspector/InspectorGroupWidget.h>
#include <AtomToolsFramework/Inspector/InspectorWidget.h>
#include <Source/Inspector/ui_InspectorWidget.h>
@@ -38,6 +39,8 @@ namespace AtomToolsFramework
m_layout = new QVBoxLayout(m_ui->m_propertyContent);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setSpacing(0);
m_headers.clear();
m_groups.clear();
}
void InspectorWidget::AddGroupsBegin()
@@ -52,8 +55,7 @@ namespace AtomToolsFramework
m_layout->addStretch();
// Scroll to top whenever there is new content
m_ui->m_propertyScrollArea->verticalScrollBar()->setValue(
m_ui->m_propertyScrollArea->verticalScrollBar()->minimum());
m_ui->m_propertyScrollArea->verticalScrollBar()->setValue(m_ui->m_propertyScrollArea->verticalScrollBar()->minimum());
setUpdatesEnabled(true);
}
@@ -68,15 +70,15 @@ namespace AtomToolsFramework
groupHeader->setText(groupDisplayName.c_str());
groupHeader->setToolTip(groupDescription.c_str());
m_layout->addWidget(groupHeader);
m_headers.push_back(groupHeader);
groupWidget->setObjectName(groupNameId.c_str());
groupWidget->setParent(m_ui->m_propertyContent);
m_layout->addWidget(groupWidget);
m_groups.push_back(groupWidget);
connect(groupHeader, &AzQtComponents::ExtendedLabel::clicked, this, [groupHeader, groupWidget]()
{
groupHeader->SetExpanded(!groupHeader->IsExpanded());
groupWidget->setVisible(groupHeader->IsExpanded());
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupHeader, groupWidget](QMouseEvent* event) {
OnHeaderClicked(event, groupHeader, groupWidget);
});
}
@@ -111,6 +113,57 @@ namespace AtomToolsFramework
groupWidget->Rebuild();
}
}
void InspectorWidget::ExpandAll()
{
for (auto headerWidget : m_headers)
{
headerWidget->SetExpanded(true);
}
for (auto groupWidget : m_groups)
{
groupWidget->setVisible(true);
}
}
void InspectorWidget::CollapseAll()
{
for (auto headerWidget : m_headers)
{
headerWidget->SetExpanded(false);
}
for (auto groupWidget : m_groups)
{
groupWidget->setVisible(false);
}
}
void InspectorWidget::OnHeaderClicked(QMouseEvent* event, InspectorGroupHeaderWidget* groupHeader, QWidget* groupWidget)
{
if (event->button() == Qt::MouseButton::LeftButton)
{
groupHeader->SetExpanded(!groupHeader->IsExpanded());
groupWidget->setVisible(groupHeader->IsExpanded());
return;
}
if (event->button() == Qt::MouseButton::RightButton)
{
QMenu menu;
menu.addAction("Expand", [groupHeader, groupWidget]() {
groupHeader->SetExpanded(true);
groupWidget->setVisible(true);
})->setEnabled(!groupHeader->IsExpanded());
menu.addAction("Collapse", [groupHeader, groupWidget]() {
groupHeader->SetExpanded(false);
groupWidget->setVisible(false);
})->setEnabled(groupHeader->IsExpanded());
menu.addAction("Expand All", [this]() { ExpandAll(); });
menu.addAction("Collapse All", [this]() { CollapseAll(); });
menu.exec(event->globalPos());
return;
}
}
} // namespace AtomToolsFramework
#include <AtomToolsFramework/Inspector/moc_InspectorWidget.cpp>
@@ -407,44 +407,43 @@ namespace AtomToolsFramework
return 0.0f;
}
QPoint RenderViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
AzFramework::ScreenPoint RenderViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
{
AZ::RPI::ViewPtr currentView = m_viewportContext->GetDefaultView();
if (currentView == nullptr)
if (AZ::RPI::ViewPtr currentView = m_viewportContext->GetDefaultView();
currentView == nullptr)
{
return QPoint();
return AzFramework::ScreenPoint(0, 0);
}
AzFramework::ScreenPoint position = AzFramework::WorldToScreen(
worldPosition,
GetCameraState()
);
return {position.m_x, position.m_y};
return AzFramework::WorldToScreen(worldPosition, GetCameraState());
}
AZStd::optional<AZ::Vector3> RenderViewportWidget::ViewportScreenToWorld(const QPoint& screenPosition, float depth)
AZStd::optional<AZ::Vector3> RenderViewportWidget::ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth)
{
const auto& cameraProjection = m_viewportContext->GetCameraProjectionMatrix();
const auto& cameraView = m_viewportContext->GetCameraViewMatrix();
const AZ::Vector4 normalizedScreenPosition {
screenPosition.x() * 2.f / width() - 1.0f,
(height() - screenPosition.y()) * 2.f / height() - 1.0f,
screenPosition.m_x * 2.f / width() - 1.0f,
(height() - screenPosition.m_y) * 2.f / height() - 1.0f,
1.f - depth, // [GFX TODO] [ATOM-1501] Currently we always assume reverse depth
1.f
};
AZ::Matrix4x4 worldFromScreen = cameraProjection * cameraView;
worldFromScreen.InvertFull();
AZ::Vector4 projectedPosition = worldFromScreen * normalizedScreenPosition;
if (projectedPosition.GetW() == 0.f)
const AZ::Vector4 projectedPosition = worldFromScreen * normalizedScreenPosition;
if (projectedPosition.GetW() == 0.0f)
{
return {};
}
return projectedPosition.GetAsVector3() / projectedPosition.GetW();
}
AZStd::optional<AzToolsFramework::ViewportInteraction::ProjectedViewportRay> RenderViewportWidget::ViewportScreenToWorldRay(
const QPoint& screenPosition)
const AzFramework::ScreenPoint& screenPosition)
{
auto pos0 = ViewportScreenToWorld(screenPosition, 0.f);
auto pos1 = ViewportScreenToWorld(screenPosition, 1.f);
@@ -457,6 +456,7 @@ namespace AtomToolsFramework
AZ::Vector3 rayOrigin = pos0.value();
AZ::Vector3 rayDirection = pos1.value() - pos0.value();
rayDirection.Normalize();
return AzToolsFramework::ViewportInteraction::ProjectedViewportRay{rayOrigin, rayDirection};
}
@@ -101,6 +101,11 @@ AZ::RPI::WindowContextSharedPtr AZ::FFont::GetDefaultWindowContext() const
bool AZ::FFont::InitFont(AZ::RPI::Scene* renderScene)
{
if (!renderScene)
{
return false;
}
auto initializationState = InitializationState::Uninitialized;
// Do an atomic transition to Initializing if we're in the Uninitialized state.
// Otherwise, check the current state.
@@ -111,11 +116,6 @@ bool AZ::FFont::InitFont(AZ::RPI::Scene* renderScene)
return initializationState == InitializationState::Initialized;
}
if (!renderScene)
{
return false;
}
// Create and initialize DynamicDrawContext for font draw
AZ::RPI::Ptr<AZ::RPI::DynamicDrawContext> dynamicDraw = m_atomFont->GetOrCreateDynamicDrawForScene(renderScene);
@@ -75,6 +75,12 @@ namespace AZ
incompatible.push_back(AZ_CRC_CE("DecalService"));
}
void DecalComponentController::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
dependent.push_back(AZ_CRC_CE("TransformService"));
dependent.push_back(AZ_CRC_CE("NonUniformScaleService"));
}
DecalComponentController::DecalComponentController(const DecalComponentConfig& config)
: m_configuration(config)
{
@@ -90,6 +96,11 @@ namespace AZ
m_handle = m_featureProcessor->AcquireDecal();
}
m_cachedNonUniformScale = AZ::Vector3::CreateOne();
AZ::NonUniformScaleRequestBus::EventResult(m_cachedNonUniformScale, m_entityId, &AZ::NonUniformScaleRequests::GetScale);
AZ::NonUniformScaleRequestBus::Event(m_entityId, &AZ::NonUniformScaleRequests::RegisterScaleChangedEvent,
m_nonUniformScaleChangedHandler);
AZ::Transform local, world;
AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::GetLocalAndWorld, local, world);
OnTransformChanged(local, world);
@@ -103,6 +114,7 @@ namespace AZ
{
DecalRequestBus::Handler::BusDisconnect(m_entityId);
TransformNotificationBus::Handler::BusDisconnect(m_entityId);
m_nonUniformScaleChangedHandler.Disconnect();
if (m_featureProcessor)
{
m_featureProcessor->ReleaseDecal(m_handle);
@@ -125,7 +137,18 @@ namespace AZ
{
if (m_featureProcessor)
{
m_featureProcessor->SetDecalTransform(m_handle, world);
m_featureProcessor->SetDecalTransform(m_handle, world, m_cachedNonUniformScale);
}
}
void DecalComponentController::HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale)
{
m_cachedNonUniformScale = nonUniformScale;
if (m_featureProcessor)
{
AZ::Transform world = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(world, m_entityId, &AZ::TransformBus::Events::GetWorldTM);
m_featureProcessor->SetDecalTransform(m_handle, world, nonUniformScale);
}
}
@@ -14,6 +14,7 @@
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Component/NonUniformScaleBus.h>
#include <AtomLyIntegration/CommonFeatures/Decals/DecalBus.h>
#include <AtomLyIntegration/CommonFeatures/Decals/DecalComponentConfig.h>
#include <Atom/Feature/Decals/DecalFeatureProcessorInterface.h>
@@ -33,6 +34,7 @@ namespace AZ
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
DecalComponentController() = default;
DecalComponentController(const DecalComponentConfig& config);
@@ -64,11 +66,18 @@ namespace AZ
void OpacityChanged();
void SortKeyChanged();
void MaterialChanged();
void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale);
DecalComponentConfig m_configuration;
DecalFeatureProcessorInterface* m_featureProcessor = nullptr;
DecalFeatureProcessorInterface::DecalHandle m_handle;
EntityId m_entityId;
AZ::Vector3 m_cachedNonUniformScale = AZ::Vector3::CreateOne();
AZ::NonUniformScaleChangedEvent::Handler m_nonUniformScaleChangedHandler
{
[&](const AZ::Vector3& nonUniformScale) { HandleNonUniformScaleChange(nonUniformScale); }
};
};
} // namespace Render
} // AZ namespace
@@ -131,6 +131,7 @@ namespace AZ
void MeshComponentController::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
dependent.push_back(AZ_CRC("TransformService", 0x8ee22c50));
dependent.push_back(AZ_CRC_CE("NonUniformScaleService"));
}
void MeshComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
@@ -26,9 +26,9 @@
#include <SoundCVars.h>
#include <ATLUtils.h>
#include <I3DEngine.h>
#include <IRenderer.h>
#include <IRenderAuxGeom.h>
#include <IConsole.h>
#include <CryPhysicsDeprecation.h>
@@ -33,8 +33,8 @@
#include <IAudioSystemImplementation.h>
#include <MathConversion.h>
#include <I3DEngine.h>
#include <IRenderAuxGeom.h>
#include <IConsole.h>
namespace Audio
{
-3
View File
@@ -9,7 +9,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
add_subdirectory(ImageProcessing)
add_subdirectory(TextureAtlas)
add_subdirectory(LmbrCentral)
add_subdirectory(LyShine)
@@ -23,7 +22,6 @@ add_subdirectory(HttpRequestor)
add_subdirectory(Gestures)
add_subdirectory(FastNoise)
add_subdirectory(GradientSignal)
add_subdirectory(GameEffectSystem)
add_subdirectory(AudioSystem)
add_subdirectory(AudioEngineWwise)
add_subdirectory(GraphCanvas)
@@ -45,7 +43,6 @@ add_subdirectory(GameState)
add_subdirectory(Vegetation)
add_subdirectory(GameStateSamples)
add_subdirectory(SliceFavorites)
add_subdirectory(SVOGI)
add_subdirectory(Metastream)
add_subdirectory(ScriptCanvas)
add_subdirectory(ScriptedEntityTweener)
@@ -77,7 +77,6 @@ namespace EMotionFX
m_app.RegisterComponentDescriptor(AzFramework::TransformComponent::CreateDescriptor());
m_envPrev = gEnv;
m_env.p3DEngine = nullptr;
m_env.pRenderer = &m_data.m_renderer;
m_env.pSystem = &m_data.m_system;
gEnv = &m_env;
@@ -115,7 +115,6 @@ struct MockGlobalEnvironment
m_stubEnv.pCryPak = &m_stubPak;
m_stubEnv.pConsole = &m_stubConsole;
m_stubEnv.pSystem = &m_stubSystem;
m_stubEnv.p3DEngine = nullptr;
gEnv = &m_stubEnv;
}
@@ -1,3 +0,0 @@
<EngineDependencies versionnumber="1.0.0">
<Dependency path="scripts/effects/gameeffects.xml" optional="true" />
</EngineDependencies>
@@ -1,13 +0,0 @@
<ObjectStream version="3">
<Class name="AZStd::vector" type="{82FC5264-88D0-57CD-9307-FC52E4DAD550}">
<Class name="SeedInfo" field="element" version="2" type="{FACC3682-2ACA-4AA4-B85A-07AD276D18A0}">
<Class name="AssetId" field="assetId" version="1" type="{652ED536-3402-439B-AEBE-4A5DBC554085}">
<Class name="AZ::Uuid" field="guid" value="{BD36892B-5AF0-5A3F-AA86-577E26747F6C}" type="{E152C105-A133-4D03-BBF8-3D4B2FBA3E2A}"/>
<Class name="unsigned int" field="subId" value="0" type="{43DA906B-7DEF-4CA8-9790-854106D3F983}"/>
</Class>
<Class name="unsigned int" field="platformFlags" value="255" type="{43DA906B-7DEF-4CA8-9790-854106D3F983}"/>
<Class name="AZStd::string" field="pathHint" value="gameeffectssystem_dependencies.xml" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
</Class>
</Class>
</ObjectStream>
-12
View File
@@ -1,12 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
add_subdirectory(Code)
-37
View File
@@ -1,37 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_target(
NAME GameEffectSystem.Static STATIC
NAMESPACE Gem
FILES_CMAKE
gameeffectsystem_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
include
source
BUILD_DEPENDENCIES
PUBLIC
Legacy::CryCommon
)
ly_add_target(
NAME GameEffectSystem ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
FILES_CMAKE
gameeffectsystem_shared_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
include
BUILD_DEPENDENCIES
PRIVATE
Gem::GameEffectSystem.Static
)
@@ -1,27 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
source/GameEffectSystem_precompiled.cpp
source/GameEffectSystem_precompiled.h
include/GameEffectSystem/IGameEffectSystem.h
include/GameEffectSystem/IGameRenderNode.h
include/GameEffectSystem/GameEffectsSystemDefines.h
include/GameEffectSystem/GameEffects/IGameEffect.h
include/GameEffectSystem/GameEffects/GameEffectBase.h
source/GameEffectsSystem.h
source/GameEffectsSystem.cpp
source/GameEffects/GameEffectSoftCodeLibrary.cpp
source/RenderElements/GameRenderElement.h
source/RenderElements/GameRenderElement.cpp
source/RenderElements/GameRenderElementSoftCodeLibrary.cpp
source/RenderNodes/GameRenderNodeSoftCodeLibrary.cpp
)
@@ -1,16 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
source/GameEffectSystemGem.h
source/GameEffectSystemGem.cpp
)
@@ -1,213 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _GAMEEFFECTBASE_H_
#define _GAMEEFFECTBASE_H_
#include <GameEffectSystem/GameEffects/IGameEffect.h>
#include <GameEffectSystem/GameEffectsSystemDefines.h>
#include "TypeLibrary.h"
// Forward declares
struct SGameEffectParams;
//==================================================================================================
// Name: Flag macros
// Desc: Flag macros to make code more readable
// Author: James Chilvers
//==================================================================================================
#define SET_FLAG(currentFlags, flag, state) ((state) ? (currentFlags |= flag) : (currentFlags &= ~flag));
#define IS_FLAG_SET(currentFlags, flag) ((currentFlags & flag) ? true : false)
//--------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: CGameEffect
// Desc: Game effect - Ideal for handling a specific visual game feature
// Author: James Chilvers
//==================================================================================================
class CGameEffect
: public IGameEffect
{
DECLARE_TYPE(CGameEffect, IGameEffect); // Exposes this type for SoftCoding
public:
CGameEffect();
virtual ~CGameEffect();
void Initialize(const SGameEffectParams* gameEffectParams = NULL) override;
void Release() override;
void Update(float frameTime) override;
void SetActive(bool isActive) override;
void SetFlag(uint32 flag, bool state) override { SET_FLAG(m_flags, flag, state); }
bool IsFlagSet(uint32 flag) const override { return IS_FLAG_SET(m_flags, flag); }
uint32 GetFlags() const override { return m_flags; }
void SetFlags(uint32 flags) override { m_flags = flags; }
void GetMemoryUsage(ICrySizer* pSizer) const override { pSizer->AddObject(this, sizeof(*this)); }
void UnloadData() override { }
protected:
// General data functions
static _smart_ptr<IMaterial> LoadMaterial(const char* pMaterialName);
private:
IGameEffect* Next() const override { return m_next; }
IGameEffect* Prev() const override { return m_prev; }
void SetNext(IGameEffect* newNext) override { m_next = newNext; }
void SetPrev(IGameEffect* newPrev) override { m_prev = newPrev; }
IGameEffect* m_prev;
IGameEffect* m_next;
uint16 m_flags;
IGameEffectSystem* m_gameEffectSystem = nullptr;
#if DEBUG_GAME_FX_SYSTEM
CryFixedStringT<32> m_debugName;
#endif
}; //-----------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: CGameEffect
// Desc: Constructor
//--------------------------------------------------------------------------------------------------
inline CGameEffect::CGameEffect()
{
m_prev = NULL;
m_next = NULL;
m_flags = 0;
EBUS_EVENT_RESULT(m_gameEffectSystem, GameEffectSystemRequestBus, GetIGameEffectSystem);
} //------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: ~CGameEffect
// Desc: Destructor
//--------------------------------------------------------------------------------------------------
inline CGameEffect::~CGameEffect()
{
#if DEBUG_GAME_FX_SYSTEM
// Output message if effect hasn't been released before being deleted
const bool bEffectIsReleased =
(m_flags & GAME_EFFECT_RELEASED) || // -> Needs to be released before deleted
!(m_flags & GAME_EFFECT_INITIALISED) || // -> Except when not initialised
(gEnv->IsEditor()); // -> Or the editor (memory safely released by editor)
if (!bEffectIsReleased)
{
string dbgMessage = m_debugName + " being destroyed without being released first";
FX_ASSERT_MESSAGE(bEffectIsReleased, dbgMessage.c_str());
}
#endif
if (m_gameEffectSystem)
{
// -> Effect should have been released and been unregistered, but to avoid
// crashes call unregister here too
m_gameEffectSystem->UnRegisterEffect(this);
}
} //------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: Initialise
// Desc: Initializes game effect
//--------------------------------------------------------------------------------------------------
inline void CGameEffect::Initialize(const SGameEffectParams* gameEffectParams)
{
#if DEBUG_GAME_FX_SYSTEM
m_debugName = GetName(); // Store name so it can be accessed in destructor and debugging
#endif
if (!IsFlagSet(GAME_EFFECT_INITIALISED))
{
SGameEffectParams params;
if (gameEffectParams)
{
params = *gameEffectParams;
}
SetFlag(GAME_EFFECT_AUTO_UPDATES_WHEN_ACTIVE, params.autoUpdatesWhenActive);
SetFlag(GAME_EFFECT_AUTO_UPDATES_WHEN_NOT_ACTIVE, params.autoUpdatesWhenNotActive);
SetFlag(GAME_EFFECT_AUTO_RELEASE, params.autoRelease);
SetFlag(GAME_EFFECT_AUTO_DELETE, params.autoDelete);
m_gameEffectSystem->RegisterEffect(this);
SetFlag(GAME_EFFECT_INITIALISED, true);
SetFlag(GAME_EFFECT_RELEASED, false);
}
} //------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: Release
// Desc: Releases game effect
//--------------------------------------------------------------------------------------------------
inline void CGameEffect::Release()
{
SetFlag(GAME_EFFECT_RELEASING, true);
if (IsFlagSet(GAME_EFFECT_ACTIVE))
{
SetActive(false);
}
m_gameEffectSystem->UnRegisterEffect(this);
SetFlag(GAME_EFFECT_INITIALISED, false);
SetFlag(GAME_EFFECT_RELEASING, false);
SetFlag(GAME_EFFECT_RELEASED, true);
} //------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: Update
// Desc: Updates game effect
//--------------------------------------------------------------------------------------------------
inline void CGameEffect::Update(float frameTime)
{
FX_ASSERT_MESSAGE(IsFlagSet(GAME_EFFECT_INITIALISED),
"Effect being updated without being initialised first");
FX_ASSERT_MESSAGE((IsFlagSet(GAME_EFFECT_RELEASED) == false),
"Effect being updated after being released");
} //------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: SetActive
// Desc: Sets active status
//--------------------------------------------------------------------------------------------------
inline void CGameEffect::SetActive(bool isActive)
{
FX_ASSERT_MESSAGE(IsFlagSet(GAME_EFFECT_INITIALISED),
"Effect changing active status without being initialised first");
FX_ASSERT_MESSAGE((IsFlagSet(GAME_EFFECT_RELEASED) == false),
"Effect changing active status after being released");
SetFlag(GAME_EFFECT_ACTIVE, isActive);
m_gameEffectSystem->RegisterEffect(this); // Re-register effect with game effects system
} //------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: LoadMaterial
// Desc: Loads and calls AddRef on material
//--------------------------------------------------------------------------------------------------
inline _smart_ptr<IMaterial> CGameEffect::LoadMaterial(const char* pMaterialName)
{
_smart_ptr<IMaterial> pMaterial = NULL;
I3DEngine* p3DEngine = gEnv->p3DEngine;
if (pMaterialName && p3DEngine)
{
IMaterialManager* pMaterialManager = p3DEngine->GetMaterialManager();
if (pMaterialManager)
{
pMaterial = pMaterialManager->LoadMaterial(pMaterialName);
}
}
return pMaterial;
} //------------------------------------------------------------------------------------------------
#endif//_GAMEEFFECTBASE_H_
@@ -1,103 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _GAMEEFFECT_INTERFACE_H_
#define _GAMEEFFECT_INTERFACE_H_
#include <TypeLibrary.h>
//==================================================================================================
// Name: EGameEffectFlags
// Desc: Game effect flags
// Author: James Chilvers
//==================================================================================================
enum EGameEffectFlags
{
GAME_EFFECT_INITIALISED = (1 << 0),
GAME_EFFECT_RELEASED = (1 << 1),
GAME_EFFECT_AUTO_RELEASE = (1 << 2), // Release called when Game Effect System is destroyed
GAME_EFFECT_AUTO_DELETE = (1 << 3), // Delete is called when Game Effect System is destroyed
GAME_EFFECT_AUTO_UPDATES_WHEN_ACTIVE = (1 << 4),
GAME_EFFECT_AUTO_UPDATES_WHEN_NOT_ACTIVE = (1 << 5),
GAME_EFFECT_REGISTERED = (1 << 6),
GAME_EFFECT_ACTIVE = (1 << 7),
GAME_EFFECT_DEBUG_EFFECT = (1 << 8), // Set true for any debug effects to avoid confusion
GAME_EFFECT_UPDATE_WHEN_PAUSED = (1 << 9),
GAME_EFFECT_RELEASING = (1 << 10)
}; //-----------------------------------------------------------------------------------------------
//==================================================================================================
// Name: SGameEffectParams
// Desc: Game effect parameters
// Author: James Chilvers
//==================================================================================================
struct SGameEffectParams
{
friend class CGameEffect;
// Make constructor private to stop SGameEffectParams ever being created, should always inherit
// this
// for each effect to avoid casting problems
protected:
SGameEffectParams()
{
autoUpdatesWhenActive = true;
autoUpdatesWhenNotActive = false;
autoRelease = false;
autoDelete = false;
}
public:
bool autoUpdatesWhenActive;
bool autoUpdatesWhenNotActive;
bool autoRelease; // Release called when Game Effect System is destroyed
bool autoDelete; // Delete is called when Game Effect System is destroyed
}; //-----------------------------------------------------------------------------------------------
//==================================================================================================
// Name: IGameEffect
// Desc: Interface for all game effects
// Author: James Chilvers
//==================================================================================================
struct IGameEffect
{
DECLARE_TYPELIB(IGameEffect); // Allow soft coding on this interface
friend class CGameEffectsSystem;
public:
virtual ~IGameEffect() {}
virtual void Initialize(const SGameEffectParams* gameEffectParams = NULL) = 0;
virtual void Release() = 0;
virtual void Update(float frameTime) = 0;
virtual void SetActive(bool isActive) = 0;
virtual void SetFlag(uint32 flag, bool state) = 0;
virtual bool IsFlagSet(uint32 flag) const = 0;
virtual uint32 GetFlags() const = 0;
virtual void SetFlags(uint32 flags) = 0;
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
virtual const char* GetName() const = 0;
virtual void UnloadData() = 0;
private:
virtual IGameEffect* Next() const = 0;
virtual IGameEffect* Prev() const = 0;
virtual void SetNext(IGameEffect* newNext) = 0;
virtual void SetPrev(IGameEffect* newPrev) = 0;
}; //-----------------------------------------------------------------------------------------------
#endif//_GAMEEFFECT_INTERFACE_H_
@@ -1,179 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _EFFECTS_GAMEEFFECTSSYSTEMDEFINES_H_
#define _EFFECTS_GAMEEFFECTSSYSTEMDEFINES_H_
#pragma once
// Includes
#include "TypeLibrary.h"
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
// Defines
#define GAME_FX_SYSTEM GetIGameEffectSystem()
#ifndef _RELEASE
#define DEBUG_GAME_FX_SYSTEM 1
#else
#define DEBUG_GAME_FX_SYSTEM 0
#endif
#if DEBUG_GAME_FX_SYSTEM
// Register effect's DebugOnInput and DebugDisplay callback functions
#define REGISTER_EFFECT_DEBUG_DATA(inputEventCallback, debugDisplayCallback, effectName) \
static CGameEffectsSystem::SRegisterEffectDebugData effectName(inputEventCallback, \
debugDisplayCallback, \
#effectName)
// Debug views
enum EGameEffectsSystemDebugView
{
eGAME_FX_DEBUG_VIEW_None = 0,
eGAME_FX_DEBUG_VIEW_Profiling,
eGAME_FX_DEBUG_VIEW_EffectList,
eGAME_FX_DEBUG_VIEW_BoundingBox,
eGAME_FX_DEBUG_VIEW_BoundingSphere,
eGAME_FX_DEBUG_VIEW_Particles,
eMAX_GAME_FX_DEBUG_VIEWS
// ** If you add/remove a view then remember to update GAME_FX_DEBUG_VIEW_NAMES **
};
#else
#define REGISTER_EFFECT_DEBUG_DATA(inputEventCallback, debugDisplayCallback, effectName)
#endif
// FX Asserts
#if DEBUG_GAME_FX_SYSTEM
#define FX_ASSERT_MESSAGE(condition, message) \
CRY_ASSERT_MESSAGE(condition, message); \
if (!(condition)) \
{ \
CryLogAlways("\n*************************************************************************" \
"************"); \
CryLogAlways("FX ASSERT"); \
CryLogAlways("Condition: %s", #condition); \
CryLogAlways("Message: %s", message); \
CryLogAlways("File: %s", __FILE__); \
CryLogAlways("Line: %d", __LINE__); \
CryLogAlways("***************************************************************************" \
"**********\n"); \
}
#else
#define FX_ASSERT_MESSAGE(condition, message)
#endif
// Profile tags
#define ENABLE_GAME_FX_PROFILE_TAGS 0
#if ENABLE_GAME_FX_PROFILE_TAGS
#define GAME_FX_PROFILE_BEGIN(_TAG_NAME_) \
{ \
CryProfile::PushProfilingMarker(#_TAG_NAME_); \
gEnv->pRenderer->PushProfileMarker(#_TAG_NAME_); \
}
#define GAME_FX_PROFILE_END(_TAG_NAME_) \
{ \
CryProfile::PopProfilingMarker(); \
gEnv->pRenderer->PopProfileMarker(#_TAG_NAME_); \
}
#define GAME_FX_PROFILE_MARKER(...) \
{ \
PIXSetMarker(0, __VA_ARGS__); \
}
#else
#define GAME_FX_PROFILE_BEGIN(_TAG_NAME_) \
{ \
}
#define GAME_FX_PROFILE_END(_TAG_NAME_) \
{ \
}
#define GAME_FX_PROFILE_MARKER(...) \
{ \
}
#endif // ENABLE_GAME_FX_PROFILE_TAGS
#define GAME_FX_LISTENER_NAME "GameEffectsSystem"
#define GAME_FX_LIBRARY_NAME "GameEffectsLibrary"
#define GAME_RENDER_NODE_LISTENER_NAME "GameRenderNodeListener"
#define GAME_RENDER_NODE_LIBRARY_NAME "GameRenderNodeLibrary"
#define GAME_RENDER_ELEMENT_LISTENER_NAME "GameRenderElementListener"
#define GAME_RENDER_ELEMENT_LIBRARY_NAME "GameRenderElementLibrary"
// Macro to remove specific code when soft code is enabled
#ifdef SOFTCODE_ENABLED
#define REMOVE_IN_SOFT_CODE(_softCodeOnlyCode_)
#else
#define REMOVE_IN_SOFT_CODE(_softCodeOnlyCode_) _softCodeOnlyCode_
#endif
// Register effect's Game callbacks
#define REGISTER_GAME_CALLBACKS(enteredGameCallback, effectName) \
static SRegisterGameCallbacks effectName(enteredGameCallback)
// Create Game FX Soft Code instance
#ifdef SOFTCODE_ENABLED
#define CREATE_GAME_FX_SOFT_CODE_INSTANCE(T) \
(static_cast<T*>(GAME_FX_SYSTEM.CreateSoftCodeInstance(#T)))
#else
#define CREATE_GAME_FX_SOFT_CODE_INSTANCE(T) (new T)
#endif
// Safely release and delete effect through macro
#define SAFE_DELETE_GAME_EFFECT(pGameEffect) \
if (pGameEffect) \
{ \
pGameEffect->Release(); \
SAFE_DELETE(pGameEffect); \
}
// Safely delete game render nodes
#define SAFE_DELETE_GAME_RENDER_NODE(pGameRenderNode) \
if (pGameRenderNode) \
{ \
pGameRenderNode->ReleaseGameRenderNode(); \
gEnv->p3DEngine->FreeRenderNodeState(pGameRenderNode); \
pGameRenderNode = NULL; \
}
// Safely delete game render elements
#define SAFE_DELETE_GAME_RENDER_ELEMENT(pGameRenderElement) \
if (pGameRenderElement) \
{ \
pGameRenderElement->ReleaseGameRenderElement(); \
pGameRenderElement = NULL; \
}
// FX input
#define GAME_FX_INPUT_ReleaseDebugEffect AzFramework::InputDeviceKeyboard::Key::NavigationEnd.GetNameCrc32()
#define GAME_FX_INPUT_ResetParticleManager AzFramework::InputDeviceKeyboard::Key::NavigationDelete.GetNameCrc32()
#define GAME_FX_INPUT_PauseParticleManager AzFramework::InputDeviceKeyboard::Key::NavigationEnd.GetNameCrc32()
#define GAME_FX_INPUT_ReloadEffectData AzFramework::InputDeviceKeyboard::Key::NumPadDecimal.GetNameCrc32()
#define GAME_FX_INPUT_IncrementDebugEffectId AzFramework::InputDeviceKeyboard::Key::NumPadAdd.GetNameCrc32()
#define GAME_FX_INPUT_DecrementDebugEffectId AzFramework::InputDeviceKeyboard::Key::NumPadSubtract.GetNameCrc32()
#define GAME_FX_INPUT_IncrementDebugView AzFramework::InputDeviceKeyboard::Key::NavigationArrowRight.GetNameCrc32()
#define GAME_FX_INPUT_DecrementDebugView AzFramework::InputDeviceKeyboard::Key::NavigationArrowLeft.GetNameCrc32()
// Forward declares
struct IGameEffect;
struct IGameRenderNode;
struct IGameRenderElement;
class CGameRenderNodeSoftCodeListener;
class CGameRenderElementSoftCodeListener;
// Typedefs
typedef void (* EnteredGameCallback)();
typedef void (* DebugOnInputEventCallback)(int);
typedef void (* DebugDisplayCallback)(const Vec2& textStartPos, float textSize, float textYStep);
typedef _smart_ptr<IGameRenderNode> IGameRenderNodePtr;
typedef _smart_ptr<IGameRenderElement> IGameRenderElementPtr;
#endif//_EFFECTS_GAMEEFFECTSSYSTEMDEFINES_H_
@@ -1,163 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _GAMEEFFECTSYSTEM_INTERFACE_H_
#define _GAMEEFFECTSYSTEM_INTERFACE_H_
#include <GameEffectSystem/GameEffects/IGameEffect.h>
#include <GameEffectSystem/GameEffectsSystemDefines.h>
#include <CryPodArray.h>
#include <AzCore/EBus/EBus.h>
class IGameEffectSystem;
struct ITypeLibrary;
/**
* For requesting the GameEffectSystem.
*/
class GameEffectSystemRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
virtual IGameEffectSystem* GetIGameEffectSystem() = 0;
};
using GameEffectSystemRequestBus = AZ::EBus<GameEffectSystemRequests>;
/**
* Dispatches notifications from the GameEffectSystem.
*/
class GameEffectSystemNotifications
: public AZ::EBusTraits
{
public:
/// Called when it's appropriate to release all registered GameEffects
virtual void OnReleaseGameEffects() { }
};
using GameEffectSystemNotificationBus = AZ::EBus<GameEffectSystemNotifications>;
/// Returns global instance of IGameEffectSystem.
/// This function exists to support the legacy GAME_FX_SYSYTEM macro,
/// this is not the suggested way to fetch a singleton.
inline IGameEffectSystem& GetIGameEffectSystem()
{
IGameEffectSystem* instance = nullptr;
EBUS_EVENT_RESULT(instance, GameEffectSystemRequestBus, GetIGameEffectSystem);
return *instance;
}
class IGameEffectSystem
{
public:
virtual SC_API void RegisterEffect(IGameEffect* effect) = 0;
virtual SC_API void UnRegisterEffect(IGameEffect* effect) = 0;
virtual SC_API void GameRenderNodeInstanceReplaced(void* pOldInstance, void* pNewInstance) = 0;
virtual SC_API void GameRenderElementInstanceReplaced(void* pOldInstance, void* pNewInstance) = 0;
#ifdef SOFTCODE_ENABLED
// Create soft code instance using libs
virtual SC_API void* CreateSoftCodeInstance(const char* pTypeName);
// Register soft code lib for creation of instances
virtual SC_API void RegisterSoftCodeLib(ITypeLibrary* pLib);
#endif
SC_API static void RegisterEnteredGameCallback(EnteredGameCallback enteredGameCallback);
#ifdef DEBUG_GAME_FX_SYSTEM
SC_API static void RegisterEffectDebugData(DebugOnInputEventCallback inputEventCallback,
DebugDisplayCallback displayCallback,
const char* effectName);
#endif//DEBUG_GAME_FX_SYSTEM
};
#if DEBUG_GAME_FX_SYSTEM
// Creating a static version of SRegisterEffectDebugData inside an effect cpp registers the
// effect's debug data with the game effects system
struct SRegisterEffectDebugData
{
SRegisterEffectDebugData(DebugOnInputEventCallback inputEventCallback,
DebugDisplayCallback debugDisplayCallback, const char* effectName)
{
IGameEffectSystem::RegisterEffectDebugData(inputEventCallback, debugDisplayCallback,
effectName);
}
};
struct SEffectDebugData
{
SEffectDebugData(DebugOnInputEventCallback paramInputCallback,
DebugDisplayCallback paramDisplayCallback, const char* paramEffectName)
{
inputCallback = paramInputCallback;
displayCallback = paramDisplayCallback;
effectName = paramEffectName;
}
DebugOnInputEventCallback inputCallback;
DebugDisplayCallback displayCallback;
const char* effectName;
};
#endif//DEBUG_GAME_FX_SYSTEM
// Creating a static version of SRegisterGameCallbacks inside an effect cpp registers the
// effect's game callback functions with the game effects system
struct SRegisterGameCallbacks
{
SRegisterGameCallbacks(EnteredGameCallback enteredGameCallback)
{
IGameEffectSystem::RegisterEnteredGameCallback(enteredGameCallback);
}
};
//--------------------------------------------------------------------------------------------------
// Desc: Game Effect System Static data - contains access to any data where static initialisation
// order is critical, this will enforce initialisation on first use
//--------------------------------------------------------------------------------------------------
struct SGameEffectSystemStaticData
{
static PodArray<EnteredGameCallback>& GetEnteredGameCallbackList()
{
static PodArray<EnteredGameCallback> enteredGameCallbackList;
return enteredGameCallbackList;
}
#if DEBUG_GAME_FX_SYSTEM
static PodArray<SEffectDebugData>& GetEffectDebugList()
{
static PodArray<SEffectDebugData> effectDebugList;
return effectDebugList;
}
#endif//DEBUG_GAME_FX_SYSTEM
};
// Easy access macros
#define s_enteredGameCallbackList SGameEffectSystemStaticData::GetEnteredGameCallbackList()
#if DEBUG_GAME_FX_SYSTEM
#define s_effectDebugList SGameEffectSystemStaticData::GetEffectDebugList()
#endif//DEBUG_GAME_FX_SYSTEM
//--------------------------------------------------------------------------------------------------
// Name: RegisterEnteredGameCallback
// Desc: Registers entered game callback
//--------------------------------------------------------------------------------------------------
inline void IGameEffectSystem::RegisterEnteredGameCallback(EnteredGameCallback enteredGameCallback)
{
if (enteredGameCallback)
{
s_enteredGameCallbackList.push_back(enteredGameCallback);
}
} //-------------------------------------------------------------------------------------------------
#endif//_GAMEEFFECTSYSTEM_INTERFACE_H_
@@ -1,51 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _EFFECTS_RENDERNODES_IGAMERENDERNODE_H_
#define _EFFECTS_RENDERNODES_IGAMERENDERNODE_H_
#pragma once
#include <IEntityRenderState.h>
#include <TypeLibrary.h>
// Forward declares
struct IGameRenderNodeParams;
//==================================================================================================
// Name: IGameRenderNode
// Desc: Base interface for all game render nodes
// Author: James Chilvers
//==================================================================================================
struct IGameRenderNode
: public IRenderNode
, public _i_reference_target_t
{
DECLARE_TYPELIB(IGameRenderNode); // Allow soft coding on this interface
virtual ~IGameRenderNode() {}
virtual bool InitialiseGameRenderNode() = 0;
virtual void ReleaseGameRenderNode() = 0;
virtual void SetParams(const IGameRenderNodeParams* pParams = NULL) = 0;
}; //-----------------------------------------------------------------------------------------------
//==================================================================================================
// Name: IGameRenderNodeParams
// Desc: Game render node params
// Author: James Chilvers
//==================================================================================================
struct IGameRenderNodeParams
{
virtual ~IGameRenderNodeParams() {}
}; //------------------------------------------------------------------------------------------------
#endif//_EFFECTS_RENDERNODES_IGAMERENDERNODE_H_
@@ -1,79 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "GameEffectSystem_precompiled.h"
#include "GameEffectSystemGem.h"
namespace
{
/**
* Console command function for reloading the game effect system's data.
*/
void CmdReloadGameFx([[maybe_unused]] IConsoleCmdArgs* pArgs)
{
IGameEffectSystem* iGameEffectSystem = nullptr;
GameEffectSystemRequestBus::BroadcastResult(iGameEffectSystem, &GameEffectSystemRequestBus::Events::GetIGameEffectSystem);
if (iGameEffectSystem)
{
CGameEffectsSystem* cGameEffectsSystem = reinterpret_cast<CGameEffectsSystem*>(iGameEffectSystem);
cGameEffectsSystem->ReloadData();
}
}
}
GameEffectSystemGem::GameEffectSystemGem()
: CryHooksModule()
, m_gameEffectSystem(nullptr)
, g_gameFXSystemDebug(0)
{
GameEffectSystemRequestBus::Handler::BusConnect();
}
GameEffectSystemGem::~GameEffectSystemGem()
{
GameEffectSystemRequestBus::Handler::BusDisconnect();
}
void GameEffectSystemGem::OnSystemEvent(ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam)
{
switch (event)
{
case ESYSTEM_EVENT_GAME_POST_INIT:
// Put your init code here
// All other Gems will exist at this point
REGISTER_CVAR(g_gameFXSystemDebug, 0, 0, "Toggles game effects system debug state");
REGISTER_COMMAND("g_reloadGameFx", &CmdReloadGameFx, 0, "Reload all game fx");
m_gameEffectSystem = new CGameEffectsSystem();
m_gameEffectSystem->Initialize();
m_gameEffectSystem->LoadData();
break;
case ESYSTEM_EVENT_FULL_SHUTDOWN:
case ESYSTEM_EVENT_FAST_SHUTDOWN:
if (m_gameEffectSystem)
{
m_gameEffectSystem->ReleaseData();
m_gameEffectSystem->Destroy();
delete m_gameEffectSystem;
m_gameEffectSystem = nullptr;
}
break;
}
}
IGameEffectSystem* GameEffectSystemGem::GetIGameEffectSystem()
{
return m_gameEffectSystem;
}
AZ_DECLARE_MODULE_CLASS(Gem_GameEffectSystem, GameEffectSystemGem)
@@ -1,36 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _GEM_GAMEEFFECTSYSTEM_H_
#define _GEM_GAMEEFFECTSYSTEM_H_
#include "GameEffectsSystem.h"
class GameEffectSystemGem
: public CryHooksModule
, public GameEffectSystemRequestBus::Handler
{
public:
AZ_RTTI(GameEffectSystemGem, "{44350C39-A90B-46EB-AC1C-DB505113F4A6}", CryHooksModule);
public:
GameEffectSystemGem();
~GameEffectSystemGem() override;
void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
IGameEffectSystem* GetIGameEffectSystem() override;
private:
CGameEffectsSystem* m_gameEffectSystem;
int g_gameFXSystemDebug;
};
#endif//_GEM_GAMEEFFECTSYSTEM_H_
@@ -1,12 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "GameEffectSystem_precompiled.h"
@@ -1,21 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_
#define AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_
#include <platform.h>
#include <CryName.h>
#include <I3DEngine.h>
#include <ISerialize.h>
#include <IGem.h>
#endif//AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_
@@ -1,23 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
//==================================================================================================
// Name: GameEffectSoftCodeLibrary
// Desc: Game Effect Soft Code Library
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include "GameEffectSystem/GameEffectsSystemDefines.h"
#include "GameEffectSystem/GameEffects/IGameEffect.h"
IMPLEMENT_TYPELIB(IGameEffect, GAME_FX_LIBRARY_NAME); // Implementation of Soft Coding library
File diff suppressed because it is too large Load Diff
@@ -1,137 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _EFFECTS_GAMEEFFECTSSYSTEM_H_
#define _EFFECTS_GAMEEFFECTSSYSTEM_H_
#pragma once
// Includes
#include "GameEffectSystem/IGameEffectSystem.h"
#include "GameEffectSystem/GameEffectsSystemDefines.h"
#include <AzCore/Component/TickBus.h>
#include <AzFramework/Input/Events/InputChannelEventListener.h>
//==================================================================================================
// Name: CGameEffectsSystem
// Desc: System to handle game effects, game render nodes and game render elements
// Game effect: separates out effect logic from game logic
// Game render node: handles the render object in 3d space
// Game render element: handles the rendering of the object
// CVar activation system: system used to have data driven cvars activated in game
//effects
// Post effect activation system: system used to have data driven post effects
//activated in game effects
// Author: James Chilvers
//==================================================================================================
class CGameEffectsSystem
: public IGameEffectSystem
, public AzFramework::InputChannelEventListener
, public ISoftCodeListener
, public AZ::TickBus::Handler
{
friend struct SGameEffectSystemStaticData;
public:
void Destroy();
void Initialize();
void LoadData();
void ReleaseData();
template <class T>
T* CreateEffect() // Use if dynamic memory allocation is required for the game effect
{ // Using this function then allows easy changing of memory allocator for all dynamically
// created effects
T* newEffect = new T;
return newEffect;
}
// Each effect automatically registers and unregisters itself
SC_API void RegisterEffect(IGameEffect* effect) override;
SC_API void UnRegisterEffect(IGameEffect* effect) override;
void Update(float frameTime);
SC_API void RegisterGameRenderNode(IGameRenderNodePtr& pGameRenderNode);
SC_API void UnregisterGameRenderNode(IGameRenderNodePtr& pGameRenderNode);
SC_API void RegisterGameRenderElement(IGameRenderElementPtr& pGameRenderElement);
SC_API void UnregisterGameRenderElement(IGameRenderElementPtr& pGameRenderElement);
#ifdef SOFTCODE_ENABLED
SC_API void*
CreateSoftCodeInstance(const char* pTypeName) override; // Create soft code instance using libs
SC_API void
RegisterSoftCodeLib(ITypeLibrary* pLib) override; // Register soft code lib for creation of instances
#endif
bool OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) override;
// ISoftCodeListener implementation
void InstanceReplaced(void* pOldInstance, void* pNewInstance) override;
void GameRenderNodeInstanceReplaced(void* pOldInstance, void* pNewInstance) override;
void GameRenderElementInstanceReplaced(void* pOldInstance, void* pNewInstance) override;
// SGameRulesListener implementation
void GameRulesInitialise();
// #TODO: Have this receive events from GameRules
void EnteredGame();// override;
void ReloadData();
CGameEffectsSystem();
virtual ~CGameEffectsSystem();
// AZ::TickBus::Handler implementation
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
private:
void Reset();
void AutoReleaseAndDeleteFlaggedEffects(IGameEffect* effectList);
void AutoDeleteEffects(IGameEffect* effectList);
void SetPostEffectCVarCallbacks();
static void PostEffectCVarCallback(ICVar* cvar);
#if DEBUG_GAME_FX_SYSTEM
void DrawDebugDisplay();
void OnActivateDebugView(int debugView);
void OnDeActivateDebugView(int debugView);
int GetDebugView() const { return m_debugView; }
SC_API IGameEffect* GetDebugEffect(const char* pEffectName) const;
static int s_currentDebugEffectId;
int m_debugView;
#endif
static int s_postEffectCVarNameOffset;
#ifdef SOFTCODE_ENABLED
std::vector<ITypeLibrary*> m_softCodeTypeLibs;
typedef std::vector<IGameRenderNodePtr*> TGameRenderNodeVec;
TGameRenderNodeVec m_gameRenderNodes;
CGameRenderNodeSoftCodeListener* m_gameRenderNodeSoftCodeListener;
typedef std::vector<IGameRenderElementPtr*> TGameRenderElementVec;
TGameRenderElementVec m_gameRenderElements;
CGameRenderElementSoftCodeListener* m_gameRenderElementSoftCodeListener;
#endif
IGameEffect* m_effectsToUpdate;
IGameEffect* m_effectsNotToUpdate;
// If in update loop, this is the next effect to be updated this will get changed if the effect is unregistered
IGameEffect* m_nextEffectToUpdate;
bool m_isInitialised;
bool s_hasLoadedData;
}; //------------------------------------------------------------------------------------------------
#endif//_EFFECTS_GAMEEFFECTSSYSTEM_H_
@@ -1,79 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
//==================================================================================================
// Name: CGameRenderElement
// Desc: Base class for all game render elements
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include "GameRenderElement.h"
//--------------------------------------------------------------------------------------------------
// Name: CGameRenderElement
// Desc: Constructor
//--------------------------------------------------------------------------------------------------
CGameRenderElement::CGameRenderElement()
{
m_pREGameEffect = NULL;
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: InitialiseGameRenderElement
// Desc: Initialises game render element
//--------------------------------------------------------------------------------------------------
bool CGameRenderElement::InitialiseGameRenderElement()
{
m_pREGameEffect = (CREGameEffect*)gEnv->pRenderer->EF_CreateRE(eDATA_GameEffect);
if (m_pREGameEffect)
{
m_pREGameEffect->SetPrivateImplementation(this);
m_pREGameEffect->mfUpdateFlags(FCEF_TRANSFORM);
}
return true;
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: ReleaseGameRenderElement
// Desc: Releases game render element
//--------------------------------------------------------------------------------------------------
void CGameRenderElement::ReleaseGameRenderElement()
{
if (m_pREGameEffect)
{
m_pREGameEffect->SetPrivateImplementation(NULL);
m_pREGameEffect->Release(false);
}
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: UpdatePrivateImplementation
// Desc: Updates private implementation
//--------------------------------------------------------------------------------------------------
void CGameRenderElement::UpdatePrivateImplementation()
{
if (m_pREGameEffect)
{
m_pREGameEffect->SetPrivateImplementation(this);
}
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: GetCREGameEffect
// Desc: returns the game effect render element
//--------------------------------------------------------------------------------------------------
CREGameEffect* CGameRenderElement::GetCREGameEffect()
{
return m_pREGameEffect;
} //-------------------------------------------------------------------------------------------------
@@ -1,78 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef _EFFECTS_RENDERELEMENTS_GAMERENDERELEMENT_H_
#define _EFFECTS_RENDERELEMENTS_GAMERENDERELEMENT_H_
#pragma once
// Includes
#include "GameEffectsSystem.h"
#include <CREGameEffect.h>
// Forward declares
struct IGameRenderElementParams;
//==================================================================================================
// Name: IGameRenderElement
// Desc: Base interface for all game render elements
// Author: James Chilvers
//==================================================================================================
struct IGameRenderElement
: public IREGameEffect
, public _i_reference_target_t
{
DECLARE_TYPELIB(IGameRenderElement); // Allow soft coding on this interface
virtual ~IGameRenderElement() {}
virtual bool InitialiseGameRenderElement() = 0;
virtual void ReleaseGameRenderElement() = 0;
virtual void UpdatePrivateImplementation() = 0;
virtual CREGameEffect* GetCREGameEffect() = 0;
virtual IGameRenderElementParams* GetParams() = 0;
}; //------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: CGameRenderElement
// Desc: Base class for all game render elements
// Author: James Chilvers
//==================================================================================================
class CGameRenderElement
: public IGameRenderElement
{
DECLARE_TYPE(CGameRenderElement, IGameRenderElement); // Exposes this type for SoftCoding
public:
CGameRenderElement();
virtual ~CGameRenderElement() {}
virtual bool InitialiseGameRenderElement();
virtual void ReleaseGameRenderElement();
virtual void UpdatePrivateImplementation();
virtual CREGameEffect* GetCREGameEffect();
protected:
CREGameEffect* SOFT(m_pREGameEffect);
}; //------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: IGameRenderElementParams
// Desc: Game Render Element params
// Author: James Chilvers
//==================================================================================================
struct IGameRenderElementParams
{
virtual ~IGameRenderElementParams() {}
}; //------------------------------------------------------------------------------------------------
#endif//_EFFECTS_RENDERELEMENTS_GAMERENDERELEMENT_H_
@@ -1,24 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
//==================================================================================================
// Name: GameRenderElementSoftCodeLibrary
// Desc: Render Node Soft Code Library
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include <TypeLibrary.h>
#include "RenderElements/GameRenderElement.h"
IMPLEMENT_TYPELIB(IGameRenderElement,
GAME_RENDER_ELEMENT_LIBRARY_NAME); // Implementation of Soft Coding library
@@ -1,24 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
//==================================================================================================
// Name: GameRenderNodeSoftCodeLibrary
// Desc: Render Node Soft Code Library
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include <TypeLibrary.h>
#include <GameEffectSystem/IGameRenderNode.h>
#include <GameEffectSystem/GameEffectsSystemDefines.h>
IMPLEMENT_TYPELIB(IGameRenderNode, GAME_RENDER_NODE_LIBRARY_NAME); // Implementation of Soft Coding library
@@ -1,51 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef CRYINCLUDE_GAMEDLL_EFFECTS_RENDERNODES_IGAMERENDERNODE_H
#define CRYINCLUDE_GAMEDLL_EFFECTS_RENDERNODES_IGAMERENDERNODE_H
#pragma once
#include "Effects/RenderElements/GameRenderElement.h"
#include "Effects/GameEffectsSystem.h"
// Forward declares
struct IGameRenderNodeParams;
//==================================================================================================
// Name: IGameRenderNode
// Desc: Base interface for all game render nodes
// Author: James Chilvers
//==================================================================================================
struct IGameRenderNode
: public IRenderNode
, public _i_reference_target_t
{
DECLARE_TYPELIB(IGameRenderNode); // Allow soft coding on this interface
virtual ~IGameRenderNode() {}
virtual bool InitialiseGameRenderNode() = 0;
virtual void ReleaseGameRenderNode() = 0;
virtual void SetParams(const IGameRenderNodeParams* pParams = NULL) = 0;
}; //------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: IGameRenderNodeParams
// Desc: Game render node params
// Author: James Chilvers
//==================================================================================================
struct IGameRenderNodeParams
{
virtual ~IGameRenderNodeParams() {}
}; //------------------------------------------------------------------------------------------------
#endif // CRYINCLUDE_GAMEDLL_EFFECTS_RENDERNODES_IGAMERENDERNODE_H
-12
View File
@@ -1,12 +0,0 @@
{
"gem_name": "GameEffectSystem",
"GemFormatVersion": 3,
"LinkType": "DynamicStatic",
"Name": "GameEffectSystem",
"DisplayName": "Game Effect System",
"Summary": "Provides fundamentals for creating and managing visual effects.",
"Tags": ["Effects System"],
"Uuid": "d378b5a7b47747d0a7aa741945df58f3",
"Version": "1.0.0",
"IconPath": "preview.png"
}
@@ -27,7 +27,6 @@
#include <LyShine/Bus/UiCanvasManagerBus.h>
#include <ILevelSystem.h>
#include <I3DEngine.h>
#include <ISystem.h>
#include <IConsole.h>
@@ -59,10 +58,6 @@ namespace GameStateSamples
{
// Unload the currently loaded level
levelSystem->UnloadLevel();
if (iSystem->GetI3DEngine())
{
iSystem->GetI3DEngine()->LoadEmptyLevel();
}
}
}
@@ -13,5 +13,4 @@
#pragma once
#include <platform.h>
#include <I3DEngine.h>
#include <ISerialize.h>
-2
View File
@@ -24,7 +24,6 @@ ly_add_target(
Legacy::CryCommon
Gem::LmbrCentral
Gem::SurfaceData
Gem::ImageProcessing.Headers
Gem::ImageProcessingAtom.Headers
)
@@ -42,7 +41,6 @@ ly_add_target(
PRIVATE
Gem::GradientSignal.Static
PUBLIC
Gem::ImageProcessing.Headers # ImageProcessing/PixelFormats.h is part of a header in Includes
Gem::ImageProcessingAtom.Headers # Atom/ImageProcessing/PixelFormats.h is part of a header in Includes
RUNTIME_DEPENDENCIES
Gem::LmbrCentral
@@ -15,7 +15,7 @@
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzFramework/Asset/GenericAssetHandler.h>
#include <ImageProcessing/PixelFormats.h>
#include <Atom/ImageProcessing/PixelFormats.h>
namespace AZ
{
@@ -42,7 +42,7 @@ namespace GradientSignal
AZ::u32 m_imageWidth = 0;
AZ::u32 m_imageHeight = 0;
AZ::u8 m_bytesPerPixel = 0;
ImageProcessing::EPixelFormat m_imageFormat = ImageProcessing::EPixelFormat::ePixelFormat_Unknown;
ImageProcessingAtom::EPixelFormat m_imageFormat = ImageProcessingAtom::EPixelFormat::ePixelFormat_Unknown;
AZStd::vector<AZ::u8> m_imageData;
};
@@ -28,8 +28,6 @@
#include <QDirIterator>
#include <GradientSignalSystemComponent.h>
#include <GradientSignal/GradientImageConversion.h>
#include <ImageProcessing/ImageObject.h>
#include <ImageProcessing/ImageProcessingBus.h>
#include <Atom/ImageProcessing/ImageObject.h>
#include <Atom/ImageProcessing/ImageProcessingBus.h>
@@ -257,14 +255,6 @@ namespace GradientSignal
return AZ::Uuid::CreateString("{7520DF20-16CA-4CF6-A6DB-D96759A09EE4}");
}
static ImageProcessing::EPixelFormat AtomPixelFormatToLegacyPixelFormat(ImageProcessingAtom::EPixelFormat atomPixFormat)
{
// This could be dangerous to do if these enums have differences in the middle.
// So far the enumerations correspond 1-to-1. Worst case this could be changed into a massive switch block.
int pixelFormatInt = static_cast<int>(atomPixFormat);
return static_cast<ImageProcessing::EPixelFormat>(pixelFormatInt);
}
static AZStd::unique_ptr<ImageAsset> AtomLoadImageFromPath(const AZStd::string& fullPath)
{
ImageProcessingAtom::IImageObjectPtr imageObject;
@@ -286,7 +276,7 @@ namespace GradientSignal
imageAsset->m_imageWidth = imageObject->GetWidth(0);
imageAsset->m_imageHeight = imageObject->GetHeight(0);
imageAsset->m_imageFormat = AtomPixelFormatToLegacyPixelFormat(imageObject->GetPixelFormat());
imageAsset->m_imageFormat = imageObject->GetPixelFormat();
AZ::u8* mem = nullptr;
AZ::u32 pitch = 0;
@@ -13,7 +13,7 @@
#include "GradientSignal_precompiled.h"
#include <GradientSignal/GradientImageConversion.h>
#include <ImageProcessing/PixelFormats.h>
#include <Atom/ImageProcessing/PixelFormats.h>
namespace
{
@@ -25,10 +25,10 @@ namespace
constexpr auto A = 3;
}
ImageProcessing::EPixelFormat ExportFormatToPixelFormat(GradientSignal::ExportFormat format)
ImageProcessingAtom::EPixelFormat ExportFormatToPixelFormat(GradientSignal::ExportFormat format)
{
using namespace GradientSignal;
using namespace ImageProcessing;
using namespace ImageProcessingAtom;
switch (format)
{
@@ -49,29 +49,29 @@ namespace
}
}
template <ImageProcessing::EPixelFormat>
template <ImageProcessingAtom::EPixelFormat>
struct Underlying {};
template <>
struct Underlying<ImageProcessing::EPixelFormat::ePixelFormat_R8>
struct Underlying<ImageProcessingAtom::EPixelFormat::ePixelFormat_R8>
{
using type = AZ::u8;
};
template <>
struct Underlying<ImageProcessing::EPixelFormat::ePixelFormat_R16>
struct Underlying<ImageProcessingAtom::EPixelFormat::ePixelFormat_R16>
{
using type = AZ::u16;
};
template <>
struct Underlying<ImageProcessing::EPixelFormat::ePixelFormat_R32>
struct Underlying<ImageProcessingAtom::EPixelFormat::ePixelFormat_R32>
{
using type = AZ::u32;
};
template <>
struct Underlying<ImageProcessing::EPixelFormat::ePixelFormat_R32F>
struct Underlying<ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F>
{
using type = float;
};
@@ -167,10 +167,10 @@ namespace
buffer = AZStd::move(newBuffer);
}
template <ImageProcessing::EPixelFormat Old>
void ConvertBufferType(AZStd::vector<AZ::u8>& buffer, ImageProcessing::EPixelFormat newFormat, bool autoScale, AZStd::pair<float, float> userRange)
template <ImageProcessingAtom::EPixelFormat Old>
void ConvertBufferType(AZStd::vector<AZ::u8>& buffer, ImageProcessingAtom::EPixelFormat newFormat, bool autoScale, AZStd::pair<float, float> userRange)
{
using namespace ImageProcessing;
using namespace ImageProcessingAtom;
switch (newFormat)
{
@@ -195,9 +195,9 @@ namespace
}
}
ImageProcessing::EPixelFormat ConvertBufferType(AZStd::vector<AZ::u8>& buffer, ImageProcessing::EPixelFormat old, ImageProcessing::EPixelFormat newFormat, bool autoScale, AZStd::pair<float, float> userRange)
ImageProcessingAtom::EPixelFormat ConvertBufferType(AZStd::vector<AZ::u8>& buffer, ImageProcessingAtom::EPixelFormat old, ImageProcessingAtom::EPixelFormat newFormat, bool autoScale, AZStd::pair<float, float> userRange)
{
using namespace ImageProcessing;
using namespace ImageProcessingAtom;
switch (old)
{
@@ -356,9 +356,9 @@ namespace
mem.resize(mem.size() / channels);
}
AZStd::size_t GetChannels(ImageProcessing::EPixelFormat format)
AZStd::size_t GetChannels(ImageProcessingAtom::EPixelFormat format)
{
using namespace ImageProcessing;
using namespace ImageProcessingAtom;
switch (format)
{
@@ -379,10 +379,10 @@ namespace
}
template <template <typename> typename Op>
ImageProcessing::EPixelFormat CallHelper(ImageProcessing::EPixelFormat format,
ImageProcessingAtom::EPixelFormat CallHelper(ImageProcessingAtom::EPixelFormat format,
GradientSignal::ChannelMask mask, GradientSignal::AlphaExportTransform alphaTransform, AZStd::vector<AZ::u8>& mem)
{
using namespace ImageProcessing;
using namespace ImageProcessingAtom;
switch (format)
{
@@ -447,7 +447,7 @@ namespace
}
};
ImageProcessing::EPixelFormat OperationHelper(GradientSignal::ChannelExportTransform op, ImageProcessing::EPixelFormat format,
ImageProcessingAtom::EPixelFormat OperationHelper(GradientSignal::ChannelExportTransform op, ImageProcessingAtom::EPixelFormat format,
GradientSignal::ChannelMask mask, GradientSignal::AlphaExportTransform alphaTransform, AZStd::vector<AZ::u8>& mem)
{
switch (op)
+11 -11
View File
@@ -19,32 +19,32 @@
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/Debug/Profiler.h>
#include <ImageProcessing/PixelFormats.h>
#include <Atom/ImageProcessing/PixelFormats.h>
#include <GradientSignal/Util.h>
#include <numeric>
namespace
{
template <ImageProcessing::EPixelFormat>
template <ImageProcessingAtom::EPixelFormat>
float RetrieveValue(const AZ::u8* mem, size_t index)
{
AZ_Assert(false, "Unimplemented!");
}
template <>
float RetrieveValue<ImageProcessing::EPixelFormat::ePixelFormat_Unknown>([[maybe_unused]] const AZ::u8* mem, [[maybe_unused]] size_t index)
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_Unknown>([[maybe_unused]] const AZ::u8* mem, [[maybe_unused]] size_t index)
{
return 0.0f;
}
template <>
float RetrieveValue<ImageProcessing::EPixelFormat::ePixelFormat_R8>(const AZ::u8* mem, size_t index)
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R8>(const AZ::u8* mem, size_t index)
{
return mem[index] / static_cast<float>(std::numeric_limits<AZ::u8>::max());
}
template <>
float RetrieveValue<ImageProcessing::EPixelFormat::ePixelFormat_R16>(const AZ::u8* mem, size_t index)
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R16>(const AZ::u8* mem, size_t index)
{
// 16 bits per channel
auto actualMem = reinterpret_cast<const AZ::u16*>(mem);
@@ -54,7 +54,7 @@ namespace
}
template <>
float RetrieveValue<ImageProcessing::EPixelFormat::ePixelFormat_R32>(const AZ::u8* mem, size_t index)
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R32>(const AZ::u8* mem, size_t index)
{
// 32 bits per channel
auto actualMem = reinterpret_cast<const AZ::u32*>(mem);
@@ -64,7 +64,7 @@ namespace
}
template <>
float RetrieveValue<ImageProcessing::EPixelFormat::ePixelFormat_R32F>(const AZ::u8* mem, size_t index)
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F>(const AZ::u8* mem, size_t index)
{
// 32 bits per channel
auto actualMem = reinterpret_cast<const float*>(mem);
@@ -73,9 +73,9 @@ namespace
return *actualMem;
}
float RetrieveValue(const AZ::u8* mem, size_t index, ImageProcessing::EPixelFormat format)
float RetrieveValue(const AZ::u8* mem, size_t index, ImageProcessingAtom::EPixelFormat format)
{
using namespace ImageProcessing;
using namespace ImageProcessingAtom;
switch (format)
{
@@ -142,9 +142,9 @@ namespace GradientSignal
}
AZ::SerializeContext::DataElementNode& format = classElement.GetSubElement(formatIndex);
if (format.Convert<ImageProcessing::EPixelFormat>(context))
if (format.Convert<ImageProcessingAtom::EPixelFormat>(context))
{
format.SetData<ImageProcessing::EPixelFormat>(context, ImageProcessing::EPixelFormat::ePixelFormat_R8);
format.SetData<ImageProcessingAtom::EPixelFormat>(context, ImageProcessingAtom::EPixelFormat::ePixelFormat_R8);
}
int bppIndex = classElement.AddElement<AZ::u8>(context, "BytesPerPixel");
@@ -116,7 +116,7 @@ namespace UnitTest
m_imageData->m_imageWidth = width;
m_imageData->m_imageHeight = height;
m_imageData->m_bytesPerPixel = 1;
m_imageData->m_imageFormat = ImageProcessing::EPixelFormat::ePixelFormat_R8;
m_imageData->m_imageFormat = ImageProcessingAtom::EPixelFormat::ePixelFormat_R8;
size_t value = 0;
AZStd::hash_combine(value, seed);
@@ -141,7 +141,7 @@ namespace UnitTest
m_imageData->m_imageWidth = width;
m_imageData->m_imageHeight = height;
m_imageData->m_bytesPerPixel = 1;
m_imageData->m_imageFormat = ImageProcessing::EPixelFormat::ePixelFormat_R8;
m_imageData->m_imageFormat = ImageProcessingAtom::EPixelFormat::ePixelFormat_R8;
const AZ::u8 pixelValue = 255;
@@ -39,7 +39,7 @@ namespace
template <typename T, AZStd::size_t Len>
auto SetupAssetAndConvert(const AZStd::array<T, Len>& data, AZ::u32 dimensions,
ImageProcessing::EPixelFormat format, AZStd::size_t bytesPerPixel, const GradientSignal::ImageSettings& settings)
ImageProcessingAtom::EPixelFormat format, AZStd::size_t bytesPerPixel, const GradientSignal::ImageSettings& settings)
{
GradientSignal::ImageAsset asset;
@@ -121,7 +121,7 @@ namespace
auto inputData = Detail::GenerateInput<AZ::u8, imageDimensions, numChannels>(scaling);
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R8, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R8, bytesPerPixel,
settings);
AZStd::array<AZ::u8, outputSize> expectedValues;
@@ -165,7 +165,7 @@ namespace
auto inputData = Detail::GenerateInput<float, imageDimensions, numChannels>();
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R32G32B32A32F, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R32G32B32A32F, bytesPerPixel,
settings);
AZStd::array<float, outputSize> expectedValues;
@@ -215,7 +215,7 @@ namespace
auto inputData = Detail::GenerateInput<AZ::u8, imageDimensions, numChannels>();
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R8G8, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R8G8, bytesPerPixel,
settings);
// max(N, N + 1) = N + 1
@@ -263,7 +263,7 @@ namespace
auto inputData = Detail::GenerateInput<float, imageDimensions, numChannels>();
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R32F, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F, bytesPerPixel,
settings);
// 0 - 8 range
@@ -310,7 +310,7 @@ namespace
auto inputData = Detail::GenerateInput<AZ::u16, imageDimensions, numChannels>(scaling);
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R16G16B16A16, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R16G16B16A16, bytesPerPixel,
settings);
// Scaled = N * 100
@@ -344,7 +344,7 @@ namespace
settings.m_autoScale = true;
asset = Detail::SetupAssetAndConvert(expectedValues, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R32, sizeof(AZ::u32),
ImageProcessingAtom::EPixelFormat::ePixelFormat_R32, sizeof(AZ::u32),
settings);
// Similar process as above.
@@ -392,7 +392,7 @@ namespace
auto inputData = Detail::GenerateInput<float, imageDimensions, numChannels>(-100.0f);
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R32F, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F, bytesPerPixel,
settings);
// min-max equal to 1000 -> all values get scaled
@@ -433,14 +433,14 @@ namespace
auto inputData = Detail::GenerateInput<float, imageDimensions, numChannels>();
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R32F, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F, bytesPerPixel,
settings);
EXPECT_TRUE(asset->m_imageData.empty());
}
template<typename TType, typename TImageDimension, AZStd::size_t outputSize>
void testCommon(GradientSignal::ExportFormat outFormat, ImageProcessing::EPixelFormat pFormat, const AZStd::array<TType, outputSize>& goldenValues)
void testCommon(GradientSignal::ExportFormat outFormat, ImageProcessingAtom::EPixelFormat pFormat, const AZStd::array<TType, outputSize>& goldenValues)
{
using namespace GradientSignal;
@@ -521,10 +521,10 @@ namespace
1.0f
};
testCommon<AZ::u8, decltype(imageDimensions), outputSize>(ExportFormat::U8, ImageProcessing::EPixelFormat::ePixelFormat_R8, goldenValues1);
testCommon<AZ::u16, decltype(imageDimensions), outputSize>(ExportFormat::U16, ImageProcessing::EPixelFormat::ePixelFormat_R16, goldenValues2);
testCommon<AZ::u32, decltype(imageDimensions), outputSize>(ExportFormat::U32, ImageProcessing::EPixelFormat::ePixelFormat_R32, goldenValues3);
testCommon<float, decltype(imageDimensions), outputSize>(ExportFormat::F32, ImageProcessing::EPixelFormat::ePixelFormat_R32F, goldenValues4);
testCommon<AZ::u8, decltype(imageDimensions), outputSize>(ExportFormat::U8, ImageProcessingAtom::EPixelFormat::ePixelFormat_R8, goldenValues1);
testCommon<AZ::u16, decltype(imageDimensions), outputSize>(ExportFormat::U16, ImageProcessingAtom::EPixelFormat::ePixelFormat_R16, goldenValues2);
testCommon<AZ::u32, decltype(imageDimensions), outputSize>(ExportFormat::U32, ImageProcessingAtom::EPixelFormat::ePixelFormat_R32, goldenValues3);
testCommon<float, decltype(imageDimensions), outputSize>(ExportFormat::F32, ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F, goldenValues4);
}
TEST_F(ImageAssetTest, GradientImageAssetTransformsSuccessful)
@@ -551,7 +551,7 @@ namespace
auto inputData = Detail::GenerateInput<AZ::u16, imageDimensions, numChannels>();
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R16G16B16A16, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R16G16B16A16, bytesPerPixel,
settings);
// 0, 1, 2, ... -> (RGB / 3 + A) = 2N + 4
@@ -573,7 +573,7 @@ namespace
settings.m_useB = false;
asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R16G16B16A16, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R16G16B16A16, bytesPerPixel,
settings);
// Assertion: (N + N + 1) / 2 - (N + 3) = -5 / 2
@@ -637,7 +637,7 @@ namespace
auto inputData = Detail::GenerateInput<float, imageDimensions, numChannels>();
auto asset = Detail::SetupAssetAndConvert(inputData, imageDimensions,
ImageProcessing::EPixelFormat::ePixelFormat_R32G32B32A32F, bytesPerPixel,
ImageProcessingAtom::EPixelFormat::ePixelFormat_R32G32B32A32F, bytesPerPixel,
settings);
// 0 - 400, (red * 256 + green + blue / 256) - 32768
-4
View File
@@ -146,8 +146,6 @@ void ImGuiViewportWidget::Render()
IEditor* editor = nullptr;
EBUS_EVENT_RESULT(editor, AzToolsFramework::EditorRequests::Bus, GetEditor);
editor->GetEnv()->pSystem->RenderBegin();
IRenderer* renderer = editor->GetEnv()->pRenderer;
ColorF viewportBackgroundColor(Col_Gray);
@@ -276,8 +274,6 @@ void ImGuiViewportWidget::Render()
renderer->Unset2DMode(backupSceneMatrices);
}
bool renderStats = false;
editor->GetEnv()->pSystem->RenderEnd(renderStats, false);
RestorePreviousContext();
}
+1
View File
@@ -17,6 +17,7 @@
#include <AzCore/std/containers/stack.h>
#include <AzCore/std/containers/vector.h>
#include <Cry_Math.h>
#include <Cry_Camera.h>
#include <VertexFormats.h>
#endif
@@ -15,6 +15,8 @@
#ifdef IMGUI_ENABLED
#include "imgui/imgui.h"
#include <IConsole.h>
namespace ImGui
{
namespace LYImGuiUtils
+2 -2
View File
@@ -26,6 +26,8 @@
#include <AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h>
#include <AzFramework/Input/Devices/Touch/InputDeviceTouch.h>
#include <AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h>
#include <IConsole.h>
#include <ITimer.h>
#include <imgui/imgui_internal.h>
#include <sstream>
#include <string>
@@ -377,8 +379,6 @@ void ImGuiManager::Render()
io.DeltaTime = gEnv->pTimer->GetFrameTime();
//// END FROM PREUPDATE
TransformationMatrices backupSceneMatrices;
AZ::u32 backBufferWidth = m_windowSize.m_width;
AZ::u32 backBufferHeight = m_windowSize.m_height;
@@ -13,6 +13,5 @@
#include <platform.h>
#include <CryName.h>
#include <I3DEngine.h>
#include <ISerialize.h>
#include <IGem.h>
@@ -24,6 +24,7 @@
#include <LmbrCentral/Rendering/RenderNodeBus.h>
#include <IRenderAuxGeom.h>
#include <IViewSystem.h>
#include <IConsole.h>
#include "ImGuiColorDefines.h"
@@ -14,6 +14,5 @@
#include <platform.h>
#include <CryName.h>
#include <I3DEngine.h>
#include <ISerialize.h>
#include <IGem.h>
@@ -87,9 +87,6 @@
#include "Shape/SplineComponent.h"
#include "Shape/PolygonPrismShapeComponent.h"
// Cry interfaces.
#include <I3DEngine.h>
namespace LmbrCentral
{
static const char* s_assetCatalogFilename = "assetcatalog.xml";
@@ -473,20 +470,6 @@ namespace LmbrCentral
m_allocatorShutdowns.clear();
}
void LmbrCentralSystemComponent::OnAssetEventsDispatchEnd()
{
AZ_Assert((!gEnv) || (gEnv->mMainThreadId == CryGetCurrentThreadId()), "OnAssetEventsDispatchEnd from a non-main thread - the AssetBus should only be called from the main thread!");
// Pump deferred engine loading events.
if (gEnv && gEnv->mMainThreadId == CryGetCurrentThreadId())
{
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->ProcessAsyncStaticObjectLoadRequests();
}
}
}
void LmbrCentralSystemComponent::OnCrySystemPreInitialize([[maybe_unused]] ISystem& system, [[maybe_unused]] const SSystemInitParams& systemInitParams)
{
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, StartMonitoringAssets);
@@ -82,11 +82,6 @@ namespace LmbrCentral
void OnCrySystemShutdown(ISystem& system) override;
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// AZ::Data::AssetManagerNotificationBus::Handler
//////////////////////////////////////////////////////////////////////////
void OnAssetEventsDispatchEnd() override;
AZStd::vector<AZStd::unique_ptr<AZ::Data::AssetHandler> > m_assetHandlers;
AZStd::vector<AZStd::unique_ptr<AZ::AssetTypeInfoBus::Handler> > m_unhandledAssetInfo;
AZStd::vector<AZStd::function<void()>> m_allocatorShutdowns;
@@ -54,11 +54,6 @@ namespace LmbrCentral
return "Icons/Components/Decal.svg";
}
AZ::Uuid MaterialAssetTypeInfo::GetComponentTypeId() const
{
return AZ::Uuid("{BA3890BD-D2E7-4DB6-95CD-7E7D5525567A}");
}
// DccMaterialAssetTypeInfo
DccMaterialAssetTypeInfo::~DccMaterialAssetTypeInfo()
@@ -30,7 +30,6 @@ namespace LmbrCentral
const char* GetAssetTypeDisplayName() const override;
const char* GetGroup() const override;
const char* GetBrowserIcon() const override;
AZ::Uuid GetComponentTypeId() const override;
//////////////////////////////////////////////////////////////////////////////////////////////
void Register();
@@ -1,349 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <LmbrCentral/Rendering/MaterialOwnerBus.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Math/Color.h>
#include <IEntityRenderState.h>
#include <I3DEngine.h>
struct IRenderNode;
namespace LmbrCentral
{
//! This is helper class to provide common implementation for the MaterialOwnerRequests interface
//! that will be needed by most components that have materials.
//! This does not actually inherit the MaterialOwnerRequestBus::Handler interface because it is
//! not intended to subscribe to that bus, but it does provide implementations for all the same functions.
class MaterialOwnerRequestBusHandlerImpl
: public AZ::TickBus::Handler
, public MaterialOwnerRequestBus::Handler
{
using MaterialPtr = _smart_ptr < IMaterial >;
public:
AZ_CLASS_ALLOCATOR(MaterialOwnerRequestBusHandlerImpl, AZ::SystemAllocator, 0);
//! Initializes the MaterialOwnerRequestBusHandlerImpl, to be called when the Material owner is activated.
//! \param renderNode holds the active material that will be manipulated
//! \param entityId ID of the entity that has the Material owner
//! \param registerBus Signals to this impl that it should connect to the MaterialOwnerRequestBus on the specified id.
//
// Ideally this would be apart of the normal activate, but to keep old behavior consistent
// going to add an extra flow into this to maintain the current workflows of:
// DecalComponent and MeshComponent
//
// While still allowing a nicer interface for ActorComponent to utilize.
void Activate(IRenderNode* renderNode, const AZ::EntityId& entityId, bool registerBus = false)
{
m_clonedMaterial = nullptr;
m_renderNode = renderNode;
m_readyEventSent = false;
MaterialOwnerNotificationBus::Bind(m_notificationBus, entityId);
if (m_renderNode)
{
if (m_renderNode->IsReady())
{
// For some material owner types (like DecalComponent), the material is ready immediately. But we can't
// send the event yet because components are still being Activated, so we delay until the first tick.
AZ::TickBus::Handler::BusConnect();
}
if (registerBus)
{
MaterialOwnerRequestBus::Handler::BusConnect(entityId);
}
}
}
void Deactivate()
{
m_notificationBus = nullptr;
MaterialOwnerRequestBus::Handler::BusDisconnect();
AZ::TickBus::Handler::BusDisconnect();
}
//! Returns whether the Material has been cloned. MaterialOwnerRequestBusHandlerImpl clones the IRenderNode's Material
//! rather than modify the original to avoid affecting other entities in the scene.
bool IsMaterialCloned() const
{
return nullptr != m_clonedMaterial;
}
void SetMaterialHandle(const MaterialHandle& materialHandle)
{
SetMaterial(materialHandle.m_material);
}
MaterialHandle GetMaterialHandle()
{
MaterialHandle m;
m.m_material = GetMaterial();
return m;
}
//////////////////////////////////////////////////////////////////////////
// MaterialOwnerRequestBus interface implementation
bool IsMaterialOwnerReady() override
{
return m_renderNode && m_renderNode->IsReady();
}
void SetMaterial(MaterialPtr material) override
{
if (m_renderNode)
{
if (material && material->IsSubMaterial())
{
AZ_Error("MaterialOwnerRequestBus", false, "Material Owner cannot be given a Sub-Material.");
}
else
{
m_clonedMaterial = nullptr;
m_renderNode->SetMaterial(material);
}
}
}
MaterialPtr GetMaterial() override
{
MaterialPtr material = nullptr;
if (m_renderNode)
{
material = m_renderNode->GetMaterial();
if (!m_renderNode->IsReady())
{
if (material)
{
AZ_Warning("MaterialOwnerRequestBus", false, "A Material was found, but Material Owner is not ready. May have unexpected results. (Try using MaterialOwnerNotificationBus.OnMaterialOwnerReady or MaterialOwnerRequestBus.IsMaterialOwnerReady)");
}
else
{
AZ_Error("MaterialOwnerRequestBus", false, "Material Owner is not ready and no Material was found. Assets probably have not finished loading yet. (Try using MaterialOwnerNotificationBus.OnMaterialOwnerReady or MaterialOwnerRequestBus.IsMaterialOwnerReady)");
}
}
AZ_Assert(nullptr == m_clonedMaterial || material == m_clonedMaterial, "MaterialOwnerRequestBusHandlerImpl and RenderNode are out of sync");
}
return material;
}
void SetMaterialParamVector4(const AZStd::string& name, const AZ::Vector4& value, int materialId = 1) override
{
if (GetMaterial())
{
CloneMaterial();
const int materialIndex = materialId - 1;
Vec4 vec4(value.GetX(), value.GetY(), value.GetZ(), value.GetW());
const bool success = GetMaterial()->SetGetMaterialParamVec4(name.c_str(), vec4, false, true, materialIndex);
AZ_Error("Material Owner", success, "Failed to set Material ID %d, param '%s'.", materialId, name.c_str());
}
}
void SetMaterialParamVector3(const AZStd::string& name, const AZ::Vector3& value, int materialId = 1) override
{
if (GetMaterial())
{
CloneMaterial();
const int materialIndex = materialId - 1;
Vec3 vec3(value.GetX(), value.GetY(), value.GetZ());
const bool success = GetMaterial()->SetGetMaterialParamVec3(name.c_str(), vec3, false, true, materialIndex);
AZ_Error("Material Owner", success, "Failed to set Material ID %d, param '%s'.", materialId, name.c_str());
}
}
void SetMaterialParamColor(const AZStd::string& name, const AZ::Color& value, int materialId = 1) override
{
if (GetMaterial())
{
// When value had garbage data is was not only making the material render black, it also corrupted something
// on the GPU, making black boxes flicker over the sky.
// It was garbage due to a bug in the Color object node where all fields have to be set to some value manually; the default is not 0.
if ((value.GetR() < 0 || value.GetR() > 1) ||
(value.GetG() < 0 || value.GetG() > 1) ||
(value.GetB() < 0 || value.GetB() > 1) ||
(value.GetA() < 0 || value.GetA() > 1))
{
return;
}
CloneMaterial();
const int materialIndex = materialId - 1;
Vec4 vec4(value.GetR(), value.GetG(), value.GetB(), value.GetA());
const bool success = GetMaterial()->SetGetMaterialParamVec4(name.c_str(), vec4, false, true, materialIndex);
AZ_Error("Material Owner", success, "Failed to set Material ID %d, param '%s'.", materialId, name.c_str());
}
}
void SetMaterialParamFloat(const AZStd::string& name, float value, int materialId = 1) override
{
if (GetMaterial())
{
if (!IsMaterialCloned())
{
CloneMaterial();
}
const int materialIndex = materialId - 1;
const bool success = GetMaterial()->SetGetMaterialParamFloat(name.c_str(), value, false, true, materialIndex);
AZ_Error("Material Owner", success, "Failed to set Material ID %d, param '%s'.", materialId, name.c_str());
}
}
AZ::Vector4 GetMaterialParamVector4(const AZStd::string& name, int materialId = 1) override
{
AZ::Vector4 value = AZ::Vector4::CreateZero();
MaterialPtr material = GetMaterial();
if (material)
{
const int materialIndex = materialId - 1;
Vec4 vec4;
if (material->SetGetMaterialParamVec4(name.c_str(), vec4, true, true, materialIndex))
{
value.Set(vec4.x, vec4.y, vec4.z, vec4.w);
}
else
{
AZ_Error("Material Owner", false, "Failed to read Material ID %d, param '%s'.", materialId, name.c_str());
}
}
return value;
}
AZ::Vector3 GetMaterialParamVector3(const AZStd::string& name, int materialId = 1) override
{
AZ::Vector3 value = AZ::Vector3::CreateZero();
MaterialPtr material = GetMaterial();
if (material)
{
const int materialIndex = materialId - 1;
Vec3 vec3;
if (material->SetGetMaterialParamVec3(name.c_str(), vec3, true, true, materialIndex))
{
value.Set(vec3.x, vec3.y, vec3.z);
}
else
{
AZ_Error("Material Owner", false, "Failed to read Material ID %d, param '%s'.", materialId, name.c_str());
}
}
return value;
}
AZ::Color GetMaterialParamColor(const AZStd::string& name, int materialId = 1) override
{
AZ::Color value = AZ::Color::CreateZero();
MaterialPtr material = GetMaterial();
if (material)
{
const int materialIndex = materialId - 1;
Vec4 vec4;
if (material->SetGetMaterialParamVec4(name.c_str(), vec4, true, true, materialIndex))
{
value.Set(vec4.x, vec4.y, vec4.z, vec4.w);
}
else
{
AZ_Error("Material Owner", false, "Failed to read Material ID %d, param '%s'.", materialId, name.c_str());
}
}
return value;
}
float GetMaterialParamFloat(const AZStd::string& name, int materialId = 1) override
{
float value = 0.0f;
MaterialPtr material = GetMaterial();
if (material)
{
const int materialIndex = materialId - 1;
const bool success = material->SetGetMaterialParamFloat(name.c_str(), value, true, true, materialIndex);
AZ_Error("Material Owner", success, "Failed to read Material ID %d, param '%s'.", materialId, name.c_str());
}
return value;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// TickBus interface implementation
void OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) override
{
if (!m_readyEventSent && IsMaterialOwnerReady())
{
SendReadyEvent();
AZ::TickBus::Handler::BusDisconnect();
}
}
//////////////////////////////////////////////////////////////////////////
private:
//! Clones the active material and applies it to the IRenderNode
void CloneMaterial()
{
if (!IsMaterialCloned())
{
CloneMaterial(GetMaterial());
}
}
//! Clones the specified material and applies it to the IRenderNode
void CloneMaterial(MaterialPtr material)
{
if (material && m_renderNode)
{
AZ_Assert(nullptr == m_clonedMaterial, "Material has already been cloned. This operation is wasteful.");
m_clonedMaterial = gEnv->p3DEngine->GetMaterialManager()->CloneMultiMaterial(material);
AZ_Assert(m_clonedMaterial, "Failed to clone material. The original will be used.");
if (m_clonedMaterial)
{
m_renderNode->SetMaterial(m_clonedMaterial);
}
}
}
//! Send the OnMaterialOwnerReady event
void SendReadyEvent()
{
AZ_Assert(!m_readyEventSent, "OnMaterialOwnerReady already sent");
if (!m_readyEventSent)
{
m_readyEventSent = true;
MaterialOwnerNotificationBus::Event(m_notificationBus, &MaterialOwnerNotifications::OnMaterialOwnerReady);
}
}
MaterialOwnerNotificationBus::BusPtr m_notificationBus = nullptr; //!< Cached bus pointer to the notification bus.
IRenderNode* m_renderNode = nullptr; //!< IRenderNode which holds the active material that will be manipulated.
MaterialPtr m_clonedMaterial = nullptr; //!< The component's material can be cloned here to make a copy that is unique to this component.
bool m_readyEventSent = false; //! Tracks whether OnMaterialOwnerReady has been sent yet.
};
} // namespace LmbrCentral
@@ -45,7 +45,6 @@ set(FILES
include/LmbrCentral/Rendering/RenderNodeBus.h
include/LmbrCentral/Rendering/GiRegistrationBus.h
include/LmbrCentral/Rendering/RenderBoundsBus.h
include/LmbrCentral/Rendering/Utils/MaterialOwnerRequestBusHandlerImpl.h
include/LmbrCentral/Scripting/EditorTagComponentBus.h
include/LmbrCentral/Scripting/GameplayNotificationBus.h
include/LmbrCentral/Scripting/SimpleStateComponentBus.h
@@ -1332,12 +1332,6 @@ void CUiAnimViewDialog::OnEditorNotifyEvent(EEditorNotifyEvent event)
case eNotify_OnEndGameMode:
m_bIgnoreUpdates = false;
break;
case eNotify_OnMissionChange:
if (!m_bIgnoreUpdates)
{
ReloadSequences();
}
break;
case eNotify_OnIdleUpdate:
if (!m_bIgnoreUpdates)
{
@@ -680,26 +680,7 @@ void CUiAnimViewNodesCtrl::UpdateUiAnimNodeRecord(CRecord* pRecord, CUiAnimViewA
}
else if (nodeType == eUiAnimNodeType_Material)
{
// Check if a valid material can be found by the node name.
_smart_ptr<IMaterial> pMaterial = nullptr;
QString matName;
int subMtlIndex = GetMatNameAndSubMtlIndexFromName(matName, pAnimNode->GetName());
pMaterial = gEnv->p3DEngine->GetMaterialManager()->FindMaterial(matName.toUtf8().data());
if (pMaterial)
{
bool bMultiMat = pMaterial->GetSubMtlCount() > 0;
bool bMultiMatWithoutValidIndex = bMultiMat && (subMtlIndex < 0 || subMtlIndex >= pMaterial->GetSubMtlCount());
bool bLeafMatWithIndex = !bMultiMat && subMtlIndex != -1;
if (bMultiMatWithoutValidIndex || bLeafMatWithIndex)
{
pMaterial = nullptr;
}
}
if (!pMaterial)
{
pRecord->setForeground(0, TEXT_COLOR_FOR_INVALID_MATERIAL);
}
pRecord->setForeground(0, TEXT_COLOR_FOR_INVALID_MATERIAL);
}
// Mark the active director and other directors properly.
@@ -1309,44 +1290,6 @@ int CUiAnimViewNodesCtrl::ShowPopupMenuSingleSelection(UiAnimContextMenu& contex
bAppended = true;
}
// Sub material menu
if (bOnNode && pAnimNode->GetType() == eUiAnimNodeType_Material)
{
QString matName;
int subMtlIndex = GetMatNameAndSubMtlIndexFromName(matName, pAnimNode->GetName());
_smart_ptr<IMaterial> pMtl = gEnv->p3DEngine->GetMaterialManager()->FindMaterial(matName.toUtf8().data());
bool bMultMatNode = pMtl ? pMtl->GetSubMtlCount() > 0 : false;
bool bMatAppended = false;
if (bMultMatNode)
{
for (int k = 0; k < pMtl->GetSubMtlCount(); ++k)
{
_smart_ptr<IMaterial> pSubMaterial = pMtl->GetSubMtl(k);
if (pSubMaterial)
{
QString subMaterialName = pSubMaterial->GetName();
if (!subMaterialName.isEmpty())
{
AddMenuSeperatorConditional(contextMenu.main, bAppended);
QString subMatName = QString("[%1] %2").arg(k + 1).arg(subMaterialName);
QAction* a = contextMenu.main.addAction(subMatName);
a->setData(eMI_SelectSubmaterialBase + k);
a->setCheckable(true);
a->setChecked(k == subMtlIndex);
bMatAppended = true;
}
}
}
}
bAppended = bAppended || bMatAppended;
}
#if UI_ANIMATION_REMOVED
// We have removed support for saving out the custom colors per track
// it may be added back at some point
@@ -22,7 +22,6 @@
#include "CompoundSplineTrack.h"
#include <AzCore/std/sort.h>
#include <I3DEngine.h>
#include <ctime>
//////////////////////////////////////////////////////////////////////////
@@ -20,7 +20,6 @@
#include "StlUtils.h"
#include "EventNode.h"
#include "I3DEngine.h"
#include "AzEntityNode.h"
#include "UiAnimSerialize.h"
-1
View File
@@ -16,7 +16,6 @@
#include <Mocks/ISystemMock.h>
#include <Mocks/IRendererMock.h>
#include <Mocks/ITextureMock.h>
#include <I3DEngine.h> // needed for SRenderingPassInfo
#include <Sprite.h>
namespace UnitTest

Some files were not shown because too many files have changed in this diff Show More