/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace PhysX { namespace Editor { EditorWindow::EditorWindow(QWidget* parent) : QWidget(parent) , m_ui(new Ui::EditorWindowClass()) { m_ui->setupUi(this); auto* physicsSystem = AZ::Interface::Get(); const auto* physXSystemConfiguration = azdynamic_cast(physicsSystem->GetConfiguration()); const AzPhysics::SceneConfiguration& defaultSceneConfiguration = physicsSystem->GetDefaultSceneConfiguration(); const PhysX::Debug::DebugConfiguration& physXDebugConfiguration = AZ::Interface::Get()->GetDebugConfiguration(); m_ui->m_PhysXConfigurationWidget->SetConfiguration(*physXSystemConfiguration, physXDebugConfiguration, defaultSceneConfiguration); connect(m_ui->m_PhysXConfigurationWidget, &PhysX::Editor::ConfigurationWidget::onConfigurationChanged, this, &EditorWindow::SaveConfiguration); } void EditorWindow::RegisterViewClass() { AzToolsFramework::ViewPaneOptions options; options.preferedDockingArea = Qt::LeftDockWidgetArea; options.saveKeyName = "PhysXConfiguration"; options.isPreview = true; AzToolsFramework::RegisterViewPane(LyViewPane::PhysXConfigurationEditor, LyViewPane::CategoryTools, options); } void EditorWindow::SaveConfiguration( const PhysX::PhysXSystemConfiguration& physXSystemConfiguration, const PhysX::Debug::DebugConfiguration& physXDebugConfig, const AzPhysics::SceneConfiguration& defaultSceneConfiguration) { auto* physXSystem = GetPhysXSystem(); if (physXSystem == nullptr) { AZ_Error("PhysX", false, "Unable to save the PhysX configuration. The PhysXSystem not initialized. Any changes have not been applied."); return; } //update the physx system config if it has changed const PhysXSettingsRegistryManager& settingsRegManager = physXSystem->GetSettingsRegistryManager(); if (physXSystem->GetPhysXConfiguration() != physXSystemConfiguration) { auto saveCallback = [](const PhysXSystemConfiguration& config, PhysXSettingsRegistryManager::Result result) { AZ_Warning("PhysX", result == PhysXSettingsRegistryManager::Result::Success, "Unable to save the PhysX configuration. Any changes have not been applied."); if (result == PhysXSettingsRegistryManager::Result::Success) { if (auto* physXSystem = GetPhysXSystem()) { physXSystem->UpdateConfiguration(&config); } } }; settingsRegManager.SaveSystemConfiguration(physXSystemConfiguration, saveCallback); } if (physXSystem->GetDefaultSceneConfiguration() != defaultSceneConfiguration) { auto saveCallback = [](const AzPhysics::SceneConfiguration& config, PhysXSettingsRegistryManager::Result result) { AZ_Warning("PhysX", result == PhysXSettingsRegistryManager::Result::Success, "Unable to save the Default Scene configuration. Any changes have not been applied."); if (result == PhysXSettingsRegistryManager::Result::Success) { if (auto* physXSystem = GetPhysXSystem()) { physXSystem->UpdateDefaultSceneConfiguration(config); } } }; settingsRegManager.SaveDefaultSceneConfiguration(defaultSceneConfiguration, saveCallback); } //Update the debug configuration if (auto* physXDebug = AZ::Interface::Get()) { if (physXDebug->GetDebugConfiguration() != physXDebugConfig) { auto saveCallback = [](const Debug::DebugConfiguration& config, PhysXSettingsRegistryManager::Result result) { AZ_Warning("PhysX", result == PhysXSettingsRegistryManager::Result::Success, "Unable to save the PhysX debug configuration. Any changes have not been applied."); if (result == PhysXSettingsRegistryManager::Result::Success) { if (auto* physXDebug = AZ::Interface::Get()) { physXDebug->UpdateDebugConfiguration(config); } } }; settingsRegManager.SaveDebugConfiguration(physXDebugConfig, saveCallback); } } } } } #include