diff --git a/AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_BasicWorkflow.py b/AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_BasicWorkflow.py index 44b7dc2ee4..7a600f7976 100644 --- a/AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_BasicWorkflow.py +++ b/AutomatedTesting/Gem/PythonTests/prefab/PrefabLevel_BasicWorkflow.py @@ -7,10 +7,14 @@ SPDX-License-Identifier: Apache-2.0 OR MIT # fmt:off class Tests(): - create_new_entity = ("Entity: 'CreateNewEntity' passed", "Entity: 'CreateNewEntity' failed") - create_prefab = ("Prefab: 'CreatePrefab' passed", "Prefab: 'CreatePrefab' failed") - instantiate_prefab = ("Prefab: 'InstantiatePrefab' passed", "Prefab: 'InstantiatePrefab' failed") - new_prefab_position = ("Prefab: new prefab's position is at the expected position", "Prefab: new prefab's position is *not* at the expected position") + create_new_entity = ("'CreateNewEntity' passed", "'CreateNewEntity' failed") + create_prefab = ("'CreatePrefab' passed", "'CreatePrefab' failed") + instantiate_prefab = ("'InstantiatePrefab' passed", "'InstantiatePrefab' failed") + has_one_child = ("instantiated prefab contains only one child as expected", "instantiated prefab does *not* contain only one child as expected") + instantiated_prefab_position = ("instantiated prefab's position is at the expected position", "instantiated prefab's position is *not* at the expected position") + delete_prefab = ("'DeleteEntitiesAndAllDescendantsInInstance' passed", "'DeleteEntitiesAndAllDescendantsInInstance' failed") + instantiated_prefab_removed = ("instantiated prefab's container entity has been removed", "instantiated prefab's container entity has *not* been removed") + instantiated_child_removed = ("instantiated prefab's child entity has been removed", "instantiated prefab's child entity has *not* been removed") # fmt:on def PrefabLevel_BasicWorkflow(): @@ -18,6 +22,7 @@ def PrefabLevel_BasicWorkflow(): This test will help verify if the following functions related to Prefab work as expected: - CreatePrefab - InstantiatePrefab + - DeleteEntitiesAndAllDescendantsInInstance """ import os @@ -35,31 +40,68 @@ def PrefabLevel_BasicWorkflow(): from azlmbr.math import Vector3 import azlmbr.legacy.general as general - EXPECTED_NEW_PREFAB_POSITION = Vector3(10.00, 20.0, 30.0) + NEW_PREFAB_NAME = "new_prefab" + NEW_PREFAB_FILE_NAME = NEW_PREFAB_NAME + ".prefab" + NEW_PREFAB_FILE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), NEW_PREFAB_FILE_NAME) + INSTANTIATED_PREFAB_POSITION = Vector3(10.00, 20.0, 30.0) + INSTANTIATED_PREFAB_NAME = "instantiated_prefab" + INSTANTIATED_CHILD_ENTITY_NAME = "child_1" + TEST_LEVEL_FOLDER = "Prefab" + TEST_LEVEL_NAME = "Base" + def find_entity_by_name(entity_name): + searchFilter = entity.SearchFilter() + searchFilter.names = [entity_name] + entityIds = entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter) + if entityIds and entityIds[0].IsValid(): + return entityIds[0] + return None + + def print_error_if_failed(prefab_operation_result): + if not prefab_operation_result.IsSuccess(): + Report.info(f'Error message: {prefab_operation_result.GetError()}') + + +# Open the test level helper.init_idle() - helper.open_level("Prefab", "Base") + helper.open_level(TEST_LEVEL_FOLDER, TEST_LEVEL_NAME) # Create a new Entity at the root level new_entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', EntityId()) Report.result(Tests.create_new_entity, new_entity_id.IsValid()) # Checks for prefab creation passed or not - new_prefab_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'new_prefab.prefab') - create_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'CreatePrefabInMemory', [new_entity_id], new_prefab_file_path) - Report.result(Tests.create_prefab, create_prefab_result) + create_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'CreatePrefabInMemory', [new_entity_id], NEW_PREFAB_FILE_PATH) + Report.result(Tests.create_prefab, create_prefab_result.IsSuccess()) + print_error_if_failed(create_prefab_result) # Checks for prefab instantiation passed or not - container_entity_id = prefab.PrefabPublicRequestBus(bus.Broadcast, 'InstantiatePrefab', new_prefab_file_path, EntityId(), EXPECTED_NEW_PREFAB_POSITION) - Report.result(Tests.instantiate_prefab, container_entity_id.IsValid()) + instantiate_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'InstantiatePrefab', NEW_PREFAB_FILE_PATH, EntityId(), INSTANTIATED_PREFAB_POSITION) + Report.result(Tests.instantiate_prefab, instantiate_prefab_result.IsSuccess() and instantiate_prefab_result.GetValue().IsValid()) + print_error_if_failed(instantiate_prefab_result) + + container_entity_id = instantiate_prefab_result.GetValue() + editor.EditorEntityAPIBus(bus.Event, 'SetName', container_entity_id, INSTANTIATED_PREFAB_NAME) + + children_entity_ids = editor.EditorEntityInfoRequestBus(bus.Event, 'GetChildren', container_entity_id) + Report.result(Tests.has_one_child, len(children_entity_ids) is 1) + + child_entity_id = children_entity_ids[0] + editor.EditorEntityAPIBus(bus.Event, 'SetName', child_entity_id, INSTANTIATED_CHILD_ENTITY_NAME) # Checks if the new prefab is at the correct position and if it fails, it will provide the expected postion and the actual postion of the entity in the Editor log - new_prefab_position = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", container_entity_id) - is_at_position = new_prefab_position.IsClose(EXPECTED_NEW_PREFAB_POSITION) - Report.result(Tests.new_prefab_position, is_at_position) + actual_prefab_position = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", container_entity_id) + is_at_position = actual_prefab_position.IsClose(INSTANTIATED_PREFAB_POSITION) + Report.result(Tests.instantiated_prefab_position, is_at_position) if not is_at_position: - Report.info(f'Expected position: {EXPECTED_NEW_PREFAB_POSITION.ToString()}, actual position: {new_prefab_position.ToString()}') - + Report.info(f'Expected position: {INSTANTIATED_PREFAB_POSITION.ToString()}, actual position: {actual_prefab_position.ToString()}') + +# Checks for prefab deletion passed or not + delete_prefab_result = prefab.PrefabPublicRequestBus(bus.Broadcast, 'DeleteEntitiesAndAllDescendantsInInstance', [container_entity_id]) + Report.result(Tests.delete_prefab, delete_prefab_result.IsSuccess()) + print_error_if_failed(delete_prefab_result) + Report.result(Tests.instantiated_prefab_removed, find_entity_by_name(INSTANTIATED_PREFAB_NAME) is None) + Report.result(Tests.instantiated_child_removed, find_entity_by_name(INSTANTIATED_CHILD_ENTITY_NAME) is None) if __name__ == "__main__": from editor_python_test_tools.utils import Report diff --git a/Code/Editor/CryEditDoc.cpp b/Code/Editor/CryEditDoc.cpp index c720299ce8..90b020f452 100644 --- a/Code/Editor/CryEditDoc.cpp +++ b/Code/Editor/CryEditDoc.cpp @@ -32,9 +32,6 @@ #include #include -// CryCommon -#include - // Editor #include "Settings.h" @@ -60,6 +57,7 @@ #include // LmbrCentral +#include #include // for LmbrCentral::EditorLightComponentRequestBus //#define PROFILE_LOADING_WITH_VTUNE @@ -269,20 +267,7 @@ void CCryEditDoc::DeleteContents() CErrorReportDialog::Clear(); // Unload level specific audio binary data. - Audio::SAudioManagerRequestData oAMData(Audio::eADS_LEVEL_SPECIFIC); - Audio::SAudioRequest oAudioRequestData; - oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING); - oAudioRequestData.pData = &oAMData; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); - - // Now unload level specific audio config data. - Audio::SAudioManagerRequestData oAMData2(Audio::eADS_LEVEL_SPECIFIC); - oAudioRequestData.pData = &oAMData2; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); - - Audio::SAudioManagerRequestData oAMData3(Audio::eADS_LEVEL_SPECIFIC); - oAudioRequestData.pData = &oAMData3; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); + LmbrCentral::AudioSystemComponentRequestBus::Broadcast(&LmbrCentral::AudioSystemComponentRequestBus::Events::LevelUnloadAudio); GetIEditor()->Notify(eNotify_OnSceneClosed); CrySystemEventBus::Broadcast(&CrySystemEventBus::Events::OnCryEditorSceneClosed); @@ -413,32 +398,11 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename) #ifdef PROFILE_LOADING_WITH_VTUNE VTResume(); #endif - // Parse level specific config data. - const char* controlsPath = nullptr; - Audio::AudioSystemRequestBus::BroadcastResult(controlsPath, &Audio::AudioSystemRequestBus::Events::GetControlsPath); - QString sAudioLevelPath(controlsPath); - sAudioLevelPath += "levels/"; - AZStd::string const sLevelNameOnly = PathUtil::GetFileName(fileName.toUtf8().data()); - sAudioLevelPath += sLevelNameOnly.c_str(); - QByteArray path = sAudioLevelPath.toUtf8(); - Audio::SAudioManagerRequestData oAMData(path, Audio::eADS_LEVEL_SPECIFIC); - Audio::SAudioRequest oAudioRequestData; - oAudioRequestData.nFlags = (Audio::eARF_PRIORITY_HIGH | Audio::eARF_EXECUTE_BLOCKING); // Needs to be blocking so data is available for next preloading request! - oAudioRequestData.pData = &oAMData; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); - - Audio::SAudioManagerRequestData oAMData2(path, Audio::eADS_LEVEL_SPECIFIC); - oAudioRequestData.pData = &oAMData2; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); - - Audio::TAudioPreloadRequestID nPreloadRequestID = INVALID_AUDIO_PRELOAD_REQUEST_ID; - Audio::AudioSystemRequestBus::BroadcastResult(nPreloadRequestID, &Audio::AudioSystemRequestBus::Events::GetAudioPreloadRequestID, sLevelNameOnly.c_str()); - if (nPreloadRequestID != INVALID_AUDIO_PRELOAD_REQUEST_ID) - { - Audio::SAudioManagerRequestData oAMData3(nPreloadRequestID); - oAudioRequestData.pData = &oAMData3; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); - } + // Load level-specific audio data. + AZStd::string levelFileName{ fileName.toUtf8().constData() }; + AZStd::to_lower(levelFileName.begin(), levelFileName.end()); + LmbrCentral::AudioSystemComponentRequestBus::Broadcast( + &LmbrCentral::AudioSystemComponentRequestBus::Events::LevelLoadAudio, AZStd::string_view{ levelFileName }); { CAutoLogTime logtime("Game Engine level load"); diff --git a/Code/Editor/Lib/Tests/test_ViewportManipulatorController.cpp b/Code/Editor/Lib/Tests/test_ViewportManipulatorController.cpp index a2a7617083..9dc7e65cef 100644 --- a/Code/Editor/Lib/Tests/test_ViewportManipulatorController.cpp +++ b/Code/Editor/Lib/Tests/test_ViewportManipulatorController.cpp @@ -77,7 +77,7 @@ namespace UnitTest class ViewportManipulatorControllerFixture : public AllocatorsTestFixture { public: - static const AzFramework::ViewportId TestViewportId = AzFramework::ViewportId(0); + static const AzFramework::ViewportId TestViewportId; void SetUp() override { @@ -108,6 +108,8 @@ namespace UnitTest AZStd::unique_ptr m_inputChannelMapper; }; + const AzFramework::ViewportId ViewportManipulatorControllerFixture::TestViewportId = AzFramework::ViewportId(0); + TEST_F(ViewportManipulatorControllerFixture, An_event_is_not_propagated_to_the_viewport_when_a_manipulator_handles_it_first) { // forward input events to our controller list diff --git a/Code/Editor/MainWindow.cpp b/Code/Editor/MainWindow.cpp index bb246c2337..9560fd0fe7 100644 --- a/Code/Editor/MainWindow.cpp +++ b/Code/Editor/MainWindow.cpp @@ -97,6 +97,7 @@ AZ_POP_DISABLE_WARNING #include "ActionManager.h" #include +#include using namespace AZ; using namespace AzQtComponents; @@ -1474,25 +1475,22 @@ int MainWindow::ViewPaneVersion() const void MainWindow::OnStopAllSounds() { - Audio::SAudioRequest oStopAllSoundsRequest; - Audio::SAudioManagerRequestData oStopAllSoundsRequestData; - oStopAllSoundsRequest.pData = &oStopAllSoundsRequestData; - - CryLogAlways("