You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/PhysX/Code/Source/Configuration/PhysXSettingsRegistryManage...

123 lines
4.8 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* a third party where indicated.
*
* 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 <PhysX_precompiled.h>
#include <Configuration/PhysXSettingsRegistryManager.h>
#include <AzCore/Settings/SettingsRegistry.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzFramework/Physics/Configuration/CollisionConfiguration.h>
namespace PhysX
{
PhysXSettingsRegistryManager::PhysXSettingsRegistryManager()
{
m_settingsRegistryPath = AZStd::string::format("%s/Gems/PhysX/PhysXSystemConfiguration", AZ::SettingsRegistryMergeUtils::OrganizationRootKey);
m_defaultSceneConfigSettingsRegistryPath = AZStd::string::format("%s/Gems/PhysX/DefaultSceneConfiguration", AZ::SettingsRegistryMergeUtils::OrganizationRootKey);
m_debugSettingsRegistryPath = AZStd::string::format("%s/Gems/PhysX/Debug/PhysXDebugConfiguration", AZ::SettingsRegistryMergeUtils::OrganizationRootKey);
}
AZStd::optional<PhysXSystemConfiguration> PhysXSettingsRegistryManager::LoadSystemConfiguration() const
{
PhysXSystemConfiguration systemConfig;
bool configurationRead = false;
AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get();
if (settingsRegistry)
{
configurationRead = settingsRegistry->GetObject(systemConfig, m_settingsRegistryPath);
}
if (configurationRead)
{
AZ_TracePrintf("PhysXSystem", R"(PhysXConfiguration was read from settings registry at pointer path)"
R"( "%s)" "\n",
m_settingsRegistryPath.c_str());
return systemConfig;
}
return AZStd::nullopt;
}
AZStd::optional<AzPhysics::SceneConfiguration> PhysXSettingsRegistryManager::LoadDefaultSceneConfiguration() const
{
AzPhysics::SceneConfiguration sceneConfig;
bool configurationRead = false;
AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get();
if (settingsRegistry)
{
configurationRead = settingsRegistry->GetObject(sceneConfig, m_defaultSceneConfigSettingsRegistryPath);
}
if (configurationRead)
{
AZ_TracePrintf("PhysXSystem", R"(Default Scene Configuration was read from settings registry at pointer path)"
R"("%s)" "\n",
m_defaultSceneConfigSettingsRegistryPath.c_str());
return sceneConfig;
}
return AZStd::nullopt;
}
AZStd::optional<Debug::DebugConfiguration> PhysXSettingsRegistryManager::LoadDebugConfiguration() const
{
Debug::DebugConfiguration systemConfig;
bool configurationRead = false;
AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get();
if (settingsRegistry)
{
configurationRead = settingsRegistry->GetObject(systemConfig, m_debugSettingsRegistryPath);
}
if (configurationRead)
{
AZ_TracePrintf("PhysXSystem", R"(Debug::DebugConfiguration was read from settings registry at pointer path)"
R"( "%s)" "\n",
m_debugSettingsRegistryPath.c_str());
return systemConfig;
}
return AZStd::nullopt;
}
void PhysXSettingsRegistryManager::SaveSystemConfiguration([[maybe_unused]] const PhysXSystemConfiguration& config, const OnPhysXConfigSaveComplete& saveCallback) const
{
//PhysXEditorSettingsRegistryManager will implement, as saving is editor only currently.
if (saveCallback)
{
saveCallback(config, Result::Failed);
}
}
void PhysXSettingsRegistryManager::SaveDefaultSceneConfiguration([[maybe_unused]] const AzPhysics::SceneConfiguration& config, const OnDefaultSceneConfigSaveComplete& saveCallback) const
{
//PhysXEditorSettingsRegistryManager will implement, as saving is editor only currently.
if (saveCallback)
{
saveCallback(config, Result::Failed);
}
}
void PhysXSettingsRegistryManager::SaveDebugConfiguration([[maybe_unused]] const Debug::DebugConfiguration& config, const OnPhysXDebugConfigSaveComplete& saveCallback) const
{
//PhysXEditorSettingsRegistryManager will implement, as saving is editor only currently.
if (saveCallback)
{
saveCallback(config, Result::Failed);
}
}
} //namespace PhysX