diff --git a/AutomatedTesting/Gem/Code/Platform/Mac/tool_dependencies.cmake b/AutomatedTesting/Gem/Code/Platform/Mac/tool_dependencies.cmake index ee7be9ac6d..2e9d450ab8 100644 --- a/AutomatedTesting/Gem/Code/Platform/Mac/tool_dependencies.cmake +++ b/AutomatedTesting/Gem/Code/Platform/Mac/tool_dependencies.cmake @@ -14,4 +14,6 @@ set(GEM_DEPENDENCIES Gem::Atom_RHI_Null.Builders Gem::Atom_RHI_Metal.Private Gem::Atom_RHI_Metal.Builders + Gem::Atom_RHI_Vulkan.Builders + Gem::Atom_RHI_DX12.Builders ) \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt index 6d3727195e..31afab87ed 100644 --- a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt @@ -51,7 +51,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) TEST_SUITE sandbox TEST_SERIAL PATH ${CMAKE_CURRENT_LIST_DIR}/physics/TestSuite_Sandbox.py - TIMEOUT 3600 + TIMEOUT 1500 RUNTIME_DEPENDENCIES Legacy::Editor AZ::AssetProcessor @@ -68,7 +68,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) TEST_SUITE periodic TEST_SERIAL PATH ${CMAKE_CURRENT_LIST_DIR}/scripting/TestSuite_Active.py - TIMEOUT 1500 + TIMEOUT 3000 RUNTIME_DEPENDENCIES Legacy::Editor AZ::AssetProcessor @@ -181,21 +181,23 @@ include(${pal_dir}/PAL_traits_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_LARGE_WORLDS_TEST_SUPPORTED) ## DynVeg ## - ly_add_pytest( - NAME AutomatedTesting::DynamicVegetationTests_Main - TEST_SERIAL - TEST_SUITE main - PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg - PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark" - TIMEOUT 1500 - RUNTIME_DEPENDENCIES - AZ::AssetProcessor - Legacy::Editor - AutomatedTesting.GameLauncher - AutomatedTesting.Assets - COMPONENT - LargeWorlds - ) + # Temporarily moving all tests to periodic suite - SPEC-6553 + #ly_add_pytest( + # NAME AutomatedTesting::DynamicVegetationTests_Main + # TEST_SERIAL + # TEST_SUITE main + # PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg + # PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark" + # TIMEOUT 1500 + # RUNTIME_DEPENDENCIES + # AZ::AssetProcessor + # Legacy::Editor + # AutomatedTesting.GameLauncher + # AutomatedTesting.Assets + # COMPONENT + # LargeWorlds + #) + ly_add_pytest( NAME AutomatedTesting::DynamicVegetationTests_Sandbox @@ -214,11 +216,11 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ) ly_add_pytest( - NAME AutomatedTesting::DynamicVegetationTests_Periodic + NAME AutomatedTesting::DynamicVegetationFilterTests_Periodic TEST_SERIAL TEST_SUITE periodic PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg - PYTEST_MARKS "SUITE_periodic" + PYTEST_MARKS "SUITE_periodic and dynveg_filter" TIMEOUT 1500 RUNTIME_DEPENDENCIES AZ::AssetProcessor @@ -228,22 +230,97 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ LargeWorlds ) -## LandscapeCanvas ## ly_add_pytest( - NAME AutomatedTesting::LandscapeCanvasTests_Main + NAME AutomatedTesting::DynamicVegetationModifierTests_Periodic TEST_SERIAL - TEST_SUITE main - PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/landscape_canvas - PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark" + TEST_SUITE periodic + PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg + PYTEST_MARKS "SUITE_periodic and dynveg_modifier" TIMEOUT 1500 RUNTIME_DEPENDENCIES - AZ::AssetProcessor - Legacy::Editor - AutomatedTesting.Assets + AZ::AssetProcessor + Legacy::Editor + AutomatedTesting.Assets COMPONENT LargeWorlds ) + ly_add_pytest( + NAME AutomatedTesting::DynamicVegetationRegressionTests_Periodic + TEST_SERIAL + TEST_SUITE periodic + PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg + PYTEST_MARKS "SUITE_periodic and dynveg_regression" + TIMEOUT 1500 + RUNTIME_DEPENDENCIES + AZ::AssetProcessor + Legacy::Editor + AutomatedTesting.Assets + COMPONENT + LargeWorlds + ) + + ly_add_pytest( + NAME AutomatedTesting::DynamicVegetationAreaTests_Periodic + TEST_SERIAL + TEST_SUITE periodic + PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg + PYTEST_MARKS "SUITE_periodic and dynveg_area" + TIMEOUT 1500 + RUNTIME_DEPENDENCIES + AZ::AssetProcessor + Legacy::Editor + AutomatedTesting.Assets + COMPONENT + LargeWorlds + ) + + ly_add_pytest( + NAME AutomatedTesting::DynamicVegetationMiscTests_Periodic + TEST_SERIAL + TEST_SUITE periodic + PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg + PYTEST_MARKS "SUITE_periodic and dynveg_misc" + TIMEOUT 1500 + RUNTIME_DEPENDENCIES + AZ::AssetProcessor + Legacy::Editor + AutomatedTesting.Assets + COMPONENT + LargeWorlds + ) + + ly_add_pytest( + NAME AutomatedTesting::DynamicVegetationSurfaceTagTests_Periodic + TEST_SERIAL + TEST_SUITE periodic + PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg + PYTEST_MARKS "SUITE_periodic and dynveg_surfacetagemitter" + TIMEOUT 1500 + RUNTIME_DEPENDENCIES + AZ::AssetProcessor + Legacy::Editor + AutomatedTesting.Assets + COMPONENT + LargeWorlds + ) +## LandscapeCanvas ## + # Temporarily moving all tests to periodic suite - SPEC-6553 + #ly_add_pytest( + # NAME AutomatedTesting::LandscapeCanvasTests_Main + # TEST_SERIAL + # TEST_SUITE main + # PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/landscape_canvas + # PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark" + # TIMEOUT 1500 + # RUNTIME_DEPENDENCIES + # AZ::AssetProcessor + # Legacy::Editor + # AutomatedTesting.Assets + # COMPONENT + # LargeWorlds + #) + ly_add_pytest( NAME AutomatedTesting::LandscapeCanvasTests_Periodic TEST_SERIAL diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py index a9f6d0aa02..c7f1aba031 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py @@ -265,6 +265,7 @@ class Tracer: self.warnings = [] self.errors = [] self.asserts = [] + self.prints = [] self.has_warnings = False self.has_errors = False self.has_asserts = False @@ -310,6 +311,11 @@ class Tracer: def __repr__(self): return f"[Assert: {self.message}]" + + class PrintInfo: + def __init__(self, args): + self.window = args[0] + self.message = args[1] def _on_warning(self, args): warningInfo = Tracer.WarningInfo(args) @@ -331,13 +337,19 @@ class Tracer: Report.info("Tracer caught Assert: %s:%i[%s] \"%s\"" % (assertInfo.filename, assertInfo.line, assertInfo.function, assertInfo.message)) self.has_asserts = True return False - + + def _on_printf(self, args): + printInfo = Tracer.PrintInfo(args) + self.prints.append(printInfo) + return False + def __enter__(self): self.handler = azlmbr.debug.TraceMessageBusHandler() self.handler.connect(None) self.handler.add_callback("OnPreAssert", self._on_assert) self.handler.add_callback("OnPreWarning", self._on_warning) self.handler.add_callback("OnPreError", self._on_error) + self.handler.add_callback("OnPrintf", self._on_printf) return self def __exit__(self, type, value, traceback): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py index 0be220cad0..466cd610e4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py @@ -114,11 +114,8 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): # This should result in 400 instances, since our box is 16 m x 16 m and by default the veg system plants # 20 instances per 16 meters spawner_entity.get_set_test(0, 'Configuration|Allow Empty Assets', True) - general.idle_wait(1.0) num_expected_instances = 20 * 20 - box = azlmbr.shape.ShapeComponentRequestsBus(bus.Event, 'GetEncompassingAabb', spawner_entity.id) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - property_tree_success = property_tree_success and (num_found == num_expected_instances) + property_tree_success = property_tree_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and property_tree_success self.log(f'Property Tree spawner type test: {property_tree_success}') @@ -127,10 +124,8 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): # Since we have an empty slice path, we should have 0 instances once we disable 'Allow Empty Assets' num_expected_instances = 0 allow_empty_assets_success = allow_empty_assets_success and spawner_entity.get_set_test(0, 'Configuration|Allow Empty Assets', False) - general.idle_wait(1.0) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - self.log(f'Allow Empty Assets test: Found {num_found} instances -- Expected {num_expected_instances} instances') - allow_empty_assets_success = allow_empty_assets_success and (num_found == num_expected_instances) + self.log('Allow Empty Assets test:') + allow_empty_assets_success = allow_empty_assets_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and allow_empty_assets_success self.log(f'Allow Empty Assets test: {allow_empty_assets_success}') @@ -143,10 +138,8 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): descriptor = hydra.get_component_property_value(spawner_entity.components[2], 'Configuration|Embedded Assets|[0]') descriptor.spawner = dynamic_slice_spawner spawns_slices_success = spawns_slices_success and spawner_entity.get_set_test(2, "Configuration|Embedded Assets|[0]", descriptor) - general.idle_wait(1.0) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - self.log(f'Spawn dynamic slices test: Found {num_found} instances -- Expected {num_expected_instances} instances') - spawns_slices_success = spawns_slices_success and (num_found == num_expected_instances) + self.log('Spawn dynamic slices test:') + spawns_slices_success = spawns_slices_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and spawns_slices_success self.log(f'Spawn dynamic slices test: {spawns_slices_success}') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py index 161ad038a5..dc353aca1a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py @@ -100,21 +100,15 @@ class TestEmptyInstanceSpawner(EditorTestHelper): # This should result in 400 instances, since our box is 16 m x 16 m and by default the veg system plants # 20 instances per 16 meters - general.idle_wait(2.0) num_expected_instances = 20 * 20 - box = azlmbr.shape.ShapeComponentRequestsBus(bus.Event, 'GetEncompassingAabb', spawner_entity.id) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - property_tree_success = property_tree_success and (num_found == num_expected_instances) + property_tree_success = property_tree_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and property_tree_success - self.log(f'Found {num_found} instances -- Expected {num_expected_instances} instances') self.log(f'Property Tree spawner type test: {property_tree_success}') # 6) Validate that the "Allow Empty Assets" setting doesn't affect the EmptyInstanceSpawner allow_empty_assets_success = True spawner_entity.get_set_test(0, 'Configuration|Allow Empty Assets', False) - general.idle_wait(2.0) - num_found = azlmbr.areasystem.AreaSystemRequestBus(bus.Broadcast, 'GetInstanceCountInAabb', box) - allow_empty_assets_success = allow_empty_assets_success and (num_found == num_expected_instances) + allow_empty_assets_success = allow_empty_assets_success and self.wait_for_condition(lambda: dynveg.validate_instance_count_in_entity_shape(spawner_entity.id, num_expected_instances), 5.0) self.test_success = self.test_success and allow_empty_assets_success self.log(f'Allow Empty Assets test: {allow_empty_assets_success}') diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py index 2db8534696..17a5f72863 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py @@ -37,6 +37,7 @@ class TestAltitudeFilter(object): @pytest.mark.test_case_id('C4814463', 'C4847477') @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_AltitudeFilter_ComponentAndOverrides_InstancesPlantAtSpecifiedAltitude(self, request, editor, level, launcher_platform): @@ -61,6 +62,7 @@ class TestAltitudeFilter(object): @pytest.mark.test_case_id("C4847476") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_AltitudeFilter_ShapeSample_InstancesPlantAtSpecifiedAltitude(self, request, editor, level, launcher_platform): @@ -85,6 +87,7 @@ class TestAltitudeFilter(object): @pytest.mark.test_case_id("C4847478") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter @pytest.mark.xfail # LYN-3275 def test_AltitudeFilter_FilterStageToggle(self, request, editor, level, workspace, launcher_platform): cfg_args = [level] diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py index 1353efbf2e..5f42fc6de0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AreaComponentSlices.py @@ -52,6 +52,7 @@ class TestAreaComponents(object): @pytest.mark.test_case_id("C2627900", "C2627905", "C2627904") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_AreaComponents_SliceCreationVisibilityToggleWorks(self, request, editor, level, workspace, launcher_platform): cfg_args = [level] diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py index ad0917ca22..b40d99b100 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetListCombiner.py @@ -38,6 +38,7 @@ class TestAssetListCombiner(object): @pytest.mark.test_case_id("C4762374", "C4762373") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_AssetListCombiner_CombinedDescriptorsExpressInConfiguredArea(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py index 65472df3bc..7b34a10d66 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AssetWeightSelector.py @@ -42,6 +42,7 @@ class TestAssetWeightSelector(object): @pytest.mark.test_case_id("C6269654", "C4762368") @pytest.mark.SUITE_sandbox + @pytest.mark.dynveg_filter def test_AssetWeightSelector_InstancesExpressBasedOnWeight(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py index 45518b71fc..7466089173 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_Debugger.py @@ -40,6 +40,7 @@ class TestDebugger(object): @pytest.mark.test_case_id("C2789148") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_Debugger_DebugCVarsWork(self, request, editor, level, workspace, launcher_platform): cfg_args = [level] diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py index 3171cc032f..191f27fca0 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DistanceBetweenFilter.py @@ -38,6 +38,7 @@ class TestDistanceBetweenFilter(object): @pytest.mark.test_case_id("C4851066") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius(self, request, editor, level, launcher_platform): expected_lines = [ @@ -58,6 +59,7 @@ class TestDistanceBetweenFilter(object): @pytest.mark.test_case_id("C4814458") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py index b3cf344b2b..5c6e034a12 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynVeg_Regressions.py @@ -40,6 +40,7 @@ class Test_DynVeg_Regressions(object): @pytest.mark.test_case_id("C29470845") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_regression def test_SurfaceDataRefreshes_RemainsStable(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py index f0673a9438..9898570692 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_DynamicSliceInstanceSpawner.py @@ -41,7 +41,8 @@ class TestDynamicSliceInstanceSpawner(object): return console @pytest.mark.test_case_id("C28851763") - @pytest.mark.SUITE_sandbox + @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.parametrize("launcher_platform", ['windows_editor']) def test_DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks(self, request, editor, level, workspace, project, launcher_platform): @@ -66,6 +67,7 @@ class TestDynamicSliceInstanceSpawner(object): @pytest.mark.test_case_id('C2574330') @pytest.mark.BAT @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.parametrize("launcher_platform", ['windows_editor']) def test_DynamicSliceInstanceSpawner_Embedded_E2E_Editor(self, workspace, request, editor, level, project, launcher_platform): @@ -85,6 +87,7 @@ class TestDynamicSliceInstanceSpawner(object): @pytest.mark.test_case_id('C2574330') @pytest.mark.BAT @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.parametrize("launcher_platform", ['windows']) @pytest.mark.skip # ATOM-14703 def test_DynamicSliceInstanceSpawner_Embedded_E2E_Launcher(self, workspace, launcher, level, @@ -101,6 +104,7 @@ class TestDynamicSliceInstanceSpawner(object): @pytest.mark.test_case_id('C4762367') @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.parametrize("launcher_platform", ['windows_editor']) def test_DynamicSliceInstanceSpawner_External_E2E_Editor(self, workspace, request, editor, level, project, launcher_platform): @@ -119,6 +123,7 @@ class TestDynamicSliceInstanceSpawner(object): @pytest.mark.test_case_id('C4762367') @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.parametrize("launcher_platform", ['windows']) @pytest.mark.skip # ATOM-14703 def test_DynamicSliceInstanceSpawner_External_E2E_Launcher(self, workspace, launcher, level, diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py index fc8c31fc7b..7bd8484cf4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_EmptyInstanceSpawner.py @@ -36,13 +36,9 @@ class TestEmptyInstanceSpawner(object): file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True) - # Main suite needs at least one test - @pytest.mark.SUITE_main - def test_EmptyInstanceSpawner_Dummy(self, request, editor, level, workspace, project, launcher_platform): - pass - @pytest.mark.test_case_id("C28851762") - @pytest.mark.SUITE_sandbox + @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area def test_EmptyInstanceSpawner_EmptySpawnerWorks(self, request, editor, level, launcher_platform): cfg_args = [level] diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py index d04b827985..53b5c3b760 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_InstanceSpawnerPriority.py @@ -43,6 +43,7 @@ class TestInstanceSpawnerPriority(object): @pytest.mark.test_case_id("C5747383", "C4762382") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_InstanceSpawnerPriority_LayerAndSubPriority_HigherValuesPlantOverLower(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py index 2286238364..76b8b3cd3a 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlender.py @@ -20,17 +20,10 @@ import pytest pytest.importorskip("ly_test_tools") -import time as time - -import editor_python_test_tools.hydra_test_utils as hydra -import ly_test_tools.launchers.launcher_helper as launcher_helper +import ly_remote_console.remote_console_commands as remote_console_commands import ly_test_tools.environment.waiter as waiter import ly_test_tools.environment.file_system as file_system -import ly_remote_console.remote_console_commands as remote_console_commands -from ly_remote_console.remote_console_commands import send_command_and_expect_response as send_command_and_expect_response - -import automatedtesting_shared.screenshot_utils as screenshot_utils -from automatedtesting_shared.network_utils import check_for_listening_port +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") @@ -58,6 +51,7 @@ class TestLayerBlender(object): @pytest.mark.test_case_id("C2627906") @pytest.mark.BAT @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.parametrize("launcher_platform", ['windows_editor']) def test_LayerBlender_E2E_Editor(self, workspace, request, editor, project, level, launcher_platform): # Make sure temp level doesn't already exist @@ -95,6 +89,7 @@ class TestLayerBlender(object): @pytest.mark.test_case_id("C2627906") @pytest.mark.BAT @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.xfail @pytest.mark.parametrize("launcher_platform", ['windows']) def test_LayerBlender_E2E_Launcher(self, workspace, project, launcher, level, remote_console_instance, diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py index 6da0cdd6db..308f4480c5 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerBlocker.py @@ -38,6 +38,7 @@ class TestLayerBlocker(object): @pytest.mark.test_case_id("C2793772") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area def test_LayerBlocker_InstancesBlockedInConfiguredArea(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py index 93149c9490..d206a962da 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py @@ -40,6 +40,7 @@ class TestLayerSpawner(object): @pytest.mark.test_case_id("C4762381") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_LayerSpawner_InheritBehaviorFlag(self, request, editor, level, workspace, launcher_platform): expected_lines = [ @@ -60,6 +61,7 @@ class TestLayerSpawner(object): @pytest.mark.test_case_id("C2802020") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_LayerSpawner_InstancesPlantInAllSupportedShapes(self, request, editor, level, launcher_platform): expected_lines = [ @@ -101,6 +103,7 @@ class TestLayerSpawner(object): @pytest.mark.test_case_id("C4765973") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc @pytest.mark.xfail # LYN-3275 def test_LayerSpawner_FilterStageToggle(self, request, editor, level, workspace, launcher_platform): @@ -122,6 +125,7 @@ class TestLayerSpawner(object): @pytest.mark.test_case_id("C30000751") @pytest.mark.SUITE_sandbox + @pytest.mark.dynveg_misc @pytest.mark.skip # ATOM-14828 def test_LayerSpawner_InstancesRefreshUsingCorrectViewportCamera(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py index c04390e647..7e1b416556 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py @@ -46,6 +46,7 @@ class TestMeshBlocker(object): """ @pytest.mark.test_case_id("C3980834") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.xfail # LYN-3273 def test_MeshBlocker_InstancesBlockedByMesh(self, request, editor, level, launcher_platform): expected_lines = [ @@ -70,6 +71,7 @@ class TestMeshBlocker(object): """ @pytest.mark.test_case_id("C4766030") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_area @pytest.mark.xfail # LYN-3273 def test_MeshBlocker_InstancesBlockedByMeshHeightTuning(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py index 77638cb576..dcbffdf3b7 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshSurfaceTagEmitter.py @@ -38,6 +38,7 @@ class TestMeshSurfaceTagEmitter(object): @pytest.mark.test_case_id("C2908172") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_surfacetagemitter def test_MeshSurfaceTagEmitter_DependentOnMeshComponent(self, request, editor, level, launcher_platform): expected_lines = [ @@ -66,6 +67,7 @@ class TestMeshSurfaceTagEmitter(object): @pytest.mark.test_case_id("C2908174") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_surfacetagemitter def test_MeshSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py index ca4e30a719..0f84e2caa2 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PhysXColliderSurfaceTagEmitter.py @@ -38,6 +38,7 @@ class TestPhysXColliderSurfaceTagEmitter(object): @pytest.mark.test_case_id("C29053640") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_surfacetagemitter def test_PhysXColliderSurfaceTagEmitter_E2E_Editor(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py index ac3e0abb4f..2cf8db3b96 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py @@ -38,6 +38,7 @@ class TestPositionModifier(object): @pytest.mark.test_case_id("C4874099", "C4814461") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier def test_PositionModifier_ComponentAndOverrides_InstancesPlantAtSpecifiedOffsets(self, request, editor, level, launcher_platform): @@ -60,6 +61,7 @@ class TestPositionModifier(object): @pytest.mark.test_case_id("C4874100") @pytest.mark.SUITE_sandbox + @pytest.mark.dynveg_modifier @pytest.mark.xfail # LYN-3275 def test_PositionModifier_AutoSnapToSurfaceWorks(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py index 518949c0c0..3b0c9b3947 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_RotationModifier.py @@ -42,6 +42,7 @@ class TestRotationModifier(object): @pytest.mark.test_case_id("C4896922") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier def test_RotationModifier_InstancesRotateWithinRange(self, request, editor, level, launcher_platform) -> None: """ Launches editor and run test script to test that rotation modifier works for all axis. @@ -71,6 +72,7 @@ class TestRotationModifier(object): @pytest.mark.test_case_id("C4814460") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier def test_RotationModifierOverrides_InstancesRotateWithinRange(self, request, editor, level, launcher_platform) -> None: expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py index 6acd95e4f6..7fe7a4ece2 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ScaleModifier.py @@ -41,6 +41,7 @@ class TestScaleOverrideWorksSuccessfully(object): @pytest.mark.test_case_id("C4814462") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier def test_ScaleModifierOverrides_InstancesProperlyScale(self, request, editor, level, launcher_platform): expected_lines = [ @@ -70,6 +71,7 @@ class TestScaleOverrideWorksSuccessfully(object): @pytest.mark.test_case_id("C4896937") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier def test_ScaleModifier_InstancesProperlyScale(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py index ea90b67a7f..8acdb1b644 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_ShapeIntersectionFilter.py @@ -38,6 +38,7 @@ class TestShapeIntersectionFilter(object): @pytest.mark.test_case_id("C4874094") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_ShapeIntersectionFilter_InstancesPlantInAssignedShape(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py index 563ac1dcc5..6825686509 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeAlignmentModifier.py @@ -41,6 +41,7 @@ class TestSlopeAlignmentModifier(object): @pytest.mark.test_case_id("C4896941") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier @pytest.mark.skip # ATOM-14299 def test_SlopeAlignmentModifier_InstanceSurfaceAlignment(self, request, editor, level, launcher_platform): @@ -63,6 +64,7 @@ class TestSlopeAlignmentModifier(object): @pytest.mark.test_case_id("C4814459") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_modifier @pytest.mark.skip # ATOM-14299 def test_SlopeAlignmentModifierOverrides_InstanceSurfaceAlignment(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py index dc0f0e6514..48e532adcd 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SlopeFilter.py @@ -39,6 +39,7 @@ class TestSlopeFilter(object): @pytest.mark.test_case_id("C4874097") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_SlopeFilter_FilterStageToggle(self, request, editor, level, workspace, launcher_platform): cfg_args = [level] @@ -70,6 +71,7 @@ class TestSlopeFilter(object): @pytest.mark.test_case_id("C4814464", "C4874096") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter @pytest.mark.skip # LYN-2211 def test_SlopeFilter_ComponentAndOverrides_InstancesPlantOnValidSlopes(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py index 20cab85293..952c000232 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SurfaceMaskFilter.py @@ -40,6 +40,7 @@ class TestSurfaceMaskFilter(object): # Simple validation test to ensure that SurfaceTag can be created, set to a value, and compared to another SurfaceTag. @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_SurfaceMaskFilter_BasicSurfaceTagCreation(self, request, level, editor, launcher_platform): expected_lines = [ @@ -61,6 +62,7 @@ class TestSurfaceMaskFilter(object): @pytest.mark.test_case_id("C2561342") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_SurfaceMaskFilter_ExclusiveSurfaceTags_Function(self, request, editor, level, launcher_platform): expected_lines = [ @@ -93,6 +95,7 @@ class TestSurfaceMaskFilter(object): @pytest.mark.test_case_id("C2561341") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_SurfaceMaskFilter_InclusiveSurfaceTags_Function(self, request, editor, level, launcher_platform): expected_lines = [ @@ -125,6 +128,7 @@ class TestSurfaceMaskFilter(object): @pytest.mark.test_case_id("C3711666") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_filter def test_SurfaceMaskFilterOverrides_MultipleDescriptorOverridesPlantAsExpected(self, request, editor, level, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py index adf9a90587..0b55d06ae4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_SystemSettings.py @@ -38,6 +38,7 @@ class TestSystemSettings(object): @pytest.mark.test_case_id("C2646869") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_SystemSettings_SectorPointDensity(self, request, editor, level, launcher_platform): expected_lines = [ @@ -64,6 +65,7 @@ class TestSystemSettings(object): @pytest.mark.test_case_id("C2646870") @pytest.mark.SUITE_periodic + @pytest.mark.dynveg_misc def test_SystemSettings_SectorSize(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py b/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py index e0277180ae..1284c234bd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C100000_RigidBody_EnablingGravityWorksPoC.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C100000 # Test Case Title : Check that Gravity works -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/100000 + # fmt:off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py b/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py index c7dd8debb9..725da5fb24 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C111111 # Test Case Title : Check that Gravity works -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/111111 + # fmt:off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py b/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py index 216a75233f..380bb8a3c8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712452_ScriptCanvas_CollisionEvents.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C12712452 # Test Case Title : Verify ScriptCanvas Collision Events -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/12712452 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py b/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py index 2adf30e65e..b415688de7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712453_ScriptCanvas_MultipleRaycastNode.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C12712453 # Test Case Title : Verify Raycast Multiple Node -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12712453 + # fmt:off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py b/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py index 94eed900ff..bcf980a710 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712454_ScriptCanvas_OverlapNodeVerification.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : 12712454 # Test Case Title : Verify overlap nodes in script canvas -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12712454 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py b/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py index 61f26ebecb..668e8083c3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12712455_ScriptCanvas_ShapeCastVerification.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C12712455 # Test Case Title : Verify shape cast nodes in SC -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12712455 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py b/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py index 4745927e89..d2438110fe 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12868578_ForceRegion_DirectionHasNoAffectOnMagnitude.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C12868578 # Test Case Title : Check that World space and local space force direction doesn't affect magnitude of force exerted -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12868578 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py b/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py index 937fdd85a6..6372104fcf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12868580_ForceRegion_SplineModifiedTransform.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C12868580 # Test Case Title : Check that spline follow force works if transform components of entity are altered -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12868580 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py b/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py index 0cb0a2f841..76578460d5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12905527_ForceRegion_MagnitudeDeviation.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C12905527 # Test Case Title : Check that deviation occurring in Force Magnitude due to Values in Force direction is not large -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12905527 + # fmt: off class Tests(): diff --git a/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py b/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py index 42565333f7..38dc5488d2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C12905528_ForceRegion_WithNonTriggerCollider.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C12905528 Test Case Title : Check that user is warned if non-trigger collider component is used with force region -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/12905528 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py b/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py index 828022ccf2..d5bd946d34 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13351703_COM_NotIncludeTriggerShapes.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C13351703 # Test Case Title : Check that Center of Mass calculations should not include trigger shapes -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/13351703 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py b/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py index 77d93d9752..09b6956b06 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13352089_RigidBodies_MaxAngularVelocity.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C13352089 # Test Case Title : Verify that maximum angular velocity interacts correctly with initial angular velocity -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/13352089 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py b/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py index 1c580bfbfe..9c7a6e75e9 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13508019_Terrain_TerrainTexturePainterWorks.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C13508019 # Test Case Title : Verify terrain materials are updated after using terrain texture layer painter. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/13508019 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py b/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py index 61efe20dbd..66050565a4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C13895144_Ragdoll_ChangeLevel.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C13895144 # Test Case Title : Run a level with multiple ragdolls and then switch levels -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/13895144 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py b/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py index 5668082f78..1d0e1d5ac8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14195074_ScriptCanvas_PostUpdateEvent.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C14195074 # Test Case Title : Verify Postsimulate Events -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14195074 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py b/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py index fd5653b801..8fc58b4765 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14654881_CharacterController_SwitchLevels.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C14654881 # Test Case Title : Switching levels from a level containing a character controller component # should not lead to a crash -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14654881 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py b/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py index 03c18a5f1a..33077f2607 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14654882_Ragdoll_ragdollAPTest.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ Test case ID : C14654882 Test Case Title : Loading level with old PhysX Ragdoll component serialization should not produce asset processor errors -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14654882 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py b/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py index e52bdb7574..dca831456d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861498_ConfirmError_NoPxMesh.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C14861498 # Test Case Title : Confirm that when a PhysXCollider has no physics asset, the physics asset collider \ # shape throw an error -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14861498 + # fmt:off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py b/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py index 7a65448dcd..c6a275d04d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861500_DefaultSetting_ColliderShape.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C14861500 Test Case Title : Verify Default shape is Physics Asset -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14861500 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py index 904b5b0189..e415687001 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C14861501 Test Case Title : Verify PxMesh is auto-assigned when Collider component is added after Rendering Mesh component -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14861501 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py index 075c3f5b61..64820f7daf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C14861502 Test Case Title : Verify PxMesh is auto-assigned in collider when Mesh is assigned in Rendering Mesh component -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14861502 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py b/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py index bbaabf67f6..766a359397 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C14861504 Test Case Title : Verify if Rendering Mesh does not have a PhysX Collision Mesh fbx, then PxMesh is not auto-assigned -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14861504 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py b/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py index 45557098f7..327f40ec38 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14902097_ScriptCanvas_PreUpdateEvent.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C14902097 # Test Case Title : Verify Presimulate Events -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14902097 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py b/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py index 19caaab4fe..f7c8be8804 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14902098_ScriptCanvas_PostPhysicsUpdate.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C14902098 # Test Case Title : Check that force region simulation with Postsimulate works independently from rendering tick -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14902098 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py b/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py index 342ac6bdbd..73137ac497 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14976307_Gravity_SetGravityWorks.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C14976307 # Test Case Title : Check that Set Gravity Enabled works on an entity with gravity that starts as disabled -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/14976307 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py b/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py index 815e922a76..c76c5cab80 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14976308_ScriptCanvas_SetKinematicTargetTransform.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case # ID : C14976308 # Title : Verify that SetKinematicTarget on PhysX rigid body updates transform for kinematic entities and vice versa -# URL : https://testrail.agscollab.com/index.php?/cases/view/14976308 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py index 76ea9475ff..bdfc9d19be 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_after.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15096732 # Test Case Title : Verify Default material library works across different levels -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15096732 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py index 748052db56..d45423fe94 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096732_Material_DefaultLibraryUpdatedAcrossLevels_before.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15096732 # Test Case Title : Verify Default material library works across different levels -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15096732 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py b/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py index 4c7949cc91..3dd49d4fe4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096735_Materials_DefaultLibraryConsistency.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15096735 # Test Case Title : Verify that default material library works consistently across all systems that use it -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15096735 + # fmt:off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py b/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py index cc7dc3c5e2..c806cbb7d4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096737_Materials_DefaultMaterialLibraryChanges.py @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case Title : Verify that a change in the default material library material information # affects all the materials that reference it, even non-defaulted # exactly like if the library was selected -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15096737 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py b/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py index 0f33f0858b..bef98f6830 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15096740_Material_LibraryUpdatedCorrectly.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C15096740 Test Case Title : Verify that clearing a material library on all systems that use it, assigns the default material library -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15096740 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py b/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py index 625a8bfb4a..dadfbd7a7e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15308217_NoCrash_LevelSwitch.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15308217 # Test Case Title : Verify that the Terrain texture layer doesn't crash when changing # from on a level with a terrain component to another level without a terrain component -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15308217 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py b/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py index 3f6457f15c..ebc7d3fadd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15308221_Material_ComponentsInSyncWithLibrary.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C15308221 # Test Case Title : Verify that material library and slots are always in sync and work consistently through the different places of usage -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/15308221 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py b/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py index 57a0e6a75e..dba14552c8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15425929_Undo_Redo.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15425929 # Test Case Title : Verify that undo - redo operations do not create any error -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15425929 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py b/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py index f61886ccd0..8ff90fddaf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15425935_Material_LibraryUpdatedAcrossLevels.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15425935 # Test Case Title : Verify that the change in Material Library gets updated across levels -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15425935 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py b/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py index 99e0dcc669..21f5952678 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15556261 # Test Case Title : Check that the material assignment works with Character Controller -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15556261 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py b/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py index 4572dd322a..1e9b15fc90 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15563573_Material_AddModifyDeleteOnCharacterController.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C15563573 # Test Case Title : Check that any change (Add/Delete/Modify) made to the material surface in the material library reflects immediately in the PhysX Character Controller -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/15563573 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py b/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py index 52af7d8be5..6b31ffb13b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C15845879_ForceRegion_HighLinearDampingForce.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C15845879 # Test Case Title : Check that linear damping with high values do not make the object to quiver -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/15845879 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py index 68efd452b2..32bd02ae26 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C17411467_AddPhysxRagdollComponent.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C17411467 Test Case Title : Check that Physx Ragdoll component can be added without errors/warnings -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/17411467 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py index b13869ce12..c3a351ebea 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243580_Joints_Fixed2BodiesConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243580 # Test Case Title : Check that fixed joint constrains 2 bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243580 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py b/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py index 19feee575b..00e9a5625f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243581_Joints_FixedBreakable.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243581 # Test Case Title : Check that fixed joint is breakable -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243581 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py b/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py index c9c90d35a7..d34e3f67d3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243582_Joints_FixedLeadFollowerCollide.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243582 # Test Case Title : Check that fixed joint allows lead-follower collision -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243582 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py index 66343534a7..eafce6ceaf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243583_Joints_Hinge2BodiesConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243583 # Test Case Title : Check that hinge joint constrains 2 bodies about X-axis -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243583 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py index 3b335cc5c6..90027be2d7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243584_Joints_HingeSoftLimitsConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243584 # Test Case Title : Check that hinge joint allows soft limit constraints on 2 bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243584 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py index 289522fcac..0f677d94ae 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243585_Joints_HingeNoLimitsConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243585 # Test Case Title : Check that hinge joint allows no limit constraints on 2 bodies -# URL of the test case :https://testrail.agscollab.com/index.php?/cases/view/18243585 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py b/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py index 60b9189c83..7c973729d1 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243586_Joints_HingeLeadFollowerCollide.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243586 # Test Case Title : Check that hinge joint allows lead-follower collision -# URL of the test case :https://testrail.agscollab.com/index.php?/cases/view/18243586 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py b/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py index af6fa8cbac..4734328d70 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243587_Joints_HingeBreakable.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243587 # Test Case Title : Check that hinge joint is breakable -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243587 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py index 074ca03000..b6acfd6dd8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243588_Joints_Ball2BodiesConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243588 # Test Case Title : Check that ball joint constrains 2 bodies within cone limits -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243588 + # fmt: off class Tests: enter_game_mode = ("Entered game mode", "Failed to enter game mode") diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py index e038b33043..1ca49035b5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : 18243589 # Test Case Title : Check that ball joint allows soft limit constraints -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243589 + # fmt: off class Tests: @@ -57,6 +57,7 @@ def C18243589_Joints_BallSoftLimitsConstrained(): """ import os import sys + import math import ImportPathHelper as imports @@ -95,13 +96,33 @@ def C18243589_Joints_BallSoftLimitsConstrained(): Report.info_vector3(follower.position, "follower initial position:") leadInitialPosition = lead.position followerInitialPosition = follower.position + + followerMovedAboveJoint = False + #calculate the start vector from follower and lead positions + normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position) + normalizedStartPos = normalizedStartPos.GetNormalizedSafe() + #the targeted angle to reach between the initial vector and the current follower-lead vector + TARGET_ANGLE_DEG = 45 + targetAngle = math.radians(TARGET_ANGLE_DEG) + angleAchieved = 0.0 - # 4) Wait for several seconds - general.idle_wait(1.0) # wait for lead and follower to move + def checkAngleMet(): + #calculate the current follower-lead vector + normalVec = JointsHelper.getRelativeVector(lead.position, follower.position) + normalVec = normalVec.GetNormalizedSafe() + #dot product + acos to get the angle + angleAchieved = math.acos(normalizedStartPos.Dot(normalVec)) + #is it above target? + return angleAchieved > targetAngle + + MAX_WAIT_TIME = 2.0 #seconds + followerMovedAboveJoint = helper.wait_for_condition(checkAngleMet, MAX_WAIT_TIME) # 5) Check to see if lead and follower behaved as expected - Report.info_vector3(lead.position, "lead position after 1 second:") - Report.info_vector3(follower.position, "follower position after 1 second:") + Report.info_vector3(lead.position, "lead position:") + Report.info_vector3(follower.position, "follower position:") + angleAchievedDeg = math.degrees(angleAchieved) + Report.info(f"Angle achieved {angleAchievedDeg:.2f} Target {TARGET_ANGLE_DEG:.2f}") leadPositionDelta = lead.position.Subtract(leadInitialPosition) leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON) @@ -111,7 +132,6 @@ def C18243589_Joints_BallSoftLimitsConstrained(): followerMovedinXYZ = JointsHelper.vector3LargerThanScalar(followerPositionDelta, FLOAT_EPSILON) Report.critical_result(Tests.check_follower_position, followerMovedinXYZ) - followerMovedAboveJoint = follower.position.z > (followerInitialPosition.z + 2.5) # (followerInitialPosition.z + 2.5) is the z position past the 45 degree limit. This is to show that the follower swinged past the 45 degree cone limit, above the joint position. Report.critical_result(Tests.check_follower_above_joint, followerMovedAboveJoint) # 6) Exit Game Mode diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py index ede46fd5c5..1d5a213cd8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243590_Joints_BallNoLimitsConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243590 # Test Case Title : Check that ball joint allows no limit constraints -# URL of the test case :https://testrail.agscollab.com/index.php?/cases/view/18243590 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py b/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py index c3e527956f..8f7b2d7823 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243591_Joints_BallLeadFollowerCollide.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243591 # Test Case Title : Check that ball joint allows lead-follower collision -# URL of the test case :https://testrail.agscollab.com/index.php?/cases/view/18243591 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py b/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py index 350fccd125..0fa43cf9c8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243592_Joints_BallBreakable.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243592 # Test Case Title : Check that ball joint is breakable -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243592 + # fmt: off class Tests: enter_game_mode = ("Entered game mode", "Failed to enter game mode") diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py index 4580a229ea..37d659f181 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243593_Joints_GlobalFrameConstrained.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18243593 # Test Case Title : Check that fixed/hinge/ball joints allow constraints to global frame -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18243593 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py b/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py index 57dfc0f349..b17b97a816 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18977601_Material_FrictionCombinePriority.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18977601 # Test Case Title : Verify that when two objects with different materials collide, the friction combine priority works -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18977601 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py b/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py index 9b7fea1ab9..690d3d4d3f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18981526_Material_RestitutionCombinePriority.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C18981526 # Test Case Title : Verify when two objects with different materials collide, the restitution combine priority works -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/18981526 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py b/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py index 48c947aa1f..611b502019 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19536274_GetCollisionName_PrintsName.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C19536274 Test Case Title : Verify that the Get Collision Layer Name node prints the name of the collision layer -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/19536274 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py b/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py index 66e1302b5b..04d973cbb2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19536277_GetCollisionName_PrintsNothing.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C19536277 Test Case Title : Verify that when a group is modified using ToggleCollisionLayer node such that the new group is not in the pre-existing groups, GetCollisionGroupName node prints no value -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/19536277 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py index 32ece8541c..23996934bc 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19578018_ShapeColliderWithNoShapeComponent.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C19578018 Test Case Title : Verify that a shape collider component with no shape component indicates a missing service -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/19578018 + """ # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py b/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py index 0c42f5457d..1eb36e16f4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19578021_ShapeCollider_CanBeAdded.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C19578021 Test Case Title : Verify that a shape collider component may be added to an entity along with one or more PhysX collider components -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/19578021 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py b/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py index 769f08e3c4..f6584624c3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C19723164_ShapeColliders_WontCrashEditor.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C19723164 Test Case Title : Verify that if we had 512 shape colliders in the level, the level does not crash -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/19723164 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py index 60fa9dc44d..101b96b99b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C24308873 # Test Case Title : Check that cylinder shape collider collides with terrain -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/24308873 + # A cylinder is suspended slightly over PhysX Terrain to check that it collides when dropped diff --git a/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py b/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py index 8980e68250..052795318a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C28978033_Ragdoll_WorldBodyBusTests.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C28978033 # Test Case Title : Check that WorldRequestBus works with PhysX ragdoll -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/28978033 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py b/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py index be541e4bf9..4915d362f7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C29032500_EditorComponents_WorldBodyBusWorks.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C29032500 # Test Case Title : Check that WorldRequestBus works with editor components -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/29032500 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py index 3e3770adb9..b671cd3754 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C3510642_Terrain_NotCollideWithTerrain.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C3510642 # Test Case Title : Check that when no physX terrain component is added, collision of a PhysX object # with terrain does not work. Consequently, PhysX material assignment to terrain cannot be tested. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/3510642 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py b/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py index 5f2c40f11e..a7916129e8 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044455_Material_libraryChangesInstantly.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : 4044455 # Test Case Title : Verify that any change in any of the values including the name of the material, # once saved, is immediately reflected in the component and functionality -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044455 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py b/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py index b71c1e8ede..eced55fc76 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044456_Material_FrictionCombine.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4044456 # Test Case Title : Verify that when two objects with different materials collide, the friction combine works -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044456 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py b/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py index 1ed2e8086c..5969541a86 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044457_Material_RestitutionCombine.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4044457 # Test Case Title : Verify that when two objects with different materials collide, the restitution combine works -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044457 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py b/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py index c420250dfa..d414bc4813 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044459_Material_DynamicFriction.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4044459 # Test Case Title : Verify the functionality of dynamic friction -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044459 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py b/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py index 4e330002ff..6e864c554b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044460_Material_StaticFriction.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4044460 # Test Case Title : Verify the functionality of static friction -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044460 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py b/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py index af8990d87f..a5219ed2c7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044461_Material_Restitution.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4044461 # Test Case Title : Verify the functionality of restitution -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044461 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py b/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py index a8375114d5..e9106d89eb 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044694_Material_EmptyLibraryUsesDefault.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C4044694 # Test Case Title : Verify that if we add an empty Material library in Collider Component, the object continues to use Default material values -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/4044694 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py b/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py index 858e778f07..d65e9050bd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C4044695 Test Case Title : Verify that when you add a multiple surface fbx in PxMesh in PhysxCollider, multiple number of Material Slots populate in the Materials Section -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044695 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py b/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py index dba759015f..435e8242d5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044697_Material_PerfaceMaterialValidation.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4044697 # Test Case Title : Verify that each surface picks up the material assigned to it and behaves accordingly. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4044697 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py b/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py index 145a5e1b60..b7b3ed855f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4888315_Material_AddModifyDeleteOnCollider.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C4888315 # Test Case Title : Check that any change (Add/Delete/Modify) made to the material surface in the material library reflects immediately in the PhysX Collider component -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/4888315 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py index 59b6a3fdfc..7ebb62eaf3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925577_Materials_MaterialAssignedToTerrain.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4925577 # Test Case Title : Verify that material can be assigned to PhysX terrain in Terrain Texture Layers -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4925577 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py index e0425c35be..315cf9c3bd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925579_Material_AddModifyDeleteOnTerrain.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C4925579 # Test Case Title : Check that any change (Add/Delete/Modify) made to the material surface in the material library reflects immediately in the PhysX Terrain layers -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/4925579 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py b/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py index 9944a033e3..5fae373f47 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925580_Material_RagdollBonesMaterial.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C4925580 # Test Case Title : Verify that Material can be assigned to Ragdoll Bones and they behave as per their material -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/4925580 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py b/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py index ed872ae99e..ca37be6ff0 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4925582_Material_AddModifyDeleteOnRagdollBones.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C4925582 # Test Case Title : Check that any change (Add/Delete/Modify) made to the material surface in the material library reflects immediately in the ragdoll bones -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/4925582 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py b/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py index aa059eb224..8bb005711e 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976194_RigidBody_PhysXComponentIsValid.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976194 # Test Case Title : Verify that you can add PhysX Rigid Bodies Physics component to an Entity without any warning or Error. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976194 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py b/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py index c5740b2798..3dbf26a0ac 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976195_RigidBodies_InitialLinearVelocity.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976195 # Test Case Title : Verify that when you assign an Initial Linear Velocity to an object, # ... it moves with that linear velocity when we switch to game mode. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976195 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py b/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py index 08e171269e..7a17eb5941 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976197_RigidBodies_InitialAngularVelocity.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976197 # Test Case Title : Verify that when you assign an Initial Angular Velocity to an object, # it moves with that Angular velocity when we switch to game mode -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976197 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py b/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py index 2e19b633c4..457cb18640 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976199_RigidBodies_LinearDampingObjectMotion.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976199 # Test Case Title : Verify that with higher linear damping, the object in motion comes to rest faster -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976199 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py b/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py index b90b34be53..f423821757 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976200_RigidBody_AngularDampingObjectRotation.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976200 # Test Case Title : Verify that with higher angular damping, the object in rotation comes to rest faster -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976200 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py index 7fb0ff84ce..fd15cbbb0f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976201_RigidBody_MassIsAssigned.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976201 # Test Case Title : Verify that the value assigned to the Mass of the object, gets actually assigned to the object -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976201 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py b/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py index 7d4cf1066e..c66f5cf7b6 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976202_RigidBody_StopsWhenBelowKineticThreshold.py @@ -14,7 +14,7 @@ Test case ID : C4976202 Test Case Title : Verify that if the object is moving with Kinetic energy less than the sleep threshold value, then physX will put it to stop after 0.4 secs (once the wake counter goes to zero) if the KE is still below the threshold -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976202 + """ # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py b/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py index 29fc2ec2a3..6b29062adf 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976204_Verify_Start_Asleep_Condition.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976204 # Test Case Title : Verify that when Start Asleep is checked, the object in air does not fall down due to # gravity or does not start moving with initial linear velocity assigned to it when switched to game mode -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976204 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py b/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py index b97c590a93..934e546d65 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976206_RigidBodies_GravityEnabledActive.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976206 # Test Case Title : VErify that when Gravity enables is checked, the object falls down due to gravity [sic] -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976206 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py b/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py index 4481c00fc5..58193a1e9b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976207_PhysXRigidBodies_KinematicBehavior.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976207 # Test Case Title : Verify that when Kinematic is checked, the object behaves as a Kinematic object -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976207 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py b/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py index 79ea6e5dc7..600b20d98d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976209_RigidBody_ComputesCOM.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976209 # Test Case Title : Verify that when Compute COM is enabled, the PhysX system computes the COM of the object on its own -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976209 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py b/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py index 451081ba23..c53fb3508d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976210_COM_ManualSetting.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976210 # Test Case Title : Verify that when Compute COM is disabled, the user gets an option to add the co-ordinates of # the COM and the COM gets implemented at those co-ordinates. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976210 + import os diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py b/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py index 63f0d382c3..dada67548b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976218_RigidBodies_InertiaObjectsNotComputed.py @@ -9,7 +9,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ # Test case ID : C4976218 # Test Case Title: Verify that when compute inertia is checked, the physX engine does compute the inertia of the objects -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976218 + # fmt: off class Tests(): diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py b/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py index 8d9dc01396..78c031870d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976227_Collider_NewGroup.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976227 # Test Case Title : Validate that a Collision Group can be added -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976227 + # Level has entity with custom collision group added. # If level enters game mode, collision group addition is validated. diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py index 72442601e4..fdb862005f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C4976236 Test Case Title : Verify that you can add the physX collider component to an entity without it throwing an error or warning -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976236 + """ # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py b/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py index bb6234b69e..ac14164f45 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976242_Collision_SameCollisionlayerSameCollisiongroup.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976242 # Test Case Title : Assign same collision layer and same collision group to two entities and # verify that they collide or not -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976242 + # fmt: off class Tests(): diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py b/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py index 949ebb2b2a..44a8b15169 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976243_Collision_SameCollisionGroupDiffCollisionLayers.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976243 # Test Case Title : Assign different collision layers and same collision group # (such that this group has both these collision layers enabled) to two entities and verify that they collide -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976243 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py b/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py index c35b9fab81..ca1e7f57f5 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976244_Collider_SameGroupSameLayerCollision.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976244 # Test Case Title : Checks that two entities of similar custom layer collide -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976244 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py b/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py index dafb8d9014..5f8c0a8d67 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976245_PhysXCollider_CollisionLayerTest.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4976245 # Test Case Title : Check that two entities of collision group "None" do not collide, # even though they have the same collision layer -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4976245 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py b/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py index 8d985de402..126ebf48dc 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982593_PhysXCollider_CollisionLayerTest.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4982593 # Test Case Title : Check that two entities with different collision groups and layers do not collide. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982593 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py b/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py index 8746996ca8..c50c517086 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982595_Collider_TriggerDisablesCollision.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case ID : C4982595 # Test Case Title : Verify that when the Trigger Checkbox is ticked, the object no longer collides with another object # but simply passes through it -# Test Case URL : https://testrail.agscollab.com/index.php?/cases/view/4982595 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py index 2bd4fc5adc..29a3b7f89d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982797_Collider_ColliderOffset.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4982797 # Test Case Title : Check that collision offsets trigger collision events, # not entity transform locations -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982797 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py index f86890d8bf..6276c81871 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982798_Collider_ColliderRotationOffset.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C4982798 # Test Case Title : Verify that when the x,y,z values are defined in the offset, the collider frame # rotates from its original orientation in the direction defined by the x,y,z units -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982798 + import os diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py b/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py index c37ad2b2d2..1822a1efa7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982800_PhysXColliderShape_CanBeSelected.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C4982800 Test Case Title : Verify that the shape Sphere can be selected from the drop downlist and the value for its radius can be set -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982800 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py b/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py index 19a835da18..ef9b8171c4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982801_PhysXColliderShape_CanBeSelected.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C4982801 Test Case Title : Verify that the shape Box can be selected from drop downlist and the value for its dimensions in x,y,z can be set after that -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982801 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py b/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py index e1365d0887..642dea48de 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982802_PhysXColliderShape_CanBeSelected.py @@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C4982802 Test Case Title : Verify that the shape capsule can be selected from drop downlist and the value for its height and radius can be set after that -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982802 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py b/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py index 4ae177934a..99e93c26c9 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4982803_Enable_PxMesh_Option.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID : C4982803 Test Case Title : Verify that when the shape Physics Asset is selected, PxMesh option gets enabled and a Px Mesh can be selected and assigned to the object -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/4982803 + """ # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py b/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py index 9d2a49ac70..b4af6ab506 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5296614_PhysXMaterial_ColliderShape.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5296614 # Test Case Title : Check that unless you assign a shape to a physX collider component, # the material assigned to it does not take affect -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5296614 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py b/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py index 7617e41cad..838007436c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5340400_RigidBody_ManualMomentOfInertia.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5340400 # Test Case Title : Verify that when Compute inertia is disabled, the user gets to set the moment of inertia # and physX engine work accordingly -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5340400 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py b/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py index 0686adf15d..f17bf2492f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689518_PhysXTerrain_CollidesWithPhysXTerrain.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5689518 # Test Case Title : PhysX entities collide with PhysX Terrain -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5689518 + # A ball is suspended slightly over PhysX Terrain to check that it collides when dropped diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py b/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py index ffafeaab34..61ef63c4ae 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689522_Physxterrain_AddPhysxterrainNoEditorCrash.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5689522 # Test Case Title : Create an entity with PhysX terrain. Add another PhysX terrain and verify that # you are able to add it without any crash or error. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5689522 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py b/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py index 2b1a73f1f3..c395507ea0 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689524_MultipleTerrains_CheckWarningInConsole.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5689524 # Test Case Title : Create multiple entities each with one or more terrain components and verify that you are # able to successfully add the PhysX Terrain components to them. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5689524 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py b/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py index 265836489d..12f3955bf6 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689528_Terrain_MultipleTerrainComponents.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5689528 # Test Case Title : Create multiple entities each with one PhysX terrain component and verify that a warning # is thrown to the user -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5689528 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py b/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py index 138ae68408..c5342d7421 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689529_Verify_Terrain_RigidBody_Collider_Mesh.py @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test Case Title : Create an entity with PhysX Terrain component and add # PhysX Rigid Body PhysX, PhysX Collider and Rendering Mesh to it and # verify that it works in game mode -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5689529 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py index 7d60a61ec1..85a9037a36 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5689531_Warning_TerrainSliceTerrainComponent.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5689531 # Test Case Title : Check that when you add a spawner component to a level to spawn a # terrain and also add a terrain component explicitly, no crash happens -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5689531 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py b/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py index f01dd4582f..b1f9f8f934 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932040_ForceRegion_CubeExertsWorldForce.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5932040 # Test Case Title : Check that force region exerts world space force on rigid bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5932040 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py index 095a669541..5fc07fdc67 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932041_PhysXForceRegion_LocalSpaceForceOnRigidBodies.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5932041 # Test Case Title : Check that force region exerts local space force on rigid bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5932041 + # Sphere drops and is acted upon in an upward and positive x-ward direction by a force # with a magnitude close to the assigned force region magnitude when it reaches the force region. diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py b/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py index 04cecd45b2..b55ce59d7a 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5932042 # Test Case Title : Check that force region exerts linear damping force on rigid bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5932042 + # fmt: off @@ -135,7 +135,7 @@ def C5932042_PhysXForceRegion_LinearDamping(): # Constants CLOSE_ENOUGH = 0.001 - TIME_OUT = 2.0 + TIME_OUT = 3.0 INITIAL_VELOCITY = azmath.Vector3(0.0, 0.0, -10.0) # 1) Open level / Enter game mode diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py index 512698ce4b..b4d29f8065 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932043_ForceRegion_SimpleDragOnRigidBodies.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5932043 # Test Case Title : Check that force region exerts simple drag force on rigid bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5932043 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py b/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py index b7257b488b..6cfaf857a4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932044_ForceRegion_PointForceOnRigidBody.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5932044 # Test Case Title : Check that force region exerts point force on rigid bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5932044 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py b/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py index eca0679921..298265966c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932045_ForceRegion_Spline.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5932045 # Test Case Title : Check that force region exerts spline follow force on rigid bodies -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5932045 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py b/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py index 6aff0a7145..a8ef614f75 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959759_RigidBody_ForceRegionSpherePointForce.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959759 # Test Case Title : Check that force region (sphere) exerts point force -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959759 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py b/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py index 89eb1842be..4cb1cffd16 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959760_PhysXForceRegion_PointForceExertion.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959760 # Test Case Title : Check that force region (capsule) exerts point force -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959760 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py b/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py index ba0475266b..27f9e41a7d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959761_ForceRegion_PhysAssetExertsPointForce.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959761 # Test Case Title : Check that force region (physics asset) exerts point force -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959761 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py b/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py index 76130d25eb..4b62f9a029 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959763_ForceRegion_ForceRegionImpulsesCube.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959764 # Test Case Title : Check that rigid body (Cube) gets impulse from force region -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959764 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py b/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py index f314dae5b7..aadc07b09b 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959764_ForceRegion_ForceRegionImpulsesCapsule.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959764 # Test Case Title : Check that rigid body (Capsule) gets impulse from force region -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959764 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py b/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py index ddcba5996b..ed007594c2 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959765_ForceRegion_AssetGetsImpulsed.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959765 # Test Case Title : Check that rigid body (asset) gets impulse from force region -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959765 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py index 175f73a420..7c3f8a43aa 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959808_ForceRegion_PositionOffset.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959808 # Test Case Title : Verify Force Region Position Offset -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959808 + # fmt:off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py b/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py index 1ad53194d3..dc84be8798 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959809_ForceRegion_RotationalOffset.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959809 # Test Case Title : Verify Force Region Rotational Offset -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959809 + # fmt:off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py b/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py index 212f7cc86b..8efc3dc635 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5959810_ForceRegion_ForceRegionCombinesForces.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5959810 # Test Case Title : Check that multiple forces in single force region create correct net force -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5959810 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py b/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py index 4aa0fef642..948e172962 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5968759_ForceRegion_ExertsSeveralForcesOnRigidBody.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5968759 # Test Case Title : Check nested force regions exert forces simultaneously on rigid body -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5968759 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py b/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py index ba491c96a7..0897fcb0d7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5968760_ForceRegion_CheckNetForceChange.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C5968760 # Test Case Title : Check moving force region changes net force -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/5968760 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py b/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py index 4543b0b8f6..00d53a2d6c 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6032082_Terrain_MultipleResolutionsValid.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6032082 # Test Case Title : Verify multiple terrain resolutions are supported -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6032082 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py b/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py index 557b7e7ec5..2b427468b7 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090546_ForceRegion_SliceFileInstantiates.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6090546 # Test Case Title : Check that a force region slice can be saved and instantiated -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090546 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py b/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py index a07fd1861b..84474f0226 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090547_ForceRegion_ParentChildForceRegions.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6090547 # Test Case Title : Check that force regions in parent and child entities work together. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090547 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py index f8da62ebac..e2c55a024d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090550_ForceRegion_WorldSpaceForceNegative.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ Test case ID : C6090550 Test Case Title : Check that force region exerts world space force on rigid bodies (negative test) -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090550 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py index 0788b1da66..2e201e20bd 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090551_ForceRegion_LocalSpaceForceNegative.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ Test case ID : C6090551 Test Case Title : Check that force region exerts local space force on rigid bodies (negative test) -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090551 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py index a878819045..585a337389 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090552_ForceRegion_LinearDampingNegative.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ Test case ID : C6090552 Test Case Title : Check that force region exerts linear damping force on rigid bodies (negative test) -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090552 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py index 43c4335918..6abee0ad64 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090553_ForceRegion_SimpleDragForceOnRigidBodies.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6090553 # Test Case Title : Check that force region exerts simple drag force on rigid bodies (negative test) -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090553 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py b/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py index d7781b6040..0969cebd8d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090554_ForceRegion_PointForceNegative.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ Test case ID : C6090554 Test Case Title : Check that force region exerts point force on rigid bodies (negative test) -URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090554 + """ diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py b/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py index b1b76d896d..90f67391ad 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6090555_ForceRegion_SplineFollowOnRigidBodies.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6090555 # Test Case Title : Check that force region exerts spline follow force on rigid bodies(negative test) -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6090555 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py b/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py index 11281df4eb..ee68ef6049 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6131473_StaticSlice_OnDynamicSliceSpawn.py @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6131473 # Test Case Title : Verify a static slice is not spawned automatically everytime a dynamic slice with # PhysX Components is spawned -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6131473 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py b/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py index 6501e11e68..6693c17dff 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6224408_ScriptCanvas_EntitySpawn.py @@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6224408 # Test Case Title : Entity using PhysX nodes in Script Canvas can be spawned. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6224408 + # fmt: off class Tests: diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py b/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py index 44c8be9e1e..c360473b7f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6274125_ScriptCanvas_TriggerEvents.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6274125 # Test Case Title : Verify ScriptCanvas Trigger Events. -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6274125 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py b/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py index c1a51f2887..4b0b036970 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C6321601_Force_HighValuesDirectionAxes.py @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Test case ID : C6321601 # Test Case Title : Check that very high values of direction axes of forces do not throw error -# URL of the test case : https://testrail.agscollab.com/index.php?/cases/view/6321601 + # fmt: off diff --git a/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py b/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py index e61118ef5b..476c1df237 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py +++ b/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py @@ -27,6 +27,13 @@ def vector3LargerThanScalar(vec3Value, scalarValue): vec3Value.y > scalarValue and vec3Value.z > scalarValue) +def getRelativeVector(vecA, vecB): + relativeVec = vecA + relativeVec.x = relativeVec.x - vecB.x + relativeVec.y = relativeVec.y - vecB.y + relativeVec.z = relativeVec.z - vecB.z + return relativeVec + # Entity class for joints tests class JointEntity: diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py index f81445fe03..8f1f2f7481 100644 --- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py @@ -73,7 +73,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxsystemconfiguration.setreg','C4982593_PhysXCollider_CollisionLayer.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxsystemconfiguration.setreg','C4982593_PhysXCollider_CollisionLayer.setreg_override', 'AutomatedTesting/Registry') def test_C4982593_PhysXCollider_CollisionLayerTest(self, request, workspace, editor, launcher_platform): from . import C4982593_PhysXCollider_CollisionLayerTest as test_module self._run_test(request, workspace, editor, test_module) diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py index 4f91f539ee..3bbfe64e38 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py +++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py @@ -254,6 +254,8 @@ class TestAutomation(TestAutomationBase): from . import C4044697_Material_PerfaceMaterialValidation as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail( + reason="This test will sometimes fail as the ball will continue to roll before the timeout is reached.") @revert_physics_config def test_C4976202_RigidBody_StopsWhenBelowKineticThreshold(self, request, workspace, editor, launcher_platform): from . import C4976202_RigidBody_StopsWhenBelowKineticThreshold as test_module @@ -306,19 +308,19 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxsystemconfiguration.setreg','C4976245_PhysXCollider_CollisionLayerTest.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxsystemconfiguration.setreg','C4976245_PhysXCollider_CollisionLayerTest.setreg_override', 'AutomatedTesting/Registry') def test_C4976245_PhysXCollider_CollisionLayerTest(self, request, workspace, editor, launcher_platform): from . import C4976245_PhysXCollider_CollisionLayerTest as test_module self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxsystemconfiguration.setreg','C4976244_Collider_SameGroupSameLayerCollision.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxsystemconfiguration.setreg','C4976244_Collider_SameGroupSameLayerCollision.setreg_override', 'AutomatedTesting/Registry') def test_C4976244_Collider_SameGroupSameLayerCollision(self, request, workspace, editor, launcher_platform): from . import C4976244_Collider_SameGroupSameLayerCollision as test_module self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxdefaultsceneconfiguration.setreg','C14195074_ScriptCanvas_PostUpdateEvent.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxdefaultsceneconfiguration.setreg','C14195074_ScriptCanvas_PostUpdateEvent.setreg_override', 'AutomatedTesting/Registry') def test_C14195074_ScriptCanvas_PostUpdateEvent(self, request, workspace, editor, launcher_platform): from . import C14195074_ScriptCanvas_PostUpdateEvent as test_module self._run_test(request, workspace, editor, test_module) @@ -329,7 +331,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxdefaultsceneconfiguration.setreg','C14902097_ScriptCanvas_PreUpdateEvent.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxdefaultsceneconfiguration.setreg','C14902097_ScriptCanvas_PreUpdateEvent.setreg_override', 'AutomatedTesting/Registry') def test_C14902097_ScriptCanvas_PreUpdateEvent(self, request, workspace, editor, launcher_platform): from . import C14902097_ScriptCanvas_PreUpdateEvent as test_module self._run_test(request, workspace, editor, test_module) @@ -363,7 +365,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxsystemconfiguration.setreg','C4976227_Collider_NewGroup.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxsystemconfiguration.setreg','C4976227_Collider_NewGroup.setreg_override', 'AutomatedTesting/Registry') def test_C4976227_Collider_NewGroup(self, request, workspace, editor, launcher_platform): from . import C4976227_Collider_NewGroup as test_module self._run_test(request, workspace, editor, test_module) @@ -448,7 +450,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config - @fm.file_override('physxsystemconfiguration.setreg','C3510644_Collider_CollisionGroups.setreg', 'AutomatedTesting/Registry') + @fm.file_override('physxsystemconfiguration.setreg','C3510644_Collider_CollisionGroups.setreg_override', 'AutomatedTesting/Registry') def test_C3510644_Collider_CollisionGroups(self, request, workspace, editor, launcher_platform): from . import C3510644_Collider_CollisionGroups as test_module self._run_test(request, workspace, editor, test_module) @@ -468,12 +470,12 @@ class TestAutomation(TestAutomationBase): from . import C6090547_ForceRegion_ParentChildForceRegions as test_module self._run_test(request, workspace, editor, test_module) - @revert_physics_config + @revert_physics_config def test_C19578021_ShapeCollider_CanBeAdded(self, request, workspace, editor, launcher_platform): from . import C19578021_ShapeCollider_CanBeAdded as test_module self._run_test(request, workspace, editor, test_module) - @revert_physics_config + @revert_physics_config def test_C15425929_Undo_Redo(self, request, workspace, editor, launcher_platform): from . import C15425929_Undo_Redo as test_module self._run_test(request, workspace, editor, test_module) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/AssetEditor_CreateScriptEventFile.py b/AutomatedTesting/Gem/PythonTests/scripting/AssetEditor_CreateScriptEventFile.py new file mode 100644 index 0000000000..dcbbf47f0c --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/AssetEditor_CreateScriptEventFile.py @@ -0,0 +1,124 @@ +""" +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. + +Test case ID: T92569013 +Test Case Title: Script Event file can be created +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569013 +""" + + +# fmt: off +class Tests(): + new_event_created = ("New Script Event created", "New Script Event not created") + child_event_created = ("Child Event created", "Child not created") + file_saved = ("Script event file saved", "Script event file did not save") + console_error = ("No unexpected error in console", "Error found in console") + console_warning = ("No unexpected warning in console", "Warning found in console") +# fmt: on + + +def CreateScriptEventFile(): + """ + Summary: + Script Event file can be created + + Expected Behavior: + File is created without any errors and warnings in Console + + Test Steps: + 1) Open Asset Editor + 2) Get Asset Editor Qt object + 3) Create new Script Event Asset + 4) Add new child event + 5) Save the Script Event file + 6) Verify if file is created + 7) Verify console for errors/warnings + 8) Close Asset Editor + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + import os + from utils import Report + from utils import TestHelper as helper + from utils import Tracer + import pyside_utils + + # Open 3D Engine imports + import azlmbr.legacy.general as general + import azlmbr.editor as editor + import azlmbr.bus as bus + + # Pyside imports + from PySide2 import QtWidgets + + GENERAL_WAIT = 1.0 # seconds + + FILE_PATH = os.path.join("AutomatedTesting", "ScriptCanvas", "test_file.scriptevent") + + # 1) Open Asset Editor + general.idle_enable(True) + # Initially close the Asset Editor and then reopen to ensure we don't have any existing assets open + general.close_pane("Asset Editor") + general.open_pane("Asset Editor") + helper.wait_for_condition(lambda: general.is_pane_visible("Asset Editor"), 5.0) + + # 2) Get Asset Editor Qt object + editor_window = pyside_utils.get_editor_main_window() + asset_editor_widget = editor_window.findChild(QtWidgets.QDockWidget, "Asset Editor").findChild( + QtWidgets.QWidget, "AssetEditorWindowClass" + ) + container = asset_editor_widget.findChild(QtWidgets.QWidget, "ContainerForRows") + menu_bar = asset_editor_widget.findChild(QtWidgets.QMenuBar) + + # 3) Create new Script Event Asset + action = pyside_utils.find_child_by_pattern(menu_bar, {"type": QtWidgets.QAction, "text": "Script Events"}) + action.trigger() + result = helper.wait_for_condition( + lambda: container.findChild(QtWidgets.QFrame, "Events") is not None, 3 * GENERAL_WAIT + ) + Report.result(Tests.new_event_created, result) + + # 4) Add new child event + add_event = container.findChild(QtWidgets.QFrame, "Events").findChild(QtWidgets.QToolButton, "") + add_event.click() + result = helper.wait_for_condition( + lambda: asset_editor_widget.findChild(QtWidgets.QFrame, "EventName") is not None, GENERAL_WAIT + ) + Report.result(Tests.child_event_created, result) + + with Tracer() as section_tracer: + # 5) Save the Script Event file + editor.AssetEditorWidgetRequestsBus(bus.Broadcast, "SaveAssetAs", FILE_PATH) + + # 6) Verify if file is created + result = helper.wait_for_condition(lambda: os.path.exists(FILE_PATH), 3 * GENERAL_WAIT) + Report.result(Tests.file_saved, result) + + # 7) Verify console for errors/warnings + Report.result(Tests.console_error, not section_tracer.has_errors) + Report.result(Tests.console_warning, not section_tracer.has_warnings) + + # 8) Close Asset Editor + general.close_pane("Asset Editor") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(CreateScriptEventFile) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/AssetEditor_NewScriptEvent.py b/AutomatedTesting/Gem/PythonTests/scripting/AssetEditor_NewScriptEvent.py new file mode 100644 index 0000000000..1f801d4eeb --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/AssetEditor_NewScriptEvent.py @@ -0,0 +1,129 @@ +""" +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. + + +Test case ID: T92568942 +Test Case Title: Clicking the "+" button and selecting "New Script Event" opens the +Asset Editor with a new Script Event asset +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92568942 +""" + +from PySide2 import QtWidgets +import azlmbr.legacy.general as general + +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.utils import TestHelper as helper +from editor_python_test_tools.utils import Report + + +class Tests: + action_found = "New Script event action found" + asset_editor_opened = "Asset Editor opened" + new_asset = "Asset Editor created with new asset" + script_event = "New Script event created in Asset Editor" + + +GENERAL_WAIT = 0.5 # seconds + + +class TestAssetEditor_NewScriptEvent: + """ + Summary: + Clicking the "+" button in Node Palette and creating New Script Event opens Asset Editor + + Expected Behavior: + Clicking the "+" button and selecting "New Script Event" opens the Asset Editor with a + new Script Event asset + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Close any existing AssetEditor window + 3) Get the SC window object + 4) Click on New Script Event on Node palette + 5) Verify if Asset Editor opened + 6) Verify if a new asset with Script Canvas category is opened + 7) Close Script Canvas and Asset Editor + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + @pyside_utils.wrap_async + async def run_test(self): + # 1) Open Script Canvas window (Tools > Script Canvas) + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Close any existing AssetEditor window + general.close_pane("Asset Editor") + helper.wait_for_condition(lambda: not general.is_pane_visible("Asset Editor"), 5.0) + + # 3) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + node_palette = sc.findChild(QtWidgets.QDockWidget, "NodePalette") + frame = node_palette.findChild(QtWidgets.QFrame, "searchCustomization") + button = frame.findChild(QtWidgets.QToolButton) + pyside_utils.click_button_async(button) + + # 4) Click on New Script Event on Node palette + menu = None + + def menu_has_focus(): + nonlocal menu + for fw in [ + QtWidgets.QApplication.activePopupWidget(), + QtWidgets.QApplication.activeModalWidget(), + QtWidgets.QApplication.focusWidget(), + QtWidgets.QApplication.activeWindow(), + ]: + print(fw) + if fw and isinstance(fw, QtWidgets.QMenu) and fw.isVisible(): + menu = fw + return True + return False + + await pyside_utils.wait_for_condition(menu_has_focus, GENERAL_WAIT) + action = await pyside_utils.wait_for_action_in_menu(menu, {"text": "New Script Event"}) + Report.info(f"{Tests.action_found}: {action is not None}") + action.trigger() + pyside_utils.queue_hide_event(menu) + + # 5) Verify if Asset Editor opened + result = helper.wait_for_condition(lambda: general.is_pane_visible("Asset Editor"), GENERAL_WAIT) + Report.info(f"{Tests.asset_editor_opened}: {result}") + + # 6) Verify if a new asset with Script Canvas category is opened + asset_editor = editor_window.findChild(QtWidgets.QDockWidget, "Asset Editor") + row_container = asset_editor.findChild(QtWidgets.QWidget, "ContainerForRows") + # NOTE: QWidget ContainerForRows will have frames of Name, Category, ToolTip etc. + # To validate if a new script event file is generated, we check for + # QFrame Category and its value + categories = row_container.findChildren(QtWidgets.QFrame, "Category") + Report.info(f"{Tests.new_asset}: {len(categories)>0}") + result = False + for frame in categories: + line_edit = frame.findChild(QtWidgets.QLineEdit) + result = True if (line_edit and line_edit.text() == "Script Events") else False + Report.info(f"{Tests.script_event}: {result}") + + # 7) Close Script Canvas and Asset Editor + general.close_pane("Script Canvas") + general.close_pane("Asset Editor") + + +test = TestAssetEditor_NewScriptEvent() +test.run_test() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Debugging_TargetMultipleEntities.py b/AutomatedTesting/Gem/PythonTests/scripting/Debugging_TargetMultipleEntities.py new file mode 100644 index 0000000000..a26cb4f923 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/Debugging_TargetMultipleEntities.py @@ -0,0 +1,144 @@ +""" +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. + + +Test case ID: T92568856 +Test Case Title: Multiple Entities can be targeted in the Debugger tool +URLs of the test case: https://testrail.agscollab.com/index.php?/tests/view/92568856 +""" + + +# fmt: off +class Tests(): + level_created = ("New level created", "New level not created") + entities_found = ("Entities are found in Logging window", "Entities are not found in Logging window") + select_multiple_targets = ("Multiple targets are selected", "Multiple targets are not selected") +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +def Debugging_TargetMultipleEntities(): + """ + Summary: + Multiple Entities can be targeted in the Debugger tool + + Expected Behavior: + Selected files can be checked for logging. + Upon checking, checkboxes of the parent folders change to either full or partial check. + + Test Steps: + 1) Create temp level + 2) Create two entities with scriptcanvas components + 3) Set values for scriptcanvas + 4) Open Script Canvas window and get sc opbject + 5) Open Debugging(Logging) window + 6) Click on Entities tab in logging window + 7) Verify if the scriptcanvas exist under entities + 8) Verify if the entities can be selected + 9) Close Debugging window and Script Canvas window + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from PySide2 import QtWidgets + from PySide2.QtCore import Qt + import azlmbr.legacy.general as general + import azlmbr.math as math + import azlmbr.asset as asset + import azlmbr.bus as bus + + import os + import pyside_utils + import hydra_editor_utils as hydra + from utils import TestHelper as helper + from utils import Report + + LEVEL_NAME = "tmp_level" + ASSET_NAME_1 = "ScriptCanvas_TwoComponents0.scriptcanvas" + ASSET_NAME_2 = "ScriptCanvas_TwoComponents1.scriptcanvas" + ASSET_1 = os.path.join("scriptcanvas", ASSET_NAME_1) + ASSET_2 = os.path.join("scriptcanvas", ASSET_NAME_2) + WAIT_TIME = 3.0 + + def get_asset(asset_path): + return asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False) + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create two entities with scriptcanvas components + position = math.Vector3(512.0, 512.0, 32.0) + test_entity_1 = hydra.Entity("test_entity_1") + test_entity_1.create_entity(position, ["Script Canvas"]) + test_entity_2 = hydra.Entity("test_entity_2") + test_entity_2.create_entity(position, ["Script Canvas"]) + + # 3) Set values for scriptcanvas + test_entity_1.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_1)) + test_entity_2.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_2)) + + # 4) Open Script Canvas window and get sc opbject + general.open_pane("Script Canvas") + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + + # 5) Open Debugging(Logging) window + if ( + sc.findChild(QtWidgets.QDockWidget, "LoggingWindow") is None + or not sc.findChild(QtWidgets.QDockWidget, "LoggingWindow").isVisible() + ): + action = pyside_utils.find_child_by_pattern(sc, {"text": "Debugging", "type": QtWidgets.QAction}) + action.trigger() + logging_window = sc.findChild(QtWidgets.QDockWidget, "LoggingWindow") + + # 6) Click on Entities tab in logging window + button = pyside_utils.find_child_by_pattern(logging_window, {"type": QtWidgets.QPushButton, "text": "Entities"}) + button.click() + + # 7) Verify if the scriptcanvas exist under entities + entities = logging_window.findChild(QtWidgets.QWidget, "entitiesPage") + tree = entities.findChild(QtWidgets.QTreeView, "pivotTreeView") + asset_1_mi = pyside_utils.find_child_by_pattern(tree, ASSET_NAME_1.lower()) + asset_2_mi = pyside_utils.find_child_by_pattern(tree, ASSET_NAME_2.lower()) + result = asset_1_mi is not None and asset_2_mi is not None + Report.critical_result(Tests.entities_found, result) + + # 8) Verify if the entities can be selected + tree.expandAll() + tree.model().setData(asset_1_mi, 2, Qt.CheckStateRole) + tree.model().setData(asset_2_mi, 2, Qt.CheckStateRole) + checklist = [asset_1_mi, asset_1_mi.parent(), asset_2_mi, asset_2_mi.parent()] + result = all([index.data(Qt.CheckStateRole) == 2 for index in checklist]) + Report.critical_result(Tests.select_multiple_targets, result) + + # 9) Close Debugging window and Script Canvas window + logging_window.close() + general.close_pane("Script Canvas") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + from utils import Report + + Report.start_test(Debugging_TargetMultipleEntities) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Debugging_TargetMultipleGraphs.py b/AutomatedTesting/Gem/PythonTests/scripting/Debugging_TargetMultipleGraphs.py new file mode 100644 index 0000000000..4aa5c822a7 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/Debugging_TargetMultipleGraphs.py @@ -0,0 +1,113 @@ +""" +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. + + +Test case ID: T92569137 +Test Case Title: Multiple Graphs can be targeted in the Debugger tool +URLs of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569137 +""" + + +# fmt: off +class Tests(): + select_multiple_targets = ("Multiple targets are selected", "Multiple targets are not selected") +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +def Debugging_TargetMultipleGraphs(): + """ + Summary: + Multiple Graphs can be targeted in the Debugger tool + + Expected Behavior: + Selected files can be checked for logging. + Upon checking, checkboxes of the parent folders change to either full or partial check. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Open Debugging Tool if not opened already + 4) Select Graphs tab under logging window + 5) Select multiple targets from levels and scriptcanvas + 6) Verify if multiple targets are selected + 7) Close Debugging window and Script Canvas window + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from PySide2 import QtWidgets + from PySide2.QtCore import Qt + import azlmbr.legacy.general as general + + import pyside_utils + from utils import TestHelper as helper + from utils import Report + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 6.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + + # 3) Open Debugging Tool if not opened already + if ( + sc.findChild(QtWidgets.QDockWidget, "LoggingWindow") is None + or not sc.findChild(QtWidgets.QDockWidget, "LoggingWindow").isVisible() + ): + action = pyside_utils.find_child_by_pattern(sc, {"text": "Debugging", "type": QtWidgets.QAction}) + action.trigger() + logging_window = sc.findChild(QtWidgets.QDockWidget, "LoggingWindow") + + # 4) Select Graphs tab under logging window + button = pyside_utils.find_child_by_pattern(logging_window, {"type": QtWidgets.QPushButton, "text": "Graphs"}) + button.click() + + # 5) Select multiple targets from levels and scriptcanvas + graphs = logging_window.findChild(QtWidgets.QWidget, "graphsPage") + tree = graphs.findChild(QtWidgets.QTreeView, "pivotTreeView") + # Select the first child under levels + level_model_index = pyside_utils.find_child_by_pattern(tree, "levels") + level_child_index = pyside_utils.get_item_view_index(tree, 0, 0, level_model_index) + tree.model().setData(level_child_index, 2, Qt.CheckStateRole) + # Select the first child under scriptcanvas + sc_model_index = pyside_utils.find_child_by_pattern(tree, "scriptcanvas") + sc_child_index = pyside_utils.get_item_view_index(tree, 0, 0, sc_model_index) + tree.model().setData(sc_child_index, 2, Qt.CheckStateRole) + + # 6) Verify if multiple targets are selected + result = all([index.data(Qt.CheckStateRole) != 0 for index in (level_model_index, sc_model_index)]) + result = result and all([index.data(Qt.CheckStateRole) == 2 for index in (level_child_index, sc_child_index)]) + Report.result(Tests.select_multiple_targets, result) + + # 7) Close Debugging window and Script Canvas window + logging_window.close() + general.close_pane("Script Canvas") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(Debugging_TargetMultipleGraphs) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py b/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py index 25dd83e5e2..4fa1e1257f 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/Docking_Pane.py @@ -16,7 +16,6 @@ URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/1702 # fmt: off class Tests(): - open_sc_window = ("Script Canvas window is opened", "Failed to open Script Canvas window") pane_opened = ("Pane is opened successfully", "Failed to open pane") dock_pane = ("Pane is docked successfully", "Failed to dock Pane into one or more allowed area") # fmt: on @@ -78,8 +77,7 @@ def Docking_Pane(): # 1) Open Script Canvas window (Tools > Script Canvas) general.open_pane("Script Canvas") - is_sc_visible = helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) - Report.result(Tests.open_sc_window, is_sc_visible) + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) # 2) Make sure Node Palette pane is opened editor_window = pyside_utils.get_editor_main_window() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/EditMenu_UndoRedo.py b/AutomatedTesting/Gem/PythonTests/scripting/EditMenu_UndoRedo.py new file mode 100644 index 0000000000..a87d9e9be9 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/EditMenu_UndoRedo.py @@ -0,0 +1,123 @@ +""" +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. + + +Test case ID: T92569049 +Test Case Title: Edit > Undo undoes the last action +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569049 +Test case ID: T92569051 +Test Case Title: Edit > Redo redoes the last undone action +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569051 +""" + + +# fmt: off +class Tests(): + variable_created = ("New variable created", "New variable not created") + undo_worked = ("Undo action working", "Undo action did not work") + redo_worked = ("Redo action working", "Redo action did not work") +# fmt: on + + +def EditMenu_UndoRedo(): + """ + Summary: + Edit > Undo undoes the last action + Edit > Redo redoes the last undone action + We create a new variable in variable manager, undo and verify if variable is removed, + redo it and verify if the variable is created again. + + Expected Behavior: + The last action is undone. + The last undone action is redone. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Open Variable Manager if not opened already + 4) Create Graph + 5) Create new variable + 6) Verify if the variable is created initially + 7) Trigger Undo action and verify if variable is removed in Variable Manager + 8) Trigger Redo action and verify if variable is readded in Variable Manager + 9) Close SC window + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from PySide2 import QtWidgets, QtCore + + import azlmbr.legacy.general as general + + import pyside_utils + + # 1) Open Script Canvas window + general.idle_enable(True) + general.open_pane("Script Canvas") + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + + # 3) Open Variable Manager if not opened already + if sc.findChild(QtWidgets.QDockWidget, "VariableManager") is None: + action = pyside_utils.find_child_by_pattern(sc, {"text": "Variable Manager", "type": QtWidgets.QAction}) + action.trigger() + variable_manager = sc.findChild(QtWidgets.QDockWidget, "VariableManager") + + # 4) Create Graph + action = pyside_utils.find_child_by_pattern(sc, {"objectName": "action_New_Script", "type": QtWidgets.QAction}) + action.trigger() + + # 5) Create new variable + add_button = variable_manager.findChild(QtWidgets.QPushButton, "addButton") + add_button.click() # Click on Create Variable button + # Select variable type + table_view = variable_manager.findChild(QtWidgets.QTableView, "variablePalette") + model_index = pyside_utils.find_child_by_pattern(table_view, "Boolean") + # Click on it to create variable + pyside_utils.item_view_index_mouse_click(table_view, model_index) + + # 6) Verify if the variable is created initially + graph_vars = variable_manager.findChild(QtWidgets.QTableView, "graphVariables") + result = graph_vars.model().rowCount(QtCore.QModelIndex()) == 1 # since we added 1 variable, rowcount=1 + Report.result(Tests.variable_created, result) + + # 7) Trigger Undo action and verify if variable is removed in Variable Manager + action = sc.findChild(QtWidgets.QAction, "action_Undo") + action.trigger() + result = graph_vars.model().rowCount(QtCore.QModelIndex()) == 0 # since we triggered undo, rowcount=0 + Report.result(Tests.undo_worked, result) + + # 8) Trigger Redo action and verify if variable is readded in Variable Manager + action = sc.findChild(QtWidgets.QAction, "action_Redo") + action.trigger() + result = ( + graph_vars.model().rowCount(QtCore.QModelIndex()) == 1 + ) # since action is redone 1 variable is readded, rowcount=1 + Report.result(Tests.redo_worked, result) + + # 9) Close SC window + general.close_pane("Script Canvas") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(EditMenu_UndoRedo) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Entity_AddScriptCanvasComponent.py b/AutomatedTesting/Gem/PythonTests/scripting/Entity_AddScriptCanvasComponent.py new file mode 100644 index 0000000000..fd8e9b1173 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/Entity_AddScriptCanvasComponent.py @@ -0,0 +1,88 @@ +""" +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. + +Test case ID: T92562978 +Test Case Title: Script Canvas Component can be added to an entity +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92562978 +""" + + +# fmt: off +class Tests(): + level_created = ("New level created", "Failed to create new level") + entity_created = ("Test Entity created", "Failed to create test entity") + add_sc_component = ("Script Canvas component added to entity", "Failed to add SC component to entity") + no_errors_found = ("Tracer found no errors", "One or more errors found by Tracer") + no_warnings_found = ("Tracer found no warnings", "One or more warnings found by Tracer") +# fmt: on + + +def Entity_AddScriptCanvasComponent(): + """ + Summary: + verify if Script Canvas component can be added to Entity without any issue + + Expected Behavior: + Script Canvas Component is added to the entity successfully without issue. + + Test Steps: + 1) Create temp level + 2) Create test entity + 3) Start Tracer + 4) Add Script Canvas component to test entity + 5) Search for errors and warnings + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from utils import TestHelper as helper + from utils import Tracer + from editor_entity_utils import EditorEntity + import azlmbr.legacy.general as general + + LEVEL_NAME = "tmp_level" + WAIT_TIME = 3.0 # SECONDS + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create new entity + test_entity = EditorEntity.create_editor_entity("test_entity") + Report.result(Tests.entity_created, test_entity.id.IsValid()) + + # 3) Start Tracer + with Tracer() as section_tracer: + + # 4) Add Script Canvas component to test entity + test_entity.add_component("Script Canvas") + Report.result(Tests.add_sc_component, test_entity.has_component("Script Canvas")) + + # 5) Search for errors and warnings + Report.result(Tests.no_errors_found, not section_tracer.has_errors) + Report.result(Tests.no_warnings_found, not section_tracer.has_warnings) + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + from utils import Report + + Report.start_test(Entity_AddScriptCanvasComponent) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/FileMenu_New_Open.py b/AutomatedTesting/Gem/PythonTests/scripting/FileMenu_New_Open.py new file mode 100644 index 0000000000..f72ac8ea01 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/FileMenu_New_Open.py @@ -0,0 +1,98 @@ +""" +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. + + +Test case ID: T92569037 +Test Case Title: File > New Script creates a new script +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569037 +Test case ID: T92569039 +Test Case Title: File > Open opens the Open... dialog +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569039 +""" + +import os +import sys +from PySide2 import QtWidgets +import azlmbr.legacy.general as general + +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.utils import Report + +# fmt: off +class Tests(): + new_action = "File->New action working as expected" + open_action = "File->Open action working as expected" +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +class TestFileMenuNewOpen: + """ + Summary: + When clicked on File->New, new script opens and File->Open should open the FileBrowser + + Expected Behavior: + New and Open actions should work as expected. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Trigger File->New action + 4) Verify if New tab is opened + 5) Trigger File->Open action + 6) Close Script Canvas window + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + @pyside_utils.wrap_async + async def run_test(self): + # 1) Open Script Canvas window (Tools > Script Canvas) + general.open_pane("Script Canvas") + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + sc_main = sc.findChild(QtWidgets.QMainWindow) + sc_tabs = sc_main.findChild(QtWidgets.QTabWidget, "ScriptCanvasTabs") + + # 3) Trigger File->New action + initial_tabs_count = sc_tabs.count() + action = pyside_utils.find_child_by_pattern( + sc_main, {"objectName": "action_New_Script", "type": QtWidgets.QAction} + ) + action.trigger() + + # 4) Verify if New tab is opened + general.idle_wait(GENERAL_WAIT) + Report.info(f"{Tests.new_action}: {sc_tabs.count() == initial_tabs_count + 1}") + + # 5) Trigger File->Open action + action = pyside_utils.find_child_by_pattern(sc_main, {"objectName": "action_Open", "type": QtWidgets.QAction}) + pyside_utils.trigger_action_async(action) + general.idle_wait(GENERAL_WAIT) + popup = await pyside_utils.wait_for_modal_widget() + Report.info(f"{Tests.open_action}: {popup and 'Open' in popup.windowTitle()}") + popup.close() + + # 6) Close Script Canvas window + general.close_pane("Script Canvas") + + +test = TestFileMenuNewOpen() +test.run_test() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/GraphClose_SavePrompt.py b/AutomatedTesting/Gem/PythonTests/scripting/GraphClose_SavePrompt.py new file mode 100644 index 0000000000..ce610b159b --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/GraphClose_SavePrompt.py @@ -0,0 +1,110 @@ +""" +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. + + +Test case ID: T92563070 +Test Case Title: Graphs can be closed by clicking X on the Graph name tab +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92563070 +Test case ID: T92563068 +Test Case Title: Save Prompt: User is prompted to save a graph on close after +creating a new graph +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92563068 +""" + +import os +import sys +from PySide2 import QtWidgets +import azlmbr.legacy.general as general + +import editor_python_test_tools.pyside_utils as pyside_utils +from editor_python_test_tools.utils import TestHelper as helper +from editor_python_test_tools.utils import Report + +# fmt: off +class Tests(): + new_graph = "New graph created" + save_prompt = "Save prompt opened as expected" + close_graph = "Close button worked as expected" +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +class TestGraphCloseSavePrompt: + """ + Summary: + The graph is closed when x button is clicked. + Save Prompt is opened before closing. + + Expected Behavior: + New and Open actions should work as expected. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Trigger File->New action + 4) Verify if New tab is opened + 5) Close new tab using X on top of graph and check for save dialog + 6) Check if tab is closed + 7) Close Script Canvas window + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + @pyside_utils.wrap_async + async def run_test(self): + # 1) Open Script Canvas window (Tools > Script Canvas) + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + sc_main = sc.findChild(QtWidgets.QMainWindow) + sc_tabs = sc_main.findChild(QtWidgets.QTabWidget, "ScriptCanvasTabs") + tab_bar = sc_tabs.findChild(QtWidgets.QTabBar) + + # 3) Trigger File->New action + initial_tabs_count = sc_tabs.count() + action = pyside_utils.find_child_by_pattern( + sc_main, {"objectName": "action_New_Script", "type": QtWidgets.QAction} + ) + action.trigger() + + # 4) Verify if New tab is opened + result = helper.wait_for_condition(lambda: sc_tabs.count() == initial_tabs_count + 1, GENERAL_WAIT) + Report.info(f"{Tests.new_graph}: {result}") + + # 5) Close new tab using X on top of graph and check for save dialog + close_button = tab_bar.findChildren(QtWidgets.QAbstractButton)[0] + pyside_utils.click_button_async(close_button) + popup = await pyside_utils.wait_for_modal_widget() + if popup: + Report.info(f"{Tests.save_prompt}: {popup.findChild(QtWidgets.QDialog, 'SaveChangesDialog') is not None}") + dont_save = popup.findChild(QtWidgets.QPushButton, "m_continueButton") + dont_save.click() + + # 6) Check if tab is closed + await pyside_utils.wait_for_condition(lambda: sc_tabs.count() == initial_tabs_count, 5.0) + Report.info(f"{Tests.close_graph}: {sc_tabs.count()==initial_tabs_count}") + + # 7) Close Script Canvas window + general.close_pane("Script Canvas") + + +test = TestGraphCloseSavePrompt() +test.run_test() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Graph_ZoomInZoomOut.py b/AutomatedTesting/Gem/PythonTests/scripting/Graph_ZoomInZoomOut.py new file mode 100644 index 0000000000..a93b6e61d1 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/Graph_ZoomInZoomOut.py @@ -0,0 +1,120 @@ +""" +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. + + +Test case ID: T92569079 +Test Case Title: View > Zoom In zooms the graph in +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569079 +Test case ID: T92569081 +Test Case Title: View > Zoom In zooms the graph out +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569081 +""" + + +# fmt: off +class Tests(): + zoom_in = ("Zoom In action working as expected", "Zoom In action not working as expected") + zoom_out = ("Zoom Out action working as expected", "Zoom Out action not working as expected") +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +def Graph_ZoomInZoomOut(): + """ + Summary: + The graph can be zoomed in and zoomed out. + + Expected Behavior: + The graph is zoomed in when when we click View->ZoomIn + The graph is zoomed out when when we click View->ZoomOut + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Create new graph + 4) Get initial graph transform values + 5) Trigger Zoom In and verify if the graph transform scale is increased + 6) Trigger Zoom Out and verify if the graph transform scale is decreased + 7) Close Script Canvas window + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + # Helper imports + import ImportPathHelper as imports + + imports.init() + + from PySide2 import QtWidgets + import azlmbr.legacy.general as general + + import pyside_utils + from utils import TestHelper as helper + from utils import Report + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + sc_main = sc.findChild(QtWidgets.QMainWindow) + + # 3) Create new graph + create_new_graph = pyside_utils.find_child_by_pattern( + sc_main, {"objectName": "action_New_Script", "type": QtWidgets.QAction} + ) + create_new_graph.trigger() + + # 4) Get initial graph transform values + graphics_view = sc_main.findChild(QtWidgets.QGraphicsView) + # NOTE: transform m11 and m22 are horizontal and vertical scales of graph + # they increase when zoomed in and decreased when zoomed out + curr_m11, curr_m22 = graphics_view.transform().m11(), graphics_view.transform().m22() + + # 5) Trigger Zoom In and verify if the graph transform scale is increased + zin = pyside_utils.find_child_by_pattern(sc_main, {"objectName": "action_ZoomIn", "type": QtWidgets.QAction}) + zin.trigger() + result = helper.wait_for_condition( + lambda: curr_m11 < graphics_view.transform().m11() and curr_m22 < graphics_view.transform().m22(), GENERAL_WAIT, + ) + Report.result(Tests.zoom_in, result) + + # 6) Trigger Zoom Out and verify if the graph transform scale is decreased + curr_m11, curr_m22 = graphics_view.transform().m11(), graphics_view.transform().m22() + zout = pyside_utils.find_child_by_pattern(sc_main, {"objectName": "action_ZoomOut", "type": QtWidgets.QAction}) + zout.trigger() + result = helper.wait_for_condition( + lambda: curr_m11 > graphics_view.transform().m11() and curr_m22 > graphics_view.transform().m22(), GENERAL_WAIT, + ) + Report.result(Tests.zoom_out, result) + + # 7) Close Script Canvas window + general.close_pane("Script Canvas") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(Graph_ZoomInZoomOut) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ImportPathHelper.py b/AutomatedTesting/Gem/PythonTests/scripting/ImportPathHelper.py index 8aede24d0e..a45024cebf 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/ImportPathHelper.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/ImportPathHelper.py @@ -13,4 +13,5 @@ def init(): import os import sys sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared') + sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../EditorPythonTestTools/editor_python_test_tools') \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/scripting/NodeInspector_RenameVariable.py b/AutomatedTesting/Gem/PythonTests/scripting/NodeInspector_RenameVariable.py new file mode 100644 index 0000000000..33d3f4137a --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/NodeInspector_RenameVariable.py @@ -0,0 +1,132 @@ +""" +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. + +Test case ID: T92568982 +Test Case Title: Renaming variables in the Node Inspector +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92568982 +""" + + +# fmt: off +class Tests(): + variable_created = ("New variable created", "New variable is not created") + node_inspector_rename = ("Variable is renamed in Node Inspector", "Variable is not renamed in Node Inspector") + variable_manager_rename = ("Variable is renamed in Variable Manager", "Variable is not renamed in Variable Manager") +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +def NodeInspector_RenameVariable(): + """ + Summary: + Renaming variables in the Node Inspector, renames the actual variable. + + Expected Behavior: + The Variable's name is changed in both Node Inspector and Variable Manager. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Open Variable Manager if not opened already + 4) Open Node Inspector if not opened already + 5) Create new graph and a new variable in Variable manager + 6) Click on the variable + 7) Update name in Node Inspector and click on ENTER + 8) Verify if the name is updated in Node inspector and Variable manager + 9) Close Script Canvas window + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + TEST_NAME = "test name" + + from PySide2 import QtWidgets, QtCore, QtTest + from PySide2.QtCore import Qt + import azlmbr.legacy.general as general + + import pyside_utils + from utils import TestHelper as helper + + def open_tool(sc, dock_widget_name, pane_name): + if sc.findChild(QtWidgets.QDockWidget, dock_widget_name) is None: + action = pyside_utils.find_child_by_pattern(sc, {"text": pane_name, "type": QtWidgets.QAction}) + action.trigger() + tool = sc.findChild(QtWidgets.QDockWidget, dock_widget_name) + return tool + + # 1) Open Script Canvas window + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + + # 3) Open Variable Manager if not opened already + variable_manager = open_tool(sc, "VariableManager", "Variable Manager") + + # 4) Open Node Inspector if not opened already + node_inspector = open_tool(sc, "NodeInspector", "Node Inspector") + + # 5) Create new graph and a new variable in Variable manager + action = pyside_utils.find_child_by_pattern(sc, {"objectName": "action_New_Script", "type": QtWidgets.QAction}) + action.trigger() + graph_vars = variable_manager.findChild(QtWidgets.QTableView, "graphVariables") + add_button = variable_manager.findChild(QtWidgets.QPushButton, "addButton") + add_button.click() + # Select variable type + table_view = variable_manager.findChild(QtWidgets.QTableView, "variablePalette") + model_index = pyside_utils.find_child_by_pattern(table_view, "Boolean") + # Click on it to create variable + pyside_utils.item_view_index_mouse_click(table_view, model_index) + result = graph_vars.model().rowCount(QtCore.QModelIndex()) == 1 + var_mi = pyside_utils.find_child_by_pattern(graph_vars, "Variable 1") + result = result and (var_mi is not None) + Report.critical_result(Tests.variable_created, result) + + # 6) Click on the variable + pyside_utils.item_view_index_mouse_click(graph_vars, var_mi) + + # 7) Update name in Node Inspector and click on ENTER + helper.wait_for_condition( + lambda: node_inspector.findChild(QtWidgets.QWidget, "ContainerForRows") is not None, GENERAL_WAIT + ) + row_container = node_inspector.findChild(QtWidgets.QWidget, "ContainerForRows") + name_frame = row_container.findChild(QtWidgets.QWidget, "Name") + name_line_edit = name_frame.findChild(QtWidgets.QLineEdit) + name_line_edit.setText(TEST_NAME) + QtTest.QTest.keyClick(name_line_edit, Qt.Key_Return, Qt.NoModifier) + + # 8) Verify if the name is updated in Node inspector and Variable manager + helper.wait_for_condition(lambda: var_mi.data(Qt.DisplayRole) == TEST_NAME, GENERAL_WAIT) + Report.critical_result(Tests.node_inspector_rename, name_line_edit.text() == TEST_NAME) + Report.critical_result(Tests.variable_manager_rename, var_mi.data(Qt.DisplayRole) == TEST_NAME) + + # 9) Close Script Canvas window + general.close_pane("Script Canvas") + + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(NodeInspector_RenameVariable) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/NodePalette_ClearSelection.py b/AutomatedTesting/Gem/PythonTests/scripting/NodePalette_ClearSelection.py new file mode 100644 index 0000000000..de30e46767 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/NodePalette_ClearSelection.py @@ -0,0 +1,94 @@ +""" +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. + +Test case ID: T92562993 +Test Case Title: Clicking the X button on the Search Box clears the currently entered string +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92562993 +""" + + +# fmt: off +class Tests(): + set_search_string = ("Search string is set", "Search string is not set") + search_string_cleared = ("Search string cleared as expected", "Search string not cleared") +# fmt: on + + +def NodePalette_ClearSelection(): + """ + Summary: + We enter some string in the Node Palette Search box, and click on the X button to verify if the + search string got cleared. + + Expected Behavior: + Clicking the X button on the Search Box clears the currently entered string + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Open Node Manager if not opened already + 4) Set some string in the Search box + 5) Verify if the test string is set + 6) Clear search string and verify if it is cleared + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from PySide2 import QtWidgets + + from utils import TestHelper as helper + + import azlmbr.legacy.general as general + + import pyside_utils + + TEST_STRING = "Test String" + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 3.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + + # 3) Open Node Manager if not opened already + if sc.findChild(QtWidgets.QDockWidget, "NodePalette") is None: + action = pyside_utils.find_child_by_pattern(sc, {"text": "Node Palette", "type": QtWidgets.QAction}) + action.trigger() + node_palette = sc.findChild(QtWidgets.QDockWidget, "NodePalette") + search_frame = node_palette.findChild(QtWidgets.QFrame, "searchFrame") + + # 4) Set some string in the Search box + search_box = search_frame.findChild(QtWidgets.QLineEdit, "searchFilter") + search_box.setText(TEST_STRING) + + # 5) Verify if the test string is set + Report.result(Tests.set_search_string, search_box.text() == TEST_STRING) + + # 6) Clear search string and verify if it is cleared + clear_text_button = search_frame.findChild(QtWidgets.QToolButton, "ClearToolButton") + clear_text_button.click() + Report.result(Tests.search_string_cleared, search_box.text() == "") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + from utils import Report + + Report.start_test(NodePalette_ClearSelection) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/NodePalette_SelectNode.py b/AutomatedTesting/Gem/PythonTests/scripting/NodePalette_SelectNode.py new file mode 100644 index 0000000000..2ab76071a6 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/NodePalette_SelectNode.py @@ -0,0 +1,104 @@ +""" +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. + + +Test case ID: T92568940 +Test Case Title: Categories and Nodes can be selected +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92568940 +""" + + +# fmt: off +class Tests(): + category_selected = ("Category can be selected", "Category cannot be selected") + node_selected = ("Node can be selected", "Node cannot be selected") +# fmt: on + + +GENERAL_WAIT = 0.5 # seconds + + +def NodePalette_SelectNode(): + """ + Summary: + Categories and Nodes can be selected + + Expected Behavior: + When clicked on Node Palette, nodes and categories can be selected. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Expand QTreeView + 4) Click on category and check if it is selected + 5) Click on node and check if it is selected + 6) Close Script Canvas window + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + CATEGORY = "AI" + NODE = "Find Path To Entity" + + from PySide2 import QtWidgets + import azlmbr.legacy.general as general + + import pyside_utils + from utils import TestHelper as helper + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + if sc.findChild(QtWidgets.QDockWidget, "NodePalette") is None: + action = pyside_utils.find_child_by_pattern(sc, {"text": "Node Palette", "type": QtWidgets.QAction}) + action.trigger() + node_palette = sc.findChild(QtWidgets.QDockWidget, "NodePalette") + tree = node_palette.findChild(QtWidgets.QTreeView, "treeView") + + # 3) Expand QTreeView + tree.expandAll() + + # 4) Click on category and check if it is selected + category_index = pyside_utils.find_child_by_hierarchy(tree, CATEGORY) + tree.scrollTo(category_index) + pyside_utils.item_view_index_mouse_click(tree, category_index) + pyside_utils.wait_for_condition(tree.selectedIndexes() and tree.selectedIndexes()[0] == category_index) + Report.result(Tests.category_selected, tree.selectedIndexes()[0] == category_index) + + # 5) Click on node and check if it is selected + node_index = pyside_utils.find_child_by_pattern(tree, NODE) + helper.wait_for_condition(lambda: tree.isExpanded(node_index), GENERAL_WAIT) + pyside_utils.item_view_index_mouse_click(tree, node_index) + pyside_utils.wait_for_condition(tree.selectedIndexes()[0] == node_index) + Report.result(Tests.node_selected, tree.selectedIndexes()[0] == node_index) + + # 6) Close Script Canvas window + general.close_pane("Script Canvas") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(NodePalette_SelectNode) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/OnEntityActivatedDeactivated_PrintMessage.py b/AutomatedTesting/Gem/PythonTests/scripting/OnEntityActivatedDeactivated_PrintMessage.py new file mode 100644 index 0000000000..51b63c4268 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/OnEntityActivatedDeactivated_PrintMessage.py @@ -0,0 +1,184 @@ +""" +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. + +Test case ID: T92569253 // T92569254 +Test Case Title: On Entity Activated // On Entity Deactivated +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569253 // https://testrail.agscollab.com/index.php?/tests/view/92569254 +""" + + +# fmt: off +class Tests(): + level_created = ("Successfully created temp level", "Failed to create temp level") + controller_exists = ("Successfully found controller entity", "Failed to find controller entity") + activated_exists = ("Successfully found activated entity", "Failed to find activated entity") + deactivated_exists = ("Successfully found deactivated entity","Failed to find deactivated entity") + start_states_correct = ("Start states set up successfully", "Start states set up incorrectly") + game_mode_entered = ("Successfully entered game mode" "Failed to enter game mode") + lines_found = ("Successfully found expected prints", "Failed to find expected prints") + game_mode_exited = ("Successfully exited game mode" "Failed to exit game mode") +# fmt: on + + +def OnEntityActivatedDeactivated_PrintMessage(): + """ + Summary: + Verify that the On Entity Activation node is working as expected + + Expected Behavior: + Upon entering game mode, the Controller entity will wait 1 second and then activate the ActivationTest + entity. The script attached to ActivationTest will print out a message on activation. The Controller + will also deactivate the DeactivationTest entity, which should print a message. + + Test Steps: + 1) Create temp level + 2) Setup the level + 3) Validate the entities + 4) Start the Tracer + 5) Enter Game Mode + 6) Validate Print message + 7) Exit game mode + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + import os + + from utils import TestHelper as helper + from editor_entity_utils import EditorEntity as Entity + from utils import Report + from utils import Tracer + + import azlmbr.legacy.general as general + + EditorEntity = str + LEVEL_NAME = "tmp_level" + WAIT_TIME = 3.0 # SECONDS + EXPECTED_LINES = ["Activator Script: Activated", "Deactivator Script: Deactivated"] + controller_dict = { + "name": "Controller", + "status": "active", + "path": os.path.join("ScriptCanvas", "OnEntityActivatedScripts", "controller.scriptcanvas") + } + activated_dict = { + "name": "ActivationTest", + "status": "inactive", + "path": os.path.join("ScriptCanvas", "OnEntityActivatedScripts", "activator.scriptcanvas") + } + deactivated_dict = { + "name": "DeactivationTest", + "status": "active", + "path": os.path.join("ScriptCanvas", "OnEntityActivatedScripts", "deactivator.scriptcanvas") + } + + def get_asset(asset_path): + return azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, "GetAssetIdByPath", asset_path, azlmbr.math.Uuid(), False) + + def setup_level(): + def create_editor_entity(entity_dict:dict, entity_to_activate:EditorEntity=None, entity_to_deactivate:EditorEntity=None) -> EditorEntity: + entity = Entity.create_editor_entity(entity_dict["name"]) + entity.set_start_status(entity_dict["status"]) + sc_component = entity.add_component("Script Canvas") + sc_component.set_component_property_value("Script Canvas Asset|Script Canvas Asset", get_asset(entity_dict["path"])) + + if entity_dict["name"] == "Controller": + sc_component.get_property_tree() + sc_component.set_component_property_value("Properties|Variable Fields|Variables|[0]|Name,Value|Datum|Datum|EntityToActivate", entity_to_activate.id) + sc_component.set_component_property_value("Properties|Variable Fields|Variables|[1]|Name,Value|Datum|Datum|EntityToDeactivate", entity_to_deactivate.id) + return entity + + activated = create_editor_entity(activated_dict) + deactivated = create_editor_entity(deactivated_dict) + create_editor_entity(controller_dict, activated, deactivated) + + def validate_entity_exist(entity_name: str, test_tuple: tuple): + """ + Validate the entity with the given name exists in the level + :return: entity: editor entity object + """ + entity = Entity.find_editor_entity(entity_name) + Report.critical_result(test_tuple, entity.id.IsValid()) + return entity + + def validate_start_state(entity:EditorEntity, expected_state:str): + """ + Validate that the starting state of the entity is correct, if it isn't then attempt to rectify and recheck. + :return: bool: Whether state is set as expected + """ + state_options = { + "active": azlmbr.globals.property.EditorEntityStartStatus_StartActive, + "inactive": azlmbr.globals.property.EditorEntityStartStatus_StartInactive, + "editor": azlmbr.globals.property.EditorEntityStartStatus_EditorOnly, + } + if expected_state.lower() not in state_options.keys(): + raise ValueError(f"{expected_state} is an invalid option; valid options: active, inactive, or editor.") + + state = entity.get_start_status() + if state != state_options[expected_state]: + # If state fails to set, set_start_status will assert + entity.set_start_status(expected_state) + return True + + def validate_entities_in_level(): + controller = validate_entity_exist(controller_dict["name"], Tests.controller_exists) + state1_correct = validate_start_state(controller, controller_dict["status"]) + + act_tester = validate_entity_exist(activated_dict["name"], Tests.activated_exists) + state2_correct = validate_start_state(act_tester, activated_dict["status"]) + + deac_tester = validate_entity_exist(deactivated_dict["name"], Tests.deactivated_exists) + state3_correct = validate_start_state(deac_tester, deactivated_dict["status"]) + + all_states_correct = state1_correct and state2_correct and state3_correct + Report.critical_result(Tests.start_states_correct, all_states_correct) + + def locate_expected_lines(line_list: list): + found_lines = [printInfo.message.strip() for printInfo in section_tracer.prints] + return all(line in found_lines for line in line_list) + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Setup the level + setup_level() + + # 3) Validate the entities + validate_entities_in_level() + + # 4) Start the Tracer + with Tracer() as section_tracer: + + # 5) Enter Game Mode + helper.enter_game_mode(Tests.game_mode_entered) + + # 6) Validate Print message + helper.wait_for_condition(lambda: locate_expected_lines(EXPECTED_LINES), WAIT_TIME) + + Report.result(Tests.lines_found, locate_expected_lines(EXPECTED_LINES)) + + # 7) Exit game mode + helper.exit_game_mode(Tests.game_mode_exited) + + +if __name__ == "__main__": + import ImportPathHelper as imports + imports.init() + + from utils import Report + + Report.start_test(OnEntityActivatedDeactivated_PrintMessage) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py b/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py index 6100285092..666f052240 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/Opening_Closing_Pane.py @@ -17,7 +17,6 @@ URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/1702 # fmt: off class Tests(): - open_sc_window = ("Script Canvas window is opened", "Failed to open Script Canvas window") default_visible = ("All the panes visible by default", "One or more panes do not visible by default") open_panes = ("All the Panes opened successfully", "Failed to open one or more panes") close_pane = ("All the Panes closed successfully", "Failed to close one or more panes") @@ -49,11 +48,6 @@ def Opening_Closing_Pane(): :return: None """ - # Helper imports - import ImportPathHelper as imports - - imports.init() - from editor_python_test_tools.utils import Report from editor_python_test_tools.utils import TestHelper as helper import editor_python_test_tools.pyside_utils as pyside_utils @@ -82,8 +76,7 @@ def Opening_Closing_Pane(): # 1) Open Script Canvas window (Tools > Script Canvas) general.open_pane("Script Canvas") - is_sc_visible = helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) - Report.result(Tests.open_sc_window, is_sc_visible) + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) # 2) Restore default layout editor_window = pyside_utils.get_editor_main_window() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Pane_RetainOnSCRestart.py b/AutomatedTesting/Gem/PythonTests/scripting/Pane_RetainOnSCRestart.py new file mode 100644 index 0000000000..fa5e9e6068 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/Pane_RetainOnSCRestart.py @@ -0,0 +1,164 @@ +""" +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. + +Test case ID: C1702821 // C1702832 +Test Case Title: Retain visibility, size and location upon Script Canvas restart +URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/1702821 and + https://testrail.agscollab.com/index.php?/cases/view/1702832 +""" + + +# fmt: off +class Tests(): + relaunch_sc = ("Script Canvas window is relaunched", "Failed to relaunch Script Canvas window") + test_panes_visible = ("All the test panes are opened", "Failed to open one or more test panes") + close_pane_1 = ("Test pane 1 is closed", "Failed to close test pane 1") + visiblity_retained = ("Test pane retained its visiblity on SC restart", "Failed to retain visiblity of test pane on SC restart") + resize_pane_3 = ("Test pane 3 resized successfully", "Failed to resize Test pane 3") + size_retained = ("Test pane retained its size on SC restart", "Failed to retain size of test pane on SC restart") + location_changed = ("Location of test pane 2 changed successfully", "Failed to change locatio of test pane 2") + location_retained = ("Test pane retained its location on SC restart", "Failed to retain location of test pane on SC restart") +# fmt: on + + +def Pane_RetainOnSCRestart(): + """ + Summary: + The Script Canvas window is opened to verify if Script canvas panes can retain its visibility, size and location + upon ScriptCanvas restart. + + Expected Behavior: + The ScriptCanvas pane retain it's visiblity, size and location upon ScriptCanvas restart. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Make sure test panes are open and visible + 3) Close test pane 1 + 4) Change dock location of test pane 2 + 5) Resize test pane 3 + 6) Relaunch Script Canvas + 7) Verify if test pane 1 retain its visiblity + 8) Verify if location of test pane 2 is retained + 9) Verify if size of test pane 3 is retained + 10) Restore default layout and close SC window + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + # Helper imports + from utils import Report + from utils import TestHelper as helper + import pyside_utils + + # Open 3D Engine Imports + import azlmbr.legacy.general as general + + # Pyside imports + from PySide2 import QtCore, QtWidgets + from PySide2.QtCore import Qt + + # Constants + TEST_PANE_1 = "NodePalette" # test visibility + TEST_PANE_2 = "VariableManager" # test location + TEST_PANE_3 = "NodeInspector" # test size + SCALE_INT = 10 # Random resize scale integer + DOCKAREA = Qt.TopDockWidgetArea # Preferred top area since no widget is docked on top + + def click_menu_option(window, option_text): + action = pyside_utils.find_child_by_pattern(window, {"text": option_text, "type": QtWidgets.QAction}) + action.trigger() + + def find_pane(window, pane_name): + return window.findChild(QtWidgets.QDockWidget, pane_name) + + # Test starts here + general.idle_enable(True) + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 3.0) + + # 2) Make sure test panes are open and visible + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + click_menu_option(sc, "Restore Default Layout") + test_pane_1 = sc.findChild(QtWidgets.QDockWidget, TEST_PANE_1) + test_pane_2 = sc.findChild(QtWidgets.QDockWidget, TEST_PANE_2) + test_pane_3 = sc.findChild(QtWidgets.QDockWidget, TEST_PANE_3) + + Report.result( + Tests.test_panes_visible, test_pane_1.isVisible() and test_pane_2.isVisible() and test_pane_3.isVisible() + ) + + # Initiate try block here to restore default in finally block + try: + # 3) Close test pane + test_pane_1.close() + Report.result(Tests.close_pane_1, not test_pane_1.isVisible()) + + # 4) Change dock location of test pane 2 + sc_main = sc.findChild(QtWidgets.QMainWindow) + sc_main.addDockWidget(DOCKAREA, find_pane(sc_main, TEST_PANE_2), QtCore.Qt.Vertical) + Report.result(Tests.location_changed, sc_main.dockWidgetArea(find_pane(sc_main, TEST_PANE_2)) == DOCKAREA) + + # 5) Resize test pane 3 + initial_size = test_pane_3.frameSize() + test_pane_3.resize(initial_size.width() + SCALE_INT, initial_size.height() + SCALE_INT) + new_size = test_pane_3.frameSize() + resize_success = ( + abs(initial_size.width() - new_size.width()) == abs(initial_size.height() - new_size.height()) == SCALE_INT + ) + Report.result(Tests.resize_pane_3, resize_success) + + # 6) Relaunch Script Canvas + general.close_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 2.0) + + general.open_pane("Script Canvas") + sc_visible = helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + Report.result(Tests.relaunch_sc, sc_visible) + + # 7) Verify if test pane 1 retain its visiblity + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + Report.result(Tests.visiblity_retained, not find_pane(sc, TEST_PANE_1).isVisible()) + + # 8) Verify if location of test pane 2 is retained + sc_main = sc.findChild(QtWidgets.QMainWindow) + Report.result(Tests.location_retained, sc_main.dockWidgetArea(find_pane(sc_main, TEST_PANE_2)) == DOCKAREA) + + # 9) Verify if size of test pane 3 is retained + test_pane_3 = sc.findChild(QtWidgets.QDockWidget, TEST_PANE_3) + retained_size = test_pane_3.frameSize() + retain_success = retained_size != initial_size + Report.result(Tests.size_retained, retain_success) + + finally: + # 10) Restore default layout and close SC window + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + click_menu_option(sc, "Restore Default Layout") + sc.close() + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(Pane_RetainOnSCRestart) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py b/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py index 9262e76cb0..180f577953 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/Resizing_Pane.py @@ -16,7 +16,6 @@ URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/1702 # fmt: off class Tests(): - open_sc_window = ("Script Canvas window is opened", "Failed to open Script Canvas window") open_pane = ("Pane opened successfully", "Failed to open pane") resize_pane = ("Pane window resized successfully", "Failed to resize pane window") # fmt: on @@ -46,11 +45,6 @@ def Resizing_Pane(): :return: None """ - # Helper imports - import ImportPathHelper as imports - - imports.init() - from editor_python_test_tools.utils import Report from editor_python_test_tools.utils import TestHelper as helper import editor_python_test_tools.pyside_utils as pyside_utils @@ -76,8 +70,7 @@ def Resizing_Pane(): # 1) Open Script Canvas window (Tools > Script Canvas) general.open_pane("Script Canvas") - is_sc_visible = helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) - Report.result(Tests.open_sc_window, is_sc_visible) + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) # 2) Restore default layout editor_window = pyside_utils.get_editor_main_window() diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_ChangingAssets.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_ChangingAssets.py new file mode 100644 index 0000000000..38d60ad871 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_ChangingAssets.py @@ -0,0 +1,116 @@ +""" +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. + +Test case ID: T92562986 +Test Case Title: Changing the assigned Script Canvas Asset on an entity properly updates +level functionality +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92562986 +""" + + +# fmt: off +class Tests(): + level_created = ("New level created", "New level not created") + entity_created = ("Test Entity created", "Test Entity not created") + game_mode_entered = ("Game Mode successfully entered", "Game mode failed to enter") + game_mode_exited = ("Game Mode successfully exited", "Game mode failed to exited") + found_lines = ("Expected log lines were found", "Expected log lines were not found") +# fmt: on + + +def ScriptCanvas_ChangingAssets(): + """ + Summary: + Changing the assigned Script Canvas Asset on an entity properly updates level functionality + + Expected Behavior: + When game mode is entered, respective strings of assigned assets should be printed + + Test Steps: + 1) Create temp level + 2) Create new entity + 3) Start Tracer + 4) Set first script and evaluate + 5) Set second script and evaluate + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + import os + + from utils import TestHelper as helper + from utils import Tracer + import hydra_editor_utils as hydra + import azlmbr.legacy.general as general + import azlmbr.math as math + import azlmbr.asset as asset + import azlmbr.bus as bus + import azlmbr.paths as paths + + LEVEL_NAME = "tmp_level" + ASSET_1 = os.path.join("scriptcanvas", "ScriptCanvas_TwoComponents0.scriptcanvas") + ASSET_2 = os.path.join("scriptcanvas", "ScriptCanvas_TwoComponents1.scriptcanvas") + EXP_LINE_1 = "Greetings from the first script" + EXP_LINE_2 = "Greetings from the second script" + WAIT_TIME = 3.0 # SECONDS + + def get_asset(asset_path): + return asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False) + + def find_expected_line(expected_line): + found_lines = [printInfo.message.strip() for printInfo in section_tracer.prints] + return expected_line in found_lines + + def set_asset_evaluate(test_entity, ASSET_PATH, EXP_LINE): + # Set Script Canvas entity + test_entity.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_PATH)) + + # Enter/exit game mode + helper.enter_game_mode(Tests.game_mode_entered) + helper.wait_for_condition(lambda: find_expected_line(EXP_LINE), WAIT_TIME) + Report.result(Tests.found_lines, find_expected_line(EXP_LINE)) + helper.exit_game_mode(Tests.game_mode_exited) + + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create new entity + position = math.Vector3(512.0, 512.0, 32.0) + test_entity = hydra.Entity("test_entity") + test_entity.create_entity(position, ["Script Canvas"]) + + # 3) Start Tracer + with Tracer() as section_tracer: + + # 4) Set first script and evaluate + set_asset_evaluate(test_entity, ASSET_1, EXP_LINE_1) + + # 5) Set second script and evaluate + set_asset_evaluate(test_entity, ASSET_2, EXP_LINE_2) + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + from utils import Report + + Report.start_test(ScriptCanvas_ChangingAssets) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_TwoComponents.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_TwoComponents.py new file mode 100644 index 0000000000..896bee96e5 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_TwoComponents.py @@ -0,0 +1,118 @@ +""" +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. + +Test case ID: T92563190 +Test Case Title: A single Entity with two Script Canvas components works properly +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92563190 +""" + + +# fmt: off +class Tests(): + level_created = ("New level created", "New level not created") + game_mode_entered = ("Game Mode successfully entered", "Game mode failed to enter") + game_mode_exited = ("Game Mode successfully exited", "Game mode failed to exited") + found_lines = ("Expected log lines were found", "Expected log lines were not found") +# fmt: on + + +class LogLines: + expected_lines = ["Greetings from the first script", "Greetings from the second script"] + + +def ScriptCanvas_TwoComponents(): + """ + Summary: + A test entity contains two Script Canvas components with different unique script canvas files. + Each of these files will have a print node set to activate on graph start. + + Expected Behavior: + When game mode is entered, two unique strings should be printed out to the console + + Test Steps: + 1) Create level + 2) Create entity with SC components + 3) Start Tracer + 4) Enter game mode + 5) Wait for expected lines to be found + 6) Report if expected lines were found + 7) Exit game mode + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + import os + + from utils import TestHelper as helper + import hydra_editor_utils as hydra + from utils import Report + from utils import Tracer + import azlmbr.legacy.general as general + import azlmbr.math as math + import azlmbr.asset as asset + import azlmbr.bus as bus + + LEVEL_NAME = "tmp_level" + ASSET_1 = os.path.join("scriptcanvas", "ScriptCanvas_TwoComponents0.scriptcanvas") + ASSET_2 = os.path.join("scriptcanvas", "ScriptCanvas_TwoComponents1.scriptcanvas") + WAIT_TIME = 3.0 # SECONDS + + def get_asset(asset_path): + return asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False) + + def locate_expected_lines(): + found_lines = [] + for printInfo in section_tracer.prints: + found_lines.append(printInfo.message.strip()) + + return all(line in found_lines for line in LogLines.expected_lines) + + # 1) Create level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create entity with SC components + position = math.Vector3(512.0, 512.0, 32.0) + test_entity = hydra.Entity("test_entity") + test_entity.create_entity(position, ["Script Canvas", "Script Canvas"]) + test_entity.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_1)) + test_entity.get_set_test(1, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_2)) + + # 3) Start Tracer + with Tracer() as section_tracer: + + # 4) Enter game mode + helper.enter_game_mode(Tests.game_mode_entered) + + # 5) Wait for expected lines to be found + helper.wait_for_condition(locate_expected_lines, WAIT_TIME) + + # 6) Report if expected lines were found + Report.result(Tests.found_lines, locate_expected_lines()) + + # 7) Exit game mode + helper.exit_game_mode(Tests.game_mode_exited) + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(ScriptCanvas_TwoComponents) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_TwoEntities.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_TwoEntities.py new file mode 100644 index 0000000000..401e6c0271 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptCanvas_TwoEntities.py @@ -0,0 +1,107 @@ +""" +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. + +Test case ID: T92563191 +Test Case Title: Two Entities can use the same Graph asset successfully at RunTime +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92563191 +""" + + +# fmt: off +class Tests(): + level_created = ("New level created", "New level not created") + game_mode_entered = ("Game Mode successfully entered", "Game mode failed to enter") + game_mode_exited = ("Game Mode successfully exited", "Game mode failed to exited") + found_lines = ("Expected log lines were found", "Expected log lines were not found") +# fmt: on + + +def ScriptCanvas_TwoEntities(): + """ + Summary: + Two Entities can use the same Graph asset successfully at RunTime. The script canvas asset + attached to the enties will print the respective entity names. + + Expected Behavior: + When game mode is entered, respective strings of different entities should be printed. + + Test Steps: + 1) Create temp level + 2) Create two new entities with different names + 3) Set ScriptCanvas asset to both the entities + 4) Enter/Exit game mode and verify log lines + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + import os + + from utils import TestHelper as helper + from utils import Tracer + import hydra_editor_utils as hydra + import azlmbr.legacy.general as general + import azlmbr.math as math + import azlmbr.asset as asset + import azlmbr.bus as bus + + LEVEL_NAME = "tmp_level" + ASSET_PATH = os.path.join("scriptcanvas", "T92563191_test.scriptcanvas") + EXPECTED_LINES = ["Entity Name: test_entity_1", "Entity Name: test_entity_2"] + WAIT_TIME = 0.5 # SECONDS + + def get_asset(asset_path): + return asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False) + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create two new entities with different names + position = math.Vector3(512.0, 512.0, 32.0) + test_entity_1 = hydra.Entity("test_entity_1") + test_entity_1.create_entity(position, ["Script Canvas"]) + + test_entity_2 = hydra.Entity("test_entity_2") + test_entity_2.create_entity(position, ["Script Canvas"]) + + # 3) Set ScriptCanvas asset to both the entities + test_entity_1.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_PATH)) + test_entity_2.get_set_test(0, "Script Canvas Asset|Script Canvas Asset", get_asset(ASSET_PATH)) + + # 4) Enter/Exit game mode and verify log lines + with Tracer() as section_tracer: + + helper.enter_game_mode(Tests.game_mode_entered) + # wait for WAIT_TIME to let the script print strings + general.idle_wait(WAIT_TIME) + helper.exit_game_mode(Tests.game_mode_exited) + + found_lines = [printInfo.message.strip() for printInfo in section_tracer.prints] + result = all(line in found_lines for line in EXPECTED_LINES) + + Report.result(Tests.found_lines, result) + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + from utils import Report + + Report.start_test(ScriptCanvas_TwoEntities) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_SendReceiveAcrossMultiple.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_SendReceiveAcrossMultiple.py new file mode 100644 index 0000000000..d671229cdf --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_SendReceiveAcrossMultiple.py @@ -0,0 +1,120 @@ +""" +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. + +Test case ID: T92567321 +Test Case Title: Script Events: Can send and receive a script event across multiple entities successfully +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92567321 +""" + + +# fmt: off +class Tests(): + level_created = ("Successfully created temporary level", "Failed to create temporary level") + entitya_created = ("Successfully created EntityA", "Failed to create EntityA") + entityb_created = ("Successfully created EntityB", "Failed to create EntityB") + enter_game_mode = ("Successfully entered game mode", "Failed to enter game mode") + lines_found = ("Successfully found expected message", "Failed to find expected message") + exit_game_mode = ("Successfully exited game mode", "Failed to exit game mode") +# fmt: on + + +def ScriptEvents_SendReceiveAcrossMultiple(): + """ + Summary: + EntityA and EntityB will be created in a level. Attached to both will be a Script Canvas component. The Script Event created for the test will be sent from EntityA to EntityB. + + Expected Behavior: + The output of the Script Event should be printed to the console + + Test Steps: + 1) Create test level + 2) Create EntityA/EntityB (add scriptcanvas files part of entity setup) + 3) Start Tracer + 4) Enter Game Mode + 5) Read for line + 6) Exit Game Mode + + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + import os + + from editor_entity_utils import EditorEntity as Entity + from utils import Report + from utils import TestHelper as helper + from utils import Tracer + + import azlmbr.legacy.general as general + + LEVEL_NAME = "tmp_level" + WAIT_TIME = 3.0 + ASSET_PREFIX = "T92567321" + asset_paths = { + "event": os.path.join("TestAssets", f"{ASSET_PREFIX}.scriptevents"), + "assetA": os.path.join("ScriptCanvas", f"{ASSET_PREFIX}A.scriptcanvas"), + "assetB": os.path.join("ScriptCanvas", f"{ASSET_PREFIX}B.scriptcanvas"), + } + sc_for_entities = { + "EntityA": asset_paths["assetA"], + "EntityB": asset_paths["assetB"] + } + EXPECTED_LINES = ["Incoming Message Received"] + + def get_asset(asset_path): + return azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, "GetAssetIdByPath", asset_path, azlmbr.math.Uuid(), False) + + def create_editor_entity(name, sc_asset): + entity = Entity.create_editor_entity(name) + sc_comp = entity.add_component("Script Canvas") + sc_comp.set_component_property_value("Script Canvas Asset|Script Canvas Asset", get_asset(sc_asset)) + Report.critical_result(Tests.__dict__[name.lower()+"_created"], entity.id.isValid()) + + def locate_expected_lines(line_list: list): + found_lines = [printInfo.message.strip() for printInfo in section_tracer.prints] + + return all(line in found_lines for line in line_list) + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create EntityA/EntityB + for key in sc_for_entities.keys(): + create_editor_entity(key, sc_for_entities[key]) + + # 3) Start Tracer + with Tracer() as section_tracer: + + # 4) Enter Game Mode + helper.enter_game_mode(Tests.enter_game_mode) + + # 5) Read for line + lines_located = helper.wait_for_condition(lambda: locate_expected_lines(EXPECTED_LINES), WAIT_TIME) + Report.result(Tests.lines_found, lines_located) + + # 6) Exit Game Mode + helper.exit_game_mode(Tests.exit_game_mode) + + +if __name__ == "__main__": + import ImportPathHelper as imports + imports.init() + + from utils import Report + + Report.start_test(ScriptEvents_SendReceiveAcrossMultiple) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_SendReceiveSuccessfully.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_SendReceiveSuccessfully.py new file mode 100644 index 0000000000..b5e26d14ae --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_SendReceiveSuccessfully.py @@ -0,0 +1,110 @@ +""" +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. + +Test case ID: T92567320 +Test Case Title: Script Events: Can send and receive a script event successfully +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92567320 +""" + + +# fmt: off +class Tests(): + level_created = ("Successfully created temporary level", "Failed to create temporary level") + entity_created = ("Successfully created test entity", "Failed to create test entity") + enter_game_mode = ("Successfully entered game mode", "Failed to enter game mode") + lines_found = ("Successfully found expected message", "Failed to find expected message") + exit_game_mode = ("Successfully exited game mode", "Failed to exit game mode") +# fmt: on + + +def ScriptEvents_SendReceiveSuccessfully(): + """ + Summary: + An entity exists in the level that contains a Script Canvas component. In the graph is both a Send Event + and a Receive Event. + + Expected Behavior: + After entering game mode the graph on the entity should print an expected message to the console + + Test Steps: + 1) Create test level + 2) Create test entity + 3) Start Tracer + 4) Enter Game Mode + 5) Read for line + 6) Exit Game Mode + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + import os + from editor_entity_utils import EditorEntity as Entity + from utils import Report + from utils import TestHelper as helper + from utils import Tracer + + import azlmbr.legacy.general as general + import azlmbr.asset as asset + import azlmbr.math as math + import azlmbr.bus as bus + + LEVEL_NAME = "tmp_level" + WAIT_TIME = 3.0 # SECONDS + EXPECTED_LINES = ["T92567320: Message Received"] + SC_ASSET_PATH = os.path.join("ScriptCanvas", "T92567320.scriptcanvas") + + def create_editor_entity(name, sc_asset): + entity = Entity.create_editor_entity(name) + sc_comp = entity.add_component("Script Canvas") + asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", sc_asset, math.Uuid(), False) + sc_comp.set_component_property_value("Script Canvas Asset|Script Canvas Asset", asset_id) + Report.critical_result(Tests.entity_created, entity.id.isValid()) + + def locate_expected_lines(line_list: list): + found_lines = [printInfo.message.strip() for printInfo in section_tracer.prints] + + return all(line in found_lines for line in line_list) + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create test entity + create_editor_entity("TestEntity", SC_ASSET_PATH) + + # 3) Start Tracer + with Tracer() as section_tracer: + + # 4) Enter Game Mode + helper.enter_game_mode(Tests.enter_game_mode) + + # 5) Read for line + lines_located = helper.wait_for_condition(lambda: locate_expected_lines(EXPECTED_LINES), WAIT_TIME) + Report.result(Tests.lines_found, lines_located) + + # 6) Exit Game Mode + helper.exit_game_mode(Tests.exit_game_mode) + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(ScriptEvents_SendReceiveSuccessfully) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py index 8c34f29ebf..d87f2986bf 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py @@ -12,22 +12,243 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import pytest import os import sys +sys.path.append(os.path.dirname(__file__)) +import ImportPathHelper as imports +imports.init() + +import hydra_test_utils as hydra +import ly_test_tools.environment.file_system as file_system from ly_test_tools import LAUNCHERS - -sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared') - from base import TestAutomationBase +TEST_DIRECTORY = os.path.dirname(__file__) + + @pytest.mark.SUITE_periodic @pytest.mark.parametrize("launcher_platform", ['windows_editor']) @pytest.mark.parametrize("project", ["AutomatedTesting"]) class TestAutomation(TestAutomationBase): - + @pytest.mark.test_case_id("C1702834", "C1702823") + def test_Opening_Closing_Pane(self, request, workspace, editor, launcher_platform): + from . import Opening_Closing_Pane as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("C1702824") def test_Docking_Pane(self, request, workspace, editor, launcher_platform): from . import Docking_Pane as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.test_case_id("C1702829") def test_Resizing_Pane(self, request, workspace, editor, launcher_platform): from . import Resizing_Pane as test_module self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92563190") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_ScriptCanvas_TwoComponents(self, request, workspace, editor, launcher_platform, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import ScriptCanvas_TwoComponents as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92562986") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_ScriptCanvas_ChangingAssets(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import ScriptCanvas_ChangingAssets as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92569079", "T92569081") + def test_Graph_ZoomInZoomOut(self, request, workspace, editor, launcher_platform): + from . import Graph_ZoomInZoomOut as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92568940") + def test_NodePalette_SelectNode(self, request, workspace, editor, launcher_platform): + from . import NodePalette_SelectNode as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92569253") + @pytest.mark.test_case_id("T92569254") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_OnEntityActivatedDeactivated_PrintMessage(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import OnEntityActivatedDeactivated_PrintMessage as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92562993") + def test_NodePalette_ClearSelection(self, request, workspace, editor, launcher_platform, project): + from . import NodePalette_ClearSelection as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92563191") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_ScriptCanvas_TwoEntities(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import ScriptCanvas_TwoEntities as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92569013") + def test_AssetEditor_CreateScriptEventFile(self, request, workspace, editor, launcher_platform, project): + def teardown(): + file_system.delete( + [os.path.join(workspace.paths.project(), "ScriptCanvas", "test_file.scriptevent")], True, True + ) + request.addfinalizer(teardown) + file_system.delete( + [os.path.join(workspace.paths.project(), "ScriptCanvas", "test_file.scriptevent")], True, True + ) + from . import AssetEditor_CreateScriptEventFile as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92569165", "T92569167", "T92569168", "T92569170") + def test_Toggle_ScriptCanvasTools(self, request, workspace, editor, launcher_platform): + from . import Toggle_ScriptCanvasTools as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92568982") + def test_NodeInspector_RenameVariable(self, request, workspace, editor, launcher_platform, project): + from . import NodeInspector_RenameVariable as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92569137") + def test_Debugging_TargetMultipleGraphs(self, request, workspace, editor, launcher_platform, project): + from . import Debugging_TargetMultipleGraphs as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92568856") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_Debugging_TargetMultipleEntities(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import Debugging_TargetMultipleEntities as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92569049", "T92569051") + def test_EditMenu_UndoRedo(self, request, workspace, editor, launcher_platform, project): + from . import EditMenu_UndoRedo as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("C1702825", "C1702831") + def test_UnDockedPane_CloseSCWindow(self, request, workspace, editor, launcher_platform): + from . import UnDockedPane_CloseSCWindow as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92562978") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_Entity_AddScriptCanvasComponent(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import Entity_AddScriptCanvasComponent as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("C1702821", "C1702832") + def test_Pane_RetainOnSCRestart(self, request, workspace, editor, launcher_platform): + from . import Pane_RetainOnSCRestart as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92567321") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_ScriptEvents_SendReceiveAcrossMultiple(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import ScriptEvents_SendReceiveAcrossMultiple as test_module + self._run_test(request, workspace, editor, test_module) + + @pytest.mark.test_case_id("T92567320") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_ScriptEvents_SendReceiveSuccessfully(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import ScriptEvents_SendReceiveSuccessfully as test_module + self._run_test(request, workspace, editor, test_module) + +# NOTE: We had to use hydra_test_utils.py, as TestAutomationBase run_test method +# fails because of pyside_utils import +@pytest.mark.SUITE_periodic +@pytest.mark.parametrize("launcher_platform", ["windows_editor"]) +@pytest.mark.parametrize("project", ["AutomatedTesting"]) +class TestScriptCanvasTests(object): + """ + The following tests use hydra_test_utils.py to launch the editor and validate the results. + """ + + @pytest.mark.test_case_id("T92569037", "T92569039") + def test_FileMenu_New_Open(self, request, editor, launcher_platform): + expected_lines = [ + "File->New action working as expected: True", + "File->Open action working as expected: True", + ] + hydra.launch_and_validate_results( + request, TEST_DIRECTORY, editor, "FileMenu_New_Open.py", expected_lines, auto_test_mode=False, timeout=60, + ) + + @pytest.mark.test_case_id("T92568942") + def test_AssetEditor_NewScriptEvent(self, request, editor, launcher_platform): + expected_lines = [ + "New Script event action found: True", + "Asset Editor opened: True", + "Asset Editor created with new asset: True", + "New Script event created in Asset Editor: True", + ] + hydra.launch_and_validate_results( + request, + TEST_DIRECTORY, + editor, + "AssetEditor_NewScriptEvent.py", + expected_lines, + auto_test_mode=False, + timeout=60, + ) + + @pytest.mark.test_case_id("T92563068", "T92563070") + def test_GraphClose_SavePrompt(self, request, editor, launcher_platform): + expected_lines = [ + "New graph created: True", + "Save prompt opened as expected: True", + "Close button worked as expected: True", + ] + hydra.launch_and_validate_results( + request, + TEST_DIRECTORY, + editor, + "GraphClose_SavePrompt.py", + expected_lines, + auto_test_mode=False, + timeout=60, + ) + + @pytest.mark.test_case_id("T92564789", "T92568873") + def test_VariableManager_CreateDeleteVars(self, request, editor, launcher_platform): + var_types = ["Boolean", "Color", "EntityID", "Number", "String", "Transform", "Vector2", "Vector3", "Vector4"] + expected_lines = [f"Success: {var_type} variable is created" for var_type in var_types] + expected_lines.extend([f"Success: {var_type} variable is deleted" for var_type in var_types]) + hydra.launch_and_validate_results( + request, + TEST_DIRECTORY, + editor, + "VariableManager_CreateDeleteVars.py", + expected_lines, + auto_test_mode=False, + timeout=60, + ) \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/scripting/Toggle_ScriptCanvasTools.py b/AutomatedTesting/Gem/PythonTests/scripting/Toggle_ScriptCanvasTools.py new file mode 100644 index 0000000000..4024e28277 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/Toggle_ScriptCanvasTools.py @@ -0,0 +1,137 @@ +""" +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. + +Test case ID: C92569165, C92569167, C92569168, C92569170 +Test Case Title: Tools > Node Palette toggles the Node Palette + Tools > Node Inspector toggles the Node Inspector + Tools > Bookmarks toggles the Bookmarks + Tools > Variable Manager toggles the Variable Manager + +URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/92569165 + https://testrail.agscollab.com/index.php?/cases/view/92569167 + https://testrail.agscollab.com/index.php?/cases/view/92569168 + https://testrail.agscollab.com/index.php?/cases/view/92569170 +""" + + +# fmt: off +class Tests(): + node_palette_opened = ("NodePalette is opened successfully", "Failed to open NodePalette") + node_inspector_opened = ("NodeInspector is opened successfully", "Failed to open NodeInspector") + bookmark_opened = ("Bookmarks is opened successfully", "Failed to open Bookmarks") + variable_manager_opened = ("VariableManager is opened successfully", "Failed to open VariableManager") + node_palette_closed_by_start = ("NodePalette is closed successfully", "Failed to close NodePalette") + node_inspector_closed_by_start = ("NodeInspector is closed successfully", "Failed to close NodeInspector") + bookmark_closed_by_start = ("Bookmarks is closed successfully", "Failed to close Bookmarks") + variable_manager_closed_by_start = ("VariableManager is closed successfully", "Failed to close VariableManager") + node_palette_closed_by_end = ("NodePalette is closed successfully", "Failed to close NodePalette") + node_inspector_closed_by_end = ("NodeInspector is closed successfully", "Failed to close NodeInspector") + bookmark_closed_by_end = ("Bookmarks is closed successfully", "Failed to close Bookmarks") + variable_manager_closed_by_end = ("VariableManager is closed successfully", "Failed to close VariableManager") +# fmt: on + + +def Toggle_ScriptCanvasTools(): + """ + Summary: + Toggle Node Palette, Node Inspector, Bookmarks and Variable Manager in Script Canvas. + Make sure each pane opens and closes successfully. + + Expected Behavior: + Each pane opens and closes successfully. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Make sure Node Palette, Node Inspector, Bookmarks and Variable Manager panes are closed in Script Canvas window + 3) Open Node Palette, Node Inspector, Bookmarks and Variable Manager in Script Canvas window + 4) Close Node Palette, Node Inspector, Bookmarks and Variable Manager in Script Canvas window + 5) Restore default layout + 6) Close Script Canvas window + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from utils import Report + from utils import TestHelper as helper + import pyside_utils + + # Open 3D Engine imports + import azlmbr.legacy.general as general + + # Pyside imports + from PySide2 import QtWidgets + + def click_menu_option(window, option_text): + action = pyside_utils.find_child_by_pattern(window, {"text": option_text, "type": QtWidgets.QAction}) + action.trigger() + + def find_pane(window, pane_name): + return window.findChild(QtWidgets.QDockWidget, pane_name) + + def close_tool(window, pane_widget, test_tuple): + pane = find_pane(window, pane_widget) + pane.close() + Report.result(test_tuple, not pane.isVisible()) + + def open_tool(window, pane_widget, tool, test_tuple): + pane = find_pane(window, pane_widget) + if not pane.isVisible(): + click_menu_option(window, tool) + pane = find_pane(window, pane_widget) + Report.result(test_tuple, pane.isVisible()) + + # Test starts here + general.idle_enable(True) + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Make sure Node Palette, Node Inspector, Bookmarks and Variable Manager panes are closed in Script Canvas window + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + close_tool(sc, "NodePalette", Tests.node_palette_closed_by_start) + close_tool(sc, "NodeInspector", Tests.node_inspector_closed_by_start) + close_tool(sc, "BookmarkDockWidget", Tests.bookmark_closed_by_start) + close_tool(sc, "VariableManager", Tests.variable_manager_closed_by_start) + + # 3) Open Node Palette, Node Inspector, Bookmarks and Variable Manager in Script Canvas window + open_tool(sc, "NodePalette", "Node Palette", Tests.node_palette_opened) + open_tool(sc, "NodeInspector", "Node Inspector", Tests.node_inspector_opened) + open_tool(sc, "BookmarkDockWidget", "Bookmarks", Tests.bookmark_opened) + open_tool(sc, "VariableManager", "Variable Manager", Tests.variable_manager_opened) + + # 4) Close Node Palette, Node Inspector, Bookmarks and Variable Manager in Script Canvas window + close_tool(sc, "NodePalette", Tests.node_palette_closed_by_end) + close_tool(sc, "NodeInspector", Tests.node_inspector_closed_by_end) + close_tool(sc, "BookmarkDockWidget", Tests.bookmark_closed_by_end) + close_tool(sc, "VariableManager", Tests.variable_manager_closed_by_end) + + # 5) Restore default layout + # Need this step to restore to default in case of test failure + click_menu_option(sc, "Restore Default Layout") + + # 6) Close Script Canvas window + sc.close() + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(Toggle_ScriptCanvasTools) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/UnDockedPane_CloseSCWindow.py b/AutomatedTesting/Gem/PythonTests/scripting/UnDockedPane_CloseSCWindow.py new file mode 100644 index 0000000000..875f28ec95 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/UnDockedPane_CloseSCWindow.py @@ -0,0 +1,128 @@ +""" +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. + +Test case ID: C1702825 // C1702831 +Test Case Title: Undocking // Closing script canvas with the pane floating +URLs of the test case: https://testrail.agscollab.com/index.php?/cases/view/1702825 & + https://testrail.agscollab.com/index.php?/cases/view/1702831 +""" + + +# fmt: off +class Tests(): + undock_pane = ("Pane is undocked successfully", "Failed to undock pane") + close_sc_window = ("Script Canvas window is closed", "Failed to close Script Canvas window") + pane_closed = ("Pane is closed successfully", "Failed to close the pane") +# fmt: on + + +def UnDockedPane_CloseSCWindow(): + """ + Summary: + The Script Canvas window is opened with one of the pane undocked. + Verify if undocked pane closes upon closing Script canvas window. + + Expected Behavior: + The undocked pane closes when Script Canvas window closed. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Undock Node Palette pane + 3) Connect to Pane visibility signal emitter to verify pane closed + 4) Close Script Canvas window + 5) Restore default layout + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + # Helper imports + from utils import Report + from utils import TestHelper as helper + import pyside_utils + + # Open 3D Engine imports + import azlmbr.legacy.general as general + + # Pyside imports + from PySide2 import QtWidgets + + TEST_PANE = "NodePalette" # Chosen most commonly used pane + + def click_menu_option(window, option_text): + action = pyside_utils.find_child_by_pattern(window, {"text": option_text, "type": QtWidgets.QAction}) + action.trigger() + + def find_pane(window, pane_name): + return window.findChild(QtWidgets.QDockWidget, pane_name) + + def on_top_level_changed(): + # This function has test condition always True since it gets emitted only when condition satisfied + Report.result(Tests.undock_pane, True) + + def on_pane_closed(): + # This function has test condition always True since it gets emitted only when condition satisfied + Report.result(Tests.pane_closed, True) + + # Test starts here + general.idle_enable(True) + + # 1) Open Script Canvas window (Tools > Script Canvas) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + + # 2) Undock Node Palette pane + # Make sure Node Palette pane is opened + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + pane = find_pane(sc, TEST_PANE) + if not pane.isVisible(): + click_menu_option(sc, "Node Palette") + pane = find_pane(sc, TEST_PANE) # New reference + + # We drag/drop pane over the graph since it doesn't allow docking, so this will undock it + try: + graph = find_pane(sc, "GraphCanvasEditorCentralWidget") + try: + pane.topLevelChanged.connect(on_top_level_changed) + pyside_utils.drag_and_drop(pane, graph) + finally: + pane.topLevelChanged.disconnect(on_top_level_changed) + + # 3) Connect to Pane visibility signal emitter to verify pane closed + # No need to disconnect this since pane widget gets deleted when SC window closed + pane.visibilityChanged.connect(on_pane_closed) + + # 4) Close Script Canvas window + sc.close() + is_sc_visible = helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 2.0) + Report.result(Tests.close_sc_window, not is_sc_visible) + + finally: + # 5) Restore default layout + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0) + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + click_menu_option(sc, "Restore Default Layout") + sc.close() + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(UnDockedPane_CloseSCWindow) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/VariableManager_CreateDeleteVars.py b/AutomatedTesting/Gem/PythonTests/scripting/VariableManager_CreateDeleteVars.py new file mode 100644 index 0000000000..6facc324d4 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/VariableManager_CreateDeleteVars.py @@ -0,0 +1,123 @@ +""" +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. + +Test case ID: T92564789 +Test Case Title: Each Variable type can be created +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92564789 +Test case ID: T92568873 +Test Case Title: Each Variable type can be deleted +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92568873 +""" + + +def VariableManager_CreateDeleteVars(): + """ + Summary: + Each variable type can be created and deleted in variable manager. + + Expected Behavior: + Each variable type can be created and deleted in variable manager. + + Test Steps: + 1) Open Script Canvas window (Tools > Script Canvas) + 2) Get the SC window object + 3) Open Variable Manager if not opened already + 4) Create Graph + 5) Create variable of each type and verify if it is created + 6) Delete each type of variable and verify if it is deleted + 7) Close SC window + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + + from PySide2 import QtWidgets, QtCore, QtTest + + from PySide2.QtCore import Qt + + from utils import TestHelper as helper + + import azlmbr.legacy.general as general + + import pyside_utils + + def generate_test_tuple(var_type, action): + return (f"{var_type} variable is {action}d", f"{var_type} variable is not {action}d") + + # 1) Open Script Canvas window + general.idle_enable(True) + general.open_pane("Script Canvas") + helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 10.0) + + # 2) Get the SC window object + editor_window = pyside_utils.get_editor_main_window() + sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas") + + # 3) Open Variable Manager if not opened already + if sc.findChild(QtWidgets.QDockWidget, "VariableManager") is None: + action = pyside_utils.find_child_by_pattern(sc, {"text": "Variable Manager", "type": QtWidgets.QAction}) + action.trigger() + variable_manager = sc.findChild(QtWidgets.QDockWidget, "VariableManager") + + # 4) Create Graph + action = pyside_utils.find_child_by_pattern(sc, {"objectName": "action_New_Script", "type": QtWidgets.QAction}) + action.trigger() + + graph_vars = variable_manager.findChild(QtWidgets.QTableView, "graphVariables") + + var_types = ["Boolean", "Color", "EntityID", "Number", "String", "Transform", "Vector2", "Vector3", "Vector4"] + + # 5) Create variable of each type and verify if it is created + for index, var_type in enumerate(var_types): + # Create new variable + add_button = variable_manager.findChild(QtWidgets.QPushButton, "addButton") + add_button.click() # Click on Create Variable button + # Select variable type + table_view = variable_manager.findChild(QtWidgets.QTableView, "variablePalette") + model_index = pyside_utils.find_child_by_pattern(table_view, var_type) + # Click on it to create variable + pyside_utils.item_view_index_mouse_click(table_view, model_index) + # Verify if the variable is created + # NOTE: To check if variable of a type is created, we are checking 1) rowcount + # 2) If we have row with variable "Variable " + # 3) Type of variable, which is next column of the variable name + result = graph_vars.model().rowCount(QtCore.QModelIndex()) == ( + index + 1 + ) # since we added 1 variable, rowcount will increase by 1 + var_mi = pyside_utils.find_child_by_pattern(graph_vars, f"Variable {index+1}") + result = result and (var_mi is not None) and (var_mi.siblingAtColumn(1).data(Qt.DisplayRole) == var_type) + Report.result(generate_test_tuple(var_type, "create"), result) + + # 6) Delete each type of variable and verify if it is deleted + for index, var_type in enumerate(var_types): + # Delete variable and verify if its deleted + # NOTE: To check if variable of a type is deleted, we are checking rowcount + var_mi = pyside_utils.find_child_by_pattern(graph_vars, f"Variable {index+1}") + pyside_utils.item_view_index_mouse_click(graph_vars, var_mi) + QtTest.QTest.keyClick(graph_vars, Qt.Key_Delete, Qt.NoModifier) + # since variable is deleted, rowcount will decrease by 1 + result = graph_vars.model().rowCount(QtCore.QModelIndex()) == (len(var_types) - (index + 1)) + Report.result(generate_test_tuple(var_type, "delete"), result) + + # 7) Close SC window + general.close_pane("Script Canvas") + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + from utils import Report + + Report.start_test(VariableManager_CreateDeleteVars) diff --git a/AutomatedTesting/Registry/C14195074_ScriptCanvas_PostUpdateEvent.setreg b/AutomatedTesting/Registry/C14195074_ScriptCanvas_PostUpdateEvent.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C14195074_ScriptCanvas_PostUpdateEvent.setreg rename to AutomatedTesting/Registry/C14195074_ScriptCanvas_PostUpdateEvent.setreg_override diff --git a/AutomatedTesting/Registry/C14902097_ScriptCanvas_PreUpdateEvent.setreg b/AutomatedTesting/Registry/C14902097_ScriptCanvas_PreUpdateEvent.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C14902097_ScriptCanvas_PreUpdateEvent.setreg rename to AutomatedTesting/Registry/C14902097_ScriptCanvas_PreUpdateEvent.setreg_override diff --git a/AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg b/AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg rename to AutomatedTesting/Registry/C3510644_Collider_CollisionGroups.setreg_override diff --git a/AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg b/AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg rename to AutomatedTesting/Registry/C4976227_Collider_NewGroup.setreg_override diff --git a/AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg b/AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg rename to AutomatedTesting/Registry/C4976244_Collider_SameGroupSameLayerCollision.setreg_override diff --git a/AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg b/AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg rename to AutomatedTesting/Registry/C4976245_PhysXCollider_CollisionLayerTest.setreg_override diff --git a/AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg b/AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg_override similarity index 100% rename from AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg rename to AutomatedTesting/Registry/C4982593_PhysXCollider_CollisionLayer.setreg_override diff --git a/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/activator.scriptcanvas b/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/activator.scriptcanvas new file mode 100644 index 0000000000..89d86f0d54 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/activator.scriptcanvas @@ -0,0 +1,778 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/controller.scriptcanvas b/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/controller.scriptcanvas new file mode 100644 index 0000000000..83a899798e --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/controller.scriptcanvas @@ -0,0 +1,1865 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/deactivator.scriptcanvas b/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/deactivator.scriptcanvas new file mode 100644 index 0000000000..ca98ee303a --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/OnEntityActivatedScripts/deactivator.scriptcanvas @@ -0,0 +1,766 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/ScriptCanvas_TwoComponents0.scriptcanvas b/AutomatedTesting/ScriptCanvas/ScriptCanvas_TwoComponents0.scriptcanvas new file mode 100644 index 0000000000..af3afead19 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/ScriptCanvas_TwoComponents0.scriptcanvas @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/ScriptCanvas_TwoComponents1.scriptcanvas b/AutomatedTesting/ScriptCanvas/ScriptCanvas_TwoComponents1.scriptcanvas new file mode 100644 index 0000000000..0a16717520 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/ScriptCanvas_TwoComponents1.scriptcanvas @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/T92563191_test.scriptcanvas b/AutomatedTesting/ScriptCanvas/T92563191_test.scriptcanvas new file mode 100644 index 0000000000..f0797739a5 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/T92563191_test.scriptcanvas @@ -0,0 +1,750 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/T92567320.scriptcanvas b/AutomatedTesting/ScriptCanvas/T92567320.scriptcanvas new file mode 100644 index 0000000000..d509442435 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/T92567320.scriptcanvas @@ -0,0 +1,1266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/T92567321A.scriptcanvas b/AutomatedTesting/ScriptCanvas/T92567321A.scriptcanvas new file mode 100644 index 0000000000..644a5daa17 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/T92567321A.scriptcanvas @@ -0,0 +1,778 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ScriptCanvas/T92567321B.scriptcanvas b/AutomatedTesting/ScriptCanvas/T92567321B.scriptcanvas new file mode 100644 index 0000000000..54c83c2933 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/T92567321B.scriptcanvas @@ -0,0 +1,880 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/ShaderLib/raytracingscenesrg.srgi b/AutomatedTesting/ShaderLib/raytracingscenesrg.srgi deleted file mode 100644 index ac1d663bb8..0000000000 --- a/AutomatedTesting/ShaderLib/raytracingscenesrg.srgi +++ /dev/null @@ -1,28 +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 read README.md for an explanation on why scenesrg.srgi and viewsrg.srgi are -// located in this folder (And how you can optionally customize your own scenesrg.srgi -// and viewsrg.srgi in your game project). - -#include - -partial ShaderResourceGroup RayTracingSceneSrg : SRG_RayTracingScene -{ -/* Intentionally Empty. Helps define the SrgSemantic for RayTracingSceneSrg once.*/ -}; - -#define AZ_COLLECTING_PARTIAL_SRGS -#include -#undef AZ_COLLECTING_PARTIAL_SRGS diff --git a/AutomatedTesting/TestAssets/T92567320.scriptevents b/AutomatedTesting/TestAssets/T92567320.scriptevents new file mode 100644 index 0000000000..63cf20f2d0 --- /dev/null +++ b/AutomatedTesting/TestAssets/T92567320.scriptevents @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/TestAssets/T92567321.scriptevents b/AutomatedTesting/TestAssets/T92567321.scriptevents new file mode 100644 index 0000000000..6f9308ad02 --- /dev/null +++ b/AutomatedTesting/TestAssets/T92567321.scriptevents @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Code/CryEngine/CryCommon/CryEngineDecalInfo.h b/Code/CryEngine/CryCommon/CryEngineDecalInfo.h deleted file mode 100644 index f38533e341..0000000000 --- a/Code/CryEngine/CryCommon/CryEngineDecalInfo.h +++ /dev/null @@ -1,77 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : declaration of struct CryEngineDecalInfo. - -// Note: -// 3D Engine and Character Animation subsystems (as well as perhaps -// some others) transfer data about the decals that need to be spawned -// via this structure. This is to avoid passing many parameters through -// each function call, and to save on copying these parameters when just -// simply passing the structure from one function to another. - -#ifndef CRYINCLUDE_CRYCOMMON_CRYENGINEDECALINFO_H -#define CRYINCLUDE_CRYCOMMON_CRYENGINEDECALINFO_H -#pragma once - -#include "Cry_Math.h" - -// Summary: -// Structure containing common parameters that describe a decal - -struct SDecalOwnerInfo -{ - SDecalOwnerInfo() { memset(this, 0, sizeof(*this)); nRenderNodeSlotId = nRenderNodeSlotSubObjectId = -1; } - struct IStatObj* GetOwner(Matrix34A& objMat); - - struct IRenderNode* pRenderNode; // Owner (decal will be attached to or wrapped around of this object) - PodArray* pDecalReceivers; - int nRenderNodeSlotId; // is set internally by 3dengine - int nRenderNodeSlotSubObjectId; // is set internally by 3dengine - int nMatID; -}; - -struct CryEngineDecalInfo -{ - SDecalOwnerInfo ownerInfo; - Vec3 vPos; // Decal position (world coordinates) - Vec3 vNormal; // Decal/face normal - float fSize; // Decal size - float fLifeTime; // Decal life time (in seconds) - float fAngle; // Angle of rotation - struct IStatObj* pIStatObj; // Decal geometry - Vec3 vHitDirection; // Direction from weapon/player position to decal position (bullet direction) - float fGrowTime, fGrowTimeAlpha;// Used for blood pools - unsigned int nGroupId; // Used for multi-component decals - bool bSkipOverlappingTest; // Always spawn decals even if there are a lot of other decals in same place - bool bAssemble; // Assemble to bigger decals if more than 1 decal is on the same place - bool bForceEdge; // force the decal to the nearest edge of the owner mesh and project it accordingly - bool bForceSingleOwner; // Do not attempt to cast the decal into the environment even if it's large enough - bool bDeferred; - uint8 sortPrio; - char szMaterialName[_MAX_PATH]; // name of material used for rendering the decal (in favor of szTextureName/nTid and the default decal shader) - bool preventDecalOnGround; // mainly for decal placement support - const Matrix33* pExplicitRightUpFront; // mainly for decal placement support - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const{} - - // the constructor fills in some non-obligatory fields; the other fields must be filled in by the client - CryEngineDecalInfo () - { - memset(this, 0, sizeof(*this)); - ownerInfo.nRenderNodeSlotId = ownerInfo.nRenderNodeSlotSubObjectId = -1; - sortPrio = 255; - } -}; - -#endif // CRYINCLUDE_CRYCOMMON_CRYENGINEDECALINFO_H diff --git a/Code/CryEngine/CryCommon/Gem.h b/Code/CryEngine/CryCommon/Gem.h deleted file mode 100644 index 3097fcf304..0000000000 --- a/Code/CryEngine/CryCommon/Gem.h +++ /dev/null @@ -1,98 +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 - -#if defined(AZ_RESTRICTED_PLATFORM) - #include AZ_RESTRICTED_FILE(Gem_h) -#endif - -#if defined(LINUX) || defined(APPLE) || defined(ANDROID) - #define OPENGL 1 -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include <3dEngine.h> -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include diff --git a/Code/CryEngine/CryCommon/I3DEngine.h b/Code/CryEngine/CryCommon/I3DEngine.h deleted file mode 100644 index 883b0a6d3b..0000000000 --- a/Code/CryEngine/CryCommon/I3DEngine.h +++ /dev/null @@ -1,3021 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : 3dengine interface - -#ifndef CRYINCLUDE_CRYCOMMON_I3DENGINE_H -#define CRYINCLUDE_CRYCOMMON_I3DENGINE_H -#pragma once - -// The maximum number of unique surface types that can be used per node -#define MMRM_MAX_SURFACE_TYPES 16 -#define COMPILED_OCTREE_FILE_NAME "terrain/terrain.dat" - -// !!! Do not add any headers here !!! -#include "CryEngineDecalInfo.h" -#include -#include // <> required for Interfuscator -#include "IRenderer.h" -#include // <> required for Interfuscator -#include // <> required for Interfuscator -#include // <> required for Interfuscator -#include // <> required for Interfuscator -#include "CryArray.h" -#include // <> required for Interfuscator -#include -// !!! Do not add any headers here !!! - -class IOpticsManager; -class CContentCGF; -class ICrySizer; -class CRenderView; -struct ISystem; -struct CVars; -struct pe_params_particle; -struct IMaterial; -struct SpawnParams; -struct ForceObject; -struct IRenderNode; -struct IObjManager; -struct IDeferredPhysicsEventManager; -struct IBSPTree3D; -struct ITextureLoadHandler; -struct ITimeOfDay; -struct MacroTextureConfiguration; - -namespace LegacyProceduralVegetation -{ - class IVegetationPoolManager; -} - -namespace LegacyTerrain -{ - struct MacroTextureConfiguration; -} - -namespace ChunkFile -{ - struct IChunkFileWriter; -} - -namespace AZ -{ - class Aabb; -} - -enum E3DEngineParameter -{ - E3DPARAM_SUN_COLOR, - - E3DPARAM_SUN_SPECULAR_MULTIPLIER, - - E3DPARAM_AMBIENT_GROUND_COLOR, - E3DPARAM_AMBIENT_MIN_HEIGHT, - E3DPARAM_AMBIENT_MAX_HEIGHT, - - E3DPARAM_FOG_COLOR, - E3DPARAM_FOG_COLOR2, - E3DPARAM_FOG_RADIAL_COLOR, - - E3DPARAM_VOLFOG_HEIGHT_DENSITY, - E3DPARAM_VOLFOG_HEIGHT_DENSITY2, - - E3DPARAM_VOLFOG_GRADIENT_CTRL, - - E3DPARAM_VOLFOG_GLOBAL_DENSITY, - E3DPARAM_VOLFOG_RAMP, - - E3DPARAM_VOLFOG_SHADOW_RANGE, - E3DPARAM_VOLFOG_SHADOW_DARKENING, - E3DPARAM_VOLFOG_SHADOW_ENABLE, - - E3DPARAM_VOLFOG2_CTRL_PARAMS, - E3DPARAM_VOLFOG2_SCATTERING_PARAMS, - E3DPARAM_VOLFOG2_RAMP, - E3DPARAM_VOLFOG2_COLOR, - E3DPARAM_VOLFOG2_GLOBAL_DENSITY, - E3DPARAM_VOLFOG2_HEIGHT_DENSITY, - E3DPARAM_VOLFOG2_HEIGHT_DENSITY2, - E3DPARAM_VOLFOG2_COLOR1, - E3DPARAM_VOLFOG2_COLOR2, - - E3DPARAM_SKYLIGHT_SUN_INTENSITY, - - E3DPARAM_SKYLIGHT_KM, - E3DPARAM_SKYLIGHT_KR, - E3DPARAM_SKYLIGHT_G, - - E3DPARAM_SKYLIGHT_WAVELENGTH_R, - E3DPARAM_SKYLIGHT_WAVELENGTH_G, - E3DPARAM_SKYLIGHT_WAVELENGTH_B, - - E3DPARAM_NIGHSKY_HORIZON_COLOR, - E3DPARAM_NIGHSKY_ZENITH_COLOR, - E3DPARAM_NIGHSKY_ZENITH_SHIFT, - - E3DPARAM_NIGHSKY_STAR_INTENSITY, - - E3DPARAM_NIGHSKY_MOON_DIRECTION, - E3DPARAM_NIGHSKY_MOON_COLOR, - E3DPARAM_NIGHSKY_MOON_SIZE, - E3DPARAM_NIGHSKY_MOON_INNERCORONA_COLOR, - E3DPARAM_NIGHSKY_MOON_INNERCORONA_SCALE, - E3DPARAM_NIGHSKY_MOON_OUTERCORONA_COLOR, - E3DPARAM_NIGHSKY_MOON_OUTERCORONA_SCALE, - - E3DPARAM_CLOUDSHADING_MULTIPLIERS, - E3DPARAM_CLOUDSHADING_SUNCOLOR, - E3DPARAM_CLOUDSHADING_SKYCOLOR, - - E3DPARAM_CORONA_SIZE, - - E3DPARAM_OCEANFOG_COLOR, - E3DPARAM_OCEANFOG_DENSITY, - - // Sky highlight (ex. From Lightning) - E3DPARAM_SKY_HIGHLIGHT_COLOR, - E3DPARAM_SKY_HIGHLIGHT_SIZE, - E3DPARAM_SKY_HIGHLIGHT_POS, - - E3DPARAM_SKY_MOONROTATION, - - E3DPARAM_SKY_SKYBOX_ANGLE, - E3DPARAM_SKY_SKYBOX_STRETCHING, - - EPARAM_SUN_SHAFTS_VISIBILITY, - - E3DPARAM_SKYBOX_MULTIPLIER, - - E3DPARAM_DAY_NIGHT_INDICATOR, - - // Tone mapping tweakables - E3DPARAM_HDR_FILMCURVE_SHOULDER_SCALE, - E3DPARAM_HDR_FILMCURVE_LINEAR_SCALE, - E3DPARAM_HDR_FILMCURVE_TOE_SCALE, - E3DPARAM_HDR_FILMCURVE_WHITEPOINT, - - E3DPARAM_HDR_EYEADAPTATION_PARAMS, - E3DPARAM_HDR_EYEADAPTATION_PARAMS_LEGACY, - E3DPARAM_HDR_BLOOM_AMOUNT, - - E3DPARAM_HDR_COLORGRADING_COLOR_SATURATION, - E3DPARAM_HDR_COLORGRADING_COLOR_BALANCE, - - E3DPARAM_COLORGRADING_FILTERS_PHOTOFILTER_COLOR, - E3DPARAM_COLORGRADING_FILTERS_PHOTOFILTER_DENSITY, - E3DPARAM_COLORGRADING_FILTERS_GRAIN -}; - -enum EShadowMode -{ - ESM_NORMAL = 0, - ESM_HIGHQUALITY -}; - -struct IBSPTree3D -{ - typedef DynArray CFace; - typedef DynArray FaceList; - - virtual ~IBSPTree3D() {} - virtual bool IsInside(const Vec3& vPos) const = 0; - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - - virtual size_t WriteToBuffer(void* pBuffer) const = 0; - virtual void ReadFromBuffer(const void* pBuffer) = 0; -}; - -////////////////////////////////////////////////////////////////////////// -// Description: -// This structure is filled and passed by the caller to the DebugDraw functions of the stat object or entity. -struct SGeometryDebugDrawInfo -{ - Matrix34 tm; // Transformation Matrix - ColorB color; // Optional color of the lines. - ColorB lineColor; // Optional color of the lines. - - // Optional flags controlling how to render debug draw information. - uint32 bNoCull : 1; - uint32 bNoLines : 1; - uint32 bExtrude : 1; // Extrude debug draw geometry alittle bit so it is over real geometry. - - SGeometryDebugDrawInfo() - : color(255, 0, 255, 255) - , lineColor(255, 255, 0, 255) - , bNoLines(0) - , bNoCull(0) { tm.SetIdentity(); } -}; - -struct SFrameLodInfo -{ - uint32 nID; - float fLodRatio; - float fTargetSize; - uint nMinLod; - uint nMaxLod; - - SFrameLodInfo() - { - nID = 0; - fLodRatio = 0.f; - fTargetSize = 0.f; - nMinLod = 0; - nMaxLod = 6; - } -}; -struct SMeshLodInfo -{ - static const int s_nMaxLodCount = 5; - float fGeometricMean; - uint nFaceCount; - uint32 nFrameLodID; - SMeshLodInfo() - { - Clear(); - } - void Clear() - { - fGeometricMean = 0.f; - nFaceCount = 0; - nFrameLodID = 0; - } - void Merge(const SMeshLodInfo& lodInfo) - { - uint nTotalCount = nFaceCount + lodInfo.nFaceCount; - if (nTotalCount > 0) - { - float fGeometricMeanTotal = 0.f; - if (fGeometricMean > 0.f) - { - fGeometricMeanTotal += logf(fGeometricMean) * nFaceCount; - } - if (lodInfo.fGeometricMean > 0.f) - { - fGeometricMeanTotal += logf(lodInfo.fGeometricMean) * lodInfo.nFaceCount; - } - fGeometricMean = expf(fGeometricMeanTotal / (float)nTotalCount); - nFaceCount = nTotalCount; - } - } -}; -// Summary: -// Physics material enumerator, allows for 3dengine to get material id from game code. -struct IPhysMaterialEnumerator -{ - // - virtual ~IPhysMaterialEnumerator(){} - virtual int EnumPhysMaterial(const char* szPhysMatName) = 0; - virtual bool IsCollidable(int nMatId) = 0; - virtual int GetMaterialCount() = 0; - virtual const char* GetMaterialNameByIndex(int index) = 0; - // -}; - - -// Summary: -// Physics foreign data flags. -enum EPhysForeignFlags -{ - PFF_HIDABLE = 0x1, - PFF_HIDABLE_SECONDARY = 0x2, - PFF_EXCLUDE_FROM_STATIC = 0x4, - PFF_UNIMPORTANT = 0x20, - PFF_OUTDOOR_AREA = 0x40, - PFF_MOVING_PLATFORM = 0x80, -}; - -// Summary: -// Ocean data flags. -enum EOceanRenderFlags -{ - OCR_NO_DRAW = 1 << 0, - OCR_OCEANVOLUME_VISIBLE = 1 << 1, -}; - -// Summary: -// Structure to pass vegetation group properties. -struct IStatInstGroup -{ - enum EPlayerHideable - { - ePlayerHideable_None = 0, - ePlayerHideable_High, - ePlayerHideable_Mid, - ePlayerHideable_Low, - - ePlayerHideable_COUNT, - }; - - IStatInstGroup() - { - pStatObj = 0; - szFileName[0] = 0; - bHideability = 0; - bHideabilitySecondary = 0; - fBending = 0; - nCastShadowMinSpec = 0; - bRecvShadow = 0; - bDynamicDistanceShadows = false; - bUseAlphaBlending = 0; - fSpriteDistRatio = 1.f; - fShadowDistRatio = 1.f; - fMaxViewDistRatio = 1.f; - fLodDistRatio = 1.f; - fBrightness = 1.f; - pMaterial = 0; - - fDensity = 1; - fElevationMax = 4096; - fElevationMin = 8; - fSize = 1; - fSizeVar = 0; - fSlopeMax = 255; - fSlopeMin = 0; - fStiffness = 0.5f; - fDamping = 2.5f; - fVariance = 0.6f; - fAirResistance = 1.f; - bRandomRotation = false; - nRotationRangeToTerrainNormal = 0; - nMaterialLayers = 0; - bAllowIndoor = false; - fAlignToTerrainCoefficient = 0.f; - bAutoMerged = false; - minConfigSpec = (ESystemConfigSpec)0; - nTexturesAreStreamedIn = 0; - nPlayerHideable = ePlayerHideable_None; - nID = -1; - } - - IStatObj* GetStatObj() - { - IStatObj* p = pStatObj; - return (IStatObj*)p; - } - const IStatObj* GetStatObj() const - { - const IStatObj* p = pStatObj; - return (const IStatObj*)p; - } - - _smart_ptr pStatObj; - char szFileName[256]; - bool bHideability; - bool bHideabilitySecondary; - float fBending; - uint8 nCastShadowMinSpec; - bool bRecvShadow; - bool bDynamicDistanceShadows; - bool bUseAlphaBlending; - float fSpriteDistRatio; - float fLodDistRatio; - float fShadowDistRatio; - float fMaxViewDistRatio; - float fBrightness; - bool bRandomRotation; - int32 nRotationRangeToTerrainNormal; - float fAlignToTerrainCoefficient; - bool bAllowIndoor; - bool bAutoMerged; - - float fDensity; - float fElevationMax; - float fElevationMin; - float fSize; - float fSizeVar; - float fSlopeMax; - float fSlopeMin; - float fStiffness; - float fDamping; - float fVariance; - float fAirResistance; - - float fVegRadius; - float fVegRadiusVert; - float fVegRadiusHor; - - int nPlayerHideable; - int nID; - - // Minimal configuration spec for this vegetation group. - ESystemConfigSpec minConfigSpec; - - // Override material for this instance group. - _smart_ptr pMaterial; - - // Material layers bitmask -> which layers are active. - uint8 nMaterialLayers; - - // Textures Are Streamed In. - uint8 nTexturesAreStreamedIn; - - // Flags similar to entity render flags. - int m_dwRndFlags; -}; - -// Description: -// Water volumes should usually be created by I3DEngine::CreateWaterVolume. -// Summary: -// Interface to water volumes. -struct IWaterVolume -{ - // - //DOC-IGNORE-BEGIN - virtual ~IWaterVolume(){} - virtual void UpdatePoints(const Vec3* pPoints, int nCount, float fHeight) = 0; - virtual void SetFlowSpeed(float fSpeed) = 0; - virtual void SetAffectToVolFog(bool bAffectToVolFog) = 0; - virtual void SetTriSizeLimits(float fTriMinSize, float fTriMaxSize) = 0; - // virtual void SetMaterial(const char * szShaderName) = 0; - virtual void SetMaterial(_smart_ptr pMaterial) = 0; - virtual _smart_ptr GetMaterial() = 0; - virtual const char* GetName() const = 0; - virtual void SetName(const char* szName) = 0; - //DOC-IGNORE-END - - // Description: - // Used to change the water level. Will assign a new Z value to all - // vertices of the water geometry. - // Arguments: - // vNewOffset - Position of the new water level - // Summary: - // Sets a new water level. - virtual void SetPositionOffset(const Vec3& vNewOffset) = 0; - // -}; - -struct SClipVolumeBlendInfo -{ - static const int BlendPlaneCount = 2; - - Plane_tpl blendPlanes[BlendPlaneCount]; - struct IClipVolume* blendVolumes[BlendPlaneCount]; -}; - -struct IClipVolume -{ - enum EClipVolumeFlags - { - eClipVolumeConnectedToOutdoor = BIT(0), - eClipVolumeIgnoreGI = BIT(1), - eClipVolumeAffectedBySun = BIT(2), - eClipVolumeBlend = BIT(3), - eClipVolumeIsVisArea = BIT(4), - eClipVolumeIgnoreOutdoorAO = BIT(5), - }; - - virtual ~IClipVolume() {}; - virtual void GetClipVolumeMesh(_smart_ptr& renderMesh, Matrix34& worldTM) const = 0; - virtual AABB GetClipVolumeBBox() const = 0; - virtual bool IsPointInsideClipVolume(const Vec3& point) const = 0; - - virtual uint8 GetStencilRef() const = 0; - virtual uint GetClipVolumeFlags() const = 0; -}; - -// Summary: -// Provides information about the different VisArea volumes. -struct IVisArea - : public IClipVolume -{ - // - virtual ~IVisArea(){} - // Summary: - // Gets the last rendered frame id. - // Return Value: - // An int which contains the frame id. - virtual int GetVisFrameId() = 0; - - // Description: - // Gets a list of all the VisAreas which are connected to the current one. - // Arguments: - // pAreas - Pointer to an array of IVisArea* - // nMaxConnNum - The maximum of IVisArea to write in pAreas - // bSkipDisabledPortals - Ignore portals which are disabled - // Return Value: - // An integer which hold the amount of VisArea found to be connected. If - // the return is equal to nMaxConnNum, it's possible that not all - // connected VisAreas were returned due to the restriction imposed by the - // argument. - // Summary: - // Gets all the areas which are connected to the current one. - virtual int GetVisAreaConnections(IVisArea** pAreas, int nMaxConnNum, bool bSkipDisabledPortals = false) = 0; - - // Summary: - // Determines if it's connected to an outdoor area. - // Return Value: - // True if the VisArea is connected to an outdoor area. - virtual bool IsConnectedToOutdoor() const = 0; - - // Summary: - // Determines if the visarea ignores Global Illumination inside. - // Return Value: - // True if the VisArea ignores Global Illumination inside. - virtual bool IsIgnoringGI() const = 0; - - // Summary: - // Determines if the visarea ignores Outdoor Ambient occlusion inside. - // Return Value: - // True if the VisArea ignores Outdoor Ambient Occlusion inside. - virtual bool IsIgnoringOutdoorAO() const = 0; - - // Summary: - // Gets the name. - // Notes: - // The name is always returned in lower case. - // Return Value: - // A null terminated char array containing the name of the VisArea. - virtual const char* GetName() = 0; - - // Summary: - // Determines if this VisArea is a portal. - // Return Value: - // True if the VisArea is a portal, or false in the opposite case. - virtual bool IsPortal() const = 0; - - // Description: - // Searches for a specified VisArea to see if it's connected to the current - // VisArea. - // Arguments: - // pAnotherArea - A specified VisArea to find - // nMaxRecursion - The maximum number of recursion to do while searching - // bSkipDisabledPortals - Will avoid searching disabled VisAreas - // pVisitedAreas - if not NULL - will get list of all visited areas - // Return Value: - // True if the VisArea was found. - // Summary: - // Searches for a specified VisArea. - virtual bool FindVisArea(IVisArea* pAnotherArea, int nMaxRecursion, bool bSkipDisabledPortals) = 0; - - // Description: - // Searches for the surrounding VisAreas which connected to the current - // VisArea. - // Arguments: - // nMaxRecursion - The maximum number of recursion to do while searching - // bSkipDisabledPortals - Will avoid searching disabled VisAreas - // pVisitedAreas - if not NULL - will get list of all visited areas - // Return Value: - // None. - // Summary: - // Searches for the surrounding VisAreas. - virtual void FindSurroundingVisArea(int nMaxRecursion, bool bSkipDisabledPortals, PodArray* pVisitedAreas = NULL, int nMaxVisitedAreas = 0, int nDeepness = 0) = 0; - - // Summary: - // Determines if it's affected by outdoor lighting. - // Return Value: - // Returns true if the VisArea if it's affected by outdoor lighting, else - // false will be returned. - virtual bool IsAffectedByOutLights() const = 0; - - // Summary: - // Determines if the spere can be affect the VisArea. - // Return Value: - // Returns true if the VisArea can be affected by the sphere, else - // false will be returned. - virtual bool IsSphereInsideVisArea(const Vec3& vPos, const f32 fRadius) = 0; - - // Summary: - // Clips geometry inside or outside a vis area. - // Return Value: - // Whether geom was clipped. - virtual bool ClipToVisArea(bool bInside, Sphere& sphere, Vec3 const& vNormal) = 0; - - // Summary: - // Gives back the axis aligned bounding box of VisArea. - // Return Value: - // Returns the pointer of a AABB. - virtual const AABB* GetAABBox() const = 0; - - // Summary: - // Gives back the axis aligned bounding box of all static objects in the VisArea. - // This AABB can be huger than the ViaArea AABB as some objects might not be completely inside the VisArea. - // Return Value: - // Returns the pointer to the AABB. - virtual const AABB* GetStaticObjectAABBox() const = 0; - - // Summary: - // Determines if the point can be affect the VisArea. - // Return Value: - // Returns true if the VisArea can be affected by the point, else - // false will be returned. - virtual bool IsPointInsideVisArea(const Vec3& vPos) const = 0; - - virtual void GetShapePoints(const Vec3*& pPoints, size_t& nPoints) = 0; - virtual float GetHeight() = 0; - // -}; - -#include "OceanConstants.h" - -// float m_SortId : offseted by +WATER_LEVEL_SORTID_OFFSET if the camera object line is crossing the water surface -// : otherwise offseted by -WATER_LEVEL_SORTID_OFFSET -#define WATER_LEVEL_SORTID_OFFSET 10000000 - -#define DEFAULT_SID 0 - -// Summary: -// indirect lighting quadtree definition. -namespace NQT -{ - // Forward declaration - template - class CQuadTree; -} - -#define FILEVERSION_TERRAIN_SHLIGHTING_FILE 5 - -enum EVoxelBrushShape -{ - evbsSphere = 1, - evbsBox, -}; - -enum EVoxelEditTarget -{ - evetVoxelObjects = 1, -}; - -enum EVoxelEditOperation -{ - eveoNone = 0, - eveoPaintHeightPos, - eveoPaintHeightNeg, - eveoCreate, - eveoSubstract, - eveoMaterial, - eveoBaseColor, - eveoBlurPos, - eveoBlurNeg, - eveoCopyTerrainPos, - eveoCopyTerrainNeg, - eveoPickHeight, - eveoIntegrateMeshPos, - eveoIntegrateMeshNeg, - eveoForceDepth, - eveoLimitLod, - eveoLast, -}; - -#define COMPILED_VISAREA_MAP_FILE_NAME "terrain\\indoor.dat" -#define COMPILED_MERGED_MESHES_BASE_NAME "terrain\\merged_meshes_sectors\\" -#define COMPILED_MERGED_MESHES_LIST "mmrm_used_meshes.lst" -#define LEVEL_INFO_FILE_NAME "levelinfo.xml" - -////////////////////////////////////////////////////////////////////////// - -#pragma pack(push,4) - -#define VISAREAMANAGER_CHUNK_VERSION 6 - -#define SERIALIZATION_FLAG_BIG_ENDIAN 1 -#define SERIALIZATION_FLAG_SECTOR_PALETTES 2 - -#define TCH_FLAG2_AREA_ACTIVATION_IN_USE 1 - -struct SVisAreaManChunkHeader -{ - int8 nVersion; - int8 nDummy; - int8 nFlags; - int8 nFlags2; - int nChunkSize; - int nVisAreasNum; - int nPortalsNum; - int nOcclAreasNum; - - AUTO_STRUCT_INFO -}; - -struct SOcTreeNodeChunk -{ - int16 nChunkVersion; - int16 ucChildsMask; - AABB nodeBox; - int32 nObjectsBlockSize; - - AUTO_STRUCT_INFO -}; - -struct SHotUpdateInfo -{ - SHotUpdateInfo() - { - nHeigtmap = 1; - nObjTypeMask = ~0; - pVisibleLayerMask = NULL; - pLayerIdTranslation = NULL; - areaBox.Reset(); - } - - uint32 nHeigtmap; - uint32 nObjTypeMask; - const uint8* pVisibleLayerMask; - const uint16* pLayerIdTranslation; - AABB areaBox; - - AUTO_STRUCT_INFO -}; - -#define OCTREE_CHUNK_VERSION 29 - -//============================================================================================== - -// Summary: -// Common header for binary files used by 3dengine -struct SCommonFileHeader -{ - char signature[4]; // File signature, should be "CRY " - uint8 file_type; // File type - uint8 flags; // File common flags - uint16 version; // File version - - AUTO_STRUCT_INFO -}; - -struct IVisAreaCallback -{ - // - virtual ~IVisAreaCallback(){} - virtual void OnVisAreaDeleted(IVisArea* pVisArea) = 0; - // -}; - -struct IVisAreaManager -{ - // - virtual ~IVisAreaManager(){} - // Summary: - // Loads data into VisAreaManager engine from memory block. - virtual bool SetCompiledData(uint8* pData, int nDataSize, std::vector** ppStatObjTable, std::vector<_smart_ptr >** ppMatTable, bool bHotUpdate, SHotUpdateInfo* pExportInfo) = 0; - - // Summary: - // Saves data from VisAreaManager engine into memory block. - virtual bool GetCompiledData(uint8* pData, int nDataSize, std::vector** ppStatObjTable, std::vector<_smart_ptr >** ppMatTable, std::vector** ppStatInstGroupTable, EEndian eEndian, SHotUpdateInfo* pExportInfo = NULL) = 0; - - // Summary: - // Returns VisAreaManager data memory block size. - virtual int GetCompiledDataSize(SHotUpdateInfo* pExportInfo = NULL) = 0; - - // Summary: - // Returns the accumulated number of visareas and portals. - virtual int GetNumberOfVisArea() const = 0; - - // Summary: - // Returns the visarea interface based on the id (0..GetNumberOfVisArea()) it can be a visarea or a portal. - virtual IVisArea* GetVisAreaById(int nID) const = 0; - - virtual void AddListener(IVisAreaCallback* pListener) = 0; - virtual void RemoveListener(IVisAreaCallback* pListener) = 0; - - virtual void PrepareSegmentData(const AABB& box) = 0; - virtual void ReleaseInactiveSegments() = 0; - virtual bool CreateSegment(int nSID) = 0; - virtual bool DeleteSegment(int nSID, bool bDeleteNow) = 0; - virtual bool StreamCompiledData(uint8* pData, int nDataSize, int nSID, std::vector* pStatObjTable, std::vector<_smart_ptr >* pMatTable, std::vector* pStatInstGroupTable, const Vec2& vIndexOffset) = 0; - virtual void OffsetPosition(const Vec3& delta) = 0; - virtual void UpdateConnections() = 0; - // Summary: - // Clones all vis areas in a region of the level, offsetting and rotating them based - // on the values passed in. - // Arguments: - // offset - Offset amount, relative to the center of the region passed in. - // zRotation - Rotation around the z axis, in radians. - virtual void CloneRegion(const AABB& region, const Vec3& offset, float zRotation) = 0; - - // Summary: - // Removes all vis areas in a region of the level. - virtual void ClearRegion(const AABB& region) = 0; - - virtual void GetObjectsByType(PodArray& lstObjects, EERType objType, const AABB* pBBox, ObjectTreeQueryFilterCallback filterCallback = nullptr) = 0; - virtual void GetObjectsByFlags(uint dwFlags, PodArray& lstObjects) = 0; - - virtual void GetObjects(PodArray& lstObjects, const AABB* pBBox) = 0; - - virtual bool IsOutdoorAreasVisible() = 0; -}; - -struct SSkyLightRenderParams -{ - static const int skyDomeTextureWidth = 64; - static const int skyDomeTextureHeight = 32; - static const int skyDomeTextureSize = 64 * 32; - - static const int skyDomeTextureWidthBy8 = 8; - static const int skyDomeTextureWidthBy4Log = 4; // = log2(64/4) - static const int skyDomeTextureHeightBy2Log = 4; // = log2(32/2) - - SSkyLightRenderParams() - : m_pSkyDomeMesh(0) - , m_pSkyDomeTextureDataMie(0) - , m_pSkyDomeTextureDataRayleigh(0) - , m_skyDomeTexturePitch(0) - , m_skyDomeTextureTimeStamp(-1) - , m_partialMieInScatteringConst(0.0f, 0.0f, 0.0f, 0.0f) - , m_partialRayleighInScatteringConst(0.0f, 0.0f, 0.0f, 0.0f) - , m_sunDirection(0.0f, 0.0f, 0.0f, 0.0f) - , m_phaseFunctionConsts(0.0f, 0.0f, 0.0f, 0.0f) - , m_hazeColor(0.0f, 0.0f, 0.0f, 0.0f) - , m_hazeColorMieNoPremul(0.0f, 0.0f, 0.0f, 0.0f) - , m_hazeColorRayleighNoPremul(0.0f, 0.0f, 0.0f, 0.0f) - , m_skyColorTop(0.0f, 0.0f, 0.0f) - , m_skyColorNorth(0.0f, 0.0f, 0.0f) - , m_skyColorEast(0.0f, 0.0f, 0.0f) - , m_skyColorSouth(0.0f, 0.0f, 0.0f) - , m_skyColorWest(0.0f, 0.0f, 0.0f) - { - } - - // Sky dome mesh - _smart_ptr m_pSkyDomeMesh; - - // temporarily add padding bytes to prevent fetching Vec4 constants below from wrong offset - uint32 dummy0; - uint32 dummy1; - - // Sky dome texture data - const void* m_pSkyDomeTextureDataMie; - const void* m_pSkyDomeTextureDataRayleigh; - size_t m_skyDomeTexturePitch; - int m_skyDomeTextureTimeStamp; - - int pad;//Enable 16 byte alignment for Vec4s - - // Sky dome shader constants - Vec4 m_partialMieInScatteringConst; - Vec4 m_partialRayleighInScatteringConst; - Vec4 m_sunDirection; - Vec4 m_phaseFunctionConsts; - Vec4 m_hazeColor; - Vec4 m_hazeColorMieNoPremul; - Vec4 m_hazeColorRayleighNoPremul; - - // Sky hemisphere colors - Vec3 m_skyColorTop; - Vec3 m_skyColorNorth; - Vec3 m_skyColorEast; - Vec3 m_skyColorSouth; - Vec3 m_skyColorWest; -}; - -struct SVisAreaInfo -{ - float fHeight; - Vec3 vAmbientColor; - bool bAffectedByOutLights; - bool bIgnoreSkyColor; - bool bSkyOnly; - float fViewDistRatio; - bool bDoubleSide; - bool bUseDeepness; - bool bUseInIndoors; - bool bOceanIsVisible; - bool bIgnoreGI; - bool bIgnoreOutdoorAO; - float fPortalBlending; -}; - -struct SDebugFPSInfo -{ - SDebugFPSInfo() - : fAverageFPS(0.0f) - , fMaxFPS(0.0f) - , fMinFPS(0.0f) - { - } - float fAverageFPS; - float fMinFPS; - float fMaxFPS; -}; - -struct SRainParams -{ - SRainParams() - : fAmount(0.f) - , fCurrentAmount(0.f) - , fRadius(0.f) - , nUpdateFrameID(-1) - , bIgnoreVisareas(false) - , bDisableOcclusion(false) - , matOccTrans(IDENTITY) - , matOccTransRender(IDENTITY) - , qRainRotation(IDENTITY) - , areaAABB(AABB::RESET) - , bApplySkyColor(false) - , fSkyColorWeight(0.5f) - { - } - - Matrix44 matOccTrans; // Transformation matrix for rendering into a new occ map - Matrix44 matOccTransRender; // Transformation matrix for rendering occluded rain using current occ map - Quat qRainRotation; // Quaternion for the scene's rain entity rotation - AABB areaAABB; - - Vec3 vWorldPos; - Vec3 vColor; - - float fAmount; - float fCurrentAmount; - float fRadius; - - // Deferred rain params - float fFakeGlossiness; // unused - float fFakeReflectionAmount; // unused - float fDiffuseDarkening; - float fRainDropsAmount; - float fRainDropsSpeed; - float fRainDropsLighting; - float fMistAmount; - float fMistHeight; - float fPuddlesAmount; - float fPuddlesMaskAmount; - float fPuddlesRippleAmount; - float fSplashesAmount; - - int nUpdateFrameID; - - bool bApplyOcclusion; - bool bIgnoreVisareas; - bool bDisableOcclusion; - -// Summary: -// Common scene rain parameters shared across engine and editor - bool bApplySkyColor; - float fSkyColorWeight; - - // Bus ID to listen to -}; - -struct SSnowParams -{ - SSnowParams() - : m_vWorldPos(0, 0, 0) - , m_fRadius(0.0) - , m_fSnowAmount(0.0) - , m_fFrostAmount(0.0) - , m_fSurfaceFreezing(0.0) - , m_nSnowFlakeCount(0) - , m_fSnowFlakeSize(0.0) - , m_fSnowFallBrightness(0.0) - , m_fSnowFallGravityScale(0.0) - , m_fSnowFallWindScale(0.0) - , m_fSnowFallTurbulence(0.0) - , m_fSnowFallTurbulenceFreq(0.0) - { - } - - Vec3 m_vWorldPos; - float m_fRadius; - - // Surface params. - float m_fSnowAmount; - float m_fFrostAmount; - float m_fSurfaceFreezing; - - - // Snowfall params. - int m_nSnowFlakeCount; - float m_fSnowFlakeSize; - float m_fSnowFallBrightness; - float m_fSnowFallGravityScale; - float m_fSnowFallWindScale; - float m_fSnowFallTurbulence; - float m_fSnowFallTurbulenceFreq; -}; - - -struct IScreenshotCallback -{ - // - virtual ~IScreenshotCallback(){} - virtual void SendParameters(void* data, uint32 width, uint32 height, f32 minx, f32 miny, f32 maxx, f32 maxy) = 0; - // -}; - -class IStreamedObjectListener -{ -public: - // - virtual void OnCreatedStreamedObject(const char* filename, void* pHandle) = 0; - virtual void OnRequestedStreamedObject(void* pHandle) = 0; - virtual void OnReceivedStreamedObject(void* pHandle) = 0; - virtual void OnUnloadedStreamedObject(void* pHandle) = 0; - virtual void OnBegunUsingStreamedObjects(void** pHandles, size_t numHandles) = 0; - virtual void OnEndedUsingStreamedObjects(void** pHandles, size_t numHandles) = 0; - virtual void OnDestroyedStreamedObject(void* pHandle) = 0; - // -protected: - virtual ~IStreamedObjectListener() {} -}; - -#pragma pack(push, 16) - -struct SFogVolumeData -{ - AABB avgAABBox; - ColorF fogColor; - int m_volumeType; - Vec3 m_heightFallOffBasePoint; - float m_densityOffset; - Vec3 m_heightFallOffDirScaled; - float m_globalDensity; - - SFogVolumeData() : - avgAABBox(AABB::RESET), - m_globalDensity(0.0f), - m_densityOffset(0.0f), - m_volumeType(0), - m_heightFallOffBasePoint(Vec3(0, 0, 0)), - m_heightFallOffDirScaled(Vec3(0, 0, 0)), - fogColor(ColorF(1.0f, 1.0f, 1.0f, 1.0f)) - { - } - -}; - -// Summary: -// Light volumes data - -#define LIGHTVOLUME_MAXLIGHTS 16 - -struct SLightVolume -{ - struct SLightData - { - SLightData() - : vPos(0, 0, 0, 0) - , vColor(0, 0, 0, 0) - , vParams(0, 0, 0, 0) {} - SLightData(const Vec4& vInPos, const Vec4& vInColor, const Vec4& vInParams) - : vPos(vInPos) - , vColor(vInColor) - , vParams(vInParams) {} - - Vec4 vPos; - Vec4 vColor; - Vec4 vParams; - }; - - SLightVolume() - { - pData.reserve(LIGHTVOLUME_MAXLIGHTS); - } - - typedef DynArray LightDataVector; - - DEFINE_ALIGNED_DATA(LightDataVector, pData, 16); -}; - -#pragma pack(pop) - -struct CRNTmpData -{ - struct SRNUserData - { - int m_narrDrawFrames[MAX_RECURSION_LEVELS]; - SLodDistDissolveTransitionState lodDistDissolveTransitionState; - Matrix34 objMat; - OcclusionTestClient m_OcclState; - struct IClipVolume* m_pClipVolume; - SBending m_Bending; - SBending m_BendingPrev; - Vec3 vCurrentWind; - uint32 nBendingLastFrame : 29; - uint32 bWindCurrent : 1; - uint32 bBendingSet : 1; - uint16 nCubeMapId; - uint16 nCubeMapIdCacheClearCounter; - uint8 nWantedLod; - CRenderObject* m_pRenderObject[MAX_STATOBJ_LODS_NUM]; - CRenderObject* m_arrPermanentRenderObjects[MAX_STATOBJ_LODS_NUM]; - } userData; - - CRNTmpData() { memset(this, 0, sizeof(*this)); assert((void*)this == (void*)&this->userData); nPhysAreaChangedProxyId = ~0; } - CRNTmpData* pNext, * pPrev; - CRNTmpData** pOwnerRef; - uint32 nFrameInfoId; - uint32 nPhysAreaChangedProxyId; - - void Unlink() - { - if (!pNext || !pPrev) - { - return; - } - pNext->pPrev = pPrev; - pPrev->pNext = pNext; - pNext = pPrev = NULL; - } - - void Link(CRNTmpData* Before) - { - if (pNext || pPrev) - { - return; - } - pNext = Before->pNext; - Before->pNext->pPrev = this; - Before->pNext = this; - pPrev = Before; - } - - int Count() - { - int nCounter = 0; - for (CRNTmpData* pElem = pNext; pElem != this; pElem = pElem->pNext) - { - nCounter++; - } - return nCounter; - } - - void OffsetPosition(const Vec3& delta) - { - userData.objMat.SetTranslation(userData.objMat.GetTranslation() + delta); - } -}; - - -// Summary: -// Interface to the 3d Engine. -struct I3DEngine - : public IProcess -{ - struct SObjectsStreamingStatus - { - int nReady; - int nInProgress; - int nTotal; - int nActive; - int nAllocatedBytes; - int nMemRequired; - int nMeshPoolSize; // in MB - - }; - - struct OceanAnimationData - { - float fWindDirection; - float fWindSpeed; - float fWavesSpeed; - float fWavesAmount; - float fWavesSize; - float fWindDirectionU; - float fWindDirectionV; - }; - - struct SStremaingBandwidthData - { - SStremaingBandwidthData() - { - memset(this, 0, sizeof(SStremaingBandwidthData)); - } - float fBandwidthActual; - float fBandwidthRequested; - }; - - enum eStreamingSubsystem - { - eStreamingSubsystem_Textures, - eStreamingSubsystem_Objects, - eStreamingSubsystem_Audio, - }; - - using LoadStaticObjectAsyncResult = AZStd::function)>; - - struct StaticObjectAsyncLoadRequest - { - StaticObjectAsyncLoadRequest() = default; - - LoadStaticObjectAsyncResult m_callback; - string m_filename; - string m_geomName; - bool m_useStreaming; - unsigned long m_loadingFlags; - }; - - struct CausticsParams - { - float tiling = 0.0f; - float distanceAttenuation = 0.0f; - float height = 0.0f; - float depth = 0.0f; - float intensity = 0.0f; - }; - - - // - // Summary: - // Initializes the 3D Engine. - // See Also: - // ShutDown - // Notes: - // Only call once, after creating the instance. - virtual bool Init() = 0; - - - // Summary: - // Sets the path used to load levels. - // See Also: - // LoadLevel - // Arguments: - // szFolderName - Should contains the folder to be used - virtual void SetLevelPath(const char* szFolderName) = 0; - - virtual bool CheckMinSpec(uint32 nMinSpec) = 0; - - virtual void PrepareOcclusion(const CCamera& rCamera) = 0; - virtual void EndOcclusion() = 0; - // Description: - // Will load a level from the folder specified with SetLevelPath. If a - // level is already loaded, the resources will be deleted before. - // See Also: - // SetLevelPath - // Arguments: - // szFolderName - Name of the subfolder to load - // szMissionName - Name of the mission - // Return Value: - // A boolean which indicate the result of the function; true is - // succeed, or false if failed. - // Summary: - // Load a level. - virtual bool LoadLevel(const char* szFolderName, const char* szMissionName) = 0; - virtual bool InitLevelForEditor(const char* szFolderName, const char* szMissionName) = 0; - virtual bool LevelLoadingInProgress() = 0; - // Summary: - // Handles any work needed at start of new frame. - // Notes: - // Should be called for every frame. - virtual void OnFrameStart() = 0; - - // Description: - // Must be called after the game completely finishes loading the level. - // 3D engine uses it to pre-cache some resources needed for rendering. - // See Also: - // LoadLevel - // Summary: - // Pre-caches some resources need for rendering. - virtual void PostLoadLevel() = 0; - - // Description: - // Loads the required assets for a null level. - virtual void LoadEmptyLevel() = 0; - - // Summary: - // Clears all rendering resources, all objects, characters and materials, voxels and terrain. - // Notes: - // Should always be called before LoadLevel, and also before loading textures from a script. - virtual void UnloadLevel() = 0; - - - // Summary: - // Updates the 3D Engine. - // Notes: - // Should be called for every frame. - virtual void Update() = 0; - - // Summary: - // Returns the Camera used for Rendering on 3DEngine Side, normaly equal to the view camera, except if frozen with e_camerafreeze - // Notes: - // Only valid during RenderWorld(else the camera of the last frame is used) - // This is the camera which should be used for all Engine side culling (since e_camerafreeze allows easy debugging then) - virtual const CCamera& GetRenderingCamera() const = 0; - virtual float GetZoomFactor() const = 0; - - // Summary: - // clear all per frame temp data used in SRenderingPass - virtual void Tick() = 0; - - // Summary: - // Update all ShaderItems flags, only required after shaders were reloaded at runtime - virtual void UpdateShaderItems() = 0; - - // Summary: - // Deletes the 3D Engine instance. - virtual void Release() = 0; - - // Summary: - // Draws the world. - // See Also: - // SetCamera - // Arguments: - // szDebugName - name that can be visualized for debugging purpose, must not be 0 - virtual void RenderWorld(int nRenderFlags, const SRenderingPassInfo& passInfo, const char* szDebugName) = 0; - - virtual void RenderSceneReflection(int nRenderFlags, const SRenderingPassInfo& passInfo) = 0; - - // Summary: - // Prepares for the world stream update, should be called before rendering - virtual void PreWorldStreamUpdate(const CCamera& cam) = 0; - - // Summary: - // Performs the actual world streaming update. PreWorldStreamUpdate must be called before - virtual void WorldStreamUpdate() = 0; - - // Summary: - // Shuts down the 3D Engine. - virtual void ShutDown() = 0; - - // Summary: - // Loads a static object from a CGF file. Does not increment the static object's reference counter. The reference returned is not guaranteed to be valid when run outside the main thread. Best used for priming the cache - // See Also: - // IStatObj - // Arguments: - // fileName - CGF Filename - should not be 0 or "" - // geomName - Optional name of geometry inside CGF. - // subObject - [Out]Optional Out parameter,Pointer to the - // loadingFlags - Zero or a bitwise combination of the flags from ELoadingFlags, defined in IMaterial.h, under the interface IMaterialManager. - // data - Raw buffer contain CGF data. - // dataSize - Size of the raw data buffer. - // Return Value: - // A pointer to an object derived from IStatObj. - virtual IStatObj* LoadStatObjUnsafeManualRef(const char* fileName, const char* geomName = nullptr, /*[Out]*/ IStatObj::SSubObject** subObject = nullptr, - bool useStreaming = true, unsigned long loadingFlags = 0, const void* data = nullptr, int dataSize = 0) = 0; - - // Summary: - // Loads a static object from a CGF file. Increments the static object's reference counter. This method is threadsafe. Not suitable for preloading - // See Also: - // IStatObj - // Arguments: - // fileName - CGF Filename - should not be 0 or "", even if data is provided. - // geomName - Optional name of geometry inside CGF. - // subObject - [Out]Optional Out parameter,Pointer to the - // loadingFlags - Zero or a bitwise combination of the flags from ELoadingFlags, defined in IMaterial.h, under the interface IMaterialManager. - // data - Raw buffer contain CGF data. - // dataSize - Size of the raw data buffer. - // Return Value: - // A smart pointer to an object derived from IStatObj. - virtual _smart_ptr LoadStatObjAutoRef(const char* fileName, const char* geomName = nullptr, /*[Out]*/ IStatObj::SSubObject** subObject = nullptr, - bool useStreaming = true, unsigned long loadingFlags = 0, const void* data = nullptr, int dataSize = 0) = 0; - - // Summary: - // Flushes queued async mesh loads. - virtual void ProcessAsyncStaticObjectLoadRequests() = 0; - - // Summary: - // Loads a static object from a CGF file asynchronously and invokes a callback on completion. - // Actual load will occur on the main thread. - // See Also: - // IStatObj - // Arguments: - // callback - The user callback to invoke on completion. - // szFileName - CGF Filename - should not be 0 or "" - // szGeomName - Optional name of geometry inside CGF. - // ppSubObject - [Out]Optional Out parameter,Pointer to the - // nLoadingFlags - Zero or a bitwise combination of the flags from ELoadingFlags, - // defined in IMaterial.h, under the interface IMaterialManager. - // Return Value: - // None - virtual void LoadStatObjAsync(LoadStaticObjectAsyncResult resultCallback, const char* szFileName, const char* szGeomName = nullptr, bool bUseStreaming = true, unsigned long nLoadingFlags = 0) = 0; - - // Summary: - // Finds a static object created from the given filename - // See Also: - // IStatObj - // Arguments: - // szFileName - CGF Filename - should not be 0 or "" - // Return Value: - // A pointer to an object derived from IStatObj. - virtual IStatObj* FindStatObjectByFilename(const char* filename) = 0; - - // Summary: - // Gets gsm range - // Return Value: - // An integer representing the gsm range. - virtual const float GetGSMRange() = 0; - - // Summary: - // Gets gsm range step - // Return Value: - // An integer representing the gsm range step - virtual const float GetGSMRangeStep() = 0; - - // Summary: - // Gets the amount of loaded objects. - // Return Value: - // An integer representing the amount of loaded objects. - virtual int GetLoadedObjectCount() { return 0; } - - // Summary: - // Fills pObjectsArray with pointers to loaded static objects - // if pObjectsArray is NULL only fills nCount parameter with amount of loaded objects. - virtual void GetLoadedStatObjArray(IStatObj** pObjectsArray, int& nCount) = 0; - - // Summary: - // Gets stats on streamed objects - virtual void GetObjectsStreamingStatus(SObjectsStreamingStatus& outStatus) = 0; - - // Summary: - // Gets stats on the streaming bandwidth requests from subsystems - // Arguments: - // subsystem - the streaming subsystem we want bandwidth data for - // outData - structure containing the bandwidth data for the subsystem requested - virtual void GetStreamingSubsystemData(int subsystem, SStremaingBandwidthData& outData) = 0; - - // Summary: - // Registers an entity to be rendered. - // Arguments: - // pEntity - The entity to render - virtual void RegisterEntity(IRenderNode* pEntity, int nSID = -1, int nSIDConsideredSafe = -1) = 0; - - // Summary: - // Selects an entity for debugging. - // Arguments: - // pEntity - The entity to render - virtual void SelectEntity(IRenderNode* pEntity) = 0; - - ////////////////////////////////////////////// - // Start Confetti ////////////////////////// - // Summary: - // Return the setting for sun shadows. Return false for sub classes without sun shadows settings. - virtual bool IsSunShadows(){ return false; }; - // End Confetti////////////////////////////// - ////////////////////////////////////////////// - - // Summary: - // Offers same functionality as Cry3DEngineBase::MakeSystemMaterialFromShader - virtual _smart_ptr MakeSystemMaterialFromShaderHelper(const char* sShaderName, SInputShaderResources* Res = NULL) = 0; - - virtual bool CheckMinSpecHelper(uint32 nMinSpec) = 0; - - virtual void OnCasterDeleted(IShadowCaster* pCaster) = 0; - - virtual void GetStatObjAndMatTables(DynArray* pStatObjTable, DynArray<_smart_ptr>* pMatTable, DynArray* pStatInstGroupTable, uint32 nObjTypeMask) = 0; - -#ifndef _RELEASE - enum EDebugDrawListAssetTypes - { - DLOT_ALL = 0, - DLOT_CHARACTER = BIT(2), - DLOT_STATOBJ = BIT(3) - }; - - struct SObjectInfoToAddToDebugDrawList - { - const char* pName; - const char* pClassName; - const char* pFileName; - IRenderNode* pRenderNode; - uint32 numTris; - uint32 numVerts; - uint32 texMemory; - uint32 meshMemory; - EDebugDrawListAssetTypes type; - const AABB* pBox; - const Matrix34* pMat; - }; - - virtual void AddObjToDebugDrawList(SObjectInfoToAddToDebugDrawList& objInfo) = 0; - virtual bool IsDebugDrawListEnabled() const = 0; -#endif - - - // Summary: - // Notices the 3D Engine to stop rendering a specified entity. - // Arguments: - // pEntity - The entity to stop render - virtual void UnRegisterEntityDirect(IRenderNode* pEntity) = 0; - virtual void UnRegisterEntityAsJob(IRenderNode* pEnt) = 0; - // Summary: - // Returns whether a world pos is under water. - virtual bool IsUnderWater(const Vec3& vPos) const = 0; - - // Summary: - // Returns whether ocean volume is visible or not. - virtual void SetOceanRenderFlags(uint8 nFlags) = 0; - virtual uint8 GetOceanRenderFlags() const = 0; - virtual uint32 GetOceanVisiblePixelsCount() const = 0; - - // Summary: - // Gets the closest walkable bottom z straight beneath the given reference position. - // Notes: - // This function will take into account both the global terrain elevation and local voxel (or other solid walkable object). - // Arguments: - // referencePos - Position from where to start searching downwards. - // maxRelevantDepth - Max depth caller is interested in relative to referencePos (for ray casting performance reasons). - // objtypes - expects physics entity flags. Use this to specify what object types make a valid bottom for you. - // Return Value: - // A float value which indicate the global world z of the bottom level beneath the referencePos. - // If the referencePos is below terrain but not inside any voxel area BOTTOM_LEVEL_UNKNOWN is returned. - virtual float GetBottomLevel(const Vec3& referencePos, float maxRelevantDepth, int objtypes) = 0; - // A set of overloads for enabling users to use different sets of input params. Basically, only - // referencePos is mandatory. The overloads as such don't need to be virtual but this seems to be - // a purely virtual interface. - virtual float GetBottomLevel(const Vec3& referencePos, float maxRelevantDepth = 10.0f) = 0; - virtual float GetBottomLevel(const Vec3& referencePos, int objflags) = 0; - - // Summary: - // Gets the ocean water level. Fastest option, always prefer is only ocean height required. - // Notes: - // This function will take into account just the global water level. - // Return Value: - // A float value which indicate the water level. In case no water was - // found at the specified location, the value WATER_LEVEL_UNKNOWN will - // be returned. - virtual float GetWaterLevel() = 0; - - // Summary: - // Gets the closest walkable bottom z straight beneath the given reference position. - // - Use with caution the accurate query - SLOW - // Notes: - // This function will take into account both the global water level and any water volume present. - // Function is provided twice for performance with diff. arguments. - // Arguments: - // pvPos - Desired position to inspect the water level - // pent - Pointer to return the physical entity to test against (optional) - // Return Value: - // A float value which indicate the water level. In case no water was - // found at the specified location, the value WATER_LEVEL_UNKNOWN will - // be returned. - virtual float GetWaterLevel(const Vec3* pvPos, IPhysicalEntity* pent = NULL, bool bAccurate = false) = 0; - - // Summary: - // Gets the ocean water level for a specified position. - // - Use with caution the accurate query - SLOW - // Notes: - // This function only takes into account ocean water. - // Arguments: - // pCurrPos - Position to check water level - // Return Value: - // A float value which indicate the water level. - virtual float GetAccurateOceanHeight(const Vec3& pCurrPos) const = 0; - - // Summary: - // Gets caustics parameters. - virtual CausticsParams GetCausticsParams() const = 0; - - // Summary: - // Gets ocean animation parameters. - virtual OceanAnimationData GetOceanAnimationParams() const = 0; - - // Summary: - // Gets HDR setup parameters. - // Return Value: - virtual void GetHDRSetupParams (Vec4 pParams[5]) const = 0; - - // Summary: - // Removes all particles and decals from the world. - virtual void ResetParticlesAndDecals() = 0; - - // Summary: - // Creates new decals on the walls, static objects, terrain and entities. - // Arguments: - // Decal - Structure describing the decal effect to be applied - virtual void CreateDecal(const CryEngineDecalInfo& Decal) = 0; - - // Summary: - // Removes decals in a specified range. - // Arguments: - // vAreaBox - Specify the area in which the decals will be removed - // pEntity - if not NULL will only delete decals attached to this entity - virtual void DeleteDecalsInRange(AABB* pAreaBox, IRenderNode* pEntity) = 0; - - // Summary: - // Sets the current sun base color. - virtual void SetSunColor(Vec3 vColor) = 0; - - // Summary: - // Gets the current sun animated color. - virtual Vec3 GetSunAnimColor() = 0; - - // Summary: - // Sets the current sky brightening multiplier. - virtual void SetSunAnimColor(const Vec3& color) = 0; - - // Summary: - // Sets the current sun animation speed. - virtual float GetSunAnimSpeed() = 0; - - // Summary: - virtual void SetSunAnimSpeed(float sunAnimSpeed) = 0; - - // Summary: - // Gets the current sun animation phase. - virtual AZ::u8 GetSunAnimPhase() = 0; - // Summary: - // Sets the current sun animation phase. - virtual void SetSunAnimPhase(AZ::u8 sunAnimPhase) = 0; - - // Summary: - // Gets the current sun animation index. - virtual AZ::u8 GetSunAnimIndex() = 0; - - // Summary: - // Sets the current sun animation index. - virtual void SetSunAnimIndex(AZ::u8 sunAnimIndex) = 0; - - // Summary: - // Sets current rain parameters. - virtual void SetRainParams(const SRainParams& rainParams) = 0; - - // Summary: - // Gets the validity and fills current rain parameters. - virtual bool GetRainParams(SRainParams& rainParams) = 0; - - // Summary: - // Sets current snow surface parameters. - virtual void SetSnowSurfaceParams(const Vec3& vCenter, float fRadius, float fSnowAmount, float fFrostAmount, float fSurfaceFreezing) = 0; - - // Summary: - // Gets current snow surface parameters. - virtual bool GetSnowSurfaceParams(Vec3& vCenter, float& fRadius, float& fSnowAmount, float& fFrostAmount, float& fSurfaceFreezing) = 0; - - // Summary: - // Sets current snow parameters. - virtual void SetSnowFallParams(int nSnowFlakeCount, float fSnowFlakeSize, float fSnowFallBrightness, float fSnowFallGravityScale, float fSnowFallWindScale, float fSnowFallTurbulence, float fSnowFallTurbulenceFreq) = 0; - - // Summary: - // Gets current snow parameters. - virtual bool GetSnowFallParams(int& nSnowFlakeCount, float& fSnowFlakeSize, float& fSnowFallBrightness, float& fSnowFallGravityScale, float& fSnowFallWindScale, float& fSnowFallTurbulence, float& fSnowFallTurbulenceFreq) = 0; - - // Summary: - // Sets the view distance scale. - // Arguments: - // fScale - may be between 0 and 1, 1.f = Unmodified view distance set by level designer, value of 0.5 will reduce it twice - // Notes: - // This value will be reset automatically to 1 on next level loading. - virtual void SetMaxViewDistanceScale(float fScale) = 0; - - // Summary: - // Gets the view distance. - // Return Value: - // A float value representing the maximum view distance. - virtual float GetMaxViewDistance(bool bScaled = true) = 0; - - virtual const SFrameLodInfo& GetFrameLodInfo() const = 0; - virtual void SetFrameLodInfo(const SFrameLodInfo& frameLodInfo) = 0; - - // Summary: - // Sets the fog color. - virtual void SetFogColor(const Vec3& vFogColor) = 0; - - // Summary: - // Gets the fog color. - virtual Vec3 GetFogColor() = 0; - - // Summary: - // Gets various sky light parameters. - virtual void GetSkyLightParameters(Vec3& sunDir, Vec3& sunIntensity, float& Km, float& Kr, float& g, Vec3& rgbWaveLengths) = 0; - - // Summary: - // Sets various sky light parameters. - virtual void SetSkyLightParameters(const Vec3& sunDir, const Vec3& sunIntensity, float Km, float Kr, float g, const Vec3& rgbWaveLengths, bool forceImmediateUpdate = false) = 0; - - // Return Value: - // In logarithmic scale -4.0 .. 4.0 - virtual float GetLightsHDRDynamicPowerFactor() const = 0; - - // Return true if tessellation is allowed for given render object - virtual bool IsTessellationAllowed(const CRenderObject* pObj, const SRenderingPassInfo& passInfo, bool bIgnoreShadowPass = false) const = 0; - - // allows to modify material on render nodes at run-time (make sure it is properly restored back) - virtual void SetRenderNodeMaterialAtPosition(EERType eNodeType, const Vec3& vPos, _smart_ptr pMat) = 0; - - // override the camera precache point with the requested position for the current round - virtual void OverrideCameraPrecachePoint(const Vec3& vPos) = 0; - - // begin streaming of meshes and textures for specified position, pre-cache stops after fTimeOut seconds - virtual int AddPrecachePoint(const Vec3& vPos, const Vec3& vDir, float fTimeOut = 3.f, float fImportanceFactor = 1.0f) = 0; - virtual void ClearPrecachePoint(int id) = 0; - virtual void ClearAllPrecachePoints() = 0; - - virtual void GetPrecacheRoundIds(int pRoundIds[MAX_STREAM_PREDICTION_ZONES]) = 0; - - virtual void TraceFogVolumes(const Vec3& vPos, const AABB& objBBox, SFogVolumeData& fogVolData, const SRenderingPassInfo& passInfo, bool fogVolumeShadingQuality) = 0; - - //DOC-IGNORE-BEGIN - - // Internal functions, mostly used by the editor, which won't be documented for now - - // Summary: - // Removes all static objects on the map (for editor) - virtual void RemoveAllStaticObjects(int nSID = DEFAULT_SID) = 0; - - // Summary: - // Sets group parameters - virtual bool SetStatInstGroup(int nGroupId, const IStatInstGroup& siGroup, int nSID = 0) = 0; - - // Summary: - // Gets group parameters - virtual bool GetStatInstGroup(int nGroupId, IStatInstGroup& siGroup, int nSID = 0) = 0; - - //DOC-IGNORE-END - - // Summary: - // Notifies of an explosion, and maybe creates an hole in the terrain - // Description: - // This function should usually make sure that no static objects are near before making the hole. - // Arguments: - // vPos - Position of the explosion - // fRadius - Radius of the explosion - // bDeformTerrain - Allow to deform the terrain - virtual void OnExplosion(Vec3 vPos, float fRadius, bool bDeformTerrain = true) = 0; - - // Summary: - // Sets the physics material enumerator - // Arguments: - // pPhysMaterialEnumerator - The physics material enumarator to set - virtual void SetPhysMaterialEnumerator(IPhysMaterialEnumerator* pPhysMaterialEnumerator) = 0; - - // Summary: - // Gets the physics material enumerator - // Return Value: - // A pointer to an IPhysMaterialEnumerator derived object. - virtual IPhysMaterialEnumerator* GetPhysMaterialEnumerator() = 0; - - //DOC-IGNORE-BEGIN - //Internal functions - - // Summary: - // Allows to enable fog in editor - virtual void SetupDistanceFog() = 0; - - // Summary: - // Loads environment settings for specified mission - virtual void LoadMissionDataFromXMLNode(const char* szMissionName) = 0; - - virtual void LoadEnvironmentSettingsFromXML(XmlNodeRef pInputNode, int nSID = DEFAULT_SID) = 0; - - // Summary: - // This one is called by the editor when the terrain editing tools are not being built. - // This is the case when the game developers are using external tools to author terrain. - // The Octree data and the terrain heightmap data are stored in the same file. - // This method makes sure only the non-terrain data of the Octree is loaded. - virtual bool LoadCompiledOctreeForEditor() = 0; - - //DOC-IGNORE-END - - //DOC-IGNORE-BEGIN - // Set direction to the sun - // virtual void SetSunDir( const Vec3& vNewSunDir ) = 0; - - // Summary: - // Return non-normalized direction to the sun - virtual Vec3 GetSunDir() const = 0; - - // Summary: - // Return normalized direction to the sun - virtual Vec3 GetSunDirNormalized() const = 0; - - // Summary: - // Return realtime (updated every frame with real sun position) normalized direction to the scene - virtual Vec3 GetRealtimeSunDirNormalized() const = 0; - - //Internal function used by 3d engine and renderer - // Summary: - // Gets distance to the sector containig ocean water - virtual float GetDistanceToSectorWithWater() = 0; - //DOC-IGNORE-END - - // Summary: - // Gets the sun color - // Notes: - // Should have been specified in the editor. - // Return Value: - // An rgb value contained in a Vec3 object. - virtual Vec3 GetSunColor() const = 0; - - // Summary: - // Retrieves the current SSAO multiplier - // Notes: - // Return Value: - // scalar value - virtual float GetSSAOAmount() const = 0; - - // Summary: - // Retrieves the current SSAO contrast multiplier - // Notes: - // Return Value: - // scalar value - virtual float GetSSAOContrast() const = 0; - // Summary: - // Frees entity render info. - virtual void FreeRenderNodeState(IRenderNode* pEntity) = 0; - - // Summary: - // Adds the level's path to a specified filename. - // Arguments: - // szFileName - The filename for which we need to add the path - // Return Value: - // Full path for the filename; including the level path and the filename appended after. - virtual const char* GetLevelFilePath(const char* szFileName) = 0; - - // Summary: - // Displays statistic on the 3d Engine. - // Arguments: - // fTextPosX - X position for the text - // fTextPosY - Y position for the text - // fTextStepY - Amount of pixels to distance each line - // bEnhanced - false=normal, true=more interesting information - virtual void DisplayInfo(float& fTextPosX, float& fTextPosY, float& fTextStepY, bool bEnhanced) = 0; - - // Summary: - // Displays CPU and GPU memory usage statistics on screen - virtual void DisplayMemoryStatistics() = 0; - - // Summary: - // Draws text right aligned at the y pixel precision. - virtual void DrawTextRightAligned(const float x, const float y, const char* format, ...) PRINTF_PARAMS(4, 5) = 0; - virtual void DrawTextRightAligned(const float x, const float y, const float scale, const ColorF& color, const char* format, ...) PRINTF_PARAMS(6, 7) = 0; - - virtual void DrawBBoxHelper(const Vec3& vMin, const Vec3& vMax, ColorB col = Col_White) = 0; - virtual void DrawBBoxHelper(const AABB& box, ColorB col = Col_White) = 0; - - // Summary: - // Enables or disables portal at a specified position. - // Arguments: - // vPos - Position to place the portal - // bActivate - Set to true in order to enable the portal, or to false to disable - // szEntityName - - virtual void ActivatePortal(const Vec3& vPos, bool bActivate, const char* szEntityName) = 0; - - //DOC-IGNORE-BEGIN - // Summary: - // Counts memory usage - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; - - // Summary: - // Counts resource memory usage - // Arguments: - // cstAABB - Use the whole level AABB if you want to grab the resources - // from the whole level. For height level, use something BIG - // (ie: +-FLT_MAX) - virtual void GetResourceMemoryUsage(ICrySizer* pSizer, const AABB& cstAABB) = 0; - //DOC-IGNORE-END - - // Summary: - // Creates a new VisArea. - // Return Value: - // A pointer to a newly created VisArea object - virtual IVisArea* CreateVisArea(uint64 visGUID) = 0; - - // Summary: - // Deletes a VisArea. - // Arguments: - // pVisArea - A pointer to the VisArea to delete - virtual void DeleteVisArea(IVisArea* pVisArea) = 0; - - //mat: todo - - // Summary: - // Updates the VisArea - // Arguments: - // pArea - - // pPoints - - // nCount - - // szName - - // info - - // bReregisterObjects - - virtual void UpdateVisArea(IVisArea* pArea, const Vec3* pPoints, int nCount, const char* szName, const SVisAreaInfo& info, bool bReregisterObjects) = 0; - - // Summary: - // Determines if two VisAreas are connected. - // Description: - // Used to determine if a sound is potentially hearable between two VisAreas. - // Arguments: - // pArea1 - A pointer to a VisArea - // pArea2 - A pointer to a VisArea - // nMaxRecursion - Maximum number of recursions to be done - // bSkipDisabledPortals - Indicate if disabled portals should be skipped - // Return Value: - // A boolean value set to true if the two VisAreas are connected, else false will be returned. - virtual bool IsVisAreasConnected(IVisArea* pArea1, IVisArea* pArea2, int nMaxRecursion = 1, bool bSkipDisabledPortals = true) = 0; - - // Summary: - // Creates a ClipVolume. - // Return Value: - // A pointer to a newly created ClipVolume object - virtual IClipVolume* CreateClipVolume() = 0; - - // Summary: - // Deletes a ClipVolume. - // Arguments: - // pClipVolume - A pointer to the ClipVolume to delete - virtual void DeleteClipVolume(IClipVolume* pClipVolume) = 0; - - // Summary: - // Updates a ClipVolume - // Arguments: - // pClipVolume - Pointer to volume that needs updating - // pRenderMesh - Pointer to new render mesh - // worldTM - Updated world transform - // szName - Updated ClipVolume name - virtual void UpdateClipVolume(IClipVolume* pClipVolume, _smart_ptr pRenderMesh, IBSPTree3D* pBspTree, const Matrix34& worldTM, bool bActive, uint32 flags, const char* szName) = 0; - - //mat: todo - - // Summary: - // Creates instance of IRenderNode object with specified type. - virtual IRenderNode* CreateRenderNode(EERType type) = 0; - - // Summary: - // Delete RenderNode object. - virtual void DeleteRenderNode(IRenderNode* pRenderNode) = 0; - - - // Summary: - // Gets wind direction and force, averaged within a box. - virtual Vec3 GetWind(const AABB& box, bool bIndoors) const = 0; - - // Summary: - // Gets the global wind vector. - virtual Vec3 GetGlobalWind(bool bIndoors) const = 0; - - // Summary: - // Gets wind direction and forace at the sample points provided. - // Note: the positions defining the samples will be overwritten - // with the accumulated wind influences. - virtual bool SampleWind(Vec3* pSamples, int nSamples, const AABB& volume, bool bIndoors) const = 0; - - // Description: - // Gets the VisArea which is present at a specified point. - // Arguments: - // vPos: - // Return Value: - // VisArea containing point, if any. 0 otherwise. - virtual IVisArea* GetVisAreaFromPos(const Vec3& vPos) = 0; - - // Description: - // Tests for intersection against Vis Areas. - // Arguments: - // box: Volume to test for intersection. - // pNodeCache (out, optional): Set to a cached pointer, for quicker calls to ClipToVisAreas. - // Return Value: - // Whether box intersects any vis areas. - virtual bool IntersectsVisAreas(const AABB& box, void** pNodeCache = 0) = 0; - - // Description: - // Clips geometry against the boundaries of VisAreas. - // Arguments: - // pInside: Vis Area to clip inside of. If 0, clip outside all Vis Areas. - // sphere - - // vNormal - - // pNodeChache - - // Return Value: - // Whether it was clipped - virtual bool ClipToVisAreas(IVisArea* pInside, Sphere& sphere, Vec3 const& vNormal, void* pNodeCache = 0) = 0; - - // Summary: - // Enables or disables ocean rendering. - // Arguments: - // bOcean - Will enable or disable the rendering of ocean - virtual void EnableOceanRendering(bool bOcean) = 0; - - // Description: - // Register a texture load handler - virtual void AddTextureLoadHandler(ITextureLoadHandler* pHandler) = 0; - - // Description - // Unregister a texture load handler - virtual void RemoveTextureLoadHandler(ITextureLoadHandler* pHandler) = 0; - - // Description: - // Get a texture load handler for a given extension - virtual ITextureLoadHandler* GetTextureLoadHandlerForImage(const char* ext) = 0; - // Summary: - // Creates a new light source. - // Return Value: - // Pointer to newly created light or -1 if it fails. - virtual struct ILightSource* CreateLightSource() = 0; - - // Summary: - // Deletes a light. - // Arguments: - // Pointer to the light - virtual void DeleteLightSource(ILightSource* pLightSource) = 0; - - // Summary: - // Gives access to the list holding all static light sources - // Return Value: - // An array holding all the CDLight pointers. - virtual const PodArray* GetLightEntities() = 0; - - // Summary: - // Gives access to list holding all lighting volumes - // Return Value: - // An array holding all the SLightVolume pointers. - virtual void GetLightVolumes(threadID nThreadID, SLightVolume*& pLightVols, uint32& nNumVols) = 0; - - // Summary: - // Registers a volume for lighting - // Return Value: - // The index of the registered volume. - virtual uint16 RegisterVolumeForLighting(const Vec3& vPos, f32 fRadius, uint8 nClipVolumeRef, const SRenderingPassInfo& passInfo) = 0; - - // Summary: - // Reload the heightmap. - // Description: - // Reloading the heightmap will resets all decals and particles. - // Notes: - // In future will restore deleted vegetations - // Returns: - // success - virtual bool RestoreTerrainFromDisk(int nSID = 0) = 0; - - //DOC-IGNORE-BEGIN - // tmp - virtual const char* GetFilePath(const char* szFileName) { return GetLevelFilePath(szFileName); } - //DOC-IGNORE-END - - // Summary: - // Post processing effects interfaces. - virtual class IPostEffectGroupManager* GetPostEffectGroups() const = 0; - virtual class IPostEffectGroup* GetPostEffectBaseGroup() const = 0; - - // Most code should use either GetPostEffectGroups() or GetPostEffectBaseGroup() instead of these - virtual void SetPostEffectParam(const char* pParam, float fValue, bool bForceValue = false) const = 0; - virtual void SetPostEffectParamVec4(const char* pParam, const Vec4& pValue, bool bForceValue = false) const = 0; - virtual void SetPostEffectParamString(const char* pParam, const char* pszArg) const = 0; - - virtual void GetPostEffectParam(const char* pParam, float& fValue) const = 0; - virtual void GetPostEffectParamVec4(const char* pParam, Vec4& pValue) const = 0; - virtual void GetPostEffectParamString(const char* pParam, const char*& pszArg) const = 0; - - virtual int32 GetPostEffectID(const char* pPostEffectName) = 0; - - virtual void ResetPostEffects(bool bOnSpecChange = false) = 0; - //Disable post effect groups other than default and base. - virtual void DisablePostEffects() = 0; - - virtual void SetShadowsGSMCache(bool bCache) = 0; - virtual void SetCachedShadowBounds(const AABB& shadowBounds, float fAdditionalCascadesScale) = 0; - virtual void SetRecomputeCachedShadows(uint nUpdateStrategy = 0) = 0; - - // Summary: - // In debug mode check memory heap and makes assert, do nothing in release - virtual void CheckMemoryHeap() = 0; - - // Summary: - // Removes all decals attached to specified entity. - virtual void DeleteEntityDecals(IRenderNode* pEntity) = 0; - - // Summary: - // Disables CGFs unloading. - virtual void LockCGFResources() = 0; - - // Summary: - // Enables CGFs unloading (this is default state), this function will also release all not used CGF's. - virtual void UnlockCGFResources() = 0; - - // Summary: - // Release all unused CGFs. - virtual void FreeUnusedCGFResources() = 0; - - - // Summary: - // Creates static object containing empty IndexedMesh. - virtual IStatObj* CreateStatObj() = 0; - virtual IStatObj* CreateStatObjOptionalIndexedMesh(bool createIndexedMesh) = 0; - - // Summary: - // Creates the instance of the indexed mesh. - virtual IIndexedMesh* CreateIndexedMesh() = 0; - - // Summary: - // Saves/loads state of engine objects. - virtual void SerializeState(TSerialize ser) = 0; - - // Summary: - // Cleanups after save/load. - virtual void PostSerialize(bool bReading) = 0; - - // Description: - // Retrieve pointer to the material i/o interface. - virtual IMaterialHelpers& GetMaterialHelpers() = 0; - - // Description: - // Retrieve pointer to the material manager interface. - virtual IMaterialManager* GetMaterialManager() = 0; - - // Description: - // Retrieve pointer to the object manager interface. - virtual IObjManager* GetObjManager() = 0; - - ////////////////////////////////////////////////////////////////////////// - // CGF Loader. - ////////////////////////////////////////////////////////////////////////// - // Description: - // Creates a chunkfile content instance - // Returns 'NULL' if the memory for the instance could not be allocated - virtual CContentCGF* CreateChunkfileContent(const char* filename) = 0; - - // Description: - // Deletes the chunkfile content instance - virtual void ReleaseChunkfileContent(CContentCGF*) = 0; - - // Description: - // Loads the contents of a chunkfile into the given CContentCGF. - // Returns 'false' on error. - virtual bool LoadChunkFileContent(CContentCGF* pCGF, const char* filename, bool bNoWarningMode = false, bool bCopyChunkFile = true) = 0; - - // Description: - // Loads the contents of a chunkfile into the given CContentCGF. - // Returns 'false' on error. - virtual bool LoadChunkFileContentFromMem(CContentCGF* pCGF, const void* pData, size_t nDataLen, uint32 nLoadingFlags, bool bNoWarningMode = false, bool bCopyChunkFile = true) = 0; - - // Description: - // Creates ChunkFile. - virtual IChunkFile* CreateChunkFile(bool bReadOnly = false) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Chunk file writer. - ////////////////////////////////////////////////////////////////////////// - enum EChunkFileFormat - { - eChunkFileFormat_0x745, - eChunkFileFormat_0x746, - }; - virtual ChunkFile::IChunkFileWriter* CreateChunkFileWriter(EChunkFileFormat eFormat, AZ::IO::IArchive* pPak, const char* filename) const = 0; - virtual void ReleaseChunkFileWriter(ChunkFile::IChunkFileWriter* p) const = 0; - - // Description: - // Returns true if the ocean was created successfully. - virtual bool CreateOcean(_smart_ptr pTerrainWaterMat, float waterLevel) = 0; - - // Description: - // Deletes the ocean if it exists, otherwise does nothing. - virtual void DeleteOcean() = 0; - - // Description: - // Changes ocean material if the ocean exists. - virtual void ChangeOceanMaterial(_smart_ptr pMat) = 0; - - // Description: - // Changes ocean water level if the ocean exists. - virtual void ChangeOceanWaterLevel(float fWaterLevel) = 0; - - virtual void InitMaterialDefautMappingAxis(_smart_ptr pMat) = 0; - - // Description: - // Returns interface to visarea manager. - virtual IVisAreaManager* GetIVisAreaManager() = 0; - - // Description: - // Places camera into every visarea or every manually set pre-cache points and render the scenes. - virtual void PrecacheLevel(bool bPrecacheAllVisAreas, Vec3* pPrecachePoints, int nPrecachePointsNum) = 0; - - // Description: - // Proposes 3dengine to load on next frame all shaders and textures synchronously. - virtual void ProposeContentPrecache() = 0; - - - - // Description: - // Returns TOD interface. - virtual ITimeOfDay* GetTimeOfDay() = 0; - - // Description: - // Updates the sky material paths. LoadSkyMaterial will handle loading these materials. - virtual void SetSkyMaterialPath(const string& skyMaterialPath) = 0; - virtual void SetSkyLowSpecMaterialPath(const string& skyMaterialPath) = 0; - - // Description: - // Loads the sky material for the level. e_SkyType will determine if we load the low spec sky material or the regular sky material. - virtual void LoadSkyMaterial() = 0; - - // Description: - // Returns SkyBox material. - virtual _smart_ptr GetSkyMaterial() = 0; - - // Description: - // Sets SkyBox Material. - virtual void SetSkyMaterial(_smart_ptr pSkyMat) = 0; - - // Description: - // Sets global 3d engine parameter. - virtual void SetGlobalParameter(E3DEngineParameter param, const Vec3& v) = 0; - void SetGlobalParameter(E3DEngineParameter param, float val) { SetGlobalParameter(param, Vec3(val, 0, 0)); }; - - // Description: - // Retrieves global 3d engine parameter. - virtual void GetGlobalParameter(E3DEngineParameter param, Vec3& v) = 0; - float GetGlobalParameter(E3DEngineParameter param) { Vec3 v(0, 0, 0); GetGlobalParameter(param, v); return v.x; }; - - virtual void SetShadowMode(EShadowMode shadowMode) = 0; - virtual EShadowMode GetShadowMode() const = 0; - virtual void AddPerObjectShadow(IShadowCaster* pCaster, float fConstBias, float fSlopeBias, float fJitter, const Vec3& vBBoxScale, uint nTexSize) = 0; - virtual void RemovePerObjectShadow(IShadowCaster* pCaster) = 0; - virtual struct SPerObjectShadow* GetPerObjectShadow(IShadowCaster* pCaster) = 0; - virtual void GetCustomShadowMapFrustums(struct ShadowMapFrustum*& arrFrustums, int& nFrustumCount) = 0; - - // Description: - // Saves pStatObj to a stream. - // Notes: - // Full mesh for generated ones, path/geom otherwise - virtual int SaveStatObj(IStatObj* pStatObj, TSerialize ser) = 0; - // Description: - // Loads statobj from a stream - virtual IStatObj* LoadStatObj(TSerialize ser) = 0; - - // Description: - // Returns true if input line segment intersect clouds sprites. - virtual bool CheckIntersectClouds(const Vec3& p1, const Vec3& p2) = 0; - - // Description: - // Removes references to RenderMesh - virtual void OnRenderMeshDeleted(IRenderMesh* pRenderMesh) = 0; - - // Used to highlight an object under the reticule - virtual void DebugDraw_UpdateDebugNode() = 0; - - // Description: - // Used by editor during AO computations - virtual bool RayObjectsIntersection2D(Vec3 vStart, Vec3 vEnd, Vec3& vHitPoint, EERType eERType) = 0; - - - // Description: - // Used by editor during object alignment - virtual bool RenderMeshRayIntersection(IRenderMesh* pRenderMesh, SRayHitInfo& hitInfo, _smart_ptr pCustomMtl = 0) = 0; - - virtual void CheckCreateRNTmpData(CRNTmpData** ppInfo, IRenderNode* pRNode, const SRenderingPassInfo& passInfo) = 0; - - // Description: - // Frees lod transition state - virtual void FreeRNTmpData(CRNTmpData** ppInfo) = 0; - - // Description: - // Returns true if the Octree is ready. - virtual bool IsObjectTreeReady() = 0; - - virtual IOctreeNode* GetIObjectTree() = 0; - - // Description: - // Call function 2 times (first to get the size then to fill in the data) - // Arguments: - // pObjects - 0 if only the count is required - // Return Value: - // Count returned - virtual uint32 GetObjectsByType(EERType objType, IRenderNode** pObjects = 0) = 0; - virtual uint32 GetObjectsByTypeInBox(EERType objType, const AABB& bbox, IRenderNode** pObjects = 0, ObjectTreeQueryFilterCallback filterCallback = nullptr) = 0; - virtual uint32 GetObjectsInBox(const AABB& bbox, IRenderNode** pObjects = 0) = 0; - virtual uint32 GetObjectsByFlags(uint dwFlag, IRenderNode** pObjects = 0) = 0; - - // variant which takes a POD array which is resized in the function itself - virtual void GetObjectsByTypeInBox(EERType objType, const AABB& bbox, PodArray* pLstObjects, ObjectTreeQueryFilterCallback filterCallback = nullptr) = 0; - - // Called from editor whenever an object is modified by the user - virtual void OnObjectModified(IRenderNode* pRenderNode, uint dwFlags) = 0; - - virtual void FillDebugFPSInfo(SDebugFPSInfo&) = 0; - - virtual const char* GetLevelFolder() = 0; - - virtual bool IsAreaActivationInUse() = 0; - - virtual void RenderRenderNode_ShadowPass(IShadowCaster* pRNode, const SRenderingPassInfo& passInfo, AZ::LegacyJobExecutor* pJobExecutor) = 0; - - virtual IOpticsManager* GetOpticsManager() = 0; - - // Description: - // Syncs and performs outstanding operations for the Asyncrhon ProcessStreaming Update - virtual void SyncProcessStreamingUpdate() = 0; - - // Set Callback for Editor to store additional information in Minimap tool - virtual void SetScreenshotCallback(IScreenshotCallback* pCallback) = 0; - - // Show/Hide objects by layer (useful for streaming and performance) - virtual void ActivateObjectsLayer(uint16 nLayerId, bool bActivate, bool bPhys, bool bObjects, bool bStaticLights, const char* pLayerName, IGeneralMemoryHeap* pHeap = NULL, bool bCheckLayerActivation = true) = 0; - - // Get object layer memory usage - virtual void GetLayerMemoryUsage(uint16 nLayerId, ICrySizer* pSizer, int* pNumBrushes, int* pNumDecals) const = 0; - - // Collect layer ID's to skip loading objects from these layers, e.g. to skip console specific layers - virtual void SkipLayerLoading(uint16 nLayerId, bool bClearList) = 0; - - // Activate streaming of render node and all sub-components - virtual void PrecacheRenderNode(IRenderNode* pObj, float fEntDistanceReal) = 0; - - virtual IDeferredPhysicsEventManager* GetDeferredPhysicsEventManager() = 0; - - virtual void SetStreamableListener(IStreamedObjectListener* pListener) = 0; - - // following functions are used by SRenderingPassInfo - virtual CCamera* GetRenderingPassCamera(const CCamera& rCamera) = 0; - - struct SSvoStaticTexInfo - { - SSvoStaticTexInfo() - { - ZeroStruct(*this); - } - - // SVO data pools - ITexture* pTexTree; - ITexture* pTexOpac; - ITexture* pTexRgb0; - ITexture* pTexRgb1; - ITexture* pTexDynl; - ITexture* pTexRgb2; - ITexture* pTexRgb3; - ITexture* pTexNorm; - ITexture* pTexAldi; - - ITexture* pGlobalSpecCM; - - float fGlobalSpecCM_Mult; - int nTexDimXY; - int nTexDimZ; - int nBrickSize; - bool bSvoReady; - bool bSvoFreeze; - }; - - struct SLightTI - { - Vec4 vPosR; - Vec4 vDirF; - Vec4 vCol; - float fSortVal; - class ITexture* pCM; - }; - - virtual void GetSvoStaticTextures(I3DEngine::SSvoStaticTexInfo& svoInfo, PodArray* pLightsTI_S, PodArray* pLightsTI_D) = 0; - - struct SSvoNodeInfo - { - AABB wsBox; - AABB tcBox; - int nAtlasOffset; - }; - - virtual void GetSvoBricksForUpdate(PodArray& arrNodeInfo, bool getDynamic) = 0; - -#if defined(USE_GEOM_CACHES) - // Summary: - // Loads a geometry cache from a CAX file. - // See Also: - // IGeomCache - // Arguments: - // szFileName - CAX Filename - should not be 0 or "" - // Return Value: - // A pointer to an object derived from IGeomCache. - virtual IGeomCache* LoadGeomCache(const char* szFileName) = 0; - - // Finds a geom cache created from the given filename - // See Also: - // IGeomCache - // Arguments: - // szFileName - CAX Filename - should not be 0 or "" - // Return Value: - // A pointer to an object derived from IGeomCache. - virtual IGeomCache* FindGeomCacheByFilename(const char* szFileName) = 0; -#endif - - // Summary: - // Loads a designer object from a stream of _decoded_ binary node. (Base64Decode) - // Arguments: - // szBinaryStream - decoded stream + size - virtual IStatObj* LoadDesignerObject(int nVersion, const char* szBinaryStream, int size) = 0; - - // Summary: - // Makes sure all queued culling jobs are completely finished. - // This is useful when adding or removing Components that trigger AZ::Job creation - // like the terrain system. It is important to complete those jobs before removing - // such type of components. - virtual void WaitForCullingJobsCompletion() = 0; - - // -}; - -#pragma pack(pop) - -#include - -// state of 3dengine during rendering -// used to prevent global state -struct SRenderingPassInfo -{ - enum EShadowMapType - { - SHADOW_MAP_NONE = 0, - SHADOW_MAP_GSM, - SHADOW_MAP_LOCAL, - SHADOW_MAP_CACHED, - SHADOW_MAP_CACHED_MGPU_COPY - }; - - // enum flags to identify which objects to skip for this pass - enum ESkipRenderingFlags - { - SHADOWS = BIT(0), - ENTITIES = BIT(3), - WATEROCEAN = BIT(5), - DECALS = BIT(7), - MERGED_MESHES = BIT(10), - ROADS = BIT(13), - WATER_VOLUMES = BIT(14), - CLOUDS = BIT(15), - CUBEMAP_GEN = BIT(16), - GEOM_CACHES = BIT(17), - DISABLE_RENDER_CHUNK_MERGE = BIT(18), - - // below are precombined flags - STATIC_OBJECTS = ENTITIES, - DEFAULT_FLAGS = SHADOWS | ENTITIES | WATEROCEAN | DECALS | MERGED_MESHES | ROADS | WATER_VOLUMES | CLOUDS | GEOM_CACHES, - DEFAULT_RECURSIVE_FLAGS = ENTITIES | WATEROCEAN | DECALS | MERGED_MESHES | ROADS | WATER_VOLUMES | CLOUDS | GEOM_CACHES - }; - - // creating function for RenderingPassInfo, the create functions will fetch all other necessary - // information like thread id/frame id, etc - static SRenderingPassInfo CreateGeneralPassRenderingInfo(const CCamera& rCamera, uint32 nRenderingFlags = DEFAULT_FLAGS, bool bAuxWindow = false); - static SRenderingPassInfo CreateRecursivePassRenderingInfo(const CCamera& rCamera, uint32 nRenderingFlags = DEFAULT_RECURSIVE_FLAGS); - static SRenderingPassInfo CreateShadowPassRenderingInfo(const CCamera& rCamera, int nLightFlags, int nShadowMapLod, bool bExtendedLod, bool bIsMGPUCopy, uint32* pShadowGenMask, uint32 nSide, uint32 nShadowFrustumID, uint32 nRenderingFlags = DEFAULT_FLAGS); - static SRenderingPassInfo CreateTempRenderingInfo(const CCamera& rCamera, const SRenderingPassInfo& rPassInfo); - static SRenderingPassInfo CreateTempRenderingInfo(uint32 nRenderingFlags, const SRenderingPassInfo& rPassInfo); - - // state getter - bool IsGeneralPass() const; - - bool IsRecursivePass() const; - uint32 GetRecursiveLevel() const; - - bool IsShadowPass() const; - bool IsCachedShadowPass() const; - EShadowMapType GetShadowMapType() const; - bool IsDisableRenderChunkMerge() const; - - bool IsAuxWindow() const; - - threadID ThreadID() const; - void SetThreadID(threadID id) { m_nThreadID = static_cast(id); } - - int GetFrameID() const; - uint32 GetMainFrameID() const; - - const CCamera& GetCamera() const; - bool IsCameraUnderWater() const; - - float GetZoomFactor() const; - float GetInverseZoomFactor() const; - bool RenderShadows() const; - bool RenderEntities() const; - bool RenderWaterOcean() const; - bool RenderDecals() const; - bool RenderWaterVolumes() const; - bool RenderClouds() const; - bool RenderGeomCaches() const; - - bool IsRenderingCubemap() const; - - uint32* ShadowGenMaskAddress() const; - uint32 ShadowFrustumID() const; - uint8 ShadowFrustumSide() const; - uint8 ShadowFrustumLod() const; - - CRenderView* GetRenderView() const; - - SRenderingPassInfo(threadID id) - { - SRenderingPassInfo(); - SetThreadID(id); - m_pRenderView = gEnv->pRenderer->GetRenderViewForThread(id); - } - -private: - - // private constructor, creation is only allowed with create functions - SRenderingPassInfo() - : pShadowGenMask(NULL) - , nShadowSide(0) - , nShadowLod(0) - , nShadowFrustumId(0) - , m_bAuxWindow(0) - , m_nRenderStackLevel(0) - , m_eShadowMapRendering(static_cast(SHADOW_MAP_NONE)) - , m_bCameraUnderWater(0) - , m_nRenderingFlags(0) - , m_fZoomFactor(0.0f) - , m_pCamera(NULL) - { - threadID nThreadID = 0; - gEnv->pRenderer->EF_Query(EFQ_MainThreadList, nThreadID); - m_nThreadID = aznumeric_caster(nThreadID); - m_nRenderFrameID = gEnv->pRenderer->GetFrameID(); - m_nRenderMainFrameID = gEnv->pRenderer->GetFrameID(false); - m_pRenderView = gEnv->pRenderer->GetRenderViewForThread(m_nThreadID); - } - - void InitRenderingFlags(uint32 nRenderingFlags); - void SetCamera(const CCamera& cam); - - uint8 m_nThreadID; - uint8 m_nRenderStackLevel; - uint8 m_eShadowMapRendering; // State flag denoting what type of shadow map is being currently rendered into - uint8 m_bCameraUnderWater; - - uint32 m_nRenderingFlags; - - float m_fZoomFactor; - - int m_nRenderFrameID; - uint32 m_nRenderMainFrameID; - - const CCamera* m_pCamera; - - // Render view used for this rendering pass - CRenderView* m_pRenderView; - - // members used only in shadow pass - uint32* pShadowGenMask; - uint32 nShadowFrustumId; - uint8 nShadowSide : 4; - uint8 nShadowLod : 4; - uint8 m_bAuxWindow; -}; - -/////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsGeneralPass() const -{ - return m_nRenderStackLevel == 0 && m_bAuxWindow == 0 && static_cast(m_eShadowMapRendering) == SHADOW_MAP_NONE; -} - -/////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsRecursivePass() const -{ - return m_nRenderStackLevel > 0; -} - -/////////////////////////////////////////////////////////////////////////////// -inline uint32 SRenderingPassInfo::GetRecursiveLevel() const -{ - return m_nRenderStackLevel; -} - -/////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsShadowPass() const -{ - return static_cast(m_eShadowMapRendering) != SHADOW_MAP_NONE; -} - -/////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsCachedShadowPass() const -{ - return IsShadowPass() && - (GetShadowMapType() == SRenderingPassInfo::SHADOW_MAP_CACHED || - GetShadowMapType() == SRenderingPassInfo::SHADOW_MAP_CACHED_MGPU_COPY); -} -/////////////////////////////////////////////////////////////////////////////// -inline SRenderingPassInfo::EShadowMapType SRenderingPassInfo::GetShadowMapType() const -{ - assert(IsShadowPass()); - return static_cast(m_eShadowMapRendering); -} - -/////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsAuxWindow() const -{ - return m_bAuxWindow != 0; -} - -/////////////////////////////////////////////////////////////////////////////// -inline threadID SRenderingPassInfo::ThreadID() const -{ - return m_nThreadID; -} - -/////////////////////////////////////////////////////////////////////////////// -inline int SRenderingPassInfo::GetFrameID() const -{ - return m_nRenderFrameID; -} - -/////////////////////////////////////////////////////////////////////////////// -inline uint32 SRenderingPassInfo::GetMainFrameID() const -{ - return m_nRenderMainFrameID; -} - -/////////////////////////////////////////////////////////////////////////////// -inline const CCamera& SRenderingPassInfo::GetCamera() const -{ - assert(m_pCamera != NULL); - return *m_pCamera; -} - -/////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsCameraUnderWater() const -{ - return m_bCameraUnderWater != 0; -} - -/////////////////////////////////////////////////////////////////////////////// -inline float SRenderingPassInfo::GetZoomFactor() const -{ - return m_fZoomFactor; -} - -/////////////////////////////////////////////////////////////////////////////// -inline float SRenderingPassInfo::GetInverseZoomFactor() const -{ - return 1.0f / m_fZoomFactor; -} - - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderShadows() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::SHADOWS) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderEntities() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::ENTITIES) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderWaterOcean() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::WATEROCEAN) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderDecals() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::DECALS) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderWaterVolumes() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::WATER_VOLUMES) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderClouds() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::CLOUDS) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::RenderGeomCaches() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::GEOM_CACHES) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsRenderingCubemap() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::CUBEMAP_GEN) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline bool SRenderingPassInfo::IsDisableRenderChunkMerge() const -{ - return (m_nRenderingFlags& SRenderingPassInfo::DISABLE_RENDER_CHUNK_MERGE) != 0; -} - -//////////////////////////////////////////////////////////////////////////////// -inline uint32* SRenderingPassInfo::ShadowGenMaskAddress() const -{ - assert(pShadowGenMask); - return pShadowGenMask; -} - -//////////////////////////////////////////////////////////////////////////////// -inline uint32 SRenderingPassInfo::ShadowFrustumID() const -{ - return nShadowFrustumId; -} - -//////////////////////////////////////////////////////////////////////////////// -inline uint8 SRenderingPassInfo::ShadowFrustumSide() const -{ - return nShadowSide; -} - -//////////////////////////////////////////////////////////////////////////////// -inline uint8 SRenderingPassInfo::ShadowFrustumLod() const -{ - return nShadowLod; -} -//////////////////////////////////////////////////////////////////////////////// -inline CRenderView* SRenderingPassInfo::GetRenderView() const -{ - return m_pRenderView; -} -//////////////////////////////////////////////////////////////////////////////// -inline void SRenderingPassInfo::SetCamera(const CCamera& cam) -{ - m_pCamera = gEnv->p3DEngine->GetRenderingPassCamera(cam); - m_bCameraUnderWater = gEnv->p3DEngine->IsUnderWater(cam.GetPosition()); - m_fZoomFactor = 0.2f + 0.8f * (RAD2DEG(cam.GetFov()) / 60.f); -} - -//////////////////////////////////////////////////////////////////////////////// -inline void SRenderingPassInfo::InitRenderingFlags(uint32 nRenderingFlags) -{ - m_nRenderingFlags = nRenderingFlags; -#if (ALLOW_CONST_CVAR_MODIFICATIONS) - static ICVar* pDefaultMaterial = gEnv->pConsole->GetCVar("e_DefaultMaterial"); - static ICVar* pShadows = gEnv->pConsole->GetCVar("e_Shadows"); - static ICVar* pEntities = gEnv->pConsole->GetCVar("e_Entities"); - static ICVar* pWaterOcean = gEnv->pConsole->GetCVar("e_WaterOcean"); - static ICVar* pDecals = gEnv->pConsole->GetCVar("e_Decals"); - static ICVar* pWaterVolumes = gEnv->pConsole->GetCVar("e_WaterVolumes"); - static ICVar* pClouds = gEnv->pConsole->GetCVar("e_Clouds"); - static ICVar* pGeomCaches = gEnv->pConsole->GetCVar("e_GeomCaches"); - - if (pShadows->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::SHADOWS; - } - if (pEntities->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::ENTITIES; - } - if (pWaterOcean->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::WATEROCEAN; - } - if (pDecals->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::DECALS; - } - if (pWaterVolumes->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::WATER_VOLUMES; - } - if (pClouds->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::CLOUDS; - } - if (pGeomCaches->GetIVal() == 0) - { - m_nRenderingFlags &= ~SRenderingPassInfo::GEOM_CACHES; - } - - // on dedicated server, never render any object at all - if (gEnv->IsDedicated()) - { - m_nRenderingFlags = 0; - } -#endif // (ALLOW_CONST_CVAR_MODIFICATIONS) -} - -//////////////////////////////////////////////////////////////////////////////// -inline SRenderingPassInfo SRenderingPassInfo::CreateGeneralPassRenderingInfo(const CCamera& rCamera, uint32 nRenderingFlags, bool bAuxWindow) -{ - static ICVar* pCameraFreeze = gEnv->pConsole->GetCVar("e_CameraFreeze"); - - // Update Camera only if e_camerafreeze is not set - const CCamera& rCameraToSet = (pCameraFreeze && pCameraFreeze->GetIVal() != 0) ? gEnv->p3DEngine->GetRenderingCamera() : rCamera; - - SRenderingPassInfo passInfo; - passInfo.SetCamera(rCameraToSet); - passInfo.InitRenderingFlags(nRenderingFlags); - passInfo.m_bAuxWindow = bAuxWindow; - - return passInfo; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRenderingPassInfo SRenderingPassInfo::CreateRecursivePassRenderingInfo(const CCamera& rCamera, uint32 nRenderingFlags) -{ - static ICVar* pRecursionViewDistRatio = gEnv->pConsole->GetCVar("e_RecursionViewDistRatio"); - - SRenderingPassInfo passInfo; - passInfo.m_nRenderStackLevel = 1; - passInfo.SetCamera(rCamera); - - // adjust view distance in recursive mode by adjusting the ZoomFactor - passInfo.m_fZoomFactor /= pRecursionViewDistRatio->GetFVal(); - - passInfo.InitRenderingFlags(nRenderingFlags); - - return passInfo; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRenderingPassInfo SRenderingPassInfo::CreateShadowPassRenderingInfo(const CCamera& rCamera, int nLightFlags, int nShadowMapLod, bool bExtendedLod, bool bIsMGPUCopy, uint32* pShadowGenMask, uint32 nSide, uint32 nShadowFrustumID, uint32 nRenderingFlags) -{ - SRenderingPassInfo passInfo; - passInfo.SetCamera(rCamera); - passInfo.InitRenderingFlags(nRenderingFlags); - - // set correct shadow map type - if (nLightFlags & DLF_SUN) - { - assert(nShadowMapLod >= 0 && nShadowMapLod < 8); - if (bExtendedLod) - { - passInfo.m_eShadowMapRendering = bIsMGPUCopy ? static_cast(SHADOW_MAP_CACHED_MGPU_COPY) : static_cast(SHADOW_MAP_CACHED); - } - else - { - passInfo.m_eShadowMapRendering = static_cast(SHADOW_MAP_GSM); - } - } - else if (nLightFlags & (DLF_POINT | DLF_PROJECT | DLF_AREA_LIGHT)) - { - passInfo.m_eShadowMapRendering = static_cast(SHADOW_MAP_LOCAL); - } - else - { - passInfo.m_eShadowMapRendering = static_cast(SHADOW_MAP_NONE); - } - - passInfo.pShadowGenMask = pShadowGenMask; - passInfo.nShadowSide = nSide; - passInfo.nShadowLod = nShadowMapLod; - passInfo.nShadowFrustumId = nShadowFrustumID; - - return passInfo; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRenderingPassInfo SRenderingPassInfo::CreateTempRenderingInfo(const CCamera& rCamera, const SRenderingPassInfo& rPassInfo) -{ - SRenderingPassInfo passInfo = rPassInfo; - passInfo.SetCamera(rCamera); - - passInfo.pShadowGenMask = NULL; - passInfo.nShadowSide = 0; - passInfo.nShadowFrustumId = 0; - - return passInfo; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRenderingPassInfo SRenderingPassInfo::CreateTempRenderingInfo(uint32 nRenderingFlags, const SRenderingPassInfo& rPassInfo) -{ - SRenderingPassInfo passInfo = rPassInfo; - passInfo.m_nRenderingFlags = nRenderingFlags; - return passInfo; -} - -/////////////////////////////////////////////////////////////////////////////// -// class to wrap a special counter used to presort SRendItems -// this is used to fix random ordering introduced by parallelization -// of parts of the 3DEngine -struct SRendItemSorter -{ - // Deferred PreProcess needs a special ordering, use these to prefix the values - // to ensure the deferred shading pass is after all LPV objects - enum EDeferredPreprocess - { - eLPVPass = 0, - eDeferredShadingPass = BIT(30) - }; - - static SRendItemSorter CreateRendItemSorter(const SRenderingPassInfo& passInfo); - static SRendItemSorter CreateShadowPassRendItemSorter(const SRenderingPassInfo& passInfo); - static SRendItemSorter CreateParticleRendItemSorter(const SRenderingPassInfo& passInfo); - static SRendItemSorter CreateDeferredPreProcessRendItemSorter(const SRenderingPassInfo& passInfo, EDeferredPreprocess deferredPrerocessType); - static SRendItemSorter CreateDefaultRendItemSorter(); - - void IncreaseOctreeCounter() { nValue += eOctreeNodeCounter; } - void IncreaseObjectCounter() { nValue += eObjectCounter; } - void IncreaseGroupCounter() { nValue += eGroupCounter; } - - void IncreaseParticleCounter() { nValue += eParticleCounter; } - uint32 ParticleCounter() const { return nValue & ~eRecursivePassMask; } - - uint32 ShadowFrustumID() const { return nValue & ~eRecursivePassMask; } - - uint32 GetValue() const { return nValue; } - - bool operator<(const SRendItemSorter& rOther) const - { - return nValue < rOther.nValue; - } - - bool IsRecursivePass() const { return (nValue & eRecursivePassMask) != 0; } - - SRendItemSorter() - : nValue(0) {} - explicit SRendItemSorter(uint32 _nValue) - : nValue(_nValue) {} - -private: - // encode various counter in a single value - enum - { - eRecursivePassMask = BIT(31) - }; // present in all combinations - - // flags used for regular SRendItems - enum - { - eObjectCounter = BIT(0) - }; // bits 0-14 used - enum - { - eOctreeNodeCounter = BIT(14) - }; // bits 15-27 used - enum - { - eGroupCounter = BIT(27) - }; // bits 28-31 used - - // flags used for Particles - enum - { - eParticleCounter = BIT(0) - }; - - uint32 nValue; -}; - -/////////////////////////////////////////////////////////////////////////////// -inline SRendItemSorter SRendItemSorter::CreateRendItemSorter(const SRenderingPassInfo& passInfo) -{ - SRendItemSorter rendItemSorter; - rendItemSorter.nValue = 0; - rendItemSorter.nValue |= passInfo.IsRecursivePass() ? eRecursivePassMask : 0; - return rendItemSorter; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRendItemSorter SRendItemSorter::CreateShadowPassRendItemSorter(const SRenderingPassInfo& passInfo) -{ - SRendItemSorter rendItemSorter; - rendItemSorter.nValue = passInfo.ShadowFrustumID(); - rendItemSorter.nValue |= passInfo.IsRecursivePass() ? eRecursivePassMask : 0; - return rendItemSorter; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRendItemSorter SRendItemSorter::CreateParticleRendItemSorter(const SRenderingPassInfo& passInfo) -{ - SRendItemSorter rendItemSorter; - rendItemSorter.nValue = 0; - rendItemSorter.nValue |= passInfo.IsRecursivePass() ? eRecursivePassMask : 0; - return rendItemSorter; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRendItemSorter SRendItemSorter::CreateDeferredPreProcessRendItemSorter(const SRenderingPassInfo& passInfo, EDeferredPreprocess deferredPrerocessType) -{ - SRendItemSorter rendItemSorter; - rendItemSorter.nValue = 0; - rendItemSorter.nValue |= passInfo.IsRecursivePass() ? eRecursivePassMask : 0; - rendItemSorter.nValue |= deferredPrerocessType; - return rendItemSorter; -} - -/////////////////////////////////////////////////////////////////////////////// -inline SRendItemSorter SRendItemSorter::CreateDefaultRendItemSorter() -{ - SRendItemSorter rendItemSorter; - rendItemSorter.nValue = 0; - return rendItemSorter; -} - -//Legacy Bus for communicating with SVOGI from the legacy engine code. -class SVOGILegacyRequests - : public AZ::EBusTraits -{ -public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - using MutexType = AZStd::recursive_mutex; -// static const bool LocklessDispatch = true; - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Triggers an update of voxel data. - virtual void UpdateVoxelData() = 0; - - ////////////////////////////////////////////////////////////////////////// - // Triggers an update of voxel data to GPU. - virtual void UpdateRenderData() = 0; - - ////////////////////////////////////////////////////////////////////////// - // Called at framestart - virtual void OnFrameStart(const SRenderingPassInfo& passInfo) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Gets the textures bound for GI plus lighting data. - virtual void GetSvoStaticTextures(I3DEngine::SSvoStaticTexInfo& svoInfo, PodArray* pLightsTI_S, PodArray* pLightsTI_D) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Generates a list of bricks that need to be updated in compute shaders. - virtual void GetSvoBricksForUpdate(PodArray& arrNodeInfo, bool getDynamic) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Causes the GI system to free all voxel data. - virtual void ReleaseData() = 0; - - ////////////////////////////////////////////////////////////////////////// - // Register and unregister a mutex to protect assets during rendering. - virtual void RegisterMutex(AZStd::mutex* mutex) = 0; - virtual void UnregisterMutex() = 0; - -}; -using SVOGILegacyRequestBus = AZ::EBus; - - -#endif // CRYINCLUDE_CRYCOMMON_I3DENGINE_H - diff --git a/Code/CryEngine/CryCommon/I3DEngine_info.h b/Code/CryEngine/CryCommon/I3DEngine_info.h deleted file mode 100644 index f1c601fcc6..0000000000 --- a/Code/CryEngine/CryCommon/I3DEngine_info.h +++ /dev/null @@ -1,53 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_CRYCOMMON_I3DENGINE_INFO_H -#define CRYINCLUDE_CRYCOMMON_I3DENGINE_INFO_H -#pragma once - -#include "TypeInfo_impl.h" -#include "IShader_info.h" -#include // <> required for Interfuscator - -STRUCT_INFO_BEGIN(SVisAreaManChunkHeader) -STRUCT_VAR_INFO(nVersion, TYPE_INFO(int8)) -STRUCT_VAR_INFO(nDummy, TYPE_INFO(int8)) -STRUCT_VAR_INFO(nFlags, TYPE_INFO(int8)) -STRUCT_VAR_INFO(nFlags2, TYPE_INFO(int8)) -STRUCT_VAR_INFO(nChunkSize, TYPE_INFO(int)) -STRUCT_VAR_INFO(nVisAreasNum, TYPE_INFO(int)) -STRUCT_VAR_INFO(nPortalsNum, TYPE_INFO(int)) -STRUCT_VAR_INFO(nOcclAreasNum, TYPE_INFO(int)) -STRUCT_INFO_END(SVisAreaManChunkHeader) - -STRUCT_INFO_BEGIN(SOcTreeNodeChunk) -STRUCT_VAR_INFO(nChunkVersion, TYPE_INFO(int16)) -STRUCT_VAR_INFO(ucChildsMask, TYPE_INFO(int16)) -STRUCT_VAR_INFO(nodeBox, TYPE_INFO(AABB)) -STRUCT_VAR_INFO(nObjectsBlockSize, TYPE_INFO(int32)) -STRUCT_INFO_END(SOcTreeNodeChunk) - -STRUCT_INFO_BEGIN(SHotUpdateInfo) -STRUCT_VAR_INFO(nHeigtmap, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(nObjTypeMask, TYPE_INFO(uint32)) -STRUCT_VAR_INFO(areaBox, TYPE_INFO(AABB)) -STRUCT_INFO_END(SHotUpdateInfo) - -STRUCT_INFO_BEGIN(SCommonFileHeader) -STRUCT_VAR_INFO(signature, TYPE_ARRAY(4, TYPE_INFO(char))) -STRUCT_VAR_INFO(file_type, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(flags, TYPE_INFO(uint8)) -STRUCT_VAR_INFO(version, TYPE_INFO(uint16)) -STRUCT_INFO_END(SCommonFileHeader) - -#endif // CRYINCLUDE_CRYCOMMON_I3DENGINE_INFO_H diff --git a/Code/CryEngine/CryCommon/IEntityRenderState.h b/Code/CryEngine/CryCommon/IEntityRenderState.h index 92ff354eff..29b1bdc463 100644 --- a/Code/CryEngine/CryCommon/IEntityRenderState.h +++ b/Code/CryEngine/CryCommon/IEntityRenderState.h @@ -286,7 +286,6 @@ struct IRenderNode // Physicalizes node. virtual void Physicalize([[maybe_unused]] bool bInstant = false) {} - // Make sure I3DEngine::FreeRenderNodeState(this) is called in destructor of derived class. virtual ~IRenderNode() { assert(!m_pRNTmpData); }; // Summary: diff --git a/Code/CryEngine/CryCommon/ILocalMemoryUsage.h b/Code/CryEngine/CryCommon/ILocalMemoryUsage.h deleted file mode 100644 index fd1e7e3693..0000000000 --- a/Code/CryEngine/CryCommon/ILocalMemoryUsage.h +++ /dev/null @@ -1,33 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Interface for LocalMemoryUsage - - -#ifndef CRYINCLUDE_CRYCOMMON_ILOCALMEMORYUSAGE_H -#define CRYINCLUDE_CRYCOMMON_ILOCALMEMORYUSAGE_H -#pragma once - - -class CCamera; -struct IRenderer; - -struct ILocalMemoryUsage -{ - virtual ~ILocalMemoryUsage(){} - virtual void OnRender(IRenderer* pRenderer, const CCamera* camera) = 0; - virtual void OnUpdate() = 0; - virtual void DeleteGlobalData() = 0; -}; - -#endif // CRYINCLUDE_CRYCOMMON_ILOCALMEMORYUSAGE_H diff --git a/Code/CryEngine/CryCommon/IMaterial.h b/Code/CryEngine/CryCommon/IMaterial.h index 81d612397f..020ddcc871 100644 --- a/Code/CryEngine/CryCommon/IMaterial.h +++ b/Code/CryEngine/CryCommon/IMaterial.h @@ -273,7 +273,7 @@ struct IMaterial ////////////////////////////////////////////////////////////////////////// // material name ////////////////////////////////////////////////////////////////////////// - //! Set material name, (Do not use this directly, to change material name use I3DEngine::RenameMatInfo method). + //! Set material name, (Do not use this directly virtual void SetName(const char* pName) = 0; //! Returns material name. virtual const char* GetName() const = 0; @@ -404,7 +404,6 @@ struct IMaterial ////////////////////////////////////////////////////////////////////////// // Makes this specific material enter sketch mode. - // Se also: I3DEngine::LoadCGF, in I3DEngine.h. // Current supported sketch modes: // - 0, no sketch. // - 1, normal sketch mode. diff --git a/Code/CryEngine/CryCommon/IMovieSystem.h b/Code/CryEngine/CryCommon/IMovieSystem.h index c22394e1b3..ce4e59d43c 100644 --- a/Code/CryEngine/CryCommon/IMovieSystem.h +++ b/Code/CryEngine/CryCommon/IMovieSystem.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/Code/CryEngine/CryCommon/IObjManager.h b/Code/CryEngine/CryCommon/IObjManager.h index acbd5c5d18..a63a252976 100644 --- a/Code/CryEngine/CryCommon/IObjManager.h +++ b/Code/CryEngine/CryCommon/IObjManager.h @@ -202,7 +202,6 @@ struct IObjManager // time counters virtual bool IsAfterWater(const Vec3& vPos, const SRenderingPassInfo& passInfo) = 0; - virtual void GetObjectsStreamingStatus(I3DEngine::SObjectsStreamingStatus& outStatus) = 0; virtual void FreeNotUsedCGFs() = 0; virtual void MakeUnitCube() = 0; diff --git a/Code/CryEngine/CryCommon/ISystem.h b/Code/CryEngine/CryCommon/ISystem.h index 9b1e817602..96d9a6ad10 100644 --- a/Code/CryEngine/CryCommon/ISystem.h +++ b/Code/CryEngine/CryCommon/ISystem.h @@ -66,7 +66,6 @@ struct IConsole; struct IRemoteConsole; struct IRenderer; struct IProcess; -struct I3DEngine; struct ITimer; struct ICryFont; struct IMovieSystem; @@ -123,8 +122,6 @@ namespace Serialization { struct IArchiveHost; } -struct ILocalMemoryUsage; - typedef void* WIN_HWND; class CCamera; @@ -793,7 +790,6 @@ struct SSystemUpdateStats // ISystem struct SSystemGlobalEnvironment { - I3DEngine* p3DEngine; AZ::IO::IArchive* pCryPak; AZ::IO::FileIOBase* pFileIO; IFileChangeMonitor* pFileChangeMonitor; @@ -801,7 +797,6 @@ struct SSystemGlobalEnvironment IOpticsManager* pOpticsManager; ITimer* pTimer; ICryFont* pCryFont; - ILocalMemoryUsage* pLocalMemoryUsage; ::IConsole* pConsole; ISystem* pSystem = nullptr; ILog* pLog; @@ -1113,25 +1108,9 @@ struct ISystem virtual void DoWorkDuringOcclusionChecks() = 0; virtual bool NeedDoWorkDuringOcclusionChecks() = 0; - // Summary: - // Renders subsystems. - virtual void Render() = 0; - // Summary: - // Begins rendering frame. - virtual void RenderBegin() = 0; - // Summary: - // Ends rendering frame and swap back buffer. - virtual void RenderEnd(bool bRenderStats = true, bool bMainWindow = true) = 0; - //! Update screen and call some important tick functions during loading. virtual void SynchronousLoadingTick(const char* pFunc, int line) = 0; - // Description: - // Renders the statistics; this is called from RenderEnd, but if the - // Host application (Editor) doesn't employ the Render cycle in ISystem, - // it may call this method to render the essential statistics. - virtual void RenderStatistics() = 0; - // Summary: // Returns the current used memory. virtual uint32 GetUsedMemory() = 0; @@ -1229,7 +1208,6 @@ struct ISystem virtual ICryFont* GetICryFont() = 0; virtual IMemoryManager* GetIMemoryManager() = 0; virtual IMovieSystem* GetIMovieSystem() = 0; - virtual I3DEngine* GetI3DEngine() = 0; virtual ::IConsole* GetIConsole() = 0; virtual IRemoteConsole* GetIRemoteConsole() = 0; // Returns: diff --git a/Code/CryEngine/CryCommon/ITimeOfDay.h b/Code/CryEngine/CryCommon/ITimeOfDay.h deleted file mode 100644 index b491ea9359..0000000000 --- a/Code/CryEngine/CryCommon/ITimeOfDay.h +++ /dev/null @@ -1,286 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. -#pragma once - -struct SBezierKey; -struct ITimeOfDayUpdateCallback; -struct ISplineInterpolator; - - -//! Interface to the Time Of Day functionality. -struct ITimeOfDay -{ - enum ETimeOfDayParamID - { - PARAM_SUN_COLOR, - PARAM_SUN_INTENSITY, - PARAM_SUN_SPECULAR_MULTIPLIER, - - PARAM_FOG_COLOR, - PARAM_FOG_COLOR_MULTIPLIER, - PARAM_VOLFOG_HEIGHT, - PARAM_VOLFOG_DENSITY, - PARAM_FOG_COLOR2, - PARAM_FOG_COLOR2_MULTIPLIER, - PARAM_VOLFOG_HEIGHT2, - PARAM_VOLFOG_DENSITY2, - PARAM_VOLFOG_HEIGHT_OFFSET, - - PARAM_FOG_RADIAL_COLOR, - PARAM_FOG_RADIAL_COLOR_MULTIPLIER, - PARAM_VOLFOG_RADIAL_SIZE, - PARAM_VOLFOG_RADIAL_LOBE, - - PARAM_VOLFOG_FINAL_DENSITY_CLAMP, - - PARAM_VOLFOG_GLOBAL_DENSITY, - PARAM_VOLFOG_RAMP_START, - PARAM_VOLFOG_RAMP_END, - PARAM_VOLFOG_RAMP_INFLUENCE, - - PARAM_VOLFOG_SHADOW_DARKENING, - PARAM_VOLFOG_SHADOW_DARKENING_SUN, - PARAM_VOLFOG_SHADOW_DARKENING_AMBIENT, - PARAM_VOLFOG_SHADOW_RANGE, - - PARAM_VOLFOG2_HEIGHT, - PARAM_VOLFOG2_DENSITY, - PARAM_VOLFOG2_HEIGHT2, - PARAM_VOLFOG2_DENSITY2, - PARAM_VOLFOG2_GLOBAL_DENSITY, - PARAM_VOLFOG2_RAMP_START, - PARAM_VOLFOG2_RAMP_END, - PARAM_VOLFOG2_COLOR1, - PARAM_VOLFOG2_ANISOTROPIC1, - PARAM_VOLFOG2_COLOR2, - PARAM_VOLFOG2_ANISOTROPIC2, - PARAM_VOLFOG2_BLEND_FACTOR, - PARAM_VOLFOG2_BLEND_MODE, - PARAM_VOLFOG2_COLOR, - PARAM_VOLFOG2_ANISOTROPIC, - PARAM_VOLFOG2_RANGE, - PARAM_VOLFOG2_INSCATTER, - PARAM_VOLFOG2_EXTINCTION, - PARAM_VOLFOG2_GLOBAL_FOG_VISIBILITY, - PARAM_VOLFOG2_FINAL_DENSITY_CLAMP, - - PARAM_SKYLIGHT_SUN_INTENSITY, - PARAM_SKYLIGHT_SUN_INTENSITY_MULTIPLIER, - - PARAM_SKYLIGHT_KM, - PARAM_SKYLIGHT_KR, - PARAM_SKYLIGHT_G, - - PARAM_SKYLIGHT_WAVELENGTH_R, - PARAM_SKYLIGHT_WAVELENGTH_G, - PARAM_SKYLIGHT_WAVELENGTH_B, - - PARAM_NIGHSKY_HORIZON_COLOR, - PARAM_NIGHSKY_HORIZON_COLOR_MULTIPLIER, - PARAM_NIGHSKY_ZENITH_COLOR, - PARAM_NIGHSKY_ZENITH_COLOR_MULTIPLIER, - PARAM_NIGHSKY_ZENITH_SHIFT, - - PARAM_NIGHSKY_START_INTENSITY, - - PARAM_NIGHSKY_MOON_COLOR, - PARAM_NIGHSKY_MOON_COLOR_MULTIPLIER, - PARAM_NIGHSKY_MOON_INNERCORONA_COLOR, - PARAM_NIGHSKY_MOON_INNERCORONA_COLOR_MULTIPLIER, - PARAM_NIGHSKY_MOON_INNERCORONA_SCALE, - PARAM_NIGHSKY_MOON_OUTERCORONA_COLOR, - PARAM_NIGHSKY_MOON_OUTERCORONA_COLOR_MULTIPLIER, - PARAM_NIGHSKY_MOON_OUTERCORONA_SCALE, - - PARAM_CLOUDSHADING_SUNLIGHT_MULTIPLIER, - PARAM_CLOUDSHADING_SUNLIGHT_CUSTOM_COLOR, - PARAM_CLOUDSHADING_SUNLIGHT_CUSTOM_COLOR_MULTIPLIER, - PARAM_CLOUDSHADING_SUNLIGHT_CUSTOM_COLOR_INFLUENCE, - - PARAM_SUN_SHAFTS_VISIBILITY, - PARAM_SUN_RAYS_VISIBILITY, - PARAM_SUN_RAYS_ATTENUATION, - PARAM_SUN_RAYS_SUNCOLORINFLUENCE, - PARAM_SUN_RAYS_CUSTOMCOLOR, - - PARAM_OCEANFOG_COLOR, // Remove when ocean related feature toggle is removed. - PARAM_OCEANFOG_COLOR_MULTIPLIER, // Remove when ocean related feature toggle is removed. - PARAM_OCEANFOG_DENSITY, // Remove when ocean related feature toggle is removed. - - PARAM_SKYBOX_MULTIPLIER, - - PARAM_HDR_FILMCURVE_SHOULDER_SCALE, - PARAM_HDR_FILMCURVE_LINEAR_SCALE, - PARAM_HDR_FILMCURVE_TOE_SCALE, - PARAM_HDR_FILMCURVE_WHITEPOINT, - - PARAM_HDR_COLORGRADING_COLOR_SATURATION, - PARAM_HDR_COLORGRADING_COLOR_BALANCE, - - PARAM_HDR_EYEADAPTATION_SCENEKEY, - PARAM_HDR_EYEADAPTATION_MIN_EXPOSURE, - PARAM_HDR_EYEADAPTATION_MAX_EXPOSURE, - PARAM_HDR_EYEADAPTATION_EV_MIN, - PARAM_HDR_EYEADAPTATION_EV_MAX, - PARAM_HDR_EYEADAPTATION_EV_AUTO_COMPENSATION, - PARAM_HDR_BLOOM_AMOUNT, - - PARAM_COLORGRADING_FILTERS_GRAIN, - PARAM_COLORGRADING_FILTERS_PHOTOFILTER_COLOR, - PARAM_COLORGRADING_FILTERS_PHOTOFILTER_DENSITY, - - PARAM_COLORGRADING_DOF_FOCUSRANGE, - PARAM_COLORGRADING_DOF_BLURAMOUNT, - - PARAM_SHADOWSC0_BIAS, - PARAM_SHADOWSC0_SLOPE_BIAS, - PARAM_SHADOWSC1_BIAS, - PARAM_SHADOWSC1_SLOPE_BIAS, - PARAM_SHADOWSC2_BIAS, - PARAM_SHADOWSC2_SLOPE_BIAS, - PARAM_SHADOWSC3_BIAS, - PARAM_SHADOWSC3_SLOPE_BIAS, - PARAM_SHADOWSC4_BIAS, - PARAM_SHADOWSC4_SLOPE_BIAS, - PARAM_SHADOWSC5_BIAS, - PARAM_SHADOWSC5_SLOPE_BIAS, - PARAM_SHADOWSC6_BIAS, - PARAM_SHADOWSC6_SLOPE_BIAS, - PARAM_SHADOWSC7_BIAS, - PARAM_SHADOWSC7_SLOPE_BIAS, - - PARAM_SHADOW_JITTERING, - - PARAM_HDR_DYNAMIC_POWER_FACTOR, - PARAM_TERRAIN_OCCL_MULTIPLIER, - PARAM_SUN_COLOR_MULTIPLIER, - - PARAM_TOTAL - }; - - struct SPresetInfo - { - const char* m_pName; - bool m_bCurrent; - }; - - enum EVariableType - { - TYPE_FLOAT, - TYPE_COLOR - }; - struct SVariableInfo - { - const char* name; //!< Variable name. - const char* displayName; //!< Variable user readable name. - const char* group; //!< Group name. - int nParamId; - EVariableType type; - float fValue[3]; //!< Value of the variable (3 needed for color type). - ISplineInterpolator* pInterpolator; //!< Splines that control variable value. - }; - struct SAdvancedInfo - { - float fStartTime; - float fEndTime; - float fAnimSpeed; - }; - struct SEnvironmentInfo - { - SEnvironmentInfo() - : bSunLinkedToTOD(true) - , sunRotationLatitude(0) - , sunRotationLongitude(0){} - bool bSunLinkedToTOD; - float sunRotationLatitude; - float sunRotationLongitude; - }; - - // - virtual ~ITimeOfDay(){} - - virtual int GetPresetCount() const = 0; - virtual bool GetPresetsInfos(SPresetInfo* resultArray, unsigned int arraySize) const = 0; - virtual bool SetCurrentPreset(const char* szPresetName) = 0; - virtual bool AddNewPreset(const char* szPresetName) = 0; - virtual bool RemovePreset(const char* szPresetName) = 0; - virtual bool SavePreset(const char* szPresetName) const = 0; - virtual bool LoadPreset(const char* szFilePath) = 0; - virtual void ResetPreset(const char* szPresetName) = 0; - - virtual bool ImportPreset(const char* szPresetName, const char* szFilePath) = 0; - virtual bool ExportPreset(const char* szPresetName, const char* szFilePath) const = 0; - - //! Access to variables that control time of the day appearance. - virtual int GetVariableCount() const = 0; - virtual bool GetVariableInfo(int nIndex, SVariableInfo& varInfo) const = 0; - virtual void SetVariableValue(int nIndex, float fValue[3]) = 0; - - //! Editor interface. - virtual bool InterpolateVarInRange(int nIndex, float fMin, float fMax, unsigned int nCount, Vec3* resultArray) const = 0; - virtual uint GetSplineKeysCount(int nIndex, int nSpline) const = 0; - virtual bool GetSplineKeysForVar(int nIndex, int nSpline, SBezierKey* keysArray, unsigned int keysArraySize) const = 0; - virtual bool SetSplineKeysForVar(int nIndex, int nSpline, const SBezierKey* keysArray, unsigned int keysArraySize) = 0; - virtual bool UpdateSplineKeyForVar(int nIndex, int nSpline, float fTime, float newValue) = 0; - - virtual void ResetVariables() = 0; - - //! Sets the time of the day specified in hours. - virtual void SetTime(float fHour, bool bForceUpdate = false, bool bForceEnvUpdate = true) = 0; - virtual float GetTime() = 0; - - //! Sun position. - virtual void SetSunPos(float longitude, float latitude) = 0; - virtual float GetSunLatitude() = 0; - virtual float GetSunLongitude() = 0; - - //! Updates the current ToD. - virtual void Tick() = 0; - - - virtual void SetPaused(bool paused) = 0; - - virtual void SetAdvancedInfo(const SAdvancedInfo& advInfo) = 0; - virtual void GetAdvancedInfo(SAdvancedInfo& advInfo) = 0; - - //! Updates engine parameters after variable values have been changed. - virtual void Update(bool bInterpolate = true, bool bForceUpdate = false, bool bForceEnvUpdate = true) = 0; - virtual void SetUpdateCallback(ITimeOfDayUpdateCallback* pCallback) = 0; - - virtual void BeginEditMode() = 0; - virtual void EndEditMode() = 0; - - virtual void Serialize(XmlNodeRef& node, bool bLoading) = 0; - virtual void Serialize(TSerialize ser) = 0; - - virtual void SetTimer(ITimer* pTimer) = 0; - virtual void SetEnvironmentSettings(const SEnvironmentInfo& envInfo) = 0; - virtual void LerpWith(const ITimeOfDay& other, float lerpValue, ITimeOfDay& output) const = 0; - - //! Multiplayer serialization. - static const int NETSER_FORCESET = BIT(0); - static const int NETSER_COMPENSATELAG = BIT(1); - static const int NETSER_STATICPROPS = BIT(2); - virtual void NetSerialize(TSerialize ser, float lag, uint32 flags) = 0; -}; - -struct ITimeOfDayUpdateCallback -{ - // - virtual ~ITimeOfDayUpdateCallback(){} - virtual void BeginUpdate() = 0; - virtual bool GetCustomValue(ITimeOfDay::ETimeOfDayParamID paramID, int dim, float* pValues, float& blendWeight) = 0; - virtual void EndUpdate() = 0; - // -}; - diff --git a/Code/CryEngine/CryCommon/Mocks/I3DEngineMock.h b/Code/CryEngine/CryCommon/Mocks/I3DEngineMock.h deleted file mode 100644 index b0936ddbdd..0000000000 --- a/Code/CryEngine/CryCommon/Mocks/I3DEngineMock.h +++ /dev/null @@ -1,528 +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 - -#include -#include -#include - -// the following was generated using google's python script to autogenerate mocks. -// however, it needed some hand-editing to make it work, so if you add functions to I3DEngine, -// it will probably be better to just manually add them here than try to run the script again. - -class I3DEngineMock - : public I3DEngine -{ -public: - // From IProcess - MOCK_METHOD1(SetFlags, - void(int)); - MOCK_METHOD0(GetFlags, - int(void)); - - // From I3DEngine - MOCK_METHOD0(Init, - bool()); - MOCK_METHOD1(SetLevelPath, - void(const char* szFolderName)); - MOCK_METHOD1(CheckMinSpec, - bool(uint32 nMinSpec)); - MOCK_METHOD1(PrepareOcclusion, - void(const CCamera& rCamera)); - MOCK_METHOD0(EndOcclusion, - void()); - MOCK_METHOD2(LoadLevel, - bool(const char* szFolderName, const char* szMissionName)); - MOCK_METHOD2(InitLevelForEditor, - bool(const char* szFolderName, const char* szMissionName)); - MOCK_METHOD0(LevelLoadingInProgress, - bool()); - MOCK_METHOD0(OnFrameStart, - void()); - MOCK_METHOD0(PostLoadLevel, - void()); - MOCK_METHOD0(LoadEmptyLevel, - void()); - MOCK_METHOD0(UnloadLevel, - void()); - MOCK_METHOD0(Update, - void()); - MOCK_CONST_METHOD0(GetRenderingCamera, - const CCamera&()); - MOCK_CONST_METHOD0(GetZoomFactor, - float()); - MOCK_METHOD0(Tick, - void()); - MOCK_METHOD0(UpdateShaderItems, - void()); - MOCK_METHOD0(Release, - void()); - MOCK_METHOD3(RenderWorld, - void(int nRenderFlags, const SRenderingPassInfo& passInfo, const char* szDebugName)); - MOCK_METHOD2(RenderSceneReflection, - void(int nRenderFlags, const SRenderingPassInfo& passInfo)); - MOCK_METHOD1(PreWorldStreamUpdate, - void(const CCamera& cam)); - MOCK_METHOD0(WorldStreamUpdate, - void()); - MOCK_METHOD0(ShutDown, - void()); - MOCK_METHOD7(LoadStatObjUnsafeManualRef, - IStatObj*(const char* fileName, const char* geomName, IStatObj::SSubObject** subObject, - bool useStreaming, unsigned long loadingFlags, const void* data, int dataSize)); - MOCK_METHOD7(LoadStatObjAutoRef, - _smart_ptr(const char* fileName, const char* geomName, IStatObj::SSubObject** subObject, - bool useStreaming, unsigned long loadingFlags, const void* data, int dataSize)); - MOCK_METHOD0(ProcessAsyncStaticObjectLoadRequests, - void()); - MOCK_METHOD5(LoadStatObjAsync, - void(LoadStaticObjectAsyncResult resultCallback, const char* szFileName, const char* szGeomName, bool bUseStreaming, unsigned long nLoadingFlags)); - MOCK_METHOD1(FindStatObjectByFilename, - IStatObj*(const char* filename)); - MOCK_METHOD0(GetGSMRange, - const float()); - MOCK_METHOD0(GetGSMRangeStep, - const float()); - MOCK_METHOD0(GetLoadedObjectCount, - int()); - MOCK_METHOD2(GetLoadedStatObjArray, - void(IStatObj** pObjectsArray, int& nCount)); - MOCK_METHOD1(GetObjectsStreamingStatus, - void(SObjectsStreamingStatus& outStatus)); - MOCK_METHOD2(GetStreamingSubsystemData, - void(int subsystem, SStremaingBandwidthData& outData)); - MOCK_METHOD3(RegisterEntity, - void(IRenderNode* pEntity, int nSID, int nSIDConsideredSafe)); - MOCK_METHOD1(SelectEntity, - void(IRenderNode* pEntity)); - MOCK_METHOD0(IsSunShadows, - bool()); - MOCK_METHOD2(MakeSystemMaterialFromShaderHelper - , _smart_ptr(const char* sShaderName, SInputShaderResources* Res)); - MOCK_METHOD1(CheckMinSpecHelper - , bool(uint32 nMinSpec)); - MOCK_METHOD1(OnCasterDeleted - , void(IShadowCaster* pCaster)); - MOCK_METHOD4(GetStatObjAndMatTables, - void(DynArray* pStatObjTable, DynArray<_smart_ptr>* pMatTable, DynArray* pStatInstGroupTable, uint32 nObjTypeMask)); -#ifndef _RELEASE - MOCK_METHOD1(AddObjToDebugDrawList, - void(SObjectInfoToAddToDebugDrawList& objInfo)); - MOCK_CONST_METHOD0(IsDebugDrawListEnabled, - bool()); -#endif - MOCK_METHOD1(UnRegisterEntityDirect, - void(IRenderNode* pEntity)); - MOCK_METHOD1(UnRegisterEntityAsJob, - void(IRenderNode* pEnt)); - MOCK_CONST_METHOD1(IsUnderWater, - bool(const Vec3& vPos)); - MOCK_METHOD1(SetOceanRenderFlags, - void(uint8 nFlags)); - MOCK_CONST_METHOD0(GetOceanRenderFlags, - uint8()); - MOCK_CONST_METHOD0(GetOceanVisiblePixelsCount, - uint32()); - MOCK_METHOD3(GetBottomLevel, - float(const Vec3& referencePos, float maxRelevantDepth, int objtypes)); - MOCK_METHOD2(GetBottomLevel, - float(const Vec3& referencePos, float maxRelevantDepth)); - MOCK_METHOD2(GetBottomLevel, - float(const Vec3& referencePos, int objflags)); - MOCK_METHOD0(GetWaterLevel, - float()); - MOCK_METHOD3(GetWaterLevel, - float(const Vec3* pvPos, IPhysicalEntity* pent, bool bAccurate)); - MOCK_CONST_METHOD1(GetAccurateOceanHeight, - float(const Vec3& pCurrPos)); - MOCK_CONST_METHOD0(GetCausticsParams, - CausticsParams()); - MOCK_CONST_METHOD0(GetOceanAnimationParams, - OceanAnimationData()); - MOCK_CONST_METHOD1(GetHDRSetupParams, - void(Vec4 pParams[5])); - MOCK_METHOD0(ResetParticlesAndDecals, - void()); - MOCK_METHOD1(CreateDecal, - void(const CryEngineDecalInfo& Decal)); - MOCK_METHOD2(DeleteDecalsInRange, - void(AABB* pAreaBox, IRenderNode* pEntity)); - MOCK_METHOD1(SetSunColor, - void(Vec3 vColor)); - MOCK_METHOD0(GetSunAnimColor, - Vec3()); - MOCK_METHOD1(SetSunAnimColor, - void(const Vec3& color)); - MOCK_METHOD0(GetSunAnimSpeed, - float()); - MOCK_METHOD1(SetSunAnimSpeed, - void(float sunAnimSpeed)); - MOCK_METHOD0(GetSunAnimPhase, - AZ::u8()); - MOCK_METHOD1(SetSunAnimPhase, - void(AZ::u8 sunAnimPhase)); - MOCK_METHOD0(GetSunAnimIndex, - AZ::u8()); - MOCK_METHOD1(SetSunAnimIndex, - void(AZ::u8 sunAnimIndex)); - MOCK_METHOD1(SetRainParams, - void(const SRainParams& rainParams)); - MOCK_METHOD1(GetRainParams, - bool(SRainParams& rainParams)); - MOCK_METHOD5(SetSnowSurfaceParams, - void(const Vec3& vCenter, float fRadius, float fSnowAmount, float fFrostAmount, float fSurfaceFreezing)); - MOCK_METHOD5(GetSnowSurfaceParams, - bool(Vec3& vCenter, float& fRadius, float& fSnowAmount, float& fFrostAmount, float& fSurfaceFreezing)); - MOCK_METHOD7(SetSnowFallParams, - void(int nSnowFlakeCount, float fSnowFlakeSize, float fSnowFallBrightness, float fSnowFallGravityScale, float fSnowFallWindScale, float fSnowFallTurbulence, float fSnowFallTurbulenceFreq)); - MOCK_METHOD7(GetSnowFallParams, - bool(int& nSnowFlakeCount, float& fSnowFlakeSize, float& fSnowFallBrightness, float& fSnowFallGravityScale, float& fSnowFallWindScale, float& fSnowFallTurbulence, float& fSnowFallTurbulenceFreq)); - MOCK_METHOD1(SetMaxViewDistanceScale, - void(float fScale)); - MOCK_METHOD1(GetMaxViewDistance, - float(bool)); - MOCK_CONST_METHOD0(GetFrameLodInfo, - const SFrameLodInfo&()); - MOCK_METHOD1(SetFrameLodInfo, - void(const SFrameLodInfo& frameLodInfo)); - MOCK_METHOD1(SetFogColor, - void(const Vec3& vFogColor)); - MOCK_METHOD0(GetFogColor, - Vec3()); - MOCK_METHOD6(GetSkyLightParameters, - void(Vec3& sunDir, Vec3& sunIntensity, float& Km, float& Kr, float& g, Vec3& rgbWaveLengths)); - MOCK_METHOD7(SetSkyLightParameters, - void(const Vec3& sunDir, const Vec3& sunIntensity, float Km, float Kr, float g, const Vec3& rgbWaveLengths, bool forceImmediateUpdate)); - MOCK_CONST_METHOD0(GetLightsHDRDynamicPowerFactor, - float()); - MOCK_CONST_METHOD3(IsTessellationAllowed, - bool(const CRenderObject* pObj, const SRenderingPassInfo& passInfo, bool bIgnoreShadowPass)); - MOCK_METHOD3(SetRenderNodeMaterialAtPosition, - void(EERType eNodeType, const Vec3& vPos, _smart_ptr pMat)); - MOCK_METHOD1(OverrideCameraPrecachePoint, - void(const Vec3& vPos)); - MOCK_METHOD4(AddPrecachePoint, - int(const Vec3& vPos, const Vec3& vDir, float fTimeOut, float fImportanceFactor)); - MOCK_METHOD1(ClearPrecachePoint, - void(int id)); - MOCK_METHOD0(ClearAllPrecachePoints, - void()); - MOCK_METHOD1(GetPrecacheRoundIds, - void(int pRoundIds[MAX_STREAM_PREDICTION_ZONES])); - MOCK_METHOD5(TraceFogVolumes, - void(const Vec3& vPos, const AABB& objBBox, SFogVolumeData& fogVolData, const SRenderingPassInfo& passInfo, bool fogVolumeShadingQuality)); - - MOCK_METHOD1(RemoveAllStaticObjects, - void(int)); - MOCK_METHOD3(SetStatInstGroup, - bool(int nGroupId, const IStatInstGroup& siGroup, int nSID)); - MOCK_METHOD3(GetStatInstGroup, - bool(int, IStatInstGroup&, int)); - MOCK_METHOD3(OnExplosion, - void(Vec3, float, bool)); - MOCK_METHOD1(SetPhysMaterialEnumerator, - void(IPhysMaterialEnumerator* pPhysMaterialEnumerator)); - MOCK_METHOD0(GetPhysMaterialEnumerator, - IPhysMaterialEnumerator*()); - MOCK_METHOD0(SetupDistanceFog, - void()); - MOCK_METHOD1(LoadMissionDataFromXMLNode, - void(const char* szMissionName)); - MOCK_METHOD2(LoadEnvironmentSettingsFromXML, - void(XmlNodeRef, int)); - MOCK_METHOD0(LoadCompiledOctreeForEditor, - bool()); - MOCK_CONST_METHOD0(GetSunDir, - Vec3()); - MOCK_CONST_METHOD0(GetSunDirNormalized, - Vec3()); - MOCK_CONST_METHOD0(GetRealtimeSunDirNormalized, - Vec3()); - MOCK_METHOD0(GetDistanceToSectorWithWater, - float()); - MOCK_CONST_METHOD0(GetSunColor, - Vec3()); - MOCK_CONST_METHOD0(GetSSAOAmount, - float()); - MOCK_CONST_METHOD0(GetSSAOContrast, - float()); - MOCK_METHOD1(FreeRenderNodeState, - void(IRenderNode* pEntity)); - MOCK_METHOD1(GetLevelFilePath, - const char*(const char* szFileName)); - MOCK_METHOD4(DisplayInfo, - void(float& fTextPosX, float& fTextPosY, float& fTextStepY, bool bEnhanced)); - MOCK_METHOD0(DisplayMemoryStatistics, - void()); - - // Can't mock methods with variable parameters so just create empty bodies for them. - void DrawTextRightAligned([[maybe_unused]] const float x, [[maybe_unused]] const float y, [[maybe_unused]] const char* format, ...) override {} - void DrawTextRightAligned([[maybe_unused]] const float x, [[maybe_unused]] const float y, [[maybe_unused]] const float scale, [[maybe_unused]] const ColorF& color, [[maybe_unused]] const char* format, ...) override {} - - MOCK_METHOD3(DrawBBoxHelper - , void (const Vec3& vMin, const Vec3& vMax, ColorB col)); - MOCK_METHOD2(DrawBBoxHelper - , void (const AABB& box, ColorB col)); - - MOCK_METHOD3(ActivatePortal, - void(const Vec3& vPos, bool bActivate, const char* szEntityName)); - MOCK_CONST_METHOD1(GetMemoryUsage, - void(ICrySizer* pSizer)); - MOCK_METHOD2(GetResourceMemoryUsage, - void(ICrySizer* pSizer, const AABB& cstAABB)); - MOCK_METHOD1(CreateVisArea, - IVisArea*(uint64 visGUID)); - MOCK_METHOD1(DeleteVisArea, - void(IVisArea* pVisArea)); - MOCK_METHOD6(UpdateVisArea, - void(IVisArea* pArea, const Vec3* pPoints, int nCount, const char* szName, const SVisAreaInfo& info, bool bReregisterObjects)); - MOCK_METHOD4(IsVisAreasConnected, - bool(IVisArea* pArea1, IVisArea* pArea2, int nMaxRecursion, bool bSkipDisabledPortals)); - MOCK_METHOD0(CreateClipVolume, - IClipVolume*()); - MOCK_METHOD1(DeleteClipVolume, - void(IClipVolume* pClipVolume)); - MOCK_METHOD7(UpdateClipVolume, - void(IClipVolume* pClipVolume, _smart_ptr pRenderMesh, IBSPTree3D* pBspTree, const Matrix34& worldTM, bool bActive, uint32 flags, const char* szName)); - MOCK_METHOD1(CreateRenderNode, - IRenderNode*(EERType type)); - MOCK_METHOD1(DeleteRenderNode, - void(IRenderNode* pRenderNode)); - MOCK_METHOD1(SetWind, - void(const Vec3& vWind)); - MOCK_CONST_METHOD2(GetWind, - Vec3(const AABB& box, bool bIndoors)); - MOCK_CONST_METHOD1(GetGlobalWind, - Vec3(bool bIndoors)); - MOCK_CONST_METHOD4(SampleWind, - bool(Vec3* pSamples, int nSamples, const AABB& volume, bool bIndoors)); - MOCK_METHOD1(GetVisAreaFromPos, - IVisArea*(const Vec3& vPos)); - MOCK_METHOD2(IntersectsVisAreas, - bool(const AABB& box, void** pNodeCache)); - MOCK_METHOD4(ClipToVisAreas, - bool(IVisArea* pInside, Sphere& sphere, Vec3 const& vNormal, void* pNodeCache)); - MOCK_METHOD1(EnableOceanRendering, - void(bool bOcean)); - MOCK_METHOD1(AddTextureLoadHandler, - void(ITextureLoadHandler* pHandler)); - MOCK_METHOD1(RemoveTextureLoadHandler, - void(ITextureLoadHandler* pHandler)); - MOCK_METHOD1(GetTextureLoadHandlerForImage, - ITextureLoadHandler*(const char* ext)); - MOCK_METHOD0(CreateLightSource, - struct ILightSource*()); - MOCK_METHOD1(DeleteLightSource, - void(ILightSource* pLightSource)); - MOCK_METHOD0(GetLightEntities, - const PodArray* ()); - MOCK_METHOD3(GetLightVolumes, - void(threadID nThreadID, SLightVolume*& pLightVols, uint32& nNumVols)); - MOCK_METHOD4(RegisterVolumeForLighting, - uint16(const Vec3& vPos, f32 fRadius, uint8 nClipVolumeRef, const SRenderingPassInfo& passInfo)); - MOCK_METHOD1(RestoreTerrainFromDisk, - bool(int)); - MOCK_METHOD1(GetFilePath, - const char*(const char* szFileName)); - MOCK_CONST_METHOD0(GetPostEffectGroups, - class IPostEffectGroupManager*()); - MOCK_CONST_METHOD0(GetPostEffectBaseGroup, - class IPostEffectGroup*()); - MOCK_CONST_METHOD3(SetPostEffectParam, - void(const char* pParam, float fValue, bool bForceValue)); - MOCK_CONST_METHOD3(SetPostEffectParamVec4, - void(const char* pParam, const Vec4& pValue, bool bForceValue)); - MOCK_CONST_METHOD2(SetPostEffectParamString, - void(const char* pParam, const char* pszArg)); - MOCK_CONST_METHOD2(GetPostEffectParam, - void(const char* pParam, float& fValue)); - MOCK_CONST_METHOD2(GetPostEffectParamVec4, - void(const char* pParam, Vec4& pValue)); - MOCK_CONST_METHOD2(GetPostEffectParamString, - void(const char* pParam, const char*& pszArg)); - MOCK_METHOD1(GetPostEffectID, - int32(const char* pPostEffectName)); - MOCK_METHOD1(ResetPostEffects, - void(bool)); - MOCK_METHOD0(DisablePostEffects, - void()); - MOCK_METHOD1(SetShadowsGSMCache, - void(bool bCache)); - MOCK_METHOD2(SetCachedShadowBounds, - void(const AABB& shadowBounds, float fAdditionalCascadesScale)); - MOCK_METHOD1(SetRecomputeCachedShadows, - void(uint)); - MOCK_METHOD0(CheckMemoryHeap, - void()); - MOCK_METHOD1(DeleteEntityDecals, - void(IRenderNode* pEntity)); - MOCK_METHOD0(LockCGFResources, - void()); - MOCK_METHOD0(UnlockCGFResources, - void()); - MOCK_METHOD0(FreeUnusedCGFResources, - void()); - MOCK_METHOD0(CreateStatObj, - IStatObj*()); - MOCK_METHOD1(CreateStatObjOptionalIndexedMesh, - IStatObj*(bool createIndexedMesh)); - MOCK_METHOD0(CreateIndexedMesh, - IIndexedMesh*()); - MOCK_METHOD1(SerializeState, - void(TSerialize ser)); - MOCK_METHOD1(PostSerialize, - void(bool bReading)); - MOCK_METHOD0(GetMaterialHelpers, - IMaterialHelpers&()); - MOCK_METHOD0(GetMaterialManager, - IMaterialManager*()); - MOCK_METHOD0(GetObjManager, - IObjManager*()); - MOCK_METHOD1(CreateChunkfileContent, - CContentCGF*(const char* filename)); - MOCK_METHOD1(ReleaseChunkfileContent, - void(CContentCGF*)); - MOCK_METHOD4(LoadChunkFileContent, - bool(CContentCGF* pCGF, const char* filename, bool bNoWarningMode, bool bCopyChunkFile)); - MOCK_METHOD6(LoadChunkFileContentFromMem, - bool(CContentCGF* pCGF, const void* pData, size_t nDataLen, uint32 nLoadingFlags, bool bNoWarningMode, bool bCopyChunkFile)); - MOCK_METHOD1(CreateChunkFile, - IChunkFile*(bool)); - MOCK_CONST_METHOD3(CreateChunkFileWriter, - ChunkFile::IChunkFileWriter*(EChunkFileFormat eFormat, AZ::IO::IArchive* pPak, const char* filename)); - MOCK_CONST_METHOD1(ReleaseChunkFileWriter, - void(ChunkFile::IChunkFileWriter* p)); - MOCK_METHOD2(CreateOcean, - bool(_smart_ptr pTerrainWaterMat, float waterLevel)); - MOCK_METHOD0(DeleteOcean, - void()); - MOCK_METHOD1(ChangeOceanMaterial, - void(_smart_ptr pMat)); - MOCK_METHOD1(ChangeOceanWaterLevel, - void(float fWaterLevel)); - MOCK_METHOD1(InitMaterialDefautMappingAxis - , void(_smart_ptr pMat)); - MOCK_METHOD0(GetIVisAreaManager, - IVisAreaManager*()); - MOCK_METHOD3(PrecacheLevel, - void(bool bPrecacheAllVisAreas, Vec3* pPrecachePoints, int nPrecachePointsNum)); - MOCK_METHOD0(ProposeContentPrecache, - void()); - MOCK_METHOD0(GetTimeOfDay, - ITimeOfDay*()); - MOCK_METHOD1(SetSkyMaterialPath, - void(const string& skyMaterialPath)); - MOCK_METHOD1(SetSkyLowSpecMaterialPath, - void(const string& skyMaterialPath)); - MOCK_METHOD0(LoadSkyMaterial, - void()); - MOCK_METHOD0(GetSkyMaterial, - _smart_ptr()); - MOCK_METHOD1(SetSkyMaterial, - void(_smart_ptr pSkyMat)); - MOCK_METHOD2(SetGlobalParameter, - void(E3DEngineParameter param, const Vec3& v)); - MOCK_METHOD2(GetGlobalParameter, - void(E3DEngineParameter param, Vec3& v)); - MOCK_METHOD1(SetShadowMode, - void(EShadowMode shadowMode)); - MOCK_CONST_METHOD0(GetShadowMode, - EShadowMode()); - MOCK_METHOD6(AddPerObjectShadow, - void(IShadowCaster* pCaster, float fConstBias, float fSlopeBias, float fJitter, const Vec3& vBBoxScale, uint nTexSize)); - MOCK_METHOD1(RemovePerObjectShadow, - void(IShadowCaster* pCaster)); - MOCK_METHOD1(GetPerObjectShadow, - struct SPerObjectShadow*(IShadowCaster* pCaster)); - MOCK_METHOD2(GetCustomShadowMapFrustums, - void(struct ShadowMapFrustum*& arrFrustums, int& nFrustumCount)); - MOCK_METHOD2(SaveStatObj, - int(IStatObj* pStatObj, TSerialize ser)); - MOCK_METHOD1(LoadStatObj, - IStatObj*(TSerialize ser)); - MOCK_METHOD2(CheckIntersectClouds, - bool(const Vec3& p1, const Vec3& p2)); - MOCK_METHOD1(OnRenderMeshDeleted, - void(IRenderMesh* pRenderMesh)); - MOCK_METHOD0(DebugDraw_UpdateDebugNode, - void()); - MOCK_METHOD4(RayObjectsIntersection2D, - bool(Vec3 vStart, Vec3 vEnd, Vec3& vHitPoint, EERType eERType)); - MOCK_METHOD3(RenderMeshRayIntersection, - bool(IRenderMesh* pRenderMesh, SRayHitInfo& hitInfo, _smart_ptr pCustomMtl)); - MOCK_METHOD3(CheckCreateRNTmpData - , void(CRNTmpData** ppInfo, IRenderNode* pRNode, const SRenderingPassInfo& passInfo)); - MOCK_METHOD1(FreeRNTmpData, - void(CRNTmpData** ppInfo)); - MOCK_METHOD0(IsObjectTreeReady - , bool()); - MOCK_METHOD0(GetIObjectTree - , IOctreeNode*()); - MOCK_METHOD2(GetObjectsByType, - uint32(EERType, IRenderNode**)); - MOCK_METHOD4(GetObjectsByTypeInBox, - uint32(EERType objType, const AABB& bbox, IRenderNode** pObjects, ObjectTreeQueryFilterCallback filterCallback)); - MOCK_METHOD2(GetObjectsInBox, - uint32(const AABB& bbox, IRenderNode** pObjects)); - MOCK_METHOD2(GetObjectsByFlags, - uint32(uint, IRenderNode**)); - MOCK_METHOD4(GetObjectsByTypeInBox, - void(EERType objType, const AABB& bbox, PodArray* pLstObjects, ObjectTreeQueryFilterCallback filterCallback)); - MOCK_METHOD2(OnObjectModified, - void(IRenderNode* pRenderNode, uint dwFlags)); - MOCK_METHOD1(FillDebugFPSInfo, - void(SDebugFPSInfo&)); - MOCK_METHOD0(GetLevelFolder, - const char*()); - MOCK_METHOD0(IsAreaActivationInUse, - bool()); - MOCK_METHOD3(RenderRenderNode_ShadowPass, - void(IShadowCaster* pRNode, const SRenderingPassInfo& passInfo, AZ::LegacyJobExecutor* pJobExecutor)); - MOCK_METHOD0(GetOpticsManager, - IOpticsManager*()); - MOCK_METHOD0(SyncProcessStreamingUpdate, - void()); - MOCK_METHOD1(SetScreenshotCallback, - void(IScreenshotCallback* pCallback)); - MOCK_METHOD8(ActivateObjectsLayer, - void(uint16 nLayerId, bool bActivate, bool bPhys, bool bObjects, bool bStaticLights, const char* pLayerName, IGeneralMemoryHeap* pHeap, bool bCheckLayerActivation)); - MOCK_CONST_METHOD4(GetLayerMemoryUsage, - void(uint16 nLayerId, ICrySizer* pSizer, int* pNumBrushes, int* pNumDecals)); - MOCK_METHOD2(SkipLayerLoading, - void(uint16 nLayerId, bool bClearList)); - MOCK_METHOD2(PrecacheRenderNode, - void(IRenderNode* pObj, float fEntDistanceReal)); - MOCK_METHOD0(GetDeferredPhysicsEventManager, - IDeferredPhysicsEventManager*()); - MOCK_METHOD1(SetStreamableListener, - void(IStreamedObjectListener* pListener)); - MOCK_METHOD1(GetRenderingPassCamera, - CCamera*(const CCamera& rCamera)); - MOCK_METHOD3(GetSvoStaticTextures, - void(I3DEngine::SSvoStaticTexInfo& svoInfo, PodArray* pLightsTI_S, PodArray* pLightsTI_D)); - MOCK_METHOD2(GetSvoBricksForUpdate, - void(PodArray& arrNodeInfo, bool getDynamic)); -#if defined(USE_GEOM_CACHES) - MOCK_METHOD1(LoadGeomCache, - IGeomCache*(const char* szFileName)); - MOCK_METHOD1(FindGeomCacheByFilename, - IGeomCache*(const char* szFileName)); -#endif - MOCK_METHOD3(LoadDesignerObject, - IStatObj*(int nVersion, const char* szBinaryStream, int size)); - - MOCK_METHOD0(WaitForCullingJobsCompletion, - void()); -}; - diff --git a/Code/CryEngine/CryCommon/Mocks/IRendererMock.h b/Code/CryEngine/CryCommon/Mocks/IRendererMock.h index 2021e96172..757c586261 100644 --- a/Code/CryEngine/CryCommon/Mocks/IRendererMock.h +++ b/Code/CryEngine/CryCommon/Mocks/IRendererMock.h @@ -12,11 +12,15 @@ #pragma once #include -#include // needed for SRenderingPassInfo definition #include #include #include +struct SRendItemSorter {}; +struct SRenderingPassInfo {}; +struct SClipVolumeBlendInfo {}; +struct SFogVolumeData {}; + // the following was generated using google's python script to autogenerate mocks. // however, it needed some hand-editing to make it work, so if you add functions to IRenderer, // it will probably be better to just manually add them here than try to run the script again diff --git a/Code/CryEngine/CryCommon/Mocks/ISystemMock.h b/Code/CryEngine/CryCommon/Mocks/ISystemMock.h index 5edd84fd75..4d2e80a2f3 100644 --- a/Code/CryEngine/CryCommon/Mocks/ISystemMock.h +++ b/Code/CryEngine/CryCommon/Mocks/ISystemMock.h @@ -37,12 +37,6 @@ public: void()); MOCK_METHOD0(NeedDoWorkDuringOcclusionChecks, bool()); - MOCK_METHOD0(Render, - void()); - MOCK_METHOD0(RenderBegin, - void()); - MOCK_METHOD2(RenderEnd, - void(bool, bool)); MOCK_METHOD2(SynchronousLoadingTick, void(const char* pFunc, int line)); MOCK_METHOD0(RenderStatistics, @@ -124,8 +118,6 @@ public: IMovieSystem * ()); MOCK_METHOD0(GetIAudioSystem, Audio::IAudioSystem * ()); - MOCK_METHOD0(GetI3DEngine, - I3DEngine * ()); MOCK_METHOD0(GetIConsole, ::IConsole * ()); MOCK_METHOD0(GetIRemoteConsole, diff --git a/Code/CryEngine/CryCommon/Mocks/StubTimer.h b/Code/CryEngine/CryCommon/Mocks/StubTimer.h index fe3a11fb42..cd275ac17b 100644 --- a/Code/CryEngine/CryCommon/Mocks/StubTimer.h +++ b/Code/CryEngine/CryCommon/Mocks/StubTimer.h @@ -11,6 +11,8 @@ */ #pragma once +#include + //! Simple stub timer that exposes a single simple interface for setting the current time. class StubTimer : public ITimer diff --git a/Code/CryEngine/CryCommon/WindowsUtils.h b/Code/CryEngine/CryCommon/WindowsUtils.h deleted file mode 100644 index 96b3a86606..0000000000 --- a/Code/CryEngine/CryCommon/WindowsUtils.h +++ /dev/null @@ -1,215 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#pragma once - -#if defined(WIN32) -#include "CryWindows.h" -#include "IRenderer.h" -#include "IImage.h" -#include "smartptr.h" -#include "ImageExtensionHelper.h" - -// Types supported by CreateResourceFromTexture -enum EResourceType -{ - eResourceType_IconBig, - eResourceType_IconSmall, - eResourceType_Cursor, -}; - -// Loads a (DDS) texture resource from the renderer into a Win32 GDI resource. -// Returns a HICON that must be closed with DestroyIcon(), or NULL on failure. -static HICON CreateResourceFromTexture(IRenderer* pRenderer, const char* path, EResourceType type) -{ - if (!pRenderer || !path || !*path) - { - // Invalid parameter passed - return NULL; - } - - // Find the target dimensions of the GDI resource - const int nRequestedWidth = GetSystemMetrics(type == eResourceType_IconBig ? SM_CXICON : type == eResourceType_IconSmall ? SM_CXSMICON : SM_CXCURSOR); - const int nRequestedHeight = GetSystemMetrics(type == eResourceType_IconBig ? SM_CYICON : type == eResourceType_IconSmall ? SM_CYSMICON : SM_CYCURSOR); - if (nRequestedWidth != nRequestedHeight || nRequestedHeight <= 0 || nRequestedWidth <= 0) - { - // Don't support non-squares icons or cursors - return NULL; - } - - // Load texture. - // in this case, we want to fall back on a null, not substiture the missing texture. - _smart_ptr pImage = pRenderer->EF_LoadImage(path, FIM_NOFALLBACKS); - if (!pImage || pImage->mfGet_depth() != 1 || pImage->mfGet_NumSides() != 1 || pImage->mfGetTileMode() != eTM_None) - { - // Can't load texture, or texture is a cube-map or volume texture, or uses tiling of some kind - return NULL; - } - byte* pImgRaw = pImage->mfGet_image(0); - const ETEX_Format texFormat = pImage->mfGetFormat(); - - // Pick first mip level smaller than the GDI resource - int nMip = 0; - size_t offset = 0; - int nMipWidth = pImage->mfGet_width(); - int nMipHeight = pImage->mfGet_height(); - while (nMipWidth > nRequestedWidth) - { - ++nMip; - offset += pRenderer->GetTextureFormatDataSize(nMipWidth, nMipHeight, 1, 1, texFormat); - nMipWidth = max(nMipWidth / 2, 1); - nMipHeight = max(nMipHeight / 2, 1); - } - pImgRaw += offset; - if (nMip >= pImage->mfGet_numMips()) - { - // No appropriate mip in the texture - // Note: Consider creating a full mip-chain on the texture so this can't happen - return NULL; - } - const size_t nRawSize = pRenderer->GetTextureFormatDataSize(nMipWidth, nMipHeight, 1, 1, texFormat); - -#if 0 - // Check that DDS indexing is correct here - offset += nRawSize; - for (int nIdx = nMip + 1; nIdx < pImage->mfGet_numMips(); ++nIdx) - { - const int w = max(nMipWidth >> (nIdx - nMip), 1); - const int h = max(nMipHeight >> (nIdx - nMip), 1); - offset += pRenderer->GetTextureFormatDataSize(w, h, 1, 1, texFormat); - } - assert(offset == pImage->mfGet_ImageSize()); -#endif - - // Type of bitmap to create - BITMAPV5HEADER bi = { 0 }; - bi.bV5Size = sizeof(BITMAPV5HEADER); - bi.bV5Width = nRequestedWidth; - bi.bV5Height = -nRequestedHeight; - bi.bV5Planes = 1; - bi.bV5BitCount = 32; - bi.bV5Compression = BI_BITFIELDS; - // The following mask specification specifies a supported 32 BPP alpha format for Windows XP+ - bi.bV5AlphaMask = 0xFF000000; - bi.bV5RedMask = 0x00FF0000; - bi.bV5GreenMask = 0x0000FF00; - bi.bV5BlueMask = 0x000000FF; - - // Create the DIB section with an alpha channel - const HDC hdc = GetDC(NULL); - void* lpBits; - const HBITMAP hBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &lpBits, NULL, 0); - ReleaseDC(NULL, hdc); - if (!hBitmap || !lpBits) - { - // Can't allocate OS bitmap - return NULL; - } - GdiFlush(); - - // Decompress texture - const bool bTryDecompress = texFormat != eTF_R8G8B8A8 && texFormat != eTF_B8G8R8A8 && texFormat != eTF_B8G8R8X8; - byte* const pImgDecomp = bTryDecompress ? new byte[nMipWidth * nMipHeight * sizeof(int32)] : pImgRaw; - const bool bImgDecompressed = bTryDecompress && pRenderer->DXTDecompress(pImgRaw, nRawSize, pImgDecomp, nMipWidth, nMipHeight, 1, texFormat, false, sizeof(int32)); - - // Check which conversions need to be performed - const bool bSRGB = (pImage->mfGet_Flags() & CImageExtensionHelper::EIF_SRGBRead) != 0; - const bool bSwap = (texFormat == eTF_R8G8B8A8) || bTryDecompress; - - HICON result = NULL; - if (!bTryDecompress || bImgDecompressed) - { - // Assign texture data with mismatching sizes - // Note: Any pixels not in the selected mip will become 100% transparent black, no resizing is performed - const size_t sourceRowStride = nMipWidth; - const size_t targetRowStride = nRequestedWidth; - const uint32* pSourceRow = (uint32*)pImgDecomp; - uint32* pTargetRow = (uint32*)lpBits; - - assert(sourceRowStride <= targetRowStride); - assert(nMipHeight <= nRequestedHeight); - assert(pSourceRow != pTargetRow); - assert(pSourceRow && pTargetRow); - - uint8 gammaTable[256]; - if (!bSRGB) - { - // Linear to sRGB table - const float gamma = 1.0f / 2.2f; - const float gammaMultiplier = 255.0f / powf(255.0f, gamma); - for (int i = 0; i < 256; ++i) - { - gammaTable[i] = uint8(powf(float(i), gamma) * gammaMultiplier); - } - } - else if (bSwap) - { - // sRGB to sRGB table (no change) - for (int i = 0; i < 256; ++i) - { - gammaTable[i] = uint8(i); - } - } - - for (int y = 0; y < nMipHeight; ++y, pSourceRow += sourceRowStride, pTargetRow += targetRowStride) - { - if (!bSwap && bSRGB) - { - memcpy(pTargetRow, pSourceRow, sourceRowStride * sizeof(uint32)); - } - else - { - const uint32* pSourceTexel = pSourceRow; - uint32* pTargetTexel = pTargetRow; - for (int x = 0; x < nMipWidth; ++x, ++pSourceTexel, ++pTargetTexel) - { - const uint8 red = gammaTable[uint8(*pSourceTexel >> 0)]; - const uint8 green = gammaTable[uint8(*pSourceTexel >> 8)]; - const uint8 blue = gammaTable[uint8(*pSourceTexel >> 16)]; - const uint32 alpha = *pSourceTexel & 0xFF000000; - *pTargetTexel = (red << (bSwap ? 16 : 0)) | (green << 8) | (blue << (bSwap ? 0 : 16)) | alpha; - } - } - - // Fill remaining columns with zeros - memset(pTargetRow + sourceRowStride, 0, (targetRowStride - sourceRowStride) * sizeof(uint32)); - } - - // Fill remaining rows with zeros - for (int y = nMipHeight; y < nRequestedHeight; ++y) - { - memset(pTargetRow, 0, targetRowStride * sizeof(uint32)); - pTargetRow += targetRowStride; - } - - // Convert to GDI icon - ICONINFO iconinfo = {0}; - iconinfo.fIcon = type == eResourceType_Cursor ? FALSE : TRUE; - iconinfo.hbmMask = ::CreateBitmap(nRequestedWidth, nRequestedHeight, 1, 1, NULL); - iconinfo.hbmColor = hBitmap; - result = ::CreateIconIndirect(&iconinfo); - DeleteObject(iconinfo.hbmMask); - } - - // Clean up - DeleteObject(hBitmap); - if (bTryDecompress) - { - delete[] pImgDecomp; - } - pImage.reset(); - - return result; -} - -#endif diff --git a/Code/CryEngine/CryCommon/crycommon_files.cmake b/Code/CryEngine/CryCommon/crycommon_files.cmake index ef49370c08..7d169c2643 100644 --- a/Code/CryEngine/CryCommon/crycommon_files.cmake +++ b/Code/CryEngine/CryCommon/crycommon_files.cmake @@ -14,9 +14,6 @@ set(FILES CryCommon.cpp Allocator.h FinalizingSpline.h - Gem.h - I3DEngine.h - I3DEngine_info.h IAudioInterfacesCommonData.h IAudioSystem.h IChunkFile.h @@ -86,7 +83,6 @@ set(FILES ITexture.h IThreadManager.h IThreadTask.h - ITimeOfDay.h ITimer.h IValidator.h IVideoRenderer.h @@ -143,7 +139,6 @@ set(FILES CryAssert.h CryCrc32.h CryCustomTypes.h - CryEngineDecalInfo.h CryFile.h CryFixedArray.h CryFixedString.h @@ -292,7 +287,6 @@ set(FILES platform_impl.cpp Win32specific.h Win64specific.h - WindowsUtils.h CryExtension/CryCreateClassInstance.h CryExtension/CryGUID.h CryExtension/CryTypeID.h @@ -317,7 +311,6 @@ set(FILES CryPool/STLWrapper.h CryPool/ThreadSafe.h stl/STLAlignedAlloc.h - ILocalMemoryUsage.h Serialization/Assert.h Serialization/BitVector.h Serialization/BitVectorImpl.h diff --git a/Code/CryEngine/CryCommon/crycommon_testing_files.cmake b/Code/CryEngine/CryCommon/crycommon_testing_files.cmake index ca133c2497..d20a33f791 100644 --- a/Code/CryEngine/CryCommon/crycommon_testing_files.cmake +++ b/Code/CryEngine/CryCommon/crycommon_testing_files.cmake @@ -10,7 +10,6 @@ # set(FILES - Mocks/I3DEngineMock.h Mocks/IAudioSystemMock.h Mocks/IConsoleMock.h Mocks/ICryPakMock.h diff --git a/Code/CryEngine/CrySystem/CrySystem_precompiled.h b/Code/CryEngine/CrySystem/CrySystem_precompiled.h index 6cf4c6005a..b446199b4e 100644 --- a/Code/CryEngine/CrySystem/CrySystem_precompiled.h +++ b/Code/CryEngine/CrySystem/CrySystem_precompiled.h @@ -102,7 +102,6 @@ inline int RoundToClosestMB(size_t memSize) #include #include #include -#include #include #include #include @@ -127,7 +126,6 @@ namespace AZ::IO struct IArchive; } struct ICryFont; -struct I3DEngine; struct IMovieSystem; struct IAudioSystem; struct IPhysicalWorld; diff --git a/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp b/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp index 996dee7810..d31f122d9b 100644 --- a/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp +++ b/Code/CryEngine/CrySystem/LevelSystem/LevelSystem.cpp @@ -193,10 +193,6 @@ static void UnloadMap([[maybe_unused]] IConsoleCmdArgs* args) if (gEnv->pSystem && gEnv->pSystem->GetILevelSystem() && !gEnv->IsEditor()) { gEnv->pSystem->GetILevelSystem()->UnloadLevel(); - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->LoadEmptyLevel(); - } } } @@ -674,18 +670,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName) pSpamDelay->Set(0.0f); } - if (gEnv->p3DEngine) - { - bool is3DEngineLoaded = gEnv->IsEditor() ? gEnv->p3DEngine->InitLevelForEditor(pLevelInfo->GetPath(), pLevelInfo->m_defaultGameTypeName.c_str()) - : gEnv->p3DEngine->LoadLevel(pLevelInfo->GetPath(), pLevelInfo->m_defaultGameTypeName.c_str()); - if (!is3DEngineLoaded) - { - OnLoadingError(levelName, "3DEngine failed to handle loading the level"); - - return 0; - } - } - // Parse level specific config data. AZStd::string const sLevelNameOnly(PathUtil::GetFileName(levelName)); @@ -760,14 +744,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName) gEnv->pSystem->SetSystemGlobalState(ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PRECACHE); - ////////////////////////////////////////////////////////////////////////// - // Notify 3D engine that loading finished - ////////////////////////////////////////////////////////////////////////// - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->PostLoadLevel(); - } - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// gEnv->pConsole->SetScrollMax(600 / 2); @@ -991,18 +967,6 @@ void CLevelSystem::UnloadLevel() CTimeValue tBegin = gEnv->pTimer->GetAsyncTime(); - I3DEngine* p3DEngine = gEnv->p3DEngine; - if (p3DEngine) - { - IDeferredPhysicsEventManager* pPhysEventManager = p3DEngine->GetDeferredPhysicsEventManager(); - if (pPhysEventManager) - { - // clear deferred physics queues before renderer, since we could have jobs running - // which access a rendermesh - pPhysEventManager->ClearDeferredEvents(); - } - } - //AM: Flush render thread (Flush is not exposed - using EndFrame()) //We are about to delete resources that could be in use if (gEnv->pRenderer) @@ -1076,25 +1040,10 @@ void CLevelSystem::UnloadLevel() SAFE_RELEASE(m_pCurrentLevel); - /* - Force Lua garbage collection before p3DEngine->UnloadLevel() and pRenderer->FreeResources(flags) are called. - p3DEngine->UnloadLevel() will destroy particle emitters even if they're still referenced by Lua objects that are yet to be collected. - (as per comment in 3dEngineLoad.cpp (line 501) - "Force to clean all particles that are left, even if still referenced."). - Then, during the next GC cycle, Lua finally cleans up, the particle emitter smart pointers will be pointing to invalid memory). - Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event), which is too late - (after the render resources have been purged). - This extra GC step takes a few ms more level unload time, which is a small price for fixing nasty crashes. - If, however, we wanted to claim it back, we could potentially get rid of the GC step that is triggered by ESYSTEM_EVENT_LEVEL_POST_UNLOAD to break even. - */ - + // Force Lua garbage collection (may no longer be needed now the legacy renderer has been removed). + // Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event). EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect); - // Delete engine resources - if (p3DEngine) - { - p3DEngine->UnloadLevel(); - - } // Force to clean render resources left after deleting all objects and materials. IRenderer* pRenderer = gEnv->pRenderer; if (pRenderer) diff --git a/Code/CryEngine/CrySystem/LevelSystem/SpawnableLevelSystem.cpp b/Code/CryEngine/CrySystem/LevelSystem/SpawnableLevelSystem.cpp index 67bf0a6c8e..4b6e210522 100644 --- a/Code/CryEngine/CrySystem/LevelSystem/SpawnableLevelSystem.cpp +++ b/Code/CryEngine/CrySystem/LevelSystem/SpawnableLevelSystem.cpp @@ -55,10 +55,6 @@ namespace LegacyLevelSystem if (gEnv->pSystem && gEnv->pSystem->GetILevelSystem() && !gEnv->IsEditor()) { gEnv->pSystem->GetILevelSystem()->UnloadLevel(); - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->LoadEmptyLevel(); - } } } @@ -262,22 +258,6 @@ namespace LegacyLevelSystem pSpamDelay->Set(0.0f); } - if (gEnv->p3DEngine) - { - AZ::IO::PathView levelPath(levelName); - AZStd::string parentPath(levelPath.ParentPath().Native()); - - static constexpr const char* defaultGameTypeName = "Mission0"; - bool is3DEngineLoaded = gEnv->IsEditor() ? gEnv->p3DEngine->InitLevelForEditor(parentPath.c_str(), defaultGameTypeName) - : gEnv->p3DEngine->LoadLevel(parentPath.c_str(), defaultGameTypeName); - if (!is3DEngineLoaded) - { - OnLoadingError(levelName, "3DEngine failed to handle loading the level"); - - return 0; - } - } - // Parse level specific config data. AZStd::string const sLevelNameOnly(PathUtil::GetFileName(levelName)); @@ -340,14 +320,6 @@ namespace LegacyLevelSystem gEnv->pSystem->SetSystemGlobalState(ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_START_PRECACHE); - ////////////////////////////////////////////////////////////////////////// - // Notify 3D engine that loading finished - ////////////////////////////////////////////////////////////////////////// - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->PostLoadLevel(); - } - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// gEnv->pConsole->SetScrollMax(600 / 2); @@ -569,18 +541,6 @@ namespace LegacyLevelSystem CTimeValue tBegin = gEnv->pTimer->GetAsyncTime(); - I3DEngine* p3DEngine = gEnv->p3DEngine; - if (p3DEngine) - { - IDeferredPhysicsEventManager* pPhysEventManager = p3DEngine->GetDeferredPhysicsEventManager(); - if (pPhysEventManager) - { - // clear deferred physics queues before renderer, since we could have jobs running - // which access a rendermesh - pPhysEventManager->ClearDeferredEvents(); - } - } - // AM: Flush render thread (Flush is not exposed - using EndFrame()) // We are about to delete resources that could be in use if (gEnv->pRenderer) @@ -644,25 +604,10 @@ namespace LegacyLevelSystem GetISystem()->GetIResourceManager()->UnloadLevel(); - /* - Force Lua garbage collection before p3DEngine->UnloadLevel() and pRenderer->FreeResources(flags) are called. - p3DEngine->UnloadLevel() will destroy particle emitters even if they're still referenced by Lua objects that are yet to be - collected. (as per comment in 3dEngineLoad.cpp (line 501) - "Force to clean all particles that are left, even if still referenced."). - Then, during the next GC cycle, Lua finally cleans up, the particle emitter smart pointers will be pointing to invalid memory). - Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event), which is too late - (after the render resources have been purged). - This extra GC step takes a few ms more level unload time, which is a small price for fixing nasty crashes. - If, however, we wanted to claim it back, we could potentially get rid of the GC step that is triggered by - ESYSTEM_EVENT_LEVEL_POST_UNLOAD to break even. - */ - + // Force Lua garbage collection (may no longer be needed now the legacy renderer has been removed). + // Normally the GC step is triggered at the end of this method (by the ESYSTEM_EVENT_LEVEL_POST_UNLOAD event). EBUS_EVENT(AZ::ScriptSystemRequestBus, GarbageCollect); - // Delete engine resources - if (p3DEngine) - { - p3DEngine->UnloadLevel(); - } // Force to clean render resources left after deleting all objects and materials. IRenderer* pRenderer = gEnv->pRenderer; if (pRenderer) diff --git a/Code/CryEngine/CrySystem/PerfHUD.cpp b/Code/CryEngine/CrySystem/PerfHUD.cpp index 23a5fc0ced..2aeabe2650 100644 --- a/Code/CryEngine/CrySystem/PerfHUD.cpp +++ b/Code/CryEngine/CrySystem/PerfHUD.cpp @@ -22,7 +22,6 @@ #include "MiniGUI/MiniMenu.h" #include "MiniGUI/MiniTable.h" #include -#include #include #include "System.h" @@ -853,21 +852,6 @@ void CPerfHUD::SaveStatsCallback([[maybe_unused]] void* data, [[maybe_unused]] b // RENDER CALLBACKS ////////////////////////////////////////////////////////////////////////// -/* -void CPerfHUD::DisplayRenderInfoCallback(const Rect& rect) -{ - IMiniGUIPtr pGUI; - if (CryCreateClassInstanceForInterface( cryiidof(),pGUI )) - { - //right aligned display - float x = rect.right; - float y = rect.top; - float step = 13.f; - - gEnv->p3DEngine->DisplayInfo(x, y, step, true); - } -}*/ - void CPerfHUD::EnableWidget(ICryPerfHUDWidget::EWidgetID id, int mode) { const int nWidgets = m_widgets.size(); @@ -1530,26 +1514,6 @@ void CRenderStatsWidget::Update() m_runtimeData.nFwdLights = 0; m_runtimeData.nFwdShadowLights = 0; - ////////////////////////////////////////////////////////////////////////// - if (gEnv->p3DEngine) - { - I3DEngine::SObjectsStreamingStatus objStats; - gEnv->p3DEngine->GetObjectsStreamingStatus(objStats); - - float fMeshRequiredMB = (float)(objStats.nMemRequired) / (1024 * 1024); - sprintf_s(entryBuffer, "Mesh Required: %.2f (%dMB)", fMeshRequiredMB, azlossy_cast(objStats.nMeshPoolSize)); - if (fMeshRequiredMB < objStats.nMeshPoolSize) - { - m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_NORM, CPerfHUD::TEXT_SIZE_NORM); - } - else - { - m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_ERROR, CPerfHUD::TEXT_SIZE_NORM); - CryPerfHUDWarning(1.f, "Too Many Geometry: %.2fMB", fMeshRequiredMB); - } - } - - ////////////////////////////////////////////////////////////////////////// if (gEnv->pRenderer) { @@ -1727,25 +1691,6 @@ CStreamingStatsWidget::CStreamingStatsWidget(IMiniCtrl* pParentMenu, ICryPerfHUD ////////////////////////////////////////////////////////////////////////// void CStreamingStatsWidget::Update() { - char entryBuffer[CMiniInfoBox::MAX_TEXT_LENGTH] = {0}; - - //Clear old entries - m_pInfoBox->ClearEntries(); - - I3DEngine::SObjectsStreamingStatus objStats; - gEnv->p3DEngine->GetObjectsStreamingStatus(objStats); - - float fMeshRequiredMB = (float)(objStats.nMemRequired) / (1024 * 1024); - sprintf_s(entryBuffer, "Mesh Required: %.2f (%dMB)", fMeshRequiredMB, objStats.nMeshPoolSize); - if (fMeshRequiredMB < objStats.nMeshPoolSize) - { - m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_NORM, CPerfHUD::TEXT_SIZE_NORM); - } - else - { - m_pInfoBox->AddEntry(entryBuffer, CPerfHUD::COL_ERROR, CPerfHUD::TEXT_SIZE_NORM); - CryPerfHUDWarning(1.f, "Too Many Geometry: %.2fMB", fMeshRequiredMB); - } } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/CryEngine/CrySystem/Statistics/LocalMemoryUsage.cpp b/Code/CryEngine/CrySystem/Statistics/LocalMemoryUsage.cpp deleted file mode 100644 index 7eb86de966..0000000000 --- a/Code/CryEngine/CrySystem/Statistics/LocalMemoryUsage.cpp +++ /dev/null @@ -1,1389 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Visual helper for checking a local memory usage on maps - -/* - TODO: - - Procedural vegetation - - - Permanent mip-map problem (streaming will collect a permanent mip-maps when travelling) - - ? Foliage render nodes - - must make a decision about the local / global problem: - - Particle effects (must check the calculation) - - Characters (calculation is DONE) - - - StatObj LOD streaming (I think that there is no LOD streaming, but i'm not sure about this) - - Terrain texture streaming (not detail textures!) //It's not needed because this system using a fix-size pool - - Animation streaming: completely different system, not need to measure now - - IsoMesh streaming: completely different system, not need to measure now -*/ - - -#include "CrySystem_precompiled.h" - -#include "LocalMemoryUsage.h" - -#include -#include -#include -#include - -#include - -//#define MAX_LODS 6 // I want an engine-wide const :-( -#define MAX_SLOTS 100 // GetSlotCount() is not working :-( -#define BIG_NUMBER 1e20f - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace LocalMemoryUsageDrawHelper -{ - enum eDrawRectParams - { - DSP_YDIR = 0, - DSP_XDIR = 1, - DSP_REVERSE_TRIANGLES = 2, - DSP_REVERSE_ARROW = 4, - }; - - void DrawRect(IRenderer* pRenderer, const CCamera* camera, const Vec3& p1, const Vec3& p3, const ColorB& color, int params = 0) - { - Vec3 p2, p4, projectedPos; - if (!(params & DSP_REVERSE_TRIANGLES)) - { - if (params & DSP_XDIR) - { - p2 = Vec3(p1.x, p3.y, p1.z); - p4 = Vec3(p3.x, p1.y, p3.z); - } - else - { - p2 = Vec3(p1.x, p3.y, p3.z); - p4 = Vec3(p3.x, p1.y, p1.z); - } - } - else - { - if (params & DSP_XDIR) - { - p4 = Vec3(p1.x, p3.y, p1.z); - p2 = Vec3(p3.x, p1.y, p3.z); - } - else - { - p4 = Vec3(p1.x, p3.y, p3.z); - p2 = Vec3(p3.x, p1.y, p1.z); - } - } - - if (camera->Project(p1, projectedPos) || camera->Project(p2, projectedPos) || camera->Project(p3, projectedPos) || camera->Project(p4, projectedPos)) - { - IRenderAuxGeom* pRenderAuxGeom = pRenderer->GetIRenderAuxGeom(); - - pRenderAuxGeom->DrawTriangle(p1, color, p2, color, p3, color); - pRenderAuxGeom->DrawTriangle(p3, color, p4, color, p1, color); - } - } - - void DrawArrow(IRenderer* pRenderer, const CCamera* camera, Vec3 pStart, Vec3 pEnd, float width, float head, float lengthSub, const ColorB& color, int params = 0) - { - Vec3 p1, p2, p3, p4, p5, p6, p7, projectedPos; - - if (params & DSP_REVERSE_ARROW) - { - std::swap(pStart, pEnd); - } - - Vec3 vParallel((pEnd - pStart).GetNormalized()); - Vec3 vOrto = vParallel.Cross(Vec3(0, 0, 1)).GetNormalized(); - pStart += vParallel * lengthSub; - pEnd -= vParallel * lengthSub; - - p1 = pStart - (vOrto * width * 0.5f); - p2 = pStart + (vOrto * width * 0.5f); - p3 = (pEnd - vParallel * head) - (vOrto * width * 0.5f); - p4 = (pEnd - vParallel * head) + (vOrto * width * 0.5f); - p5 = (pEnd - vParallel * head * 1.5f) - (vOrto * head * 0.9f); - p6 = (pEnd - vParallel * head * 1.5f) + (vOrto * head * 0.9f); - p7 = pEnd; - - if (camera->Project(p1, projectedPos) || camera->Project(p7, projectedPos)) - { - IRenderAuxGeom* pRenderAuxGeom = pRenderer->GetIRenderAuxGeom(); - - pRenderAuxGeom->DrawTriangle(p1, color, p2, color, p4, color); - pRenderAuxGeom->DrawTriangle(p4, color, p3, color, p1, color); - pRenderAuxGeom->DrawTriangle(p3, color, p4, color, p7, color); - pRenderAuxGeom->DrawTriangle(p4, color, p6, color, p7, color); - pRenderAuxGeom->DrawTriangle(p5, color, p3, color, p7, color); - } - } - - #define DRAWHELPER_CIRCLE_POINT_NR 32 - - - static Vec3 s_CirclePoints[DRAWHELPER_CIRCLE_POINT_NR + 1]; - static bool s_CircleDataInited = false; - void InitCircleData() - { - s_CircleDataInited = true; - float angleDiff = 2.0f * 3.1415927f / DRAWHELPER_CIRCLE_POINT_NR; - - for (int i = 0; i < DRAWHELPER_CIRCLE_POINT_NR + 1; i++) - { - s_CirclePoints[i] = Vec3(cos(i * angleDiff), sin(i * angleDiff), 0.0f); - } - } - - void DrawCircle(IRenderer* pRenderer, [[maybe_unused]] const CCamera* camera, const Vec3& origo, float radius, float ratio, const ColorB& color1, const ColorB& color2) - { - if (!s_CircleDataInited) - { - InitCircleData(); - } - float radius2 = radius * 0.90f; - - IRenderAuxGeom* pRenderAuxGeom = pRenderer->GetIRenderAuxGeom(); - - Vec3 oldPoint = origo + s_CirclePoints[0] * radius; - Vec3 oldPoint2 = origo + s_CirclePoints[0] * radius2; - - for (int i = 0; i < DRAWHELPER_CIRCLE_POINT_NR; i++) - { - Vec3 newPoint = origo + s_CirclePoints[i + 1] * radius; - Vec3 newPoint2 = origo + s_CirclePoints[i + 1] * radius2; - if (i < ratio * DRAWHELPER_CIRCLE_POINT_NR) - { - pRenderAuxGeom->DrawTriangle(origo, color1, oldPoint, color1, newPoint, color1); - } - else - { - //pRenderAuxGeom->DrawTriangle( origo, color2, oldPoint, color2, newPoint, color2 ); - pRenderAuxGeom->DrawTriangle(oldPoint2, color2, oldPoint, color2, newPoint, color2); - pRenderAuxGeom->DrawTriangle(newPoint, color2, newPoint2, color2, oldPoint2, color2); - } - oldPoint = newPoint; - oldPoint2 = newPoint2; - } - } -} - -/* -namespace Distance -{ - // Distance: AABB_AABB - //---------------------------------------------------------------------------------- - // Calculate the closest distance of a AABB to an another AABB in 3d-space. - // The function returns the squared distance. - // optionally the closest point on the hull is calculated - // - // Example: - // float result = Distance::Point_AABBSq( aabb1, aabb2 ); - //---------------------------------------------------------------------------------- - - ILINE float AABB_AABBSq( const AABB& aabb1, const AABB& aabb2 ) - { - float fDist2 = 0; - for(int i=0; i<3; ++i) - { - float max1 = aabb1.max[i]; - if(max1 < aabb2.min[i]) - { - fDist2 += sqr(max1-aabb2.min[i]); - } - else - { - float min1 = aabb1.min[i]; - if(min1 > aabb2.max[i]) - { - fDist2 += sqr(aabb2.max[i]-min1); - } - } - } - return fDist2; - } - - // Distance: AABB_AABB_2D - //---------------------------------------------------------------------------------- - // Calculate the closest distance of a AABB to an another AABB in 2d-space. - // The function returns the squared distance. - // optionally the closest point on the hull is calculated - // - // Example: - // float result = Distance::AABB_AABB2DSq( aabb1, aabb2 ); - //---------------------------------------------------------------------------------- - - ILINE float AABB_AABB2DSq( const AABB& aabb1, const AABB& aabb2 ) - { - float fDist2 = 0; - for(int i=0; i<2; ++i) //We are using only 2 of the dimensions! - { - float max1 = aabb1.max[i]; - if(max1 < aabb2.min[i]) - { - fDist2 += sqr(max1-aabb2.min[i]); - } - else - { - float min1 = aabb1.min[i]; - if(min1 > aabb2.max[i]) - { - fDist2 += sqr(aabb2.max[i]-min1); - } - } - } - return fDist2; - } -} -*/ - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -int CLocalMemoryUsage::SResource::m_arrMemoryUsage[LOCALMEMORY_SECTOR_PER_PASS]; -int CLocalMemoryUsage::SResource::m_arrPieces[LOCALMEMORY_SECTOR_PER_PASS]; - - -CLocalMemoryUsage::SResource::SResource() -{ - m_used = true; -} - -void CLocalMemoryUsage::SResource::Init(CLocalMemoryUsage* pLocalMemoryUsage) -{ - m_pLocalMemoryUsage = pLocalMemoryUsage; - - StartChecking(); -} - -void CLocalMemoryUsage::SResource::StartChecking() -{ - const RectI& actProcessedSectors = m_pLocalMemoryUsage->m_actProcessedSectors; - - float* pMipFactor = m_arrMipFactor; - for (int i = 0; i < actProcessedSectors.w * actProcessedSectors.h; i++) - { - *pMipFactor = BIG_NUMBER; - pMipFactor++; - } - bool* pRowDirty = m_arrRowDirty; - for (int i = 0; i < LOCALMEMORY_SECTOR_PER_PASS; i++) - { - *pRowDirty = false; - pRowDirty++; - } -} - -void CLocalMemoryUsage::SResource::CheckOnAllSectorsP1(const AABB& bounding, float maxViewDist, float scale, float mipFactor) -{ - //FRAME_PROFILER("! CLocalMemoryUsage::SResource::CheckOnAllSectorsP1", GetISystem(), PROFILE_SYSTEM); - - float modifiedmaxViewDist = maxViewDist; - float modifiedmaxViewDistSqr = sqr(modifiedmaxViewDist); - - const RectI& actProcessedSectors = m_pLocalMemoryUsage->m_actProcessedSectors; - - int xMin = (int)max(0, int((bounding.min.x - modifiedmaxViewDist) / LOCALMEMORY_SECTOR_SIZE ) - actProcessedSectors.x); - int xMax = (int)min(actProcessedSectors.w, int((bounding.max.x + modifiedmaxViewDist) / LOCALMEMORY_SECTOR_SIZE + 1) - actProcessedSectors.x); - int yMin = (int)max(0, int((bounding.min.y - modifiedmaxViewDist) / LOCALMEMORY_SECTOR_SIZE ) - actProcessedSectors.y); - int yMax = (int)min(actProcessedSectors.h, int((bounding.max.y + modifiedmaxViewDist) / LOCALMEMORY_SECTOR_SIZE + 1) - actProcessedSectors.y); - - AABB sectorBounding(AABB::RESET); - float sectorDistanceSqr; - float fDistYSqr; - - for (int y = yMin; y < yMax; y++) - { - float* pMipFactor = &m_arrMipFactor[actProcessedSectors.w * y + xMin]; - - sectorBounding.min.y = (y + actProcessedSectors.y) * LOCALMEMORY_SECTOR_SIZE; - sectorBounding.max.y = sectorBounding.min.y + LOCALMEMORY_SECTOR_SIZE; - sectorBounding.min.x = (xMin + actProcessedSectors.x) * LOCALMEMORY_SECTOR_SIZE; - - assert(y < LOCALMEMORY_SECTOR_PER_PASS); - m_arrRowDirty[y] = true; - - //Calculating Y distance sqr - { - fDistYSqr = 0; - if (bounding.max.y < sectorBounding.min.y) - { - fDistYSqr += sqr(bounding.max.y - sectorBounding.min.y); - } - else - { - if (bounding.min.y > sectorBounding.max.y) - { - fDistYSqr += sqr(sectorBounding.max.y - bounding.min.y); - } - } - } - - for (int x = xMin; x < xMax; x++) - { - sectorBounding.max.x = sectorBounding.min.x + LOCALMEMORY_SECTOR_SIZE; - - //sectorDistanceSqr = Distance::AABB_AABB2DSq(bounding, sectorBounding); - - //Adding X distance sqr - { - sectorDistanceSqr = fDistYSqr; - if (bounding.max.x < sectorBounding.min.x) - { - sectorDistanceSqr += sqr(bounding.max.x - sectorBounding.min.x); - } - else - { - if (bounding.min.x > sectorBounding.max.x) - { - sectorDistanceSqr += sqr(sectorBounding.max.x - bounding.min.x); - } - } - } - - if (sectorDistanceSqr < modifiedmaxViewDistSqr) - { - *pMipFactor = min(*pMipFactor, sectorDistanceSqr * scale * scale * mipFactor); - } - - pMipFactor++; - - sectorBounding.min.x = sectorBounding.max.x; - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CLocalMemoryUsage::STextureInfo::STextureInfo() -{ - m_pTexture = NULL; - - //m_size = 0; - //m_xSize = 0; - //m_ySize = 0; - //m_numMips = 0; -} - -CLocalMemoryUsage::STextureInfo::~STextureInfo() -{ - if (m_pTexture) - { - m_pTexture->Release(); - } -} - -void CLocalMemoryUsage::STextureInfo::CheckOnAllSectorsP2() -{ - int x, y, nMip, nStreamableMipNr, memoryUsage, xOldMemoryUsage, xOldPieces; - bool nonZero; - ITexture* pTexture; - - const RectI& actProcessedSectors = m_pLocalMemoryUsage->m_actProcessedSectors; - - bool wasDirty = false; - for (y = 0; y < actProcessedSectors.h; y++) - { - int* pMemoryUsage = m_arrMemoryUsage; - int* pPieces = m_arrPieces; - if (m_arrRowDirty[y] || (wasDirty)) - { - SSector* sector = &m_pLocalMemoryUsage->m_arrSectors[(y + actProcessedSectors.y) * LOCALMEMORY_SECTOR_NR_X + actProcessedSectors.x]; - float* pMipFactor = &m_arrMipFactor[y * actProcessedSectors.w ]; - xOldMemoryUsage = 0; - xOldPieces = 0; - for (x = 0; x < actProcessedSectors.w; x++) - { - nonZero = (*pMipFactor != BIG_NUMBER); - if (nonZero) // One more row - { - pTexture = m_pTexture; - if (!nonZero) - { - memoryUsage = 0; - nStreamableMipNr = 0; - } - else - { - nMip = max(0, pTexture->StreamCalculateMipsSigned(*pMipFactor)); - memoryUsage = pTexture->GetStreamableMemoryUsage(nMip); - nStreamableMipNr = pTexture->GetStreamableMipNumber() - nMip; - } - - sector->m_memoryUsage_Textures += memoryUsage; - - xOldMemoryUsage = memoryUsage; - *pMemoryUsage = memoryUsage; - xOldPieces = nStreamableMipNr; - *pPieces = nStreamableMipNr; - } - else - { - xOldMemoryUsage = 0; - *pMemoryUsage = 0; - xOldPieces = 0; - *pPieces = 0; - } - sector++; - pMipFactor++; - pMemoryUsage++; - pPieces++; - } - wasDirty = m_arrRowDirty[y]; - } - else - { - for (x = 0; x < actProcessedSectors.w; x++) - { - *pMemoryUsage = 0; - pMemoryUsage++; - *pPieces = 0; - pPieces++; - } - wasDirty = false; - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CLocalMemoryUsage::SMaterialInfo::SMaterialInfo() -{ -} - -void CLocalMemoryUsage::SMaterialInfo::AddTextureInfo(STextureInfoAndTilingFactor textureInfo) -{ - m_textures.push_back(textureInfo); -} - -void CLocalMemoryUsage::SMaterialInfo::CheckOnAllSectorsP2() -{ - int x, y; - - const RectI& actProcessedSectors = m_pLocalMemoryUsage->m_actProcessedSectors; - - for (y = 0; y < actProcessedSectors.h; y++) - { - if (m_arrRowDirty[y]) - { - float* pMipFactor = &m_arrMipFactor[y * actProcessedSectors.w ]; - for (x = 0; x < actProcessedSectors.w; x++) - { - if (*pMipFactor != BIG_NUMBER) - { - //(Spidy) Send the material MinDistance values to textures - for (TTextureVector::iterator it = m_textures.begin(); it != m_textures.end(); ++it) - { - STextureInfoAndTilingFactor& textureInfo = *it; - textureInfo.m_pTextureInfo->m_arrRowDirty[y] = true; - - float& textureMipFactor = textureInfo.m_pTextureInfo->m_arrMipFactor[actProcessedSectors.w * y + x]; - textureMipFactor = min(textureMipFactor, *pMipFactor * textureInfo.m_tilingFactor); - } - } - pMipFactor++; - } - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CLocalMemoryUsage::SStatObjInfo::SStatObjInfo() -{ - m_streamableContentMemoryUsage = 0; - - m_bSubObject = false; - /* - m_lodNr = 0; - m_vertices = 0; - m_indices = 0; - m_meshSize = 0; - m_physProxySize = 0; - m_physPrimitives = 0; - for( int i=0; i < MAX_LODS; i++) - { - m_indicesPerLod[i]=0; - } - */ -} - -void CLocalMemoryUsage::SStatObjInfo::CheckOnAllSectorsP2() -{ - int x, y, memoryUsage, pieces, xOldMemoryUsage, xOldPieces; - bool nonZero; - - const RectI& actProcessedSectors = m_pLocalMemoryUsage->m_actProcessedSectors; - - bool wasDirty = false; - for (y = 0; y < actProcessedSectors.h; y++) - { - int* pMemoryUsage = m_arrMemoryUsage; - int* pPieces = m_arrPieces; - if (m_arrRowDirty[y]) - { - SSector* sector = &m_pLocalMemoryUsage->m_arrSectors[(y + actProcessedSectors.y) * LOCALMEMORY_SECTOR_NR_X + actProcessedSectors.x]; - float* pMipFactor = &m_arrMipFactor[y * actProcessedSectors.w ]; - xOldMemoryUsage = 0; - xOldPieces = 0; - for (x = 0; x < actProcessedSectors.w; x++) - { - nonZero = (*pMipFactor != BIG_NUMBER); - if (nonZero) // One more row - { - /* - memoryUsage = 0; - float minDistance = sqrt_tpl(minDistanceSqr); - CStatObj* pStatObj = (CStatObj*)(m_pStatObj.get()); //(Spidy) Huh... - - //Iterate on all subobjects, like CStatObj::UpdateStreamableComponents - float fSubObjectScale = 1.0f; - //float fSubObjectScale = matSubObject.GetColumn0().GetLength(); //TODO - int lod = pStatObj->GetLodFromScale(1.0f, fSubObjectScale, minDistance, false); - //(Spidy) az objMatrix scale es a fLodRatioNorm mar bele vannak szamolva a minDistance-ba! - memoryUsage = m_streamableContentMemoryUsage; - */ - memoryUsage = m_streamableContentMemoryUsage; - pieces = 1; - - if (!nonZero) - { - memoryUsage = 0; - pieces = 0; - } - - sector->m_memoryUsage_Geometry += memoryUsage; - - xOldMemoryUsage = memoryUsage; - *pMemoryUsage = memoryUsage; - xOldPieces = pieces; - *pPieces = pieces; - } - else - { - xOldMemoryUsage = 0; - *pMemoryUsage = 0; - xOldPieces = 0; - *pPieces = 0; - } - sector++; - pMipFactor++; - pMemoryUsage++; - pPieces++; - } - wasDirty = m_arrRowDirty[y]; - } - else - { - for (x = 0; x < actProcessedSectors.w; x++) - { - *pMemoryUsage = 0; - pMemoryUsage++; - *pPieces = 0; - pPieces++; - } - wasDirty = false; - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CLocalMemoryUsage::SSector::SSector() -{ - StartChecking(); -} - -void CLocalMemoryUsage::SSector::StartChecking() -{ - m_memoryUsage_Textures = 0; - m_memoryUsage_Geometry = 0; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CLocalMemoryUsage::CLocalMemoryUsage() -{ - REGISTER_CVAR(sys_LocalMemoryTextureLimit, 64, VF_NULL, "LocalMemoryUsage tool: Set the texture memory limit to check streaming (Mb/sec)"); - REGISTER_CVAR(sys_LocalMemoryGeometryLimit, 32, VF_NULL, "LocalMemoryUsage tool: Set the statobj geometry memory limit to check streaming (Mb/sec)"); - REGISTER_CVAR(sys_LocalMemoryTextureStreamingSpeedLimit, 10, VF_NULL, "LocalMemoryUsage tool: Texture streaming speed limit (approx, Mb/sec)"); - REGISTER_CVAR(sys_LocalMemoryGeometryStreamingSpeedLimit, 10, VF_NULL, "LocalMemoryUsage tool: Stat object geometry streaming speed limit (approx, Mb/sec)"); - - REGISTER_CVAR(sys_LocalMemoryWarningRatio, 0.8f, VF_NULL, "LocalMemoryUsage tool: Warning ratio for streaming"); - REGISTER_CVAR(sys_LocalMemoryOuterViewDistance, 500.f, VF_NULL, "LocalMemoryUsage tool: View distance for debug draw"); - REGISTER_CVAR(sys_LocalMemoryInnerViewDistance, 100.f, VF_NULL, "LocalMemoryUsage tool: View distance for detailed debug draw"); - - REGISTER_CVAR(sys_LocalMemoryStreamingSpeedObjectLength, 10.f, VF_NULL, "LocalMemoryUsage tool: Length of the streaming speed debug object"); - REGISTER_CVAR(sys_LocalMemoryStreamingSpeedObjectWidth, 1.5f, VF_NULL, "LocalMemoryUsage tool: Width of the streaming speed debug object"); - REGISTER_CVAR(sys_LocalMemoryObjectWidth, 6.f, VF_NULL, "LocalMemoryUsage tool: Width of the streaming buffer debug object"); - REGISTER_CVAR(sys_LocalMemoryObjectHeight, 2.f, VF_NULL, "LocalMemoryUsage tool: Height of the streaming buffer debug object"); - REGISTER_CVAR(sys_LocalMemoryObjectAlpha, 128, VF_NULL, "LocalMemoryUsage tool: Color alpha of the debug objects"); - - REGISTER_CVAR(sys_LocalMemoryDiagramWidth, 0.5f, VF_NULL, "LocalMemoryUsage tool: Width of the diagrams OBSOLATE"); - - REGISTER_CVAR(sys_LocalMemoryDiagramRadius, 2.5f, VF_NULL, "LocalMemoryUsage tool: Radius of the diagram"); - REGISTER_CVAR(sys_LocalMemoryDiagramDistance, -5.5f, VF_NULL, "LocalMemoryUsage tool: Distance of the diagram from the main debug object"); - REGISTER_CVAR(sys_LocalMemoryDiagramStreamingSpeedRadius, 1.0f, VF_NULL, "LocalMemoryUsage tool: Radius of the streaming speed diagram"); - REGISTER_CVAR(sys_LocalMemoryDiagramStreamingSpeedDistance, 2.2f, VF_NULL, "LocalMemoryUsage tool: Distance of the streaming speed diagram from the streaming speed debug line"); - REGISTER_CVAR(sys_LocalMemoryDiagramAlpha, 255, VF_NULL, "LocalMemoryUsage tool: Color alpha of the diagrams"); - - REGISTER_CVAR(sys_LocalMemoryDrawText, 0, VF_NULL, "LocalMemoryUsage tool: If != 0, it will draw the numeric values"); - REGISTER_CVAR(sys_LocalMemoryLogText, 0, VF_NULL, "LocalMemoryUsage tool: If != 0, it will log the numeric values"); - - REGISTER_CVAR(sys_LocalMemoryOptimalMSecPerSec, 100, VF_NULL, "LocalMemoryUsage tool: Optimal calculation time (MSec) per secundum"); - REGISTER_CVAR(sys_LocalMemoryMaxMSecBetweenCalls, 1000, VF_NULL, "LocalMemoryUsage tool: Maximal time difference (MSec) between calls"); - - m_pStreamCgfPredicitionDistance = 0; - m_pDebugDraw = 0; - if (gEnv->pConsole) - { - m_pStreamCgfPredicitionDistance = gEnv->pConsole->GetCVar("e_StreamCgfPredicitionDistance"); - m_pDebugDraw = gEnv->pConsole->GetCVar("e_DebugDraw"); - } - - m_sectorNr.zero(); - - m_actProcessedSectors = RectI(0, 0, 0, 0); - m_actDrawedSectors = RectI(0, 0, 0, 0); - - m_AverageUpdateTime = 0.01f; - - m_sectorNr.x = LOCALMEMORY_SECTOR_NR_X; //TODO Check size of the world - m_sectorNr.y = LOCALMEMORY_SECTOR_NR_Y; -} - -CLocalMemoryUsage::~CLocalMemoryUsage() -{ - DeleteGlobalData(); -} - -void CLocalMemoryUsage::DeleteGlobalData() -{ - m_globalTextures.clear(); - m_globalMaterials.clear(); - m_globalStatObjs.clear(); -} - -void CLocalMemoryUsage::OnRender(IRenderer* pRenderer, const CCamera* camera) -{ - if (!m_pDebugDraw || (m_pDebugDraw->GetIVal() != 17)) - { - return; - } - - const Matrix34& mat = camera->GetMatrix(); - Vec3 pos; - Vec3 projectedPos; - SSector* sector; - - SAuxGeomRenderFlags auxGeomRenderFlagsClose(e_Mode3D | e_AlphaBlended | e_DrawInFrontOn | e_FillModeSolid | e_CullModeBack | e_DepthWriteOff | e_DepthTestOff); - SAuxGeomRenderFlags auxGeomRenderFlagsFar(e_Mode3D | e_AlphaBlended | e_DrawInFrontOff | e_FillModeSolid | e_CullModeBack | e_DepthWriteOff | e_DepthTestOn); - - IRenderAuxGeom* pRenderAuxGeom = pRenderer->GetIRenderAuxGeom(); - - Vec3 cameraPos = mat.GetTranslation(); - - int xMin = max(0, int((cameraPos.x - sys_LocalMemoryOuterViewDistance) / LOCALMEMORY_SECTOR_SIZE)); - int xMax = min(LOCALMEMORY_SECTOR_PER_PASS - 1, int((cameraPos.x + sys_LocalMemoryOuterViewDistance) / LOCALMEMORY_SECTOR_SIZE + 1)); - int yMin = max(0, int((cameraPos.y - sys_LocalMemoryOuterViewDistance) / LOCALMEMORY_SECTOR_SIZE)); - int yMax = min(LOCALMEMORY_SECTOR_PER_PASS - 1, int((cameraPos.y + sys_LocalMemoryOuterViewDistance) / LOCALMEMORY_SECTOR_SIZE + 1)); - m_actDrawedSectors.x = xMin; - m_actDrawedSectors.y = yMin; - m_actDrawedSectors.w = xMax - xMin + 1; - m_actDrawedSectors.h = yMax - yMin + 1; - - CTimeValue actTime = gEnv->pTimer->GetAsyncTime(); - float timeSin = sin_tpl(actTime.GetSeconds() * 10.0f) * 0.5f + 0.5f; - - ColorB color; - ColorB colorOK(LOCALMEMORY_COLOR_OK, sys_LocalMemoryObjectAlpha); - ColorB colorWarning(LOCALMEMORY_COLOR_WARNING, sys_LocalMemoryObjectAlpha); - ColorB colorError(LOCALMEMORY_COLOR_ERROR, uint8(sys_LocalMemoryObjectAlpha * timeSin)); - ColorB colorTexture(LOCALMEMORY_COLOR_TEXTURE, sys_LocalMemoryDiagramAlpha); - ColorB colorGeometry(LOCALMEMORY_COLOR_GEOMETRY, sys_LocalMemoryDiagramAlpha); - ColorB colorBlack(LOCALMEMORY_COLOR_BLACK); - f32 fColorOK[4] = {LOCALMEMORY_FCOLOR_OK, 1}; - f32 fColorWarning[4] = {LOCALMEMORY_FCOLOR_WARNING, 1}; - f32 fColorError[4] = {LOCALMEMORY_FCOLOR_ERROR, 1}; - f32 fColorOther[4] = {LOCALMEMORY_FCOLOR_OTHER, 1}; - - f32* pColor; - Vec3 v0, v1, v2, v3, v4, vTextureDiagram, vTextureDiagram2, vGeometryDiagram, vGeometryDiagram2; - - float localMemoryTextureLimit = sys_LocalMemoryTextureLimit * 1024.f * 1024.f; - float localMemoryGeometryLimit = sys_LocalMemoryGeometryLimit * 1024.f * 1024.f; - - //The assumption is that this is called on Main Thread, otherwise the loop - //Should be wrapped inside a EnumerateHandlers lambda. - auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler(); - const float defaultTerrainHeight = AzFramework::Terrain::TerrainDataRequests::GetDefaultTerrainHeight(); - - for (int y = yMin; y < yMax; y++) - { - sector = &m_arrSectors[xMin + y * LOCALMEMORY_SECTOR_NR_X]; - for (int x = xMin; x < xMax; x++) - { - pos.x = (x + 0.5f) * LOCALMEMORY_SECTOR_SIZE; - pos.y = (y + 0.5f) * LOCALMEMORY_SECTOR_SIZE; - pos.z = terrain ? terrain->GetHeightFromFloats(pos.x, pos.y) : defaultTerrainHeight; - - if (m_pDebugDraw->GetIVal() == 17) - { - float textureRatio = sector->m_memoryUsage_Textures / localMemoryTextureLimit; - float geometryRatio = sector->m_memoryUsage_Geometry / localMemoryGeometryLimit; - float maxRatio = max(textureRatio, geometryRatio); - - v0 = pos; - v1 = pos + Vec3(-sys_LocalMemoryObjectWidth, -sys_LocalMemoryObjectWidth, sys_LocalMemoryObjectHeight); - v2 = pos + Vec3(sys_LocalMemoryObjectWidth, -sys_LocalMemoryObjectWidth, sys_LocalMemoryObjectHeight); - v3 = pos + Vec3(sys_LocalMemoryObjectWidth, sys_LocalMemoryObjectWidth, sys_LocalMemoryObjectHeight); - v4 = pos + Vec3(-sys_LocalMemoryObjectWidth, sys_LocalMemoryObjectWidth, sys_LocalMemoryObjectHeight); - - if (camera->Project(v1, projectedPos) || camera->Project(v2, projectedPos) || camera->Project(v3, projectedPos) || camera->Project(v4, projectedPos)) - { - vTextureDiagram = pos + Vec3(0.f, sys_LocalMemoryObjectWidth + sys_LocalMemoryDiagramDistance + sys_LocalMemoryDiagramRadius, sys_LocalMemoryObjectHeight); - vGeometryDiagram = pos + Vec3(0.f, -sys_LocalMemoryObjectWidth - sys_LocalMemoryDiagramDistance - sys_LocalMemoryDiagramRadius, sys_LocalMemoryObjectHeight); - - if (maxRatio < sys_LocalMemoryWarningRatio) - { - color = colorOK; - pColor = fColorOK; - } - else if (maxRatio < 1.0f) - { - color = colorWarning; - pColor = fColorWarning; - } - else - { - color = colorError; - pColor = fColorError; - } - - bool close = (Distance::Point_Point2D(cameraPos, pos) < sys_LocalMemoryInnerViewDistance); - if (close) - { - pRenderAuxGeom->SetRenderFlags(auxGeomRenderFlagsClose); - - static int xDebug = 14; - static int yDebug = 19; - - if (sys_LocalMemoryDrawText) - { - camera->Project(pos, projectedPos); - - pRenderer->Draw2dLabel(projectedPos.x, projectedPos.y, 1.2f, pColor, true, "Text: %.2fMb Geom: %.2fMb", sector->m_memoryUsage_Textures / (1024.f * 1024.f), sector->m_memoryUsage_Geometry / (1024.f * 1024.f)); - /* For sector debugging - pRenderer->Draw2dLabel(projectedPos.x, projectedPos.y, 1.2f, pColor, true, "Text: %.1fMb Geom: %.1fMb - %d : %d", sector->m_memoryUsage_Textures/(1024.f*1024.f), sector->m_memoryUsage_Geometry/(1024.f*1024.f), x, y); - - if( xDebug == x && yDebug == y ) - { - float sx = projectedPos.x-80; - float sy = projectedPos.y; - - for( TStatObjMap::iterator it = m_globalStatObjs.begin(); it != m_globalStatObjs.end(); ++it ) - { - SStatObjInfo *statObjInfo = &it->second; - IStatObj* pStatObj = statObjInfo->m_pStatObj; - - int memoryUsage = 0; - float mipFactor = statObjInfo->m_arrMipFactor[y * m_actProcessedSectors.w + x]; - if( mipFactor != BIG_NUMBER ) - { - memoryUsage = statObjInfo->m_streamableContentMemoryUsage; - } - sy+=15.f; - pRenderer->Draw2dLabel(sx, sy, 1.2f, pColor, false, "Geom: %.2fMb %.4f Act:%s Orig:%s %s", memoryUsage/(1024.f*1024.f), mipFactor, pStatObj->GetFilePath(), statObjInfo->m_filePath, statObjInfo->m_bSubObject ? " SUBOBJECT" : ""); - //pRenderer->Draw2dLabel(sx, sy, 1.2f, pColor, false, "Geom: %.2fMb %.4f", memoryUsage/(1024.f*1024.f), mipFactor); - } - } - //*/ - } - if (sys_LocalMemoryLogText) - { - if (xDebug == x && yDebug == y) - { - for (TTextureMap::iterator it = m_globalTextures.begin(); it != m_globalTextures.end(); ++it) - { - STextureInfo* textureObjInfo = &it->second; - ITexture* pTexture = textureObjInfo->m_pTexture; - - float mipFactor = textureObjInfo->m_arrMipFactor[y * m_actProcessedSectors.w + x]; - if (mipFactor != BIG_NUMBER) - { - CryLog("Texture: %s %dX%d mipfactor:%.4f", pTexture->GetName(), pTexture->GetWidth(), pTexture->GetHeight(), mipFactor); - } - } - sys_LocalMemoryLogText = false; //Log only once! - } - } - } - else - { - pRenderAuxGeom->SetRenderFlags(auxGeomRenderFlagsFar); - } - - pRenderAuxGeom->DrawTriangle(v1, color, v2, color, v3, color); - pRenderAuxGeom->DrawTriangle(v3, color, v4, color, v1, color); - - pRenderAuxGeom->DrawTriangle(v0, color, v1, color, v4, color); - pRenderAuxGeom->DrawTriangle(v0, color, v2, color, v1, color); - pRenderAuxGeom->DrawTriangle(v0, color, v3, color, v2, color); - pRenderAuxGeom->DrawTriangle(v0, color, v4, color, v3, color); - - if (close) - { - LocalMemoryUsageDrawHelper::DrawCircle(pRenderer, camera, vTextureDiagram, sys_LocalMemoryDiagramRadius, textureRatio, colorTexture, colorBlack); - LocalMemoryUsageDrawHelper::DrawCircle(pRenderer, camera, vGeometryDiagram, sys_LocalMemoryDiagramRadius, geometryRatio, colorGeometry, colorBlack); - } - } - } - - sector++; - } - } -} - -void CLocalMemoryUsage::OnUpdate() -{ - if (!m_pDebugDraw || (m_pDebugDraw->GetIVal() != 17)) - { - return; - } - - //CryLogAlways("OnUpdate start-----------------------------------------"); - CTimeValue actTime = gEnv->pTimer->GetAsyncTime(); - - float callTimeDiff = (actTime - m_LastCallTime).GetSeconds(); - float neededCallTimeDiff = m_AverageUpdateTime / (sys_LocalMemoryOptimalMSecPerSec / 1000.f); - - if (callTimeDiff < neededCallTimeDiff && callTimeDiff < sys_LocalMemoryMaxMSecBetweenCalls / 1000.f) - { - return; - } - - DeleteUnusedResources(); - - m_LastCallTime = actTime; - - { - FRAME_PROFILER("! LocalMemoryUsege::Update - Start", GetISystem(), PROFILE_SYSTEM); - //StartChecking(RectI(0,0,m_sectorNr.x, m_sectorNr.y)); - StartChecking(m_actDrawedSectors); - } - - { - FRAME_PROFILER("! LocalMemoryUsege::Update - CollectGeometry P1", GetISystem(), PROFILE_SYSTEM); - CollectGeometryP1(); - } - - { - FRAME_PROFILER("! LocalMemoryUsege::Update - Materials P2", GetISystem(), PROFILE_SYSTEM); - //We must iterate on materials first - for (TMaterialMap::iterator it = m_globalMaterials.begin(); it != m_globalMaterials.end(); ++it) - { - it->second.CheckOnAllSectorsP2(); - } - } - { - FRAME_PROFILER("! LocalMemoryUsege::Update - Textures P2", GetISystem(), PROFILE_SYSTEM); - for (TTextureMap::iterator it = m_globalTextures.begin(); it != m_globalTextures.end(); ++it) - { - it->second.CheckOnAllSectorsP2(); - } - } - { - FRAME_PROFILER("! LocalMemoryUsege::Update - StatObjects P2", GetISystem(), PROFILE_SYSTEM); - for (TStatObjMap::iterator it = m_globalStatObjs.begin(); it != m_globalStatObjs.end(); ++it) - { - it->second.CheckOnAllSectorsP2(); - } - } - - CTimeValue endTime = gEnv->pTimer->GetAsyncTime(); - m_AverageUpdateTime = LERP(m_AverageUpdateTime, (endTime - actTime).GetSeconds(), 0.5f); - - //CryLogAlways("OnUpdate end***"); -} - -void CLocalMemoryUsage::DeleteUnusedResources() -{ - FRAME_PROFILER("! LocalMemoryUsege::Update - Deleting unused resources", GetISystem(), PROFILE_SYSTEM); - - // Clear the used flags - for (TStatObjMap::iterator it = m_globalStatObjs.begin(); it != m_globalStatObjs.end(); ++it) - { - it->second.m_used = false; - } - - // Iterate on used StatObjs - int nCount; - gEnv->p3DEngine->GetLoadedStatObjArray(NULL, nCount); - std::vector objectsArray; - objectsArray.resize(nCount); - if (nCount > 0) - { - gEnv->p3DEngine->GetLoadedStatObjArray(&objectsArray[0], nCount); - } - - for (std::vector::iterator it = objectsArray.begin(); it != objectsArray.end(); ++it) - { - IStatObj* pStatObj = *it; - TStatObjMap::iterator findIt = m_globalStatObjs.find((INT_PTR)pStatObj); - - if (findIt != m_globalStatObjs.end() && strcmp(pStatObj->GetFilePath(), findIt->second.m_filePath) == 0 && !findIt->second.m_bSubObject) - { - findIt->second.m_used = true; - } - - if (pStatObj->GetFlags() & STATIC_OBJECT_COMPOUND) - { - for (int k = 0; k < pStatObj->GetSubObjectCount(); k++) - { - if (!pStatObj->GetSubObject(k)) - { - continue; - } - - IStatObj* pSubStatObj = pStatObj->GetSubObject(k)->pStatObj; - - if (pSubStatObj) - { - findIt = m_globalStatObjs.find((INT_PTR)pSubStatObj); - - if (findIt != m_globalStatObjs.end() && strcmp(pSubStatObj->GetFilePath(), findIt->second.m_filePath) == 0 && findIt->second.m_bSubObject) - { - findIt->second.m_used = true; - } - } - } - } - } - - // Erase non-used StatObjs - bool changed = true; - while (changed) - { - changed = false; - for (TStatObjMap::iterator it = m_globalStatObjs.begin(); it != m_globalStatObjs.end(); ++it) - { - if (!it->second.m_used) - { - m_globalStatObjs.erase(it); - changed = true; - break; - } - } - } - /* - for( TTextureMap::iterator it = m_globalTextures.begin(); it != m_globalTextures.end(); ++it ) - it->second.m_used = false; - - bool changed = true; - while( changed ) - { - changed = false; - for( TTextureMap::iterator it = m_globalTextures.begin(); it != m_globalTextures.end(); ++it ) - { - if( !it->second.m_used ) - { - m_globalTextures.erase(it); - changed = true; - break; - } - } - } - - for( TMaterialMap::iterator it = m_globalMaterials.begin(); it != m_globalMaterials.end(); ++it ) - it->second.m_used = false; - - changed = true; - while( changed ) - { - changed = false; - for( TMaterialMap::iterator it = m_globalMaterials.begin(); it != m_globalMaterials.end(); ++it ) - { - if( !it->second.m_used ) - { - m_globalMaterials.erase(it); - changed = true; - break; - } - } - } - //*/ -} -void CLocalMemoryUsage::StartChecking(const RectI& actProcessedSectors) -{ - m_actProcessedSectors = actProcessedSectors; - - for (int y = 0; y < m_sectorNr.y; y++) - { - SSector* sector = &m_arrSectors[y * LOCALMEMORY_SECTOR_NR_X]; - for (int x = 0; x < m_sectorNr.x; x++) - { - sector->StartChecking(); - sector++; - } - } - - { - for (TTextureMap::iterator it = m_globalTextures.begin(); it != m_globalTextures.end(); ++it) - { - //FRAME_PROFILER("! LocalMemoryUsege::StartChecking - Textures", GetISystem(), PROFILE_SYSTEM); - it->second.StartChecking(); - } - } - { - for (TMaterialMap::iterator it = m_globalMaterials.begin(); it != m_globalMaterials.end(); ++it) - { - //FRAME_PROFILER("! LocalMemoryUsege::StartChecking - Materials", GetISystem(), PROFILE_SYSTEM); - it->second.StartChecking(); - } - } - { - for (TStatObjMap::iterator it = m_globalStatObjs.begin(); it != m_globalStatObjs.end(); ++it) - { - //FRAME_PROFILER("! LocalMemoryUsege::StartChecking - StatObjects", GetISystem(), PROFILE_SYSTEM); - it->second.StartChecking(); - } - } -} - -void CLocalMemoryUsage::CollectGeometryP1() -{ - ISystem* pSystem = GetISystem(); - I3DEngine* p3DEngine = pSystem->GetI3DEngine(); - - // iterate through all instances - std::vector renderNodes; - - uint32 dwCount = 0; - - dwCount += p3DEngine->GetObjectsByType(eERType_Light); - - dwCount += p3DEngine->GetObjectsByType(eERType_RenderComponent); - dwCount += p3DEngine->GetObjectsByType(eERType_SkinnedMeshRenderComponent); - dwCount += p3DEngine->GetObjectsByType(eERType_StaticMeshRenderComponent); - dwCount += p3DEngine->GetObjectsByType(eERType_DynamicMeshRenderComponent); - dwCount += p3DEngine->GetObjectsByType(eERType_Decal); - - if (dwCount > 0) - { - renderNodes.resize(dwCount + 1); - dwCount = 0; - - dwCount += p3DEngine->GetObjectsByType(eERType_Light, &renderNodes[dwCount]); - dwCount += p3DEngine->GetObjectsByType(eERType_RenderComponent, &renderNodes[dwCount]); - dwCount += p3DEngine->GetObjectsByType(eERType_StaticMeshRenderComponent, &renderNodes[dwCount]); - dwCount += p3DEngine->GetObjectsByType(eERType_DynamicMeshRenderComponent, &renderNodes[dwCount]); - dwCount += p3DEngine->GetObjectsByType(eERType_SkinnedMeshRenderComponent, &renderNodes[dwCount]); - dwCount += p3DEngine->GetObjectsByType(eERType_Decal, &renderNodes[dwCount]); - - AABB objBox; - - for (uint32 dwI = 0; dwI < dwCount; ++dwI) - { - IRenderNode* pRenderNode = renderNodes[dwI]; - - if (pRenderNode->m_fWSMaxViewDist < 0.01f) - { - continue; - } - - float objScale = 1.f; - if (pRenderNode->GetRenderNodeType() == eERType_Decal) - { - IDecalRenderNode* pDecal = (IDecalRenderNode*)pRenderNode; - objScale = max(0.001f, pDecal->GetMatrix().GetColumn0().GetLength()); - } - else if (pRenderNode->GetRenderNodeType() == eERType_FogVolume) - { - objScale = max(0.001f, ((IFogVolumeRenderNode*)pRenderNode)->GetMatrix().GetColumn0().GetLength()); - } - - float maxViewDist = pRenderNode->m_fWSMaxViewDist; - pRenderNode->FillBBox(objBox); - - _smart_ptr pRenderNodeMat = pRenderNode->GetMaterialOverride(); - - { - IStatObj* pStatObj = pRenderNode->GetEntityStatObj(); - - if (pStatObj != NULL) - { - CheckStatObjMaterialP1(pStatObj, pRenderNodeMat, objBox, maxViewDist, objScale); - } - else - { - CheckMeshMaterialP1(pRenderNode->GetRenderMesh(0), pRenderNodeMat, objBox, maxViewDist, objScale); - } - } - - for (int dwSlot = 0; dwSlot < pRenderNode->GetSlotCount(); ++dwSlot) - { - _smart_ptr pSlotMat = pRenderNode->GetEntitySlotMaterial(dwSlot); - if (!pSlotMat) - { - pSlotMat = pRenderNodeMat; - } - - Matrix34A matParent; - - if (IStatObj* pStatObj = pRenderNode->GetEntityStatObj(dwSlot, 0, &matParent, true)) - { - CheckStatObjP1(pStatObj, pRenderNode, objBox, maxViewDist, objScale); - - _smart_ptr pStatObjMat = pStatObj->GetMaterial(); - CheckStatObjMaterialP1(pStatObj, pSlotMat ? pSlotMat : pStatObjMat, objBox, maxViewDist, objScale); - } - } - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -PREFAST_SUPPRESS_WARNING(6262); -CLocalMemoryUsage::SStatObjInfo* CLocalMemoryUsage::CheckStatObjP1(IStatObj* pStatObj, [[maybe_unused]] IRenderNode* pRenderNode, AABB bounding, float maxViewDist, float scale) -{ - if (!pStatObj) - { - return NULL; - } - - if (strncmp(pStatObj->GetFilePath(), "%level%", 7) == 0) //HACK %LEVEL% brushes - { - return NULL; - } - - SStatObjInfo* pStatObjInfo = NULL; - - TStatObjMap::iterator iter = m_globalStatObjs.find((INT_PTR)pStatObj); - if (iter != m_globalStatObjs.end()) - { - pStatObjInfo = &iter->second; - pStatObjInfo->m_streamableContentMemoryUsage = pStatObj->GetStreamableContentMemoryUsage(); //TODO TEMP - } - else - { - { - FRAME_PROFILER("! CLocalMemoryUsage::CheckStatObjP1 HASH", GetISystem(), PROFILE_SYSTEM); - PREFAST_SUPPRESS_WARNING(6262) - pStatObjInfo = &m_globalStatObjs[(INT_PTR)pStatObj]; - } - - pStatObjInfo->Init(this); - pStatObjInfo->m_streamableContentMemoryUsage = pStatObj->GetStreamableContentMemoryUsage(); - //pStatObjInfo->m_pStatObj = pStatObj; - pStatObjInfo->m_filePath = pStatObj->GetFilePath(); - pStatObjInfo->m_bSubObject = pStatObj->IsSubObject(); - //CollectStatObjInfo_Recursive( pStatObjInfo, pStatObj ); - } - - pStatObjInfo->CheckOnAllSectorsP1(bounding, maxViewDist, scale, 1.0f); - - return pStatObjInfo; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -PREFAST_SUPPRESS_WARNING(6262); -void CLocalMemoryUsage::CheckMaterialP1(_smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale, float mipFactor) -{ - if (pMaterial) - { - SMaterialInfo* pMaterialInfo = NULL; - - TMaterialMap::iterator iter = m_globalMaterials.find((INT_PTR)pMaterial.get()); - if (iter != m_globalMaterials.end()) - { - pMaterialInfo = &iter->second; - } - else - { - { - FRAME_PROFILER("! CLocalMemoryUsage::CheckMaterialP1 HASH", GetISystem(), PROFILE_SYSTEM); - PREFAST_SUPPRESS_WARNING(6262) - pMaterialInfo = &m_globalMaterials[(INT_PTR)pMaterial.get()]; - } - pMaterialInfo->Init(this); - //pMaterialInfo->m_pMaterial=pMaterial; - CollectMaterialInfo_Recursive(pMaterialInfo, pMaterial); - } - - pMaterialInfo->CheckOnAllSectorsP1(bounding, maxViewDist, scale, mipFactor); - } -} - -PREFAST_SUPPRESS_WARNING(6262); -void CLocalMemoryUsage::CheckChunkMaterialP1(_smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale, CRenderChunk* pRenderChunk) -{ - _smart_ptr pCurrentMaterial = pMaterial; - - if (pRenderChunk != NULL) - { - if (pRenderChunk->m_nMatID < pMaterial->GetSubMtlCount()) - { - pCurrentMaterial = pMaterial->GetSubMtl(pRenderChunk->m_nMatID); - } - - if (pCurrentMaterial != NULL) - { - CheckMaterialP1(pCurrentMaterial, bounding, maxViewDist, scale, pRenderChunk->m_texelAreaDensity); - } - } - else - { - CheckMaterialP1(pCurrentMaterial, bounding, maxViewDist, scale, 1.f); - } -} - -PREFAST_SUPPRESS_WARNING(6262); -void CLocalMemoryUsage::CheckMeshMaterialP1(IRenderMesh* pRenderMesh, _smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale) -{ - if (pRenderMesh) - { - if (pMaterial) - { - TRenderChunkArray* pChunks = &pRenderMesh->GetChunks(); - - if (pChunks != NULL) - { - for (unsigned int i = 0; i < pChunks->size(); i++) - { - CheckChunkMaterialP1(pMaterial, bounding, maxViewDist, scale, &(*pChunks)[i]); - } - } - - pChunks = &pRenderMesh->GetChunksSkinned(); - for (unsigned int i = 0; i < pChunks->size(); i++) - { - CheckChunkMaterialP1(pMaterial, bounding, maxViewDist, scale, &(*pChunks)[i]); - } - } - } - else - { - if (pMaterial) - { - CheckChunkMaterialP1(pMaterial, bounding, maxViewDist, scale, NULL); - } - } -} - -void CLocalMemoryUsage::CheckStatObjMaterialP1(IStatObj* pStatObj, _smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale) -{ - if (pStatObj) - { - for (int i = 0; i < pStatObj->GetSubObjectCount(); i++) - { - CheckStatObjMaterialP1(pStatObj->GetSubObject(i)->pStatObj, pMaterial, bounding, scale, maxViewDist); - } - - CheckMeshMaterialP1(pStatObj->GetRenderMesh(), pMaterial, bounding, maxViewDist, scale); - } -} - -void CLocalMemoryUsage::CollectMaterialInfo_Recursive(SMaterialInfo* materialInfo, _smart_ptr pMaterial) -{ - SShaderItem& rItem = pMaterial->GetShaderItem(); - - uint32 dwSubMatCount = pMaterial->GetSubMtlCount(); - - for (uint32 dwSubMat = 0; dwSubMat < dwSubMatCount; ++dwSubMat) - { - _smart_ptr pSub = pMaterial->GetSubMtl(dwSubMat); - - if (pSub) - { - CollectMaterialInfo_Recursive(materialInfo, pSub); - } - } - - // this pMaterial - if (rItem.m_pShaderResources) - { - for (auto iter = rItem.m_pShaderResources->GetTexturesResourceMap()->begin(); - iter != rItem.m_pShaderResources->GetTexturesResourceMap()->end(); ++iter) - { - const SEfResTexture* pTextureRes = &iter->second; - - if (pTextureRes->m_Sampler.m_pITex) - { - ITexture* pTexture = pTextureRes->m_Sampler.m_pITex; - if (pTexture && pTexture->GetStreamableMipNumber() > 0) - { - STextureInfoAndTilingFactor textureInfo; - - textureInfo.m_pTextureInfo = GetTextureInfo(pTexture); - textureInfo.m_tilingFactor = pTextureRes->GetTiling(0) * pTextureRes->GetTiling(1); - - materialInfo->AddTextureInfo(textureInfo); - } - } - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -PREFAST_SUPPRESS_WARNING(6262) -CLocalMemoryUsage::STextureInfo * CLocalMemoryUsage::GetTextureInfo(ITexture * pTexture) -{ - if (!pTexture) - { - return NULL; - } - - TTextureMap::iterator iter = m_globalTextures.find((INT_PTR)pTexture); - if (iter != m_globalTextures.end()) - { - return &iter->second; - } - - //FUNCTION_PROFILER(GetISystem(), PROFILE_SYSTEM); - STextureInfo* pTextureInfo; - { - FRAME_PROFILER("! CLocalMemoryUsage::CheckStatObjP1 HASH", GetISystem(), PROFILE_SYSTEM); - PREFAST_SUPPRESS_WARNING(6262) - pTextureInfo = &m_globalTextures[(INT_PTR)pTexture]; - } - pTextureInfo->Init(this); - pTextureInfo->m_pTexture = pTexture; - pTexture->AddRef(); - - //Collect informations - //pTextureInfo->m_size = pTexture->GetDeviceDataSize(); - //pTextureInfo->m_xSize = pTexture->GetWidth(); - //pTextureInfo->m_ySize = pTexture->GetHeight(); - //pTextureInfo->m_numMips = pTexture->GetNumMips(); - - return pTextureInfo; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Code/CryEngine/CrySystem/Statistics/LocalMemoryUsage.h b/Code/CryEngine/CrySystem/Statistics/LocalMemoryUsage.h deleted file mode 100644 index 450e2eb2f9..0000000000 --- a/Code/CryEngine/CrySystem/Statistics/LocalMemoryUsage.h +++ /dev/null @@ -1,245 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Visual helper for checking a local memory usage on maps - - -#ifndef CRYINCLUDE_CRYSYSTEM_STATISTICS_LOCALMEMORYUSAGE_H -#define CRYINCLUDE_CRYSYSTEM_STATISTICS_LOCALMEMORYUSAGE_H -#pragma once - - -#include "../CryCommon/Cry_Geo.h" -#include "ILocalMemoryUsage.h" -#include "TimeValue.h" - -#define LOCALMEMORY_SECTOR_SIZE 32.f //Size of one sector -#define LOCALMEMORY_SECTOR_NR_X 128 //4096 / LOCALMEMORY_SECTOR_SIZE Sector number of the world (x) -#define LOCALMEMORY_SECTOR_NR_Y 128 //4096 / LOCALMEMORY_SECTOR_SIZE Sector number of the world (y) -#define LOCALMEMORY_SECTOR_PER_PASS 128 //4096 / 32 Sector nr for one calculation pass. Now it is the whole world; - -//Sector number must be = LOCALMEMORY_SECTOR_PER_PASS * n - -#define LOCALMEMORY_COLOR_OK 0, 255, 0 -#define LOCALMEMORY_COLOR_WARNING 255, 255, 0 -#define LOCALMEMORY_COLOR_ERROR 255, 0, 0 -#define LOCALMEMORY_COLOR_TEXTURE 0, 0, 255 -#define LOCALMEMORY_COLOR_GEOMETRY 0, 0, 0 -#define LOCALMEMORY_COLOR_BLACK 0, 0, 0, 192 -#define LOCALMEMORY_FCOLOR_OK 0, 1, 0 -#define LOCALMEMORY_FCOLOR_WARNING 1, 1, 0 -#define LOCALMEMORY_FCOLOR_ERROR 1, 0, 0 -#define LOCALMEMORY_FCOLOR_OTHER 0, 0, 1 - -struct IMaterial; -struct IStatObj; -struct IRenderMesh; -struct IRenderNode; -struct CRenderChunk; -class CCamera; - -#include - -struct CLocalMemoryUsage - : public ILocalMemoryUsage -{ -private: - - struct STextureInfo; - struct SMaterialInfo; - struct SStatObjInfo; - - typedef std__hash_map TTextureMap; // Type: hash map of textures - typedef std__hash_map TMaterialMap; // Type: hash map of materials - typedef std__hash_map TStatObjMap; // Type: hash map of stat objects - - //******************* - - struct SResource - { - CLocalMemoryUsage* m_pLocalMemoryUsage; // Inner pointer to the singleton (we can use gEnv->pLocalMemoryUsage with type cast instead this) - - float m_arrMipFactor[LOCALMEMORY_SECTOR_PER_PASS * LOCALMEMORY_SECTOR_PER_PASS]; // Mipmap factor based on minimum distance of the resource from the sector (bounding box distance) - bool m_arrRowDirty[LOCALMEMORY_SECTOR_PER_PASS]; // Dirty flag for m_arrMipFactor rows - bool m_used; - - static int m_arrMemoryUsage[LOCALMEMORY_SECTOR_PER_PASS]; // Memory usage of the resource in sectors (last row) - static int m_arrPieces[LOCALMEMORY_SECTOR_PER_PASS]; // Pieces nr of the resource in sectors (last row) - - virtual void StartChecking(); // Called every frame first - void CheckOnAllSectorsP1(const AABB& bounding, float maxViewDist, float viewDistMultiplierForLOD, float mipFactor); // Calculates the minimum of sector bounding vs renderobject bounding distances - - SResource(); - virtual void Init(CLocalMemoryUsage* pLocalMemoryUsage); - //If we will needed a destructor, it must be virtual! - }; - - //******************* - - struct STextureInfo - : public SResource - { - ITexture* m_pTexture; // Texture pointer - //int m_size; // For later use - Used memory - //int m_xSize; // For later use - Texture x size - //int m_ySize; // For later use - Texture y size - //int m_numMips; // For later use - Number of mip maps - - void CheckOnAllSectorsP2(); // Calculate memory usage using distances - - STextureInfo(); - ~STextureInfo(); - }; - - //******************* - - struct STextureInfoAndTilingFactor - { - STextureInfo* m_pTextureInfo; - float m_tilingFactor; - }; - - typedef std::vector TTextureVector; // Type: vector of textures - - struct SMaterialInfo - : public SResource - { - //_smart_ptr m_pMaterial; // For later use - TTextureVector m_textures; // Used textures - - SMaterialInfo(); - - void AddTextureInfo(STextureInfoAndTilingFactor texture);// Add a new texture (unique) - void CheckOnAllSectorsP2(); // Forward distance informations to textures - }; - - //******************* - - struct SStatObjInfo - : public SResource - { - int m_streamableContentMemoryUsage; // Total streamable memory usage - //IStatObj *m_pStatObj; //TODO kiszedni - string m_filePath; // The original file name and path of the StatObj - bool m_bSubObject; // Is the original StatObj a subobject? - /* - int m_lodNr; // For later use - int m_vertices; - int m_meshSize; - int m_physProxySize; - int m_physPrimitives; - int m_indices; - int m_indicesPerLod[MAX_LODS]; - */ - - SStatObjInfo(); - void CheckOnAllSectorsP2(); // Calculate memory usage using distances - }; - - //******************* - - struct SSector - { - SSector(); - - void StartChecking(); // Called every frame first - - int m_memoryUsage_Textures; // Sum of texture memory usage - - int m_memoryUsage_Geometry; // Sum of geometry memory usage - }; - - //******************* - PREFAST_SUPPRESS_WARNING(6262); - TTextureMap m_globalTextures; // Hash map of resources: textures - PREFAST_SUPPRESS_WARNING(6262); - TMaterialMap m_globalMaterials; // Hash map of resources: materials - PREFAST_SUPPRESS_WARNING(6262); - TStatObjMap m_globalStatObjs; // Hash map of resources: stat objects - - ICVar* m_pStreamCgfPredicitionDistance; // Config: additional object distance for streaming - ICVar* m_pDebugDraw; // Config: debug draw mode - - int sys_LocalMemoryTextureLimit; // Config: texture limit for streaming - int sys_LocalMemoryGeometryLimit; // Config: stat object geometry limit for streaming - int sys_LocalMemoryTextureStreamingSpeedLimit; // Config: texture streaming speed limit (approx) - int sys_LocalMemoryGeometryStreamingSpeedLimit; // Config: stat object geometry streaming speed limit (approx) - - float sys_LocalMemoryWarningRatio; // Config: Warning ratio for streaming - float sys_LocalMemoryOuterViewDistance; // Config: View distance for debug draw - float sys_LocalMemoryInnerViewDistance; // Config: View distance for detailed debug draw - - float sys_LocalMemoryObjectWidth; // Config: Width of the debug object - float sys_LocalMemoryObjectHeight; // Config: Height of the debug object - int sys_LocalMemoryObjectAlpha; // Config: Color alpha of the debug object - - float sys_LocalMemoryStreamingSpeedObjectLength; // Config: Length of the streaming speed debug object - float sys_LocalMemoryStreamingSpeedObjectWidth; // Config: Width of the streaming speed debug object - - float sys_LocalMemoryDiagramWidth; // Config: Width of the diagram - - float sys_LocalMemoryDiagramRadius; // Config: Radius of the diagram - float sys_LocalMemoryDiagramDistance; // Config: Distance of the diagram from the main debug object - float sys_LocalMemoryDiagramStreamingSpeedRadius; // Config: Radius of the streaming speed diagram - float sys_LocalMemoryDiagramStreamingSpeedDistance; // Config: Distance of the streaming speed diagram from the streaming speed debug line - int sys_LocalMemoryDiagramAlpha; // Config: Color alpha of the diagram - - int sys_LocalMemoryDrawText; // Config: If != 0, it will draw the numeric values - int sys_LocalMemoryLogText; // Config: If != 0, it will log the numeric values - - int sys_LocalMemoryOptimalMSecPerSec; // Config: Optimal calculation time (MSec) per secundum - int sys_LocalMemoryMaxMSecBetweenCalls; // Config: Maximal time difference (MSec) between calls - - RectI m_actProcessedSectors; // Processed sectors (now it is the whole world) - RectI m_actDrawedSectors; // Processed sectors (now it is the whole world) - - Vec2i m_sectorNr; // Sector x and y number - - float m_AverageUpdateTime; // Avarage Update() time (MSec) - CTimeValue m_LastCallTime; // Last call time of Update() - - SSector m_arrSectors[LOCALMEMORY_SECTOR_NR_X * LOCALMEMORY_SECTOR_NR_Y]; // Sectors - -public: - - CLocalMemoryUsage(); - ~CLocalMemoryUsage(); - - virtual void OnRender(IRenderer* pRenderer, const CCamera* camera); - virtual void OnUpdate(); - virtual void DeleteGlobalData(); // Deletes the m_globalXXX hash maps - -private: - void DeleteUnusedResources(); // Delete the non-used resources (especially StatObjs) - void StartChecking(const RectI& actProcessedSectors); // Called every frame first - void CollectGeometryP1(); // Calculates the minimum of sector bounding vs renderobject bounding distances - - // Get / create StatObjInfo then run Pass1 - SStatObjInfo* CheckStatObjP1(IStatObj* pStatObj, IRenderNode* pRenderNode, AABB bounding, float maxViewDist, float scale); - //void CollectStatObjInfo_Recursive( SStatObjInfo* statObjInfo, IStatObj *pStatObj ); - //void CollectGeometryInfo( SStatObjInfo* statObjInfo, IStatObj *pStatObj ); - - // Get / create MaterialInfo then run Pass1 - void CheckMaterialP1(_smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale, float mipFactor); - void CheckChunkMaterialP1(_smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale, CRenderChunk* pRenderChunk); - void CheckMeshMaterialP1(IRenderMesh* pRenderMesh, _smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale); - void CheckStatObjMaterialP1(IStatObj* pStatObj, _smart_ptr pMaterial, AABB bounding, float maxViewDist, float scale); - // Collects textures used by the material - void CollectMaterialInfo_Recursive(SMaterialInfo* materialInfo, _smart_ptr pMaterial); - - // Get / create TextureInfo - STextureInfo* GetTextureInfo(ITexture* pTexture); -}; - -#undef MAX_LODS -#endif // CRYINCLUDE_CRYSYSTEM_STATISTICS_LOCALMEMORYUSAGE_H diff --git a/Code/CryEngine/CrySystem/System.cpp b/Code/CryEngine/CrySystem/System.cpp index 827a393103..af9b674f6a 100644 --- a/Code/CryEngine/CrySystem/System.cpp +++ b/Code/CryEngine/CrySystem/System.cpp @@ -119,8 +119,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #include AZ_RESTRICTED_FILE(System_cpp) #endif - -#include #include #include #include @@ -131,7 +129,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #include #include "VisRegTest.h" #include -#include #include @@ -154,7 +151,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #include "Serialization/ArchiveHost.h" #include "SystemEventDispatcher.h" #include "ServerThrottle.h" -#include "ILocalMemoryUsage.h" #include "ResourceManager.h" #include "HMDBus.h" #include "OverloadSceneManager/OverloadSceneManager.h" @@ -682,15 +678,6 @@ void CSystem::ShutDown() // Shutdown any running VR devices. EBUS_EVENT(AZ::VR::HMDInitRequestBus, Shutdown); - - ////////////////////////////////////////////////////////////////////////// - // Clear 3D Engine resources. - if (m_env.p3DEngine) - { - m_env.p3DEngine->UnloadLevel(); - } - ////////////////////////////////////////////////////////////////////////// - // Shutdown resource manager. m_pResourceManager->Shutdown(); @@ -706,7 +693,6 @@ void CSystem::ShutDown() SAFE_DELETE(m_env.pServiceNetwork); SAFE_RELEASE(m_env.pLyShine); SAFE_RELEASE(m_env.pCryFont); - SAFE_RELEASE(m_env.p3DEngine); // depends on EntitySystem if (m_env.pConsole) { ((CXConsole*)m_env.pConsole)->FreeRenderResources(); @@ -1231,8 +1217,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) return false; } - RenderBegin(); - #ifndef EXCLUDE_UPDATE_ON_CONSOLE // do the dedicated sleep earlier than the frame profiler to avoid having it counted if (gEnv->IsDedicated()) @@ -1295,11 +1279,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) GetIRemoteConsole()->Update(); #endif - if (gEnv->pLocalMemoryUsage != NULL) - { - gEnv->pLocalMemoryUsage->OnUpdate(); - } - if (!gEnv->IsEditor() && gEnv->pRenderer) { // If the dimensions of the render target change, @@ -1490,11 +1469,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) //update time subsystem m_Time.UpdateOnFrameStart(); - if (m_env.p3DEngine) - { - m_env.p3DEngine->OnFrameStart(); - } - ////////////////////////////////////////////////////////////////////// // update rate limiter for dedicated server if (m_pServerThrottle.get()) @@ -1651,7 +1625,7 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) } ////////////////////////////////////////////////////////////////////// -bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode) +bool CSystem::UpdatePostTickBus(int updateFlags, int /*nPauseMode*/) { CTimeValue updateStart = gEnv->pTimer->GetAsyncTime(); @@ -1663,44 +1637,6 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode) UpdateMovieSystem(updateFlags, fMovieFrameTime, false); } - ////////////////////////////////////////////////////////////////////// - //update process (3D engine) - if (!(updateFlags & ESYSUPDATE_EDITOR) && !m_bNoUpdate && m_env.p3DEngine) - { - FRAME_PROFILER("SysUpdate:Update3DEngine", this, PROFILE_SYSTEM); - - if (ITimeOfDay* pTOD = m_env.p3DEngine->GetTimeOfDay()) - { - pTOD->Tick(); - } - - if (m_env.p3DEngine) - { - m_env.p3DEngine->Tick(); // clear per frame temp data - } - if (m_pProcess && (m_pProcess->GetFlags() & PROC_3DENGINE)) - { - if ((nPauseMode != 1)) - { - if (!IsEquivalent(m_ViewCamera.GetPosition(), Vec3(0, 0, 0), VEC_EPSILON)) - { - if (m_env.p3DEngine) - { - // m_env.p3DEngine->SetCamera(m_ViewCamera); - m_pProcess->Update(); - } - } - } - } - else - { - if (m_pProcess) - { - m_pProcess->Update(); - } - } - } - ////////////////////////////////////////////////////////////////////// //update sound system part 2 if (!g_cvars.sys_deferAudioUpdateOptim && !m_bNoUpdate) @@ -1748,41 +1684,8 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int nPauseMode) gEnv->pCryPak->DisableRuntimeFileAccess(true); } - // If it's in editing mode (in editor) the render is done in RenderViewport so we skip rendering here. - if (!gEnv->IsEditing() && gEnv->pRenderer && gEnv->p3DEngine) - { - if (GetIViewSystem()) - { - GetIViewSystem()->Update(min(gEnv->pTimer->GetFrameTime(), 0.1f)); - } - - // Begin occlusion job after setting the correct camera. - gEnv->p3DEngine->PrepareOcclusion(GetViewCamera()); - - CrySystemNotificationBus::Broadcast(&CrySystemNotifications::OnPreRender); - - // Also broadcast for anyone else that needs to draw global debug to do so now - AzFramework::DebugDisplayEventBus::Broadcast(&AzFramework::DebugDisplayEvents::DrawGlobalDebugInfo); - - Render(); - - gEnv->p3DEngine->EndOcclusion(); - - CrySystemNotificationBus::Broadcast(&CrySystemNotifications::OnPostRender); - - RenderEnd(); - - gEnv->p3DEngine->SyncProcessStreamingUpdate(); - - if (NeedDoWorkDuringOcclusionChecks()) - { - DoWorkDuringOcclusionChecks(); - } - - // Sync the work that must be done in the main thread by the end of frame. - gEnv->pRenderer->GetGenerateShadowRendItemJobExecutor()->WaitForCompletion(); - gEnv->pRenderer->GetGenerateRendItemJobExecutor()->WaitForCompletion(); - } + // Also broadcast for anyone else that needs to draw global debug to do so now + AzFramework::DebugDisplayEventBus::Broadcast(&AzFramework::DebugDisplayEvents::DrawGlobalDebugInfo); return !IsQuitting(); } diff --git a/Code/CryEngine/CrySystem/System.h b/Code/CryEngine/CrySystem/System.h index e4fcc82552..f5235f2ea8 100644 --- a/Code/CryEngine/CrySystem/System.h +++ b/Code/CryEngine/CrySystem/System.h @@ -408,13 +408,6 @@ public: virtual void DoWorkDuringOcclusionChecks(); virtual bool NeedDoWorkDuringOcclusionChecks() { return m_bNeedDoWorkDuringOcclusionChecks; } - //! Begin rendering frame. - void RenderBegin(); - //! Render subsystems. - void Render(); - //! End rendering frame and swap back buffer. - void RenderEnd(bool bRenderStats = true, bool bMainWindow = true); - //Called when the renderer finishes rendering the scene void OnScene3DEnd() override; @@ -429,11 +422,6 @@ public: //! Update screen and call some important tick functions during loading. void SynchronousLoadingTick(const char* pFunc, int line); - //! Renders the statistics; this is called from RenderEnd, but if the - //! Host application (Editor) doesn't employ the Render cycle in ISystem, - //! it may call this method to render the essential statistics - void RenderStatistics() override; - uint32 GetUsedMemory(); virtual void DumpMemoryUsageStatistics(bool bUseKB); @@ -469,7 +457,6 @@ public: AZ::IO::IArchive* GetIPak() { return m_env.pCryPak; }; IConsole* GetIConsole() { return m_env.pConsole; }; IRemoteConsole* GetIRemoteConsole(); - I3DEngine* GetI3DEngine(){ return m_env.p3DEngine; } IMovieSystem* GetIMovieSystem() { return m_env.pMovieSystem; }; IMemoryManager* GetIMemoryManager(){ return m_pMemoryManager; } IThreadManager* GetIThreadManager() override {return m_env.pThreadManager; } @@ -696,9 +683,6 @@ private: void CreateRendererVars(const SSystemInitParams& startupParams); void CreateSystemVars(); void CreateAudioVars(); - void RenderStats(); - void RenderOverscanBorders(); - void RenderMemStats(); AZStd::unique_ptr LoadDLL(const char* dllName); diff --git a/Code/CryEngine/CrySystem/SystemInit.cpp b/Code/CryEngine/CrySystem/SystemInit.cpp index 826810ef8a..22445ec4a5 100644 --- a/Code/CryEngine/CrySystem/SystemInit.cpp +++ b/Code/CryEngine/CrySystem/SystemInit.cpp @@ -86,7 +86,6 @@ #endif //WIN32 -#include #include #include #include @@ -107,7 +106,6 @@ #include "PhysRenderer.h" #include "LocalizedStringManager.h" #include "SystemEventDispatcher.h" -#include "Statistics/LocalMemoryUsage.h" #include "ThreadConfigManager.h" #include "Validator.h" #include "ServerThrottle.h" @@ -768,11 +766,6 @@ static void LoadDetectedSpec(ICVar* pVar) GetISystem()->SetConfigSpec(static_cast(spec), platform, false); - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->GetMaterialManager()->RefreshMaterialRuntime(); - } - no_recursive = false; } @@ -2788,12 +2781,6 @@ AZ_POP_DISABLE_WARNING m_env.pRenderer->TryFlush(); } -#if !defined(RELEASE) - m_env.pLocalMemoryUsage = new CLocalMemoryUsage(); -#else - m_env.pLocalMemoryUsage = nullptr; -#endif - if (g_cvars.sys_float_exceptions > 0) { if (g_cvars.sys_float_exceptions == 3 && gEnv->IsEditor()) // Turn off float exceptions in editor if sys_float_exceptions = 3 diff --git a/Code/CryEngine/CrySystem/SystemRender.cpp b/Code/CryEngine/CrySystem/SystemRender.cpp index a544cef4a5..68045a86ea 100644 --- a/Code/CryEngine/CrySystem/SystemRender.cpp +++ b/Code/CryEngine/CrySystem/SystemRender.cpp @@ -31,7 +31,6 @@ #include #include "Log.h" #include "XConsole.h" -#include #include #include "PhysRenderer.h" #include @@ -222,92 +221,6 @@ void CSystem::CreateRendererVars(const SSystemInitParams& startupParams) "Usage: r_OverscanBordersDrawDebugView [0=off/1=show]"); } -////////////////////////////////////////////////////////////////////////// -void CSystem::RenderBegin() -{ - FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled); - - if (m_bIgnoreUpdates) - { - return; - } - - bool rndAvail = m_env.pRenderer != 0; - - ////////////////////////////////////////////////////////////////////// - //start the rendering pipeline - if (rndAvail) - { - m_env.pRenderer->BeginFrame(); - } - - gEnv->nMainFrameID = (rndAvail) ? m_env.pRenderer->GetFrameID(false) : 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CSystem::RenderEnd([[maybe_unused]] bool bRenderStats, bool bMainWindow) -{ - { - FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled); - - if (m_bIgnoreUpdates) - { - return; - } - - if (!m_env.pRenderer) - { - return; - } - - if (bMainWindow) // we don't do this in UI Editor window for example - { -#if !defined (_RELEASE) - // Flush render data and swap buffers. - m_env.pRenderer->RenderDebug(bRenderStats); -#endif - -#if defined(USE_PERFHUD) - if (m_pPerfHUD) - { - m_pPerfHUD->Draw(); - } - if (m_pMiniGUI) - { - m_pMiniGUI->Draw(); - } -#endif - - if (!gEnv->pSystem->GetILevelSystem() || !gEnv->pSystem->GetILevelSystem()->IsLevelLoaded()) - { - IConsole* console = GetIConsole(); - - //Same goes for the console. When no level is loaded, it's okay to render it outside of the renderer - //so that users can load maps or change settings. - if (console != nullptr) - { - console->Draw(); - } - } - } - - m_env.pRenderer->ForceGC(); // XXX Rename this - m_env.pRenderer->EndFrame(); - - - if (IConsole* pConsole = GetIConsole()) - { - // if we have pending cvar calculation, execute it here - // since we know cvars will be correct here after ->EndFrame(). - if (!pConsole->IsHashCalculated()) - { - pConsole->CalcCheatVarHash(); - } - } - } -} - void CSystem::OnScene3DEnd() { //Render Console @@ -391,231 +304,3 @@ void CSystem::DisplayErrorMessage(const char* acMessage, #endif m_ErrorMessages.push_back(message); } - -//! Renders the statistics; this is called from RenderEnd, but if the -//! Host application (Editor) doesn't employ the Render cycle in ISystem, -//! it may call this method to render the essential statistics -////////////////////////////////////////////////////////////////////////// -void CSystem::RenderStatistics() -{ - RenderStats(); -} - -////////////////////////////////////////////////////////////////////// -void CSystem::Render() -{ - if (m_bIgnoreUpdates) - { - return; - } - - //check what is the current process - if (!m_pProcess) - { - return; //should never happen - } - //check if the game is in pause or - //in menu mode - //bool bPause=false; - //if (m_pProcess->GetFlags() & PROC_MENU) - // bPause=true; - - FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled); - - ////////////////////////////////////////////////////////////////////// - //draw - m_env.p3DEngine->PreWorldStreamUpdate(m_ViewCamera); - - if (m_pProcess) - { - if (m_pProcess->GetFlags() & PROC_3DENGINE) - { - if (!gEnv->IsEditing()) // Editor calls it's own rendering update - { - if (m_env.p3DEngine && !m_env.IsFMVPlaying()) - { - if (!IsEquivalent(m_ViewCamera.GetPosition(), Vec3(0, 0, 0), VEC_EPSILON) || // never pass undefined camera to p3DEngine->RenderWorld() - gEnv->IsDedicated() || (gEnv->pRenderer && gEnv->pRenderer->IsPost3DRendererEnabled())) - { - GetIRenderer()->SetViewport(0, 0, GetIRenderer()->GetWidth(), GetIRenderer()->GetHeight()); - m_env.p3DEngine->RenderWorld(SHDF_ALLOW_WATER | SHDF_ALLOWPOSTPROCESS | SHDF_ALLOWHDR | SHDF_ZPASS | SHDF_ALLOW_AO, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_ViewCamera), __FUNCTION__); - } - else - { - if (gEnv->pRenderer) - { - // force rendering of black screen to be sure we don't only render the clear color (which is the fog color by default) - gEnv->pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST); - gEnv->pRenderer->Draw2dImage(0, 0, 800, 600, -1, 0.0f, 0.0f, 1.0f, 1.0f, 0.f, - 0.0f, 0.0f, 0.0f, 1.0f, 0.f); - } - } - } -#if !defined(_RELEASE) - if (m_pVisRegTest) - { - m_pVisRegTest->AfterRender(); - } -#endif - - if (m_env.pMovieSystem) - { - m_env.pMovieSystem->Render(); - } - } - } - else - { - GetIRenderer()->SetViewport(0, 0, GetIRenderer()->GetWidth(), GetIRenderer()->GetHeight()); - m_pProcess->RenderWorld(SHDF_ALLOW_WATER | SHDF_ALLOWPOSTPROCESS | SHDF_ALLOWHDR | SHDF_ZPASS | SHDF_ALLOW_AO, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_ViewCamera), __FUNCTION__); - } - } - - m_env.p3DEngine->WorldStreamUpdate(); - - gEnv->pRenderer->SwitchToNativeResolutionBackbuffer(); -} - - -////////////////////////////////////////////////////////////////////////// -void CSystem::RenderStats() -{ -#if defined(ENABLE_PROFILING_CODE) -#ifndef _RELEASE - // if we rendered an error message on screen during the last frame, then sleep now - // to force hard stall for 3sec - if (m_bHasRenderedErrorMessage && !gEnv->IsEditor() && !IsLoading()) - { - // DO NOT REMOVE OR COMMENT THIS OUT! - // If you hit this, then you most likely have invalid (synchronous) file accesses - // which must be fixed in order to not stall the entire game. - Sleep(3000); - m_bHasRenderedErrorMessage = false; - } -#endif - - // render info messages on screen - float fTextPosX = 5.0f; - float fTextPosY = -10; - float fTextStepY = 13; - - float fFrameTime = gEnv->pTimer->GetRealFrameTime(); - TErrorMessages::iterator itnext; - for (TErrorMessages::iterator it = m_ErrorMessages.begin(); it != m_ErrorMessages.end(); it = itnext) - { - itnext = it; - ++itnext; - SErrorMessage& message = *it; - - SDrawTextInfo ti; - ti.flags = eDrawText_FixedSize | eDrawText_2D | eDrawText_Monospace; - memcpy(ti.color, message.m_Color, 4 * sizeof(float)); - ti.xscale = ti.yscale = 1.4f; - m_env.pRenderer->DrawTextQueued(Vec3(fTextPosX, fTextPosY += fTextStepY, 1.0f), ti, message.m_Message.c_str()); - - if (!IsLoading()) - { - message.m_fTimeToShow -= fFrameTime; - } - - if (message.m_HardFailure) - { - m_bHasRenderedErrorMessage = true; - } - - if (message.m_fTimeToShow < 0.0f) - { - m_ErrorMessages.erase(it); - } - } -#endif - - if (!m_env.pConsole) - { - return; - } - -#ifndef _RELEASE - if (m_rOverscanBordersDrawDebugView) - { - RenderOverscanBorders(); - } -#endif - - int iDisplayInfo = m_rDisplayInfo->GetIVal(); - if (iDisplayInfo == 0) - { - return; - } - - // Draw engine stats - if (m_env.p3DEngine) - { - // Draw 3dengine stats and get last text cursor position - float nTextPosX = 101 - 20, nTextPosY = -2, nTextStepY = 3; - m_env.p3DEngine->DisplayInfo(nTextPosX, nTextPosY, nTextStepY, iDisplayInfo != 1); - - // Dump Open 3D Engine CPU and GPU memory statistics to screen - m_env.p3DEngine->DisplayMemoryStatistics(); - - #if defined(ENABLE_LW_PROFILERS) - if (m_rDisplayInfo->GetIVal() == 2) - { - m_env.pRenderer->TextToScreen(nTextPosX, nTextPosY += nTextStepY, "SysMem %.1f mb", - float(DumpMMStats(false)) / 1024.f); - } - #endif - - #if 0 - for (int i = 0; i < NUM_POOLS; ++i) - { - int used = (g_pPakHeap->m_iBigPoolUsed[i] ? (int)g_pPakHeap->m_iBigPoolSize[i] : 0); - int size = (int)g_pPakHeap->m_iBigPoolSize[i]; - float fC1[4] = {1, 1, 0, 1}; - m_env.pRenderer->Draw2dLabel(10, 100.0f + i * 16, 2.1f, fC1, false, "BigPool %d: %d bytes of %d bytes used", i, used, size); - } - #endif - } -} - -void CSystem::RenderOverscanBorders() -{ -#ifndef _RELEASE - - if (m_env.pRenderer && m_rOverscanBordersDrawDebugView) - { - int iOverscanBordersDrawDebugView = m_rOverscanBordersDrawDebugView->GetIVal(); - if (iOverscanBordersDrawDebugView) - { - const int texId = -1; - const float uv = 0.0f; - const float rot = 0.0f; - const int whiteTextureId = m_env.pRenderer->GetWhiteTextureId(); - - const float r = 1.0f; - const float g = 1.0f; - const float b = 1.0f; - const float a = 0.2f; - - Vec2 overscanBorders = Vec2(0.0f, 0.0f); - m_env.pRenderer->EF_Query(EFQ_OverscanBorders, overscanBorders); - - const float overscanBorderWidth = overscanBorders.x * VIRTUAL_SCREEN_WIDTH; - const float overscanBorderHeight = overscanBorders.y * VIRTUAL_SCREEN_HEIGHT; - - const float xPos = overscanBorderWidth; - const float yPos = overscanBorderHeight; - const float width = VIRTUAL_SCREEN_WIDTH - (2.0f * overscanBorderWidth); - const float height = VIRTUAL_SCREEN_HEIGHT - (2.0f * overscanBorderHeight); - - m_env.pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST); - m_env.pRenderer->Draw2dImage(xPos, yPos, - width, height, - whiteTextureId, - uv, uv, uv, uv, - rot, - r, g, b, a); - } - } -#endif -} diff --git a/Code/CryEngine/CrySystem/SystemWin32.cpp b/Code/CryEngine/CrySystem/SystemWin32.cpp index 974e578f38..ce352966ac 100644 --- a/Code/CryEngine/CrySystem/SystemWin32.cpp +++ b/Code/CryEngine/CrySystem/SystemWin32.cpp @@ -15,7 +15,6 @@ #include "System.h" #include -#include #include #include #include @@ -302,23 +301,6 @@ void CSystem::CollectMemStats (ICrySizer* pSizer, MemStatsPurposeEnum nPurpose, } } - - if (m_env.p3DEngine) - { - SIZER_COMPONENT_NAME(pSizer, "Cry3DEngine"); - { - m_env.p3DEngine->GetMemoryUsage (pSizer); - { - SIZER_COMPONENT_NAME (pSizer, "$Allocations waste"); - const SmallModuleInfo* info = FindModuleInfo(stats, "Cry3DEngine.dll"); - if (info) - { - pSizer->AddObject(info, info->memInfo.allocated - info->memInfo.requested); - } - } - } - } - if (m_env.pRenderer) { SIZER_COMPONENT_NAME(pSizer, "CryRenderer"); diff --git a/Code/CryEngine/CrySystem/ViewSystem/View.cpp b/Code/CryEngine/CrySystem/ViewSystem/View.cpp index 384d1c76f5..f8b84bea19 100644 --- a/Code/CryEngine/CrySystem/ViewSystem/View.cpp +++ b/Code/CryEngine/CrySystem/ViewSystem/View.cpp @@ -98,7 +98,7 @@ void CView::Update(float frameTime, bool isActive) //see if the view have to use a custom near clipping plane const float nearPlane = (m_viewParams.nearplane >= CAMERA_MIN_NEAR) ? (m_viewParams.nearplane) : fNearZ; - const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : gEnv->p3DEngine->GetMaxViewDistance(); + const float farPlane = (m_viewParams.farplane > 0.f) ? m_viewParams.farplane : DEFAULT_FAR; float fov = (m_viewParams.fov < 0.001f) ? DEFAULT_FOV : m_viewParams.fov; // [VR] specific diff --git a/Code/CryEngine/CrySystem/ViewSystem/ViewSystem.cpp b/Code/CryEngine/CrySystem/ViewSystem/ViewSystem.cpp index 65581662c3..13f7f5b82d 100644 --- a/Code/CryEngine/CrySystem/ViewSystem/ViewSystem.cpp +++ b/Code/CryEngine/CrySystem/ViewSystem/ViewSystem.cpp @@ -533,11 +533,6 @@ void CViewSystem::BeginCutScene(IAnimSequence* pSeq, [[maybe_unused]] unsigned l { m_cutsceneCount++; - if (m_cutsceneCount == 1) - { - gEnv->p3DEngine->ResetPostEffects(); - } - VS_CALL_LISTENERS(OnBeginCutScene(pSeq, bResetFX)); } @@ -546,11 +541,6 @@ void CViewSystem::EndCutScene(IAnimSequence* pSeq, [[maybe_unused]] unsigned lon { m_cutsceneCount -= (m_cutsceneCount > 0); - if (m_cutsceneCount == 0) - { - gEnv->p3DEngine->ResetPostEffects(); - } - ClearCutsceneViews(); VS_CALL_LISTENERS(OnEndCutScene(pSeq)); diff --git a/Code/CryEngine/CrySystem/VisRegTest.cpp b/Code/CryEngine/CrySystem/VisRegTest.cpp index 81ef205b47..206d8f349a 100644 --- a/Code/CryEngine/CrySystem/VisRegTest.cpp +++ b/Code/CryEngine/CrySystem/VisRegTest.cpp @@ -18,7 +18,6 @@ #include "VisRegTest.h" #include "ISystem.h" -#include "I3DEngine.h" #include "IRenderer.h" #include "IConsole.h" #include "ITimer.h" diff --git a/Code/CryEngine/CrySystem/crysystem_files.cmake b/Code/CryEngine/CrySystem/crysystem_files.cmake index 23ad644041..bfc7b092fd 100644 --- a/Code/CryEngine/CrySystem/crysystem_files.cmake +++ b/Code/CryEngine/CrySystem/crysystem_files.cmake @@ -57,7 +57,6 @@ set(FILES UnixConsole.h SystemInit.h Serialization/MemoryReader.h - Statistics/LocalMemoryUsage.h MemoryFragmentationProfiler.h XML/ReadWriteXMLSink.h Serialization/ArchiveHost.h @@ -151,7 +150,6 @@ set(FILES MiniGUI/MiniInfoBox.h MiniGUI/MiniMenu.h MiniGUI/MiniTable.h - Statistics/LocalMemoryUsage.cpp ZLibCompressor.cpp ZLibCompressor.h SoftCode/SoftCodeMgr.cpp diff --git a/Code/Framework/AzFramework/AzFramework/Entity/EntityDebugDisplayBus.h b/Code/Framework/AzFramework/AzFramework/Entity/EntityDebugDisplayBus.h index f84f0276e1..fb6b8d7d72 100644 --- a/Code/Framework/AzFramework/AzFramework/Entity/EntityDebugDisplayBus.h +++ b/Code/Framework/AzFramework/AzFramework/Entity/EntityDebugDisplayBus.h @@ -34,6 +34,8 @@ class ITexture; namespace AzFramework { + inline constexpr AZ::s32 g_defaultSceneEntityDebugDisplayId = AZ_CRC_CE("MainViewportEntityDebugDisplayId"); // default id to draw to all viewports in the default scene + /// DebugDisplayRequests provides a debug draw api to be used by components and viewport features. class DebugDisplayRequests : public AZ::EBusTraits diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h index ea19b3a0be..95d0b9e3a7 100644 --- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h +++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesInterface.h @@ -148,6 +148,12 @@ namespace AzFramework //! Blocks until all operations made on the provided ticket before the barrier call have completed. virtual void Barrier(EntitySpawnTicket& ticket, BarrierCallback completionCallback) = 0; + //! Register a handler for OnSpawned events. + virtual void AddOnSpawnedHandler(AZ::Event>::Handler& handler) = 0; + + //! Register a handler for OnDespawned events. + virtual void AddOnDespawnedHandler(AZ::Event>::Handler& handler) = 0; + protected: [[nodiscard]] virtual void* CreateTicket(AZ::Data::Asset&& spawnable) = 0; virtual void DestroyTicket(void* ticket) = 0; diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp index 4e98616ef1..3ab004b516 100644 --- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp +++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.cpp @@ -114,6 +114,16 @@ namespace AzFramework } } + void SpawnableEntitiesManager::AddOnSpawnedHandler(AZ::Event>::Handler& handler) + { + handler.Connect(m_onSpawnedEvent); + } + + void SpawnableEntitiesManager::AddOnDespawnedHandler(AZ::Event>::Handler& handler) + { + handler.Connect(m_onDespawnedEvent); + } + auto SpawnableEntitiesManager::ProcessQueue() -> CommandQueueStatus { AZStd::queue pendingRequestQueue; @@ -223,6 +233,8 @@ namespace AzFramework ticket.m_spawnedEntities.begin() + spawnedEntitiesCount, ticket.m_spawnedEntities.end())); } + m_onSpawnedEvent.Signal(ticket.m_spawnable); + ticket.m_currentTicketId++; return true; } @@ -257,6 +269,8 @@ namespace AzFramework ticket.m_spawnedEntities.begin() + spawnedEntitiesCount, ticket.m_spawnedEntities.end())); } + m_onSpawnedEvent.Signal(ticket.m_spawnable); + ticket.m_currentTicketId++; return true; } @@ -289,6 +303,8 @@ namespace AzFramework request.m_completionCallback(*request.m_ticket); } + m_onDespawnedEvent.Signal(ticket.m_spawnable); + ticket.m_currentTicketId++; return true; } @@ -315,6 +331,8 @@ namespace AzFramework &GameEntityContextRequestBus::Events::DestroyGameEntityAndDescendants, entity->GetId()); } } + + m_onDespawnedEvent.Signal(ticket.m_spawnable); // Rebuild the list of entities. ticket.m_spawnedEntities.clear(); @@ -350,6 +368,9 @@ namespace AzFramework } ticket.m_currentTicketId++; + + m_onSpawnedEvent.Signal(ticket.m_spawnable); + return true; } else diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h index 29e9ed797b..c70b9ccaa6 100644 --- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h +++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableEntitiesManager.h @@ -60,6 +60,9 @@ namespace AzFramework void Barrier(EntitySpawnTicket& spawnInfo, BarrierCallback completionCallback) override; + void AddOnSpawnedHandler(AZ::Event>::Handler& handler) override; + void AddOnDespawnedHandler(AZ::Event>::Handler& handler) override; + // // The following function is thread safe but intended to be run from the main thread. // @@ -156,5 +159,8 @@ namespace AzFramework AZStd::deque m_delayedQueue; //!< Requests that were processed before, but couldn't be completed. AZStd::queue m_pendingRequestQueue; AZStd::mutex m_pendingRequestQueueMutex; + + AZ::Event> m_onSpawnedEvent; + AZ::Event> m_onDespawnedEvent; }; } // namespace AzFramework diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h index 56ff2010cd..884562d7e8 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h @@ -38,8 +38,9 @@ namespace AzManipulatorTestFramework void SetGridSize(float size) override; void SetAngularStep(float step) override; int GetViewportId() const override; - AZStd::optional ViewportScreenToWorld(const QPoint& screenPosition, float depth) override; - AZStd::optional ViewportScreenToWorldRay(const QPoint& screenPosition) override; + AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) override; + AZStd::optional ViewportScreenToWorldRay( + const AzFramework::ScreenPoint& screenPosition) override; private: // ViewportInteractionRequestBus ... bool GridSnappingEnabled(); @@ -47,7 +48,7 @@ namespace AzManipulatorTestFramework bool ShowGrid(); bool AngleSnappingEnabled(); float AngleStep(); - QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition); + AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition); private: AZStd::unique_ptr m_nullDebugDisplayRequests; const int m_viewportId = 1234; // Arbitrary viewport id for manipulator tests diff --git a/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp b/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp index 11f2a32441..ebef9dea30 100644 --- a/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp +++ b/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp @@ -66,10 +66,9 @@ namespace AzManipulatorTestFramework return m_angularStep; } - QPoint ViewportInteraction::ViewportWorldToScreen(const AZ::Vector3& worldPosition) + AzFramework::ScreenPoint ViewportInteraction::ViewportWorldToScreen(const AZ::Vector3& worldPosition) { - auto pos = AzFramework::WorldToScreen(worldPosition, m_cameraState); - return QPoint(pos.m_x, pos.m_y); + return AzFramework::WorldToScreen(worldPosition, m_cameraState); } void ViewportInteraction::SetCameraState(const AzFramework::CameraState& cameraState) @@ -117,12 +116,14 @@ namespace AzManipulatorTestFramework return m_viewportId; } - AZStd::optional ViewportInteraction::ViewportScreenToWorld([[maybe_unused]]const QPoint& screenPosition, [[maybe_unused]]float depth) + AZStd::optional ViewportInteraction::ViewportScreenToWorld( + [[maybe_unused]] const AzFramework::ScreenPoint& screenPosition, [[maybe_unused]] float depth) { return {}; } - AZStd::optional ViewportInteraction::ViewportScreenToWorldRay([[maybe_unused]]const QPoint& screenPosition) + AZStd::optional ViewportInteraction::ViewportScreenToWorldRay( + [[maybe_unused]] const AzFramework::ScreenPoint& screenPosition) { return {}; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.cpp index 9caca69b34..ef6d0fe1f8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.cpp @@ -117,8 +117,6 @@ namespace AzToolsFramework { EditorEntityModel::EditorEntityModel() { - AzFramework::ApplicationRequests::Bus::BroadcastResult(m_isPrefabEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); - EntityCompositionNotificationBus::Handler::BusConnect(); EditorOnlyEntityComponentNotificationBus::Handler::BusConnect(); EditorEntityRuntimeActivationChangeNotificationBus::Handler::BusConnect(); @@ -565,7 +563,7 @@ namespace AzToolsFramework { //retrieve or add an entity entry to the table //the entry must exist, even if not connected, so children and other data can be assigned - [[maybe_unused]] auto [it, inserted] = m_entityInfoTable.try_emplace(entityId, m_isPrefabEnabled); + [[maybe_unused]] auto [it, inserted] = m_entityInfoTable.try_emplace(entityId); auto& entityInfo = it->second; //the entity id defaults to invalid and must be set to match the requested id @@ -882,11 +880,6 @@ namespace AzToolsFramework } } - EditorEntityModel::EditorEntityModelEntry::EditorEntityModelEntry(bool isPrefabEnabled) - : m_isPrefabEnabled(isPrefabEnabled) - { - } - EditorEntityModel::EditorEntityModelEntry::~EditorEntityModelEntry() { Disconnect(); @@ -1213,29 +1206,15 @@ namespace AzToolsFramework auto childItr = m_childIndexCache.find(childId); if (childItr != m_childIndexCache.end()) { - if (m_isPrefabEnabled) - { - // Take the last entry and move it into the removed spot instead of deleting the entry and having to move all - // following entries one step down. - AZ::EntityId backEntity = m_children.back(); - m_children[childItr->second] = backEntity; - // Update cached index for the moved id to the new index. - m_childIndexCache[backEntity] = childItr->second; - // Now remove the deleted id from the children and cache. - m_childIndexCache.erase(childId); - m_children.erase(m_children.end() - 1); - } - else - { - m_children.erase(m_children.begin() + childItr->second); - - // rebuild index cache for faster lookup - m_childIndexCache.clear(); - for (auto childIdToCache : m_children) - { - m_childIndexCache[childIdToCache] = static_cast(m_childIndexCache.size()); - } - } + // Take the last entry and move it into the removed spot instead of deleting the entry and having to move all + // following entries one step down. + AZ::EntityId backEntity = m_children.back(); + m_children[childItr->second] = backEntity; + // Update cached index for the moved id to the new index. + m_childIndexCache[backEntity] = childItr->second; + // Now remove the deleted id from the children and cache. + m_childIndexCache.erase(childId); + m_children.erase(m_children.end() - 1); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.h index b6cceb85fe..72965b4017 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.h @@ -171,7 +171,6 @@ namespace AzToolsFramework , public PropertyEditorEntityChangeNotificationBus::Handler { public: - explicit EditorEntityModelEntry(bool isPrefabEnabled); ~EditorEntityModelEntry(); // Separately connect to EditorEntityInfoRequestBus and refresh Entity @@ -336,7 +335,6 @@ namespace AzToolsFramework bool m_visible = true; bool m_locked = false; bool m_connected = false; - bool m_isPrefabEnabled = false; AZStd::string m_name; AZStd::string m_sliceAssetName; AZStd::unordered_map m_childIndexCache; @@ -375,6 +373,5 @@ namespace AzToolsFramework AZ::EntityId m_postInstantiateBeforeEntity; AZ::EntityId m_postInstantiateSliceParent; bool m_gotInstantiateSliceDetails = false; - bool m_isPrefabEnabled = false; }; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp index 089037bbf3..4d10a4c171 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp @@ -127,8 +127,7 @@ namespace AzToolsFramework ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult( worldSurfacePosition, viewportId, &ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain, - ViewportInteraction::QPointFromScreenPoint( - mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates)); + mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates); AZ::Transform worldFromLocal; AZ::TransformBus::EventResult(worldFromLocal, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM); @@ -402,10 +401,10 @@ namespace AzToolsFramework vertexIndex, localVertex); const AZ::Vector3 worldVertex = worldFromLocal.TransformPoint(AZ::AdaptVertexOut(localVertex)); - const QPoint screenPosition = GetScreenPosition(viewportId, worldVertex); + const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, worldVertex); // check if a vertex is inside the box select region - if (editorBoxSelect.BoxRegion()->contains(screenPosition)) + if (editorBoxSelect.BoxRegion()->contains(ViewportInteraction::QPointFromScreenPoint(screenPosition))) { // see if vertexIndex is in active selection auto vertexIt = AZStd::find( diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp index e4d0cd59dd..f570c20a7e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/SurfaceManipulator.cpp @@ -103,8 +103,7 @@ namespace AzToolsFramework ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult( worldSurfacePosition, interaction.m_interactionId.m_viewportId, &ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain, - ViewportInteraction::QPointFromScreenPoint( - interaction.m_mousePick.m_screenCoordinates)); + interaction.m_mousePick.m_screenCoordinates); m_startInternal = CalculateManipulationDataStart( worldFromLocalUniformScale, worldSurfacePosition, GetLocalPosition(), @@ -129,8 +128,7 @@ namespace AzToolsFramework ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult( worldSurfacePosition, interaction.m_interactionId.m_viewportId, &ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain, - ViewportInteraction::QPointFromScreenPoint( - interaction.m_mousePick.m_screenCoordinates)); + interaction.m_mousePick.m_screenCoordinates); const GridSnapParameters gridSnapParams = GridSnapSettings(interaction.m_interactionId.m_viewportId); @@ -150,8 +148,7 @@ namespace AzToolsFramework ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult( worldSurfacePosition, interaction.m_interactionId.m_viewportId, &ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain, - ViewportInteraction::QPointFromScreenPoint( - interaction.m_mousePick.m_screenCoordinates)); + interaction.m_mousePick.m_screenCoordinates); const GridSnapParameters gridSnapParams = GridSnapSettings(interaction.m_interactionId.m_viewportId); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h index a9949d382e..6ceb175fe4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h @@ -21,8 +21,6 @@ #include #include -class QPoint; // LYN-2315 in-progress, remove this - namespace AzFramework { struct ScreenPoint; @@ -167,14 +165,14 @@ namespace AzToolsFramework /// Return the angle snapping/step size. virtual float AngleStep() = 0; /// Transform a point in world space to screen space coordinates. - virtual QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) = 0; + virtual AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) = 0; /// Transform a point in screen space coordinates to a vector in world space based on clip space depth. /// Depth specifies a relative camera depth to project in the range of [0.f, 1.f]. /// Returns the world space position if successful. - virtual AZStd::optional ViewportScreenToWorld(const QPoint& screenPosition, float depth) = 0; + virtual AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) = 0; /// Casts a point in screen space to a ray in world space originating from the viewport camera frustum's near plane. /// Returns a ray containing the ray's origin and a direction normal, if successful. - virtual AZStd::optional ViewportScreenToWorldRay(const QPoint& screenPosition) = 0; + virtual AZStd::optional ViewportScreenToWorldRay(const AzFramework::ScreenPoint& screenPosition) = 0; protected: ~ViewportInteractionRequests() = default; @@ -207,9 +205,9 @@ namespace AzToolsFramework public: /// Given a point in screen space, return the picked entity (if any). /// Picked EntityId will be returned, InvalidEntityId will be returned on failure. - virtual AZ::EntityId PickEntity(const QPoint& point) = 0; + virtual AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) = 0; /// Given a point in screen space, return the terrain position in world space. - virtual AZ::Vector3 PickTerrain(const QPoint& point) = 0; + virtual AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) = 0; /// Return the terrain height given a world position in 2d (xy plane). virtual float TerrainHeight(const AZ::Vector2& position) = 0; /// Given the current view frustum (viewport) return all visible entities. diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp index 12a0d6a8ab..8d26054562 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp @@ -19,8 +19,6 @@ namespace AzToolsFramework { namespace ViewportInteraction { - const AZ::s32 g_mainViewportEntityDebugDisplayId = AZ_CRC("MainViewportEntityDebugDisplayId", 0x58ae7fe8); - void ViewportInteractionReflect(AZ::ReflectContext* context) { if (auto serializeContext = azrtti_cast(context)) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h index 161ca2d79f..d59044e68f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h @@ -256,9 +256,5 @@ namespace AzToolsFramework /// Reflect all viewport related types. void ViewportInteractionReflect(AZ::ReflectContext* context); - - /// The Id the main DebugDisplayRequestBus will be connected on. - extern const AZ::s32 g_mainViewportEntityDebugDisplayId; - } // namespace ViewportInteraction } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index f3abc70fba..68a5b43d73 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -141,16 +141,16 @@ namespace AzToolsFramework const AZ::Vector3& entityPosition = m_entityDataCache->GetVisibleEntityPosition(entityCacheIndex); // selecting based on 2d icon - should only do it when visible and not selected - const QPoint screenPosition = GetScreenPosition(viewportId, entityPosition); + const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, entityPosition); const float distSqFromCamera = cameraState.m_position.GetDistanceSq(entityPosition); const auto iconRange = static_cast(GetIconScale(distSqFromCamera) * s_iconSize * 0.5f); const auto screenCoords = mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates; - if ( screenCoords.m_x >= screenPosition.x() - iconRange - && screenCoords.m_x <= screenPosition.x() + iconRange - && screenCoords.m_y >= screenPosition.y() - iconRange - && screenCoords.m_y <= screenPosition.y() + iconRange) + if ( screenCoords.m_x >= screenPosition.m_x - iconRange + && screenCoords.m_x <= screenPosition.m_x + iconRange + && screenCoords.m_y >= screenPosition.m_y - iconRange + && screenCoords.m_y <= screenPosition.m_y + iconRange) { entityIdUnderCursor = entityId; break; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp index 95095bd3c8..3be4bc9db2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.cpp @@ -53,11 +53,11 @@ namespace AzToolsFramework return AZ::GetMax(projectedCameraDistance, cameraState.m_nearClip) / apparentDistance; } - QPoint GetScreenPosition(const int viewportId, const AZ::Vector3& worldTranslation) + AzFramework::ScreenPoint GetScreenPosition(const int viewportId, const AZ::Vector3& worldTranslation) { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); - QPoint screenPosition = QPoint(); + auto screenPosition = AzFramework::ScreenPoint(0, 0); ViewportInteraction::ViewportInteractionRequestBus::EventResult( screenPosition, viewportId, &ViewportInteraction::ViewportInteractionRequestBus::Events::ViewportWorldToScreen, diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h index 65e0a99bfe..9936fb9afd 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorSelectionUtil.h @@ -45,7 +45,7 @@ namespace AzToolsFramework const AZ::Vector3& worldPosition, const AzFramework::CameraState& cameraState); /// Map from world space to screen space. - QPoint GetScreenPosition(int viewportId, const AZ::Vector3& worldTranslation); + AzFramework::ScreenPoint GetScreenPosition(int viewportId, const AZ::Vector3& worldTranslation); /// Given a mouse interaction, determine if the pick ray from its position /// in screen space intersected an aabb in world space. diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index ec22a2f7c8..9388f3f5f0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -316,14 +316,14 @@ namespace AzToolsFramework template static void BoxSelectAddRemoveToEntitySelection( - const AZStd::optional& boxSelect, const QPoint& screenPosition, const AZ::EntityId visibleEntityId, + const AZStd::optional& boxSelect, const AzFramework::ScreenPoint& screenPosition, const AZ::EntityId visibleEntityId, const EntityIdContainer& incomingEntityIds, EntityIdContainer& outgoingEntityIds, EditorTransformComponentSelection& entityTransformComponentSelection, EntitySelectFuncType selectFunc1, EntitySelectFuncType selectFunc2, Compare outgoingCheck) { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); - if (boxSelect->contains(screenPosition)) + if (boxSelect->contains(ViewportInteraction::QPointFromScreenPoint(screenPosition))) { const auto entityIt = incomingEntityIds.find(visibleEntityId); @@ -389,7 +389,7 @@ namespace AzToolsFramework const AZ::EntityId entityId = entityDataCache.GetVisibleEntityId(entityCacheIndex); const AZ::Vector3& entityPosition = entityDataCache.GetVisibleEntityPosition(entityCacheIndex); - const QPoint screenPosition = GetScreenPosition(viewportId, entityPosition); + const AzFramework::ScreenPoint screenPosition = GetScreenPosition(viewportId, entityPosition); if (currentKeyboardModifiers.Ctrl()) { @@ -927,7 +927,7 @@ namespace AzToolsFramework ViewportInteraction::MainEditorViewportInteractionRequestBus::EventResult( worldSurfacePosition, viewportId, &ViewportInteraction::MainEditorViewportInteractionRequestBus::Events::PickTerrain, - ViewportInteraction::QPointFromScreenPoint(mouseInteraction.m_mousePick.m_screenCoordinates)); + mouseInteraction.m_mousePick.m_screenCoordinates); // convert to local space - snap if enabled const GridSnapParameters gridSnapParams = GridSnapSettings(viewportId); diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp index c81db58c95..d1bd2a488e 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/Benchmark/PrefabUpdateInstancesBenchmarks.cpp @@ -78,7 +78,7 @@ namespace Benchmark } BENCHMARK_REGISTER_F(BM_PrefabUpdateInstances, UpdateInstances_SingeEntityInstances) ->RangeMultiplier(10) - ->Range(100, 1000) + ->Range(100, 10000) ->Unit(benchmark::kMillisecond) ->Complexity(); diff --git a/Code/Sandbox/Editor/2DViewport.cpp b/Code/Sandbox/Editor/2DViewport.cpp index d86ea03bdf..0487c9381f 100644 --- a/Code/Sandbox/Editor/2DViewport.cpp +++ b/Code/Sandbox/Editor/2DViewport.cpp @@ -650,114 +650,6 @@ void Q2DViewport::OnDestroy() ////////////////////////////////////////////////////////////////////////// void Q2DViewport::Render() { - if (GetIEditor()->IsInGameMode()) - { - return; - } - - if (!m_renderer) - { - return; - } - - if (!isVisible()) - { - return; - } - - if (!GetIEditor()->GetDocument()->IsDocumentReady()) - { - return; - } - - if (m_renderer->IsStereoEnabled()) - { - return; - } - - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - - QRect rc = rect(); - if (rc.isEmpty()) - { - return; - } - - CalculateViewTM(); - - // Render - WIN_HWND priorContext = m_renderer->GetCurrentContextHWND(); - - m_renderer->SetCurrentContext(renderOverlayHWND()); - m_renderer->BeginFrame(); - m_renderer->ChangeViewport(0, 0, rc.right(), rc.bottom(), true); - - CScopedWireFrameMode scopedWireFrame(m_renderer, R_SOLID_MODE); - auto colorf = Rgb2ColorF(m_colorBackground); - m_renderer->ClearTargetsLater(FRT_CLEAR, colorf); - - ////////////////////////////////////////////////////////////////////////// - // 2D Mode. - ////////////////////////////////////////////////////////////////////////// - if (rc.right() != 0 && rc.bottom() != 0) - { - TransformationMatrices backupSceneMatrices; - - m_renderer->Set2DMode(rc.right(), rc.bottom(), backupSceneMatrices); - - ////////////////////////////////////////////////////////////////////////// - // Draw viewport elements here. - ////////////////////////////////////////////////////////////////////////// - // Calc world bounding box for objects rendering. - m_displayBounds = GetWorldBounds(QPoint(0, 0), QPoint(rc.width(), rc.height())); - - // Draw all objects. - DisplayContext& dc = m_displayContext; - dc.settings = GetIEditor()->GetDisplaySettings(); - dc.view = this; - dc.renderer = m_renderer; - dc.engine = GetIEditor()->Get3DEngine(); - dc.flags = DISPLAY_2D; - dc.box = m_displayBounds; - dc.camera = &GetIEditor()->GetSystem()->GetViewCamera(); - - if (!dc.settings->IsDisplayLabels() || !dc.settings->IsDisplayHelpers()) - { - dc.flags |= DISPLAY_HIDENAMES; - } - if (dc.settings->IsDisplayLinks() && dc.settings->IsDisplayHelpers()) - { - dc.flags |= DISPLAY_LINKS; - } - if (m_bDegradateQuality) - { - dc.flags |= DISPLAY_DEGRADATED; - } - - SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(GetIEditor()->GetSystem()->GetViewCamera()); - - m_renderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID()); - m_renderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID()); - m_renderer->EF_StartEf(passInfo); - - dc.SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOff | e_DepthTestOn); - Draw(dc); - - m_renderer->EF_EndEf3D(SHDF_STREAM_SYNC, -1, -1, passInfo); - - m_renderer->EF_RenderTextMessages(); - - // Return back from 2D mode. - m_renderer->Unset2DMode(backupSceneMatrices); - - m_renderer->RenderDebug(false); - - ProcessRenderLisneters(m_displayContext); - - m_renderer->EndFrame(); - } - - GetIEditor()->GetRenderer()->SetCurrentContext(priorContext); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp index 0c99e63c47..c8bd157b65 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp @@ -50,8 +50,6 @@ #include "Include/IObjectManager.h" #include "CryEditDoc.h" #include "QtViewPaneManager.h" -#include "AzAssetBrowser/Preview/LegacyPreviewerFactory.h" - namespace AzAssetBrowserRequestHandlerPrivate { @@ -230,18 +228,15 @@ namespace AzAssetBrowserRequestHandlerPrivate } AzAssetBrowserRequestHandler::AzAssetBrowserRequestHandler() - : m_previewerFactory(aznew LegacyPreviewerFactory) { using namespace AzToolsFramework::AssetBrowser; AssetBrowserInteractionNotificationBus::Handler::BusConnect(); AzQtComponents::DragAndDropEventsBus::Handler::BusConnect(AzQtComponents::DragAndDropContexts::EditorViewport); - AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusConnect(); } AzAssetBrowserRequestHandler::~AzAssetBrowserRequestHandler() { - AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusDisconnect(); AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect(); AzQtComponents::DragAndDropEventsBus::Handler::BusDisconnect(); } @@ -527,15 +522,6 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA } } -const AzToolsFramework::AssetBrowser::PreviewerFactory* AzAssetBrowserRequestHandler::GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const -{ - if (m_previewerFactory->IsEntrySupported(entry)) - { - return m_previewerFactory.get(); - } - return nullptr; -} - void AzAssetBrowserRequestHandler::AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) { using namespace AzToolsFramework; diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.h index 5b7e10f2a1..707b9041ae 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.h @@ -37,12 +37,9 @@ namespace AzToolsFramework } } -class LegacyPreviewerFactory; - class AzAssetBrowserRequestHandler : protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler , protected AzQtComponents::DragAndDropEventsBus::Handler - , protected AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler { public: AzAssetBrowserRequestHandler(); @@ -66,16 +63,8 @@ protected: void DragLeave(QDragLeaveEvent* event) override; void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override; - ////////////////////////////////////////////////////////////////////////// - // PreviewerRequestBus::Handler - ////////////////////////////////////////////////////////////////////////// - const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override; - bool CanAcceptDragAndDropEvent( QDropEvent* event, AzQtComponents::DragAndDropContextBase& context, AZStd::optional*> outSources = AZStd::nullopt, AZStd::optional*> outProducts = AZStd::nullopt) const; - -private: - AZStd::unique_ptr m_previewerFactory; }; diff --git a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.cpp b/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.cpp deleted file mode 100644 index 19938db676..0000000000 --- a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.cpp +++ /dev/null @@ -1,409 +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 "EditorDefs.h" - -#include "LegacyPreviewer.h" - -// AzToolsFramework -#include -#include -#include - -// Editor -#include "Util/Image.h" -#include "Util/ImageUtil.h" - -AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING -#include -AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - -static const int s_CharWidth = 6; -const QString LegacyPreviewer::Name{ QStringLiteral("LegacyPreviewer") }; - -LegacyPreviewer::LegacyPreviewer(QWidget* parent) - : Previewer(parent) - , m_ui(new Ui::LegacyPreviewerClass()) - , m_textureType(TextureType::RGB) -{ - m_ui->setupUi(this); - m_ui->m_comboBoxRGB->addItems(QStringList() << "RGB" << "RGBA" << "Alpha"); - m_ui->m_previewCtrl->SetAspectRatio(4.0f / 3.0f); - connect(m_ui->m_comboBoxRGB, static_cast(&QComboBox::activated), this, - [=](int index) - { - m_textureType = static_cast(index); - UpdateTextureType(); - }); - Clear(); -} - -LegacyPreviewer::~LegacyPreviewer() -{ -} - -void LegacyPreviewer::Clear() const -{ - m_ui->m_previewCtrl->ReleaseObject(); - m_ui->m_modelPreviewWidget->hide(); - m_ui->m_texturePreviewWidget->hide(); - m_ui->m_fileInfoCtrl->hide(); -} - -void LegacyPreviewer::Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) -{ - using namespace AzToolsFramework::AssetBrowser; - - if (!entry) - { - Clear(); - return; - } - - switch (entry->GetEntryType()) - { - case AssetBrowserEntry::AssetEntryType::Source: - { - const SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry); - DisplaySource(sourceEntry); - break; - } - case AssetBrowserEntry::AssetEntryType::Product: - DisplayProduct(static_cast(entry)); - break; - default: - Clear(); - } -} - -const QString& LegacyPreviewer::GetName() const -{ - return Name; -} - -void LegacyPreviewer::resizeEvent(QResizeEvent* /*event*/) -{ - m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth)); -} - -bool LegacyPreviewer::DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product) -{ - m_ui->m_fileInfoCtrl->show(); - - m_fileinfo = QString::fromUtf8(product->GetName().c_str()); - - m_fileinfo += GetFileSize(product->GetRelativePath().c_str()); - - EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh"); - AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType); - - QString filename(product->GetRelativePath().c_str()); - - // Find item. - if (product->GetAssetType() == meshAssetTypeResult.GetAssetType()) - { - m_ui->m_modelPreviewWidget->show(); - m_ui->m_texturePreviewWidget->hide(); - m_ui->m_previewCtrl->LoadFile(filename); - - int nVertexCount = m_ui->m_previewCtrl->GetVertexCount(); - int nFaceCount = m_ui->m_previewCtrl->GetFaceCount(); - int nMaxLod = m_ui->m_previewCtrl->GetMaxLod(); - int nMtls = m_ui->m_previewCtrl->GetMtlCount(); - if (nFaceCount > 0) - { - m_fileinfo += tr("\r\n%1 Faces\r\n%2 Verts\r\n%3 MaxLod\r\n%4 Materials").arg(nFaceCount).arg(nVertexCount).arg(nMaxLod).arg(nMtls); - } - m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth)); - updateGeometry(); - return true; - } - - EBusFindAssetTypeByName textureAssetTypeResult("Texture"); - AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType); - - if (product->GetAssetType() == textureAssetTypeResult.GetAssetType()) - { - // Get full product file path - const char* assetCachePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@assets@"); - AZStd::string productFullPath; - AzFramework::StringFunc::Path::Join(assetCachePath, product->GetRelativePath().c_str(), productFullPath); - if (AZ::IO::FileIOBase::GetInstance()->Exists(productFullPath.c_str())) - { - // Try to display it in modern dds image loader, if no one exists, use the legacy image loader - bool foundPixmap = DisplayTextureProductModern(productFullPath.c_str()); - return foundPixmap ? foundPixmap : DisplayTextureLegacy(productFullPath.c_str()); - } - else - { - // If we cannot find the product file, means it's not treated as an asset, display its source - return DisplayTextureLegacy(product->GetFullPath().c_str()); - } - } - - Clear(); - return false; -} - -void LegacyPreviewer::DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source) -{ - using namespace AzToolsFramework::AssetBrowser; - - EBusFindAssetTypeByName textureAssetType("Texture"); - AZ::AssetTypeInfoBus::BroadcastResult(textureAssetType, &AZ::AssetTypeInfo::GetAssetType); - - if (source->GetPrimaryAssetType() == textureAssetType.GetAssetType()) - { - m_ui->m_fileInfoCtrl->show(); - m_fileinfo = QString::fromUtf8(source->GetName().c_str()); - m_fileinfo += GetFileSize(source->GetFullPath().c_str()); - const char* fullSourcePath = source->GetFullPath().c_str(); - // If it's a source dds file, try to display it using modern way - if (AzFramework::StringFunc::Path::IsExtension(fullSourcePath, "dds", false)) - { - if (DisplayTextureProductModern(fullSourcePath)) - { - return; - } - } - DisplayTextureLegacy(source->GetFullPath().c_str()); - } - else - { - AZStd::vector products; - source->GetChildrenRecursively(products); - if (products.empty()) - { - Clear(); - } - else - { - for (auto* product : products) - { - if (DisplayProduct(product)) - { - break; - } - } - } - } -} - -QString LegacyPreviewer::GetFileSize(const char* path) -{ - QString fileSizeStr; - AZ::u64 fileSizeResult = 0; - if (AZ::IO::FileIOBase::GetInstance()->Size(path, fileSizeResult)) - { - static double kb = 1024.0f; - static double mb = kb * 1024.0; - static double gb = mb * 1024.0; - - static QString byteStr = "B"; - static QString kbStr = "KB"; - static QString mbStr = "MB"; - static QString gbStr = "GB"; - -#if AZ_TRAIT_OS_PLATFORM_APPLE - kb = 1000.0; - mb = kb * 1000.0; - gb = mb * 1000.0; - - kbStr = "kB"; - mbStr = "mB"; - gbStr = "gB"; -#endif // AZ_TRAIT_OS_PLATFORM_APPLE - - if (fileSizeResult < kb) - { - fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(fileSizeResult), byteStr); - } - else if (fileSizeResult < mb) - { - double size = fileSizeResult / kb; - fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), kbStr); - } - else if (fileSizeResult < gb) - { - double size = fileSizeResult / mb; - fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), mbStr); - } - else - { - double size = fileSizeResult / gb; - fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), gbStr); - } - } - return fileSizeStr; -} - -bool LegacyPreviewer::DisplayTextureLegacy(const char* fullImagePath) -{ - m_ui->m_modelPreviewWidget->hide(); - m_ui->m_texturePreviewWidget->show(); - - bool foundPixmap = false; - if (!AZ::IO::FileIOBase::GetInstance()->IsDirectory(fullImagePath)) - { - QString strLoadFilename = QString(fullImagePath); - if (CImageUtil::LoadImage(strLoadFilename, m_previewImageSource)) - { - m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3") - .arg(m_previewImageSource.GetWidth()) - .arg(m_previewImageSource.GetHeight()) - .arg(m_previewImageSource.GetFormatDescription()); - - m_fileinfoAlphaTexture = m_fileinfo; - UpdateTextureType(); - foundPixmap = true; - } - } - - if (!foundPixmap) - { - m_ui->m_previewImageCtrl->setPixmap(QPixmap()); - m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth)); - } - - updateGeometry(); - - return foundPixmap; -} - -bool LegacyPreviewer::DisplayTextureProductModern(const char* fullProductImagePath) -{ - m_ui->m_modelPreviewWidget->hide(); - m_ui->m_texturePreviewWidget->show(); - - bool foundPixmap = false; - QImage previewImage; - AZStd::string productInfo; - AZStd::string productAlphaInfo; - AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequestsBus::BroadcastResult(foundPixmap, &AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequests::GetProductTexturePreview, fullProductImagePath, previewImage, productInfo, productAlphaInfo); - - if (foundPixmap) - { - QPixmap pix = QPixmap::fromImage(previewImage); - m_ui->m_previewImageCtrl->setPixmap(pix); - m_ui->m_previewImageCtrl->updateGeometry(); - CImageUtil::QImageToImage(previewImage, m_previewImageSource); - - m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3") - .arg(m_previewImageSource.GetWidth()) - .arg(m_previewImageSource.GetHeight()) - .arg(m_previewImageSource.GetFormatDescription()); - - m_fileinfoAlphaTexture = m_fileinfo; - - m_fileinfo += QString(productInfo.c_str()); - if (productAlphaInfo.empty()) - { - // If there is no separate info for alpha, use the image info - m_fileinfoAlphaTexture += QString(productInfo.c_str()); - } - else - { - m_fileinfoAlphaTexture += QString(productAlphaInfo.c_str()); - } - - - UpdateTextureType(); - } - else - { - m_ui->m_previewImageCtrl->setPixmap(QPixmap()); - m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth)); - } - - updateGeometry(); - return foundPixmap; -} - -void LegacyPreviewer::UpdateTextureType() -{ - m_previewImageUpdated.Copy(m_previewImageSource); - - switch (m_textureType) - { - case TextureType::RGB: - { - m_previewImageUpdated.SwapRedAndBlue(); - m_previewImageUpdated.FillAlpha(); - break; - } - case TextureType::RGBA: - { - m_previewImageUpdated.SwapRedAndBlue(); - break; - } - case TextureType::Alpha: - { - for (int h = 0; h < m_previewImageUpdated.GetHeight(); h++) - { - for (int w = 0; w < m_previewImageUpdated.GetWidth(); w++) - { - int a = m_previewImageUpdated.ValueAt(w, h) >> 24; - m_previewImageUpdated.ValueAt(w, h) = RGB(a, a, a) | 0xFF000000; - } - } - break; - } - } - // note that Qt will not deep copy the data, so WE MUST KEEP THE IMAGE DATA AROUND! - QPixmap qtPixmap = QPixmap::fromImage( - QImage(reinterpret_cast(m_previewImageUpdated.GetData()), m_previewImageUpdated.GetWidth(), m_previewImageUpdated.GetHeight(), QImage::Format_ARGB32)); - m_ui->m_previewImageCtrl->setPixmap(qtPixmap); - m_ui->m_fileInfoCtrl->setText(WordWrap(m_textureType == TextureType::Alpha? m_fileinfoAlphaTexture: m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth)); - m_ui->m_previewImageCtrl->updateGeometry(); -} - -bool LegacyPreviewer::FileInfoCompare(const FileInfo& f1, const FileInfo& f2) -{ - if ((f1.attrib & _A_SUBDIR) && !(f2.attrib & _A_SUBDIR)) - { - return true; - } - if (!(f1.attrib & _A_SUBDIR) && (f2.attrib & _A_SUBDIR)) - { - return false; - } - - return QString::compare(f1.filename, f2.filename, Qt::CaseInsensitive) < 0; -} - -QString LegacyPreviewer::WordWrap(const QString& string, int maxLength) -{ - QString result; - int length = 0; - - for (auto c : string) - { - if (c == '\n') - { - length = 0; - } - else if (length > maxLength) - { - result.append('\n'); - length = 0; - } - else - { - length++; - } - result.append(c); - } - return result; -} - -#include diff --git a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.h b/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.h deleted file mode 100644 index 0035f23442..0000000000 --- a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.h +++ /dev/null @@ -1,100 +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 - -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include -#include -#endif - -namespace Ui -{ - class LegacyPreviewerClass; -} - -namespace AzToolsFramework -{ - namespace AssetBrowser - { - class ProductAssetBrowserEntry; - class SourceAssetBrowserEntry; - class AssetBrowserEntry; - } -} - -class QResizeEvent; - -class LegacyPreviewer - : public AzToolsFramework::AssetBrowser::Previewer -{ - Q_OBJECT -public: - AZ_CLASS_ALLOCATOR(LegacyPreviewer, AZ::SystemAllocator, 0); - - explicit LegacyPreviewer(QWidget* parent = nullptr); - ~LegacyPreviewer(); - - ////////////////////////////////////////////////////////////////////////// - // AzToolsFramework::AssetBrowser::Previewer - ////////////////////////////////////////////////////////////////////////// - void Clear() const override; - void Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) override; - const QString& GetName() const override; - - static const QString Name; - -protected: - void resizeEvent(QResizeEvent * event) override; - -private: - struct FileInfo - { - QString filename; - unsigned attrib; - time_t time_create; /* -1 for FAT file systems */ - time_t time_access; /* -1 for FAT file systems */ - time_t time_write; - _fsize_t size; - }; - - enum class TextureType - { - RGB, - RGBA, - Alpha - }; - - QScopedPointer m_ui; - CImageEx m_previewImageSource; - CImageEx m_previewImageUpdated; - TextureType m_textureType; - QString m_fileinfo; - QString m_fileinfoAlphaTexture; - - bool DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product); - void DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source); - - QString GetFileSize(const char* path); - - bool DisplayTextureLegacy(const char* fullImagePath); - bool DisplayTextureProductModern(const char* fullProductImagePath); - - void UpdateTextureType(); - - static bool FileInfoCompare(const FileInfo& f1, const FileInfo& f2); - //! QLabel word wrap does not break long words such as filenames, so manual word wrap needed - static QString WordWrap(const QString& string, int maxLength); -}; diff --git a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.ui b/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.ui deleted file mode 100644 index 649192d60f..0000000000 --- a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewer.ui +++ /dev/null @@ -1,176 +0,0 @@ - - - LegacyPreviewerClass - - - - 0 - 0 - 148 - 282 - - - - Preview - - - - 0 - - - 5 - - - 0 - - - 5 - - - 0 - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - Qt::AutoText - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - CPreviewModelCtrl - QWidget -
Controls/PreviewModelCtrl.h
- 1 -
- - AzToolsFramework::AspectRatioAwarePixmapWidget - QWidget -
AzToolsFramework/UI/UICore/AspectRatioAwarePixmapWidget.hxx
- 1 -
-
- - -
diff --git a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewerFactory.cpp b/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewerFactory.cpp deleted file mode 100644 index 93620d26a6..0000000000 --- a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewerFactory.cpp +++ /dev/null @@ -1,71 +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 "EditorDefs.h" - -#include "LegacyPreviewerFactory.h" - -// AzToolsFramework -#include // for AssetBrowserEntry::AssetEntryType -#include // for EBusFindAssetTypeByName - -// Editor -#include "LegacyPreviewer.h" - - -AzToolsFramework::AssetBrowser::Previewer* LegacyPreviewerFactory::CreatePreviewer(QWidget* parent) const -{ - return new LegacyPreviewer(parent); -} - -bool LegacyPreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const -{ - using namespace AzToolsFramework::AssetBrowser; - - EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh"); - AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType); - EBusFindAssetTypeByName textureAssetTypeResult("Texture"); - AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType); - - switch (entry->GetEntryType()) - { - case AssetBrowserEntry::AssetEntryType::Source: - { - const auto* source = azrtti_cast < const SourceAssetBrowserEntry * > (entry); - if (source->GetPrimaryAssetType() == textureAssetTypeResult.GetAssetType()) - { - return true; - } - AZStd::vector < const ProductAssetBrowserEntry * > products; - source->GetChildrenRecursively < ProductAssetBrowserEntry > (products); - for (auto* product : products) - { - if (product->GetAssetType() == textureAssetTypeResult.GetAssetType() || - product->GetAssetType() == meshAssetTypeResult.GetAssetType()) - { - return true; - } - } - break; - } - case AssetBrowserEntry::AssetEntryType::Product: - const auto* product = azrtti_cast < const ProductAssetBrowserEntry * > (entry); - return product->GetAssetType() == textureAssetTypeResult.GetAssetType() || - product->GetAssetType() == meshAssetTypeResult.GetAssetType(); - } - return false; -} - -const QString& LegacyPreviewerFactory::GetName() const -{ - return LegacyPreviewer::Name; -} diff --git a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewerFactory.h b/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewerFactory.h deleted file mode 100644 index e6b133cb97..0000000000 --- a/Code/Sandbox/Editor/AzAssetBrowser/Preview/LegacyPreviewerFactory.h +++ /dev/null @@ -1,34 +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 -#include - -class QString; - -class LegacyPreviewerFactory final - : public AzToolsFramework::AssetBrowser::PreviewerFactory -{ -public: - AZ_CLASS_ALLOCATOR(LegacyPreviewerFactory, AZ::SystemAllocator, 0); - - LegacyPreviewerFactory() = default; - ~LegacyPreviewerFactory() = default; - - ////////////////////////////////////////////////////////////////////////// - // AzToolsFramework::AssetBrowser::PreviewerFactory - ////////////////////////////////////////////////////////////////////////// - AzToolsFramework::AssetBrowser::Previewer* CreatePreviewer(QWidget* parent = nullptr) const override; - bool IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override; - const QString& GetName() const override; -}; diff --git a/Code/Sandbox/Editor/BaseLibraryManager.cpp b/Code/Sandbox/Editor/BaseLibraryManager.cpp index 61c6354b1a..d9017c1be8 100644 --- a/Code/Sandbox/Editor/BaseLibraryManager.cpp +++ b/Code/Sandbox/Editor/BaseLibraryManager.cpp @@ -826,9 +826,6 @@ void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event) SetSelectedItem(0); ClearAll(); break; - case eNotify_OnMissionChange: - SetSelectedItem(0); - break; case eNotify_OnCloseScene: SetSelectedItem(0); ClearAll(); diff --git a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp b/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp deleted file mode 100644 index 9b07f59e6a..0000000000 --- a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.cpp +++ /dev/null @@ -1,1194 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "PreviewModelCtrl.h" - -// AzQtComponents -#include - -// Editor -#include "Settings.h" -#include "Util/Image.h" -#include "Include/IIconManager.h" - -struct CPreviewModelCtrl::SPreviousContext -{ - CCamera renderCamera; - CCamera systemCamera; - int width; - int height; - HWND window; - bool isMainViewport; -}; - -CPreviewModelCtrl::CPreviewModelCtrl(QWidget* parent, Qt::WindowFlags f) - : QWidget(parent, f) -{ - OnCreate(); -} - -void CPreviewModelCtrl::OnCreate() -{ - m_bShowObject = true; - m_pRenderer = 0; - m_pObj = 0; - m_pEntity = 0; - m_nTimer = 0; - m_size = Vec3(0, 0, 0); - - m_bRotate = false; - m_rotateAngle = 0; - - m_backgroundTextureId = 0; - - m_pRenderer = GetIEditor()->GetRenderer(); - - m_fov = 60; - m_camera.SetFrustum(800, 600, DEG2RAD(m_fov), 0.02f, 10000.0f); - - m_bInRotateMode = false; - m_bInMoveMode = false; - - CDLight l; - - float L = 1.0f; - l.m_fRadius = 10000; - l.m_Flags |= DLF_SUN | DLF_DIRECTIONAL; - l.SetLightColor(ColorF(L, L, L, 1)); - l.SetPosition(Vec3(100, 100, 100)); - m_lights.push_back(l); - - m_bUseBacklight = false; - m_bContextCreated = false; - m_bHaveAnythingToRender = false; - m_bGrid = true; - m_bAxis = true; - m_bAxisParticleEditor = false; - m_bUpdate = false; - m_bShowNormals = false; - m_bShowPhysics = false; - m_bShowRenderInfo = false; - - m_cameraAngles.Set(0, 0, 0); - - m_clearColor.Set(0.5f, 0.5f, 0.5f); - m_ambientColor.Set(1.0f, 1.0f, 1.0f); - m_ambientMultiplier = 0.5f; - - m_cameraChangeCallback = NULL; - m_bPrecacheMaterial = false; - m_bDrawWireFrame = false; - - m_tileX = 0.0f; - m_tileY = 0.0f; - m_tileSizeX = 1.0f; - m_tileSizeY = 1.0f; - - m_aabb = AABB(2); - FitToScreen(); - - setAttribute(Qt::WA_NativeWindow); - setAttribute(Qt::WA_PaintOnScreen); - setAttribute(Qt::WA_OpaquePaintEvent); - - GetIEditor()->RegisterNotifyListener(this); -} - -CPreviewModelCtrl::~CPreviewModelCtrl() -{ - OnDestroy(); - ReleaseObject(); - GetIEditor()->UnregisterNotifyListener(this); -} - -bool CPreviewModelCtrl::CreateContext() -{ - // Create context. - if (m_pRenderer && !m_bContextCreated) - { - StorePreviousContext(); - m_bContextCreated = true; - - // save the old context, because CreateContext sets it, and we don't actually want that: - StorePreviousContext(); - m_pRenderer->CreateContext(m_hWnd); - - RestorePreviousContext(); - return true; - } - return false; -} - -void CPreviewModelCtrl::ReleaseObject() -{ - m_pObj = NULL; - m_pEntity = 0; - m_bHaveAnythingToRender = false; -} - -void CPreviewModelCtrl::LoadFile(const QString& modelFile, bool changeCamera) -{ - m_bHaveAnythingToRender = false; - if (!m_hWnd) - { - return; - } - if (!m_pRenderer) - { - return; - } - - ReleaseObject(); - - if (modelFile.isEmpty()) - { - if (m_nTimer != 0) - { - killTimer(m_nTimer); - } - m_nTimer = 0; - update(); - return; - } - - m_loadedFile = modelFile; - - QString strFileExt = QFileInfo(modelFile).suffix(); - const bool isSKEL = strFileExt.compare(QStringLiteral(CRY_SKEL_FILE_EXT), Qt::CaseInsensitive) == 0; - const bool isSKIN = strFileExt.compare(QStringLiteral(CRY_SKIN_FILE_EXT), Qt::CaseInsensitive) == 0; - const bool isCDF = strFileExt.compare(QStringLiteral(CRY_CHARACTER_DEFINITION_FILE_EXT), Qt::CaseInsensitive) == 0; - const bool isCGA = strFileExt.compare(QStringLiteral(CRY_ANIM_GEOMETRY_FILE_EXT), Qt::CaseInsensitive) == 0; - const bool isCGF = strFileExt.compare(QStringLiteral(CRY_GEOMETRY_FILE_EXT), Qt::CaseInsensitive) == 0; - - if (isCGF) - { - // Load object. - m_pObj = GetIEditor()->Get3DEngine()->LoadStatObjAutoRef(modelFile.toUtf8().data(), NULL, NULL, false); - if (!m_pObj) - { - Warning("Loading of geometry object %s failed.", modelFile.toUtf8().constData()); - if (m_nTimer != 0) - { - killTimer(m_nTimer); - } - m_nTimer = 0; - update(); - return; - } - m_aabb.min = m_pObj->GetBoxMin(); - m_aabb.max = m_pObj->GetBoxMax(); - } - else - { - if (m_nTimer != 0) - { - killTimer(m_nTimer); - } - m_nTimer = 0; - update(); - return; - } - - m_bHaveAnythingToRender = true; - - if (changeCamera) - { - FitToScreen(); - } - - update(); -} - -void CPreviewModelCtrl::SetAspectRatio(float aspectRatio) -{ - if (aspectRatio != m_aspectRatio) - { - m_aspectRatio = aspectRatio; - m_useAspectRatio = true; - updateGeometry(); - } -} - -bool CPreviewModelCtrl::hasHeightForWidth() const -{ - return m_useAspectRatio; -} - -int CPreviewModelCtrl::heightForWidth(int w) const -{ - if (m_useAspectRatio) - { - return static_cast(static_cast(w) / m_aspectRatio); - } - - return QWidget::heightForWidth(w); -} - -void CPreviewModelCtrl::SetEntity(IRenderNode* entity) -{ - m_bHaveAnythingToRender = false; - if (m_pEntity != entity) - { - m_pEntity = entity; - if (m_pEntity) - { - m_bHaveAnythingToRender = true; - m_aabb = m_pEntity->GetBBox(); - } - update(); - } -} - -void CPreviewModelCtrl::SetObject(IStatObj* pObject) -{ - if (m_pObj != pObject) - { - m_bHaveAnythingToRender = false; - m_pObj = pObject; - if (m_pObj) - { - m_bHaveAnythingToRender = true; - m_aabb = m_pObj->GetAABB(); - } - update(); - } -} - -void CPreviewModelCtrl::SetCameraRadius(float fRadius) -{ - m_cameraRadius = fRadius; - - Matrix34 m = m_camera.GetMatrix(); - Vec3 dir = m.TransformVector(Vec3(0, 1, 0)); - Matrix34 tm = Matrix33::CreateRotationVDir(dir, 0); - tm.SetTranslation(m_cameraTarget - dir * m_cameraRadius); - m_camera.SetMatrix(tm); - if (m_cameraChangeCallback) - { - m_cameraChangeCallback(m_pCameraChangeUserData, this); - } -} - -void CPreviewModelCtrl::SetCameraLookAt(float fRadiusScale, const Vec3& fromDir) -{ - m_cameraTarget = m_aabb.GetCenter(); - m_cameraRadius = m_aabb.GetRadius() * fRadiusScale; - - Vec3 dir = fromDir.GetNormalized(); - Matrix34 tm = Matrix33::CreateRotationVDir(dir, 0); - tm.SetTranslation(m_cameraTarget - dir * m_cameraRadius); - m_camera.SetMatrix(tm); - if (m_cameraChangeCallback) - { - m_cameraChangeCallback(m_pCameraChangeUserData, this); - } -} - -CCamera& CPreviewModelCtrl::GetCamera() -{ - return m_camera; -} - -void CPreviewModelCtrl::UseBackLight(bool bEnable) -{ - if (bEnable) - { - m_lights.resize(1); - CDLight l; - l.SetPosition(Vec3(-100, 100, -100)); - float L = 0.5f; - l.SetLightColor(ColorF(L, L, L, 1)); - l.m_fRadius = 1000; - l.m_Flags |= DLF_POINT; - m_lights.push_back(l); - } - else - { - m_lights.resize(1); - } - m_bUseBacklight = bEnable; -} - -void CPreviewModelCtrl::SetCamera(CCamera& cam) -{ - m_camera.SetPosition(cam.GetPosition()); - -#if defined(AZ_PLATFORM_WINDOWS) - // Needed for high DPI mode on windows - const qreal ratio = devicePixelRatioF(); -#else - const qreal ratio = 1.0f; -#endif - const int w = width() * ratio * m_tileSizeX; - const int h = height() * ratio * m_tileSizeY; - m_camera.SetFrustum(w, h, DEG2RAD(m_fov), m_camera.GetNearPlane(), m_camera.GetFarPlane()); - - if (m_cameraChangeCallback) - { - m_cameraChangeCallback(m_pCameraChangeUserData, this); - } -} - -void CPreviewModelCtrl::SetOrbitAngles([[maybe_unused]] const Ang3& ang) -{ - assert(0); -} - -bool CPreviewModelCtrl::Render() -{ - const int w = width(); - const int h = height(); - - if (h < 2 || w < 2) - { - return false; - } - - if (!m_bContextCreated) - { - if (!CreateContext()) - { - return false; - } - } - - _smart_ptr pMaterial; - - if (m_bPrecacheMaterial) - { - // Precache material - This loads/creates the material, shader and textures - // Moving this to the top of Render() so precaching precedes current and future - // rendering code - - _smart_ptr pCurMat = pMaterial; - - if (!pCurMat) - { - pCurMat = GetCurrentMaterial(); - } - - if (pCurMat) - { - pCurMat->PrecacheMaterial(0.0f, NULL, true, true); - } - } - - SetCamera(m_camera); - - m_pRenderer->SetClearColor(Vec3(m_clearColor.r, m_clearColor.g, m_clearColor.b)); - m_pRenderer->BeginFrame(); - SetCurrentContext(); - m_pRenderer->SetRenderTile(m_tileX, m_tileY, m_tileSizeX, m_tileSizeY); - - // Render grid. Explicitly clear color and depth buffer first - // (otherwise ->EndEf3D() will do that and thereby clear the grid). - m_pRenderer->ClearTargetsImmediately(FRT_CLEAR, m_clearColor); - - DrawBackground(); - if (m_bGrid || m_bAxis) - { - DrawGrid(); - } - - // save some cvars - int showNormals = gEnv->pConsole->GetCVar("r_ShowNormals")->GetIVal(); - int showInfo = gEnv->pConsole->GetCVar("r_displayInfo")->GetIVal(); - - gEnv->pConsole->GetCVar("r_ShowNormals")->Set((int)m_bShowNormals); - gEnv->pConsole->GetCVar("r_displayInfo")->Set((int)m_bShowRenderInfo); - - // Render object. - SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_camera, SRenderingPassInfo::DEFAULT_FLAGS, true); - m_pRenderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID()); - m_pRenderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID()); - m_pRenderer->EF_StartEf(passInfo); - m_pRenderer->ResetToDefault(); - - - { - CScopedWireFrameMode scopedWireFrame(m_pRenderer, m_bDrawWireFrame ? R_WIREFRAME_MODE : R_SOLID_MODE); - - // Add lights. - for (size_t i = 0; i < m_lights.size(); i++) - { - m_pRenderer->EF_ADDDlight(&m_lights[i], passInfo); - } - - if (m_bShowObject) - { - RenderObject(pMaterial, passInfo); - } - - m_pRenderer->EF_EndEf3D(SHDF_NOASYNC | SHDF_STREAM_SYNC, -1, -1, passInfo); - } - - m_pRenderer->EF_RenderTextMessages(); - m_pRenderer->RenderDebug(false); - m_pRenderer->EndFrame(); - m_pRenderer->SetRenderTile(); - - // Restore main context. - RestorePreviousContext(); - - gEnv->pConsole->GetCVar("r_ShowNormals")->Set(showNormals); - gEnv->pConsole->GetCVar("r_displayInfo")->Set(showInfo); - - return true; -} - -void CPreviewModelCtrl::RenderObject(_smart_ptr pMaterial, SRenderingPassInfo& passInfo) -{ - SRendParams rp; - rp.dwFObjFlags = 0; - rp.AmbientColor = m_ambientColor * m_ambientMultiplier; - rp.dwFObjFlags |= FOB_NO_FOG; - rp.pMaterial = pMaterial; - - Matrix34 tm; - tm.SetIdentity(); - rp.pMatrix = &tm; - - if (m_bRotate) - { - tm.SetRotationXYZ(Ang3(0, 0, m_rotateAngle)); - m_rotateAngle += 0.1f; - } - - if (m_pObj) - { - m_pObj->Render(rp, passInfo); - } - - if (m_pEntity) - { - m_pEntity->Render(rp, passInfo); - } -} - -void CPreviewModelCtrl::DrawGrid() -{ - // Draw grid. - float step = 0.1f; - float XR = 5; - float YR = 5; - - IRenderAuxGeom* pRag = m_pRenderer->GetIRenderAuxGeom(); - SAuxGeomRenderFlags nRendFlags = pRag->GetRenderFlags(); - - pRag->SetRenderFlags(e_Def3DPublicRenderflags); - SAuxGeomRenderFlags nNewFlags = pRag->GetRenderFlags(); - nNewFlags.SetAlphaBlendMode(e_AlphaBlended); - pRag->SetRenderFlags(nNewFlags); - - int nGridAlpha = 40; - if (m_bGrid) - { - // Draw grid. - for (float x = -XR; x < XR; x += step) - { - if (fabs(x) > 0.01) - { - pRag->DrawLine(Vec3(x, -YR, 0), ColorB(150, 150, 150, nGridAlpha), Vec3(x, YR, 0), ColorB(150, 150, 150, nGridAlpha)); - } - } - for (float y = -YR; y < YR; y += step) - { - if (fabs(y) > 0.01) - { - pRag->DrawLine(Vec3(-XR, y, 0), ColorB(150, 150, 150, nGridAlpha), Vec3(XR, y, 0), ColorB(150, 150, 150, nGridAlpha)); - } - } - } - - nGridAlpha = 60; - if (m_bAxis) - { - // Draw axis. - pRag->DrawLine(Vec3(0, 0, 0), ColorB(255, 0, 0, nGridAlpha), Vec3(XR, 0, 0), ColorB(255, 0, 0, nGridAlpha)); - pRag->DrawLine(Vec3(0, 0, 0), ColorB(0, 255, 0, nGridAlpha), Vec3(0, YR, 0), ColorB(0, 255, 0, nGridAlpha)); - pRag->DrawLine(Vec3(0, 0, 0), ColorB(0, 0, 255, nGridAlpha), Vec3(0, 0, YR), ColorB(0, 0, 255, nGridAlpha)); - } - pRag->Flush(); - pRag->SetRenderFlags(nRendFlags); -} - -void CPreviewModelCtrl::timerEvent(QTimerEvent* event) -{ - if (isVisible()) - { - if (m_bHaveAnythingToRender) - { - update(); - } - } - - QWidget::timerEvent(event); -} - -void CPreviewModelCtrl::SetCameraTM(const Matrix34& cameraTM) -{ - m_camera.SetMatrix(cameraTM); - if (m_cameraChangeCallback) - { - m_cameraChangeCallback(m_pCameraChangeUserData, this); - } -} - -void CPreviewModelCtrl::GetCameraTM(Matrix34& cameraTM) -{ - cameraTM = m_camera.GetMatrix(); -} - -void CPreviewModelCtrl::DeleteRenderContex() -{ - ReleaseObject(); - - // Destroy render context. - if (m_pRenderer && m_bContextCreated) - { - m_pRenderer->DeleteContext(m_hWnd); - m_bContextCreated = false; - } -} - -void CPreviewModelCtrl::OnDestroy() -{ - DeleteRenderContex(); - - if (m_nTimer) - { - killTimer(m_nTimer); - } -} - -void CPreviewModelCtrl::OnLButtonDown(QPoint point) -{ - m_bInRotateMode = true; - m_mousePosition = point; - m_previousMousePosition = m_mousePosition; - - setFocus(); - update(); -} - -void CPreviewModelCtrl::OnLButtonUp(QPoint point) -{ - m_bInRotateMode = false; - update(); - m_mousePosition = point; - m_previousMousePosition = m_mousePosition; -} - -void CPreviewModelCtrl::OnMButtonDown(QPoint point) -{ - m_bInPanMode = true; - update(); - m_mousePosition = point; - m_previousMousePosition = m_mousePosition; -} - -void CPreviewModelCtrl::OnMButtonUp(QPoint point) -{ - m_bInPanMode = false; - update(); - m_mousePosition = point; - m_previousMousePosition = m_mousePosition; -} - -void CPreviewModelCtrl::mouseMoveEvent(QMouseEvent* event) -{ - // TODO: Add your message handler code here and/or call default - QWidget::mouseMoveEvent(event); - - const QPoint& point = event->pos(); - if (point == m_previousMousePosition) - { - return; - } - - if (m_bInMoveMode) - { - // Zoom. - Matrix34 m = m_camera.GetMatrix(); - Vec3 xdir(0, 0, 0); - Vec3 zdir = m.GetColumn1().GetNormalized(); - - float step = 0.002f; - float dx = (point.x() - m_previousMousePosition.x()); - float dy = (point.y() - m_previousMousePosition.y()); - m_camera.SetPosition(m_camera.GetPosition() + step * xdir * dx + step * zdir * dy); - SetCamera(m_camera); - - if (gSettings.stylusMode) - { - m_previousMousePosition = point; - } - else - { - AzQtComponents::SetCursorPos(mapToGlobal(m_previousMousePosition)); - } - - update(); - } - else if (m_bInRotateMode) - { - Vec3 pos = m_camera.GetMatrix().GetTranslation(); - m_cameraRadius = Vec3(m_camera.GetMatrix().GetTranslation() - m_cameraTarget).GetLength(); - // Look - Ang3 angles(-point.y() + m_previousMousePosition.y(), 0, -point.x() + m_previousMousePosition.x()); - angles = angles * 0.002f; - - Matrix34 camtm = m_camera.GetMatrix(); - Matrix33 Rz = Matrix33::CreateRotationXYZ(Ang3(0, 0, angles.z)); // Rotate around vertical axis. - Matrix33 Rx = Matrix33::CreateRotationAA(angles.x, camtm.GetColumn0()); // Rotate with angle around x axis in camera space. - - Vec3 dir = camtm.TransformVector(Vec3(0, 1, 0)); - Vec3 newdir = (Rx * Rz).TransformVector(dir).GetNormalized(); - camtm = Matrix34(Matrix33::CreateRotationVDir(newdir, 0), m_cameraTarget - newdir * m_cameraRadius); - m_camera.SetMatrix(camtm); - if (m_cameraChangeCallback) - { - m_cameraChangeCallback(m_pCameraChangeUserData, this); - } - - if (gSettings.stylusMode) - { - m_previousMousePosition = point; - } - else - { - AzQtComponents::SetCursorPos(mapToGlobal(m_previousMousePosition)); - } - - update(); - } - else if (m_bInPanMode) - { - // Slide. - float speedScale = 0.001f; - Matrix34 m = m_camera.GetMatrix(); - Vec3 xdir = m.GetColumn0().GetNormalized(); - Vec3 zdir = m.GetColumn2().GetNormalized(); - - Vec3 pos = m_cameraTarget; - pos += 0.1f * xdir * (point.x() - m_previousMousePosition.x()) * speedScale + 0.1f * zdir * (m_previousMousePosition.y() - point.y()) * speedScale; - m_cameraTarget = pos; - - Vec3 dir = m.TransformVector(Vec3(0, 1, 0)); - m.SetTranslation(m_cameraTarget - dir * m_cameraRadius); - m_camera.SetMatrix(m); - if (m_cameraChangeCallback) - { - m_cameraChangeCallback(m_pCameraChangeUserData, this); - } - - if (gSettings.stylusMode) - { - m_previousMousePosition = point; - } - else - { - AzQtComponents::SetCursorPos(mapToGlobal(m_previousMousePosition)); - } - - update(); - } -} - -void CPreviewModelCtrl::OnRButtonDown(QPoint point) -{ - m_bInMoveMode = true; - m_mousePosition = point; - m_previousMousePosition = point; - update(); -} - -void CPreviewModelCtrl::OnRButtonUp(QPoint point) -{ - m_bInMoveMode = false; - - m_mousePosition = point; - m_previousMousePosition = point; - - update(); -} - -void CPreviewModelCtrl::wheelEvent(QWheelEvent* event) -{ - const short zDelta = event->angleDelta().y(); - // TODO: Add your message handler code here and/or call default - Matrix34 m = m_camera.GetMatrix(); - Vec3 zdir = m.GetColumn1().GetNormalized(); - - //m_camera.SetPosition( m_camera.GetPos() + ydir*(m_mousePos.y-point.y),xdir*(m_mousePos.x-point.x) ); - m_camera.SetPosition(m_camera.GetPosition() + 0.002f * zdir * (zDelta)); - SetCamera(m_camera); - update(); -} - -void CPreviewModelCtrl::EnableUpdate(bool bUpdate) -{ - m_bUpdate = bUpdate; - if (m_bUpdate && !m_nTimer) - { - m_nTimer = startTimer(1000); - } - else if (!m_bUpdate && m_nTimer) - { - killTimer(m_nTimer), m_nTimer = 0; - } -} - -void CPreviewModelCtrl::Update(bool bForceUpdate) -{ - ProcessKeys(); - - if (m_bUpdate && m_bHaveAnythingToRender || bForceUpdate) - { - if (isVisible()) - { - update(); - } - } -} - -void CPreviewModelCtrl::SetRotation(bool bEnable) -{ - m_bRotate = bEnable; -} - -void CPreviewModelCtrl::OnEditorNotifyEvent(EEditorNotifyEvent event) -{ - switch (event) - { - case eNotify_OnIdleUpdate: - Update(); - break; - } -} - -void CPreviewModelCtrl::GetImageOffscreen(CImageEx& image, const QSize& customSize) -{ - // hiding a window can cause this to be dropped, since it no longer associates with - // an actual operating system window handle. - if (!m_hWnd) - { - return; - } - if (!m_pRenderer) - { - return; - } - - m_pRenderer->EnableSwapBuffers(false); - Render(); - m_pRenderer->EnableSwapBuffers(true); - - int w; - int h; - - if (customSize.isValid()) - { - w = customSize.width(); - h = customSize.height(); - } - else - { - w = width(); - h = height(); - } - - image.Allocate(w, h); - - // the renderer will read the frame buffer of the current render context, so we need to set ours as the current before we execute this command. - SetCurrentContext(); - m_pRenderer->ReadFrameBufferFast(image.GetData(), w, h); - RestorePreviousContext(); -} - -void CPreviewModelCtrl::SetClearColor(const ColorF& color) -{ - m_clearColor = color; -} - - -namespace PreviewModelControl -{ - struct MaterialId - { - const void* ptr; - int id; - - MaterialId(const void* a_ptr, int a_id) - : ptr(a_ptr) - , id(a_id) - { - } - - bool operator<(const MaterialId& a) const - { - return ptr < a.ptr || id < a.id; - } - }; - - static int GetFaceCountRecursively(IStatObj* p) - { - if (!p) - { - return 0; - } - int n = 0; - if (p->GetRenderMesh()) - { - n += p->GetRenderMesh()->GetIndicesCount() / 3; - } - for (int i = 0; i < p->GetSubObjectCount(); ++i) - { - IStatObj::SSubObject* const pS = p->GetSubObject(i); - if (pS) - { - n += GetFaceCountRecursively(pS->pStatObj); - } - } - return n; - } - - static int GetVertexCountRecursively(IStatObj* p) - { - if (!p) - { - return 0; - } - int n = 0; - if (p->GetRenderMesh()) - { - n += p->GetRenderMesh()->GetVerticesCount(); - } - for (int i = 0; i < p->GetSubObjectCount(); ++i) - { - IStatObj::SSubObject* const pS = p->GetSubObject(i); - if (pS) - { - n += GetVertexCountRecursively(pS->pStatObj); - } - } - return n; - } - - static int GetMaxLodRecursively(IStatObj* p) - { - if (!p) - { - return 0; - } - int n = 0; - for (int i = 1; i < 10; i++) - { - if (p->GetLodObject(i)) - { - n = i; - } - } - for (int i = 0; i < p->GetSubObjectCount(); ++i) - { - IStatObj::SSubObject* const pS = p->GetSubObject(i); - if (pS) - { - const int n2 = GetMaxLodRecursively(pS->pStatObj); - n = (n < n2) ? n2 : n; - } - } - return n; - } - - static void CollectMaterialsRecursively(std::set& mats, IStatObj* p) - { - if (!p) - { - return; - } - if (p->GetRenderMesh()) - { - TRenderChunkArray& ch = p->GetRenderMesh()->GetChunks(); - for (size_t i = 0; i < ch.size(); ++i) - { - mats.insert(PreviewModelControl::MaterialId(p->GetMaterial(), ch[i].m_nMatID)); - } - } - for (int i = 0; i < p->GetSubObjectCount(); ++i) - { - IStatObj::SSubObject* const pS = p->GetSubObject(i); - if (pS) - { - CollectMaterialsRecursively(mats, pS->pStatObj); - } - } - } -} - - -int CPreviewModelCtrl::GetFaceCount() -{ - if (m_pObj) - { - return PreviewModelControl::GetFaceCountRecursively(m_pObj); - } - return 0; -} - -int CPreviewModelCtrl::GetVertexCount() -{ - if (m_pObj) - { - return PreviewModelControl::GetVertexCountRecursively(m_pObj); - } - return 0; -} - -int CPreviewModelCtrl::GetMaxLod() -{ - if (m_pObj) - { - return PreviewModelControl::GetMaxLodRecursively(m_pObj); - } - return 0; -} - -int CPreviewModelCtrl::GetMtlCount() -{ - if (m_pObj) - { - std::set mats; - CollectMaterialsRecursively(mats, m_pObj); - return (int)mats.size(); - } - return 0; -} - -void CPreviewModelCtrl::FitToScreen() -{ - SetCameraLookAt(2.0f, Vec3(1, 1, -0.5)); -} - -void CPreviewModelCtrl::ProcessKeys() -{ - if (!hasFocus()) - { - return; - } - - int moveSpeed = 1; - - Matrix34 m = m_camera.GetMatrix(); - - Vec3 ydir = m.GetColumn2().GetNormalized(); - Vec3 xdir = m.GetColumn0().GetNormalized(); - - Vec3 pos = m.GetTranslation(); - - float speedScale = 60.0f * GetIEditor()->GetSystem()->GetITimer()->GetFrameTime(); - if (speedScale > 20) - { - speedScale = 20; - } - - speedScale *= 0.04f; - - if (CheckVirtualKey(Qt::Key_Shift)) - { - speedScale *= gSettings.cameraFastMoveSpeed; - } - - bool isDirty = false; - - if (CheckVirtualKey(Qt::Key_Up) || CheckVirtualKey(Qt::Key_W)) - { - // move forward - m_camera.SetPosition(pos + speedScale * moveSpeed * ydir); - SetCamera(m_camera); - isDirty = true; - } - - if (CheckVirtualKey(Qt::Key_Down) || CheckVirtualKey(Qt::Key_S)) - { - // move backward - m_camera.SetPosition(pos - speedScale * moveSpeed * ydir); - SetCamera(m_camera); - isDirty = true; - } - - if (isDirty) - { - if (!m_bUpdate) - { - // if we're not going to be autoupdating then we need to do a one-time invalidation here. - update(); - } - } -} - -void CPreviewModelCtrl::SetBackgroundTexture(const QString& textureFilename) -{ - m_backgroundTextureId = GetIEditor()->GetIconManager()->GetIconTexture(textureFilename.toUtf8().constData()); -} - -void CPreviewModelCtrl::DrawBackground() -{ - if (!m_backgroundTextureId) - { - return; - } - - int rcw = width(); - int rch = height(); - - TransformationMatrices backupSceneMatrices; - - m_pRenderer->Set2DMode(rcw, rch, backupSceneMatrices, 0.0f, 1.0f); - - m_pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST); - - float uvs[4], uvt[4]; - uvs[3] = 0; - uvt[3] = 1; - uvs[2] = 1; - uvt[2] = 1; - uvs[1] = 1; - uvt[1] = 0; - uvs[0] = 0; - uvt[0] = 0; - - float color[4] = {1, 1, 1, 1}; - - m_pRenderer->DrawImageWithUV(0, 0, 0.5f, rcw, rch, m_backgroundTextureId, uvs, uvt, color[0], color[1], color[2], color[3]); - m_pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA); - - m_pRenderer->Unset2DMode(backupSceneMatrices); -} - -_smart_ptr CPreviewModelCtrl::GetCurrentMaterial() -{ - if (m_pObj) - { - return m_pObj->GetMaterial(); - } - else if (m_pEntity) - { - return m_pEntity->GetMaterial(); - } - - return NULL; -} - -void CPreviewModelCtrl::StorePreviousContext() -{ - SPreviousContext previous; - previous.width = m_pRenderer->GetWidth(); - previous.height = m_pRenderer->GetHeight(); - previous.window = (HWND)m_pRenderer->GetCurrentContextHWND(); - previous.renderCamera = m_pRenderer->GetCamera(); - previous.systemCamera = gEnv->pSystem->GetViewCamera(); - previous.isMainViewport = m_pRenderer->IsCurrentContextMainVP(); - m_previousContexts.push_back(previous); -} - -// Copied from the non-crashing QViewport.cpp -void CPreviewModelCtrl::SetCurrentContext() -{ - StorePreviousContext(); - - m_pRenderer->SetCurrentContext(m_hWnd); - -#if defined(AZ_PLATFORM_WINDOWS) - // Needed for high DPI mode on windows - const qreal ratio = devicePixelRatioF(); -#else - const qreal ratio = 1.0f; -#endif - m_pRenderer->ChangeViewport(0, 0, width() * ratio, height() * ratio); - m_pRenderer->SetCamera(m_camera); - gEnv->pSystem->SetViewCamera(m_camera); -} - -void CPreviewModelCtrl::RestorePreviousContext() -{ - if (m_previousContexts.empty()) - { - assert(0); - return; - } - - SPreviousContext x = m_previousContexts.back(); - m_previousContexts.pop_back(); - m_pRenderer->SetCurrentContext(x.window); - m_pRenderer->ChangeViewport(0, 0, x.width, x.height, x.isMainViewport); - m_pRenderer->SetCamera(x.renderCamera); - gEnv->pSystem->SetViewCamera(x.systemCamera); -} - -void CPreviewModelCtrl::showEvent([[maybe_unused]] QShowEvent* event) -{ - m_hWnd = reinterpret_cast(effectiveWinId()); -} - -QSize CPreviewModelCtrl::minimumSizeHint() const -{ - return QSize(50, 50); -} - -QPaintEngine* CPreviewModelCtrl::paintEngine() const -{ - return nullptr; -} - -void CPreviewModelCtrl::paintEvent(QPaintEvent* event) -{ - event->accept(); - Render(); -} - -void CPreviewModelCtrl::mousePressEvent(QMouseEvent* event) -{ - switch (event->button()) - { - case Qt::LeftButton: - OnLButtonDown(event->pos()); - break; - case Qt::MiddleButton: - OnMButtonDown(event->pos()); - break; - case Qt::RightButton: - OnRButtonDown(event->pos()); - break; - } -} - -void CPreviewModelCtrl::mouseReleaseEvent(QMouseEvent* event) -{ - switch (event->button()) - { - case Qt::LeftButton: - OnLButtonUp(event->pos()); - break; - case Qt::MiddleButton: - OnMButtonUp(event->pos()); - break; - case Qt::RightButton: - OnRButtonUp(event->pos()); - break; - } -} - -#include diff --git a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h b/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h deleted file mode 100644 index 6388be9fd5..0000000000 --- a/Code/Sandbox/Editor/Controls/PreviewModelCtrl.h +++ /dev/null @@ -1,198 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H -#define CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include - -#endif - -struct IRenderNode; -class CImageEx; - -class CPreviewModelCtrl - : public QWidget - , public IEditorNotifyListener -{ - Q_OBJECT -public: - explicit CPreviewModelCtrl(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); - - QSize minimumSizeHint() const override; - -public: - void LoadFile(const QString& modelFile, bool changeCamera = true); - Vec3 GetSize() const { return m_size; }; - QString GetLoadedFile() const { return m_loadedFile; } - - void SetEntity(IRenderNode* entity); - void SetObject(IStatObj* pObject); - IStatObj* GetObject() { return m_pObj; } - void SetCameraLookAt(float fRadiusScale, const Vec3& dir = Vec3(0, 1, 0)); - void SetCameraRadius(float fRadius); - CCamera& GetCamera(); - void SetGrid(bool bEnable) { m_bGrid = bEnable; } - void SetAxis(bool bEnable, bool forParticleEditor = false) { m_bAxis = bEnable; m_bAxisParticleEditor = forParticleEditor; } - void SetRotation(bool bEnable); - void SetClearColor(const ColorF& color); - void SetBackgroundTexture(const QString& textureFilename); - void UseBackLight(bool bEnable); - bool UseBackLight() const { return m_bUseBacklight; } - void SetShowNormals(bool bShow) { m_bShowNormals = bShow; } - void SetShowPhysics(bool bShow) { m_bShowPhysics = bShow; } - void SetShowRenderInfo(bool bShow) { m_bShowRenderInfo = bShow; } - - void EnableUpdate(bool bEnable); - bool IsUpdateEnabled() const { return m_bUpdate; } - void Update(bool bForceUpdate = false); - void ProcessKeys(); - - // this turns on and off aspect-ratio-maintaining. Use it when the widget is free to resize itself. - void SetAspectRatio(float newAspectRatio); - int heightForWidth(int w) const override; - bool hasHeightForWidth() const override; - - void GetImageOffscreen(CImageEx& image, const QSize& customSize = QSize(0, 0)); - - void GetCameraTM(Matrix34& cameraTM); - void SetCameraTM(const Matrix34& cameraTM); - - // Place camera so that whole object fits on screen. - void FitToScreen(); - - // Get information about the preview model. - int GetFaceCount(); - int GetVertexCount(); - int GetMaxLod(); - int GetMtlCount(); - - void SetShowObject(bool bShowObject) {m_bShowObject = bShowObject; } - bool GetShowObject() {return m_bShowObject; } - - void SetAmbient(ColorF amb) { m_ambientColor = amb; } - void SetAmbientMultiplier(f32 multiplier) { m_ambientMultiplier = multiplier; } - - typedef void (* CameraChangeCallback)(void* m_userData, CPreviewModelCtrl* m_currentCamera); - void SetCameraChangeCallback(CameraChangeCallback callback, void* userData) { m_cameraChangeCallback = callback, m_pCameraChangeUserData = userData; } - - void EnableMaterialPrecaching(bool bPrecacheMaterial) { m_bPrecacheMaterial = bPrecacheMaterial; } - void EnableWireframeRendering(bool bDrawWireframe) { m_bDrawWireFrame = bDrawWireframe; } - -public: - ~CPreviewModelCtrl(); - - bool CreateContext(); - void ReleaseObject(); - void DeleteRenderContex(); - -protected: - void OnCreate(); - void OnDestroy(); - void OnLButtonDown(QPoint point); - void OnLButtonUp(QPoint point); - void OnMButtonDown(QPoint point); - void OnMButtonUp(QPoint point); - void OnRButtonUp(QPoint point); - void OnRButtonDown(QPoint point); - - QPaintEngine* paintEngine() const override; - void showEvent(QShowEvent* event) override; - void paintEvent(QPaintEvent* event) override; - void timerEvent(QTimerEvent* event) override; - void mouseMoveEvent(QMouseEvent* event) override; - void mousePressEvent(QMouseEvent* event) override; - void mouseReleaseEvent(QMouseEvent* event) override; - void wheelEvent(QWheelEvent* event) override; - - virtual void OnEditorNotifyEvent(EEditorNotifyEvent event); - -protected: - virtual bool Render(); - virtual void SetCamera(CCamera& cam); - - virtual void RenderObject(_smart_ptr pMaterial, SRenderingPassInfo& passInfo); - - HWND m_hWnd; - CCamera m_camera; - float m_fov; - - struct SPreviousContext; - std::vector m_previousContexts; - - void SetOrbitAngles(const Ang3& ang); - void DrawGrid(); - void DrawBackground(); - _smart_ptr GetCurrentMaterial(); - - _smart_ptr m_pObj; - - IRenderer* m_pRenderer; - bool m_bContextCreated; - - Vec3 m_size; - Vec3 m_pos; - int m_nTimer; - bool m_useAspectRatio = false; - float m_aspectRatio = 1.0f; - - QString m_loadedFile; - std::vector m_lights; - - AABB m_aabb; - Vec3 m_cameraTarget; - float m_cameraRadius; - Vec3 m_cameraAngles; - bool m_bInRotateMode; - bool m_bInMoveMode; - bool m_bInPanMode; - QPoint m_mousePosition; - QPoint m_previousMousePosition; - IRenderNode* m_pEntity; - bool m_bHaveAnythingToRender; - bool m_bGrid; - bool m_bAxis; - bool m_bAxisParticleEditor; - bool m_bUpdate; - bool m_bRotate; - float m_rotateAngle; - ColorF m_clearColor; - ColorF m_ambientColor; - f32 m_ambientMultiplier; - bool m_bUseBacklight; - bool m_bShowObject; - bool m_bPrecacheMaterial; - bool m_bDrawWireFrame; - bool m_bShowNormals; - bool m_bShowPhysics; - bool m_bShowRenderInfo; - int m_backgroundTextureId; - float m_tileX; - float m_tileY; - float m_tileSizeX; - float m_tileSizeY; - CameraChangeCallback m_cameraChangeCallback; - void* m_pCameraChangeUserData; - -protected: - void StorePreviousContext(); - void SetCurrentContext(); - void RestorePreviousContext(); -}; -#endif // CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H diff --git a/Code/Sandbox/Editor/Controls/TimeOfDaySlider.cpp b/Code/Sandbox/Editor/Controls/TimeOfDaySlider.cpp deleted file mode 100644 index 9b2b62d6f5..0000000000 --- a/Code/Sandbox/Editor/Controls/TimeOfDaySlider.cpp +++ /dev/null @@ -1,26 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : implementation file - - -#include "EditorDefs.h" - -#include "TimeOfDaySlider.h" - -QString TimeOfDaySlider::hoverValueText(int sliderValue) const -{ - return QString::fromLatin1("%1:%2").arg(static_cast(sliderValue / 60)).arg(sliderValue % 60, 2, 10, QLatin1Char('0')); -} - -#include diff --git a/Code/Sandbox/Editor/Controls/TimeOfDaySlider.h b/Code/Sandbox/Editor/Controls/TimeOfDaySlider.h deleted file mode 100644 index 72c4c08394..0000000000 --- a/Code/Sandbox/Editor/Controls/TimeOfDaySlider.h +++ /dev/null @@ -1,34 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H -#define CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H -#pragma once - - -#if !defined(Q_MOC_RUN) -#include -#endif - -class TimeOfDaySlider - : public AzQtComponents::SliderInt -{ - Q_OBJECT -public: - using AzQtComponents::SliderInt::SliderInt; - -protected: - QString hoverValueText(int sliderValue) const override; -}; - -#endif // CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index abffd1f995..b88aee8bd9 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -78,7 +78,6 @@ AZ_POP_DISABLE_WARNING #include // CryCommon -#include #include #include #include @@ -99,7 +98,6 @@ AZ_POP_DISABLE_WARNING #include "GridSettingsDialog.h" #include "LayoutConfigDialog.h" #include "ViewManager.h" -#include "ModelViewport.h" #include "FileTypeUtils.h" #include "PluginManager.h" @@ -109,14 +107,12 @@ AZ_POP_DISABLE_WARNING #include "GameEngine.h" #include "StartupTraceHandler.h" -#include "ThumbnailGenerator.h" #include "ToolsConfigPage.h" #include "Objects/SelectionGroup.h" #include "Include/IObjectManager.h" #include "WaitProgress.h" #include "ToolBox.h" -#include "Geometry/EdMesh.h" #include "LevelInfo.h" #include "EditorPreferencesDialog.h" #include "GraphicsSettingsDialog.h" @@ -392,7 +388,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_FILE_RESAVESLICES, OnFileResaveSlices) ON_COMMAND(ID_FILE_EDITEDITORINI, OnFileEditEditorini) ON_COMMAND(ID_PREFERENCES, OnPreferences) - ON_COMMAND(ID_RELOAD_GEOMETRY, OnReloadGeometry) ON_COMMAND(ID_REDO, OnRedo) ON_COMMAND(ID_TOOLBAR_WIDGET_REDO, OnRedo) ON_COMMAND(ID_RELOAD_TEXTURES, OnReloadTextures) @@ -401,7 +396,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_FILE_NEW_SLICE, OnCreateSlice) ON_COMMAND(ID_FILE_OPEN_SLICE, OnOpenSlice) #endif - ON_COMMAND(ID_RESOURCES_GENERATECGFTHUMBNAILS, OnGenerateCgfThumbnails) ON_COMMAND(ID_SWITCH_PHYSICS, OnSwitchPhysics) ON_COMMAND(ID_GAME_SYNCPLAYER, OnSyncPlayer) ON_COMMAND(ID_RESOURCES_REDUCEWORKINGSET, OnResourcesReduceworkingset) @@ -451,14 +445,12 @@ void CCryEditApp::RegisterActionHandlers() #endif ON_COMMAND(ID_DISPLAY_GOTOPOSITION, OnDisplayGotoPosition) ON_COMMAND(ID_SNAPANGLE, OnSnapangle) - ON_COMMAND(ID_EDIT_RENAMEOBJECT, OnEditRenameobject) ON_COMMAND(ID_CHANGEMOVESPEED_INCREASE, OnChangemovespeedIncrease) ON_COMMAND(ID_CHANGEMOVESPEED_DECREASE, OnChangemovespeedDecrease) ON_COMMAND(ID_CHANGEMOVESPEED_CHANGESTEP, OnChangemovespeedChangestep) ON_COMMAND(ID_FILE_SAVELEVELRESOURCES, OnFileSavelevelresources) ON_COMMAND(ID_CLEAR_REGISTRY, OnClearRegistryData) ON_COMMAND(ID_VALIDATELEVEL, OnValidatelevel) - ON_COMMAND(ID_TOOLS_VALIDATEOBJECTPOSITIONS, OnValidateObjectPositions) ON_COMMAND(ID_TOOLS_PREFERENCES, OnToolsPreferences) ON_COMMAND(ID_GRAPHICS_SETTINGS, OnGraphicsSettings) ON_COMMAND(ID_SWITCHCAMERA_DEFAULTCAMERA, OnSwitchToDefaultCamera) @@ -472,8 +464,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers) ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView) ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor) - ON_COMMAND(ID_TERRAIN_TIMEOFDAY, OnTimeOfDay) - ON_COMMAND(ID_TERRAIN_TIMEOFDAYBUTTON, OnTimeOfDay) ON_COMMAND_RANGE(ID_GAME_PC_ENABLELOWSPEC, ID_GAME_PC_ENABLEVERYHIGHSPEC, OnChangeGameSpec) @@ -1913,11 +1903,6 @@ void CCryEditApp::LoadFile(QString fileName) { return; } - CViewport* vp = GetIEditor()->GetViewManager()->GetView(0); - if (CModelViewport* mvp = viewport_cast(vp)) - { - mvp->LoadObject(fileName, 1); - } LoadTagLocations(); @@ -2953,43 +2938,6 @@ void CCryEditApp::OnReloadTextures() GetIEditor()->GetRenderer()->EF_ReloadTextures(); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnReloadGeometry() -{ - CErrorsRecorder errRecorder(GetIEditor()); - CWaitProgress wait("Reloading static geometry"); - - CLogFile::WriteLine("Reloading Static objects geometries."); - CEdMesh::ReloadAllGeometries(); - - GetIEditor()->GetObjectManager()->SendEvent(EVENT_UNLOAD_GEOM); - - GetIEditor()->GetObjectManager()->SendEvent(EVENT_RELOAD_GEOM); - GetIEditor()->Notify(eNotify_OnReloadTrackView); - - // Rephysicalize viewport meshes - for (int i = 0; i < GetIEditor()->GetViewManager()->GetViewCount(); ++i) - { - CViewport* vp = GetIEditor()->GetViewManager()->GetView(i); - if (CModelViewport* mvp = viewport_cast(vp)) - { - mvp->RePhysicalize(); - } - } - - IRenderNode** plist = new IRenderNode*[ - gEnv->p3DEngine->GetObjectsByType(eERType_StaticMeshRenderComponent,0) - ]; - for (const EERType type : AZStd::array{eERType_Dummy_10, eERType_StaticMeshRenderComponent}) - { - for (int j = gEnv->p3DEngine->GetObjectsByType(type, plist) - 1; j >= 0; j--) - { - plist[j]->Physicalize(true); - } - } - delete[] plist; -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnUndo() { @@ -3154,15 +3102,6 @@ void CCryEditApp::OnSyncPlayerUpdate(QAction* action) action->setChecked(!GetIEditor()->GetGameEngine()->IsSyncPlayerPosition()); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnGenerateCgfThumbnails() -{ - qApp->setOverrideCursor(Qt::BusyCursor); - CThumbnailGenerator gen; - gen.GenerateForDirectory("Objects\\"); - qApp->restoreOverrideCursor(); -} - void CCryEditApp::OnUpdateNonGameMode(QAction* action) { action->setEnabled(!GetIEditor()->IsInGameMode()); @@ -3261,10 +3200,9 @@ CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& levelNam m_bIsExportingLegacyData = false; } - GetIEditor()->GetGameEngine()->LoadLevel(GetIEditor()->GetGameEngine()->GetMissionName(), true, true); + GetIEditor()->GetGameEngine()->LoadLevel(true, true); GetIEditor()->GetSystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_PRECACHE_START, 0, 0); - GetIEditor()->GetGameEngine()->ReloadEnvironment(); GetIEditor()->GetSystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_PRECACHE_END, 0, 0); } @@ -3824,59 +3762,6 @@ void CCryEditApp::OnUpdateSnapangle(QAction* action) action->setChecked(gSettings.pGrid->IsAngleSnapEnabled()); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnEditRenameobject() -{ - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - if (pSelection->IsEmpty()) - { - QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QString(), QObject::tr("No Selected Objects!")); - return; - } - - IObjectManager* pObjMan = GetIEditor()->GetObjectManager(); - - if (!pObjMan) - { - return; - } - - StringDlg dlg(QObject::tr("Rename Object(s)")); - if (dlg.exec() == QDialog::Accepted) - { - CUndo undo("Rename Objects"); - QString newName; - QString str = dlg.GetString(); - int num = 0; - - for (int i = 0; i < pSelection->GetCount(); ++i) - { - CBaseObject* pObject = pSelection->GetObject(i); - - if (pObject) - { - if (pObjMan->IsDuplicateObjectName(str)) - { - pObjMan->ShowDuplicationMsgWarning(pObject, str, true); - return; - } - } - } - - for (int i = 0; i < pSelection->GetCount(); ++i) - { - newName = QStringLiteral("%1%2").arg(str).arg(num); - ++num; - CBaseObject* pObject = pSelection->GetObject(i); - - if (pObject) - { - pObjMan->ChangeObjectName(pObject, newName); - } - } - } -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnChangemovespeedIncrease() { @@ -3936,119 +3821,6 @@ void CCryEditApp::OnValidatelevel() levelInfo.Validate(); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnValidateObjectPositions() -{ - IObjectManager* objMan = GetIEditor()->GetObjectManager(); - - if (!objMan) - { - return; - } - - CErrorReport errorReport; - errorReport.SetCurrentFile(""); - errorReport.SetImmediateMode(false); - - int objCount = objMan->GetObjectCount(); - AABB bbox1; - AABB bbox2; - int bugNo = 0; - QString statTxt(""); - - std::vector objects; - objMan->GetObjects(objects); - - std::vector foundObjects; - - std::vector objIDs; - - for (int i1 = 0; i1 < objCount; ++i1) - { - CBaseObject* pObj1 = objects[i1]; - - if (!pObj1) - { - continue; - } - - // Object must have geometry - if (!pObj1->GetGeometry()) - { - continue; - } - - pObj1->GetBoundBox(bbox1); - - // Check if object has other objects inside its bbox - foundObjects.clear(); - objMan->FindObjectsInAABB(bbox1, foundObjects); - - for (int i2 = 0; i2 < foundObjects.size(); ++i2) - { - CBaseObject* pObj2 = objects[i2]; - if (!pObj2) - { - continue; - } - - if (pObj2->GetId() == pObj1->GetId()) - { - continue; - } - - if (pObj2->GetParent()) - { - continue; - } - - if (stl::find(objIDs, pObj2->GetId())) - { - continue; - } - - if (!pObj2->GetGeometry()) - { - continue; - } - - pObj2->GetBoundBox(bbox2); - - if (!bbox1.IsContainPoint(bbox2.max)) - { - continue; - } - - if (!bbox1.IsContainPoint(bbox2.min)) - { - continue; - } - - objIDs.push_back(pObj2->GetId()); - - CErrorRecord error; - error.pObject = pObj2; - error.count = bugNo; - error.error = tr("%1 inside %2 object").arg(pObj2->GetName(), pObj1->GetName()); - error.description = "Object left inside other object"; - errorReport.ReportError(error); - ++bugNo; - } - - statTxt = tr("%1/%2 [Reported Objects: %3]").arg(i1).arg(objCount).arg(bugNo); - GetIEditor()->SetStatusText(statTxt); - } - - if (errorReport.GetErrorCount() == 0) - { - QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QString(), QObject::tr("No Errors Found")); - } - else - { - errorReport.Display(); - } -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnToolsPreferences() { @@ -4197,12 +3969,6 @@ void CCryEditApp::OnOpenUICanvasEditor() QtViewPaneManager::instance()->OpenPane(LyViewPane::UiEditor); } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnTimeOfDay() -{ - GetIEditor()->OpenView("Time Of Day"); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable) { diff --git a/Code/Sandbox/Editor/CryEdit.h b/Code/Sandbox/Editor/CryEdit.h index bce7f0c90d..c0b26a9405 100644 --- a/Code/Sandbox/Editor/CryEdit.h +++ b/Code/Sandbox/Editor/CryEdit.h @@ -230,11 +230,9 @@ public: void OnFileEditEditorini(); void OnPreferences(); void OnReloadTextures(); - void OnReloadGeometry(); void OnRedo(); void OnUpdateRedo(QAction* action); void OnUpdateUndo(QAction* action); - void OnGenerateCgfThumbnails(); void OnSwitchPhysics(); void OnSwitchPhysicsUpdate(QAction* action); void OnSyncPlayer(); @@ -413,14 +411,12 @@ private: void OnDisplayGotoPosition(); void OnSnapangle(); void OnUpdateSnapangle(QAction* action); - void OnEditRenameobject(); void OnChangemovespeedIncrease(); void OnChangemovespeedDecrease(); void OnChangemovespeedChangestep(); void OnFileSavelevelresources(); void OnClearRegistryData(); void OnValidatelevel(); - void OnValidateObjectPositions(); void OnToolsPreferences(); void OnGraphicsSettings(); void OnSwitchToDefaultCamera(); @@ -435,7 +431,6 @@ private: void OnOpenTrackView(); void OnOpenAudioControlsEditor(); void OnOpenUICanvasEditor(); - void OnTimeOfDay(); void OnChangeGameSpec(UINT nID); void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable); void OnUpdateGameSpec(QAction* action); diff --git a/Code/Sandbox/Editor/CryEditDoc.cpp b/Code/Sandbox/Editor/CryEditDoc.cpp index 2138c5c79e..ffcbd00a5f 100644 --- a/Code/Sandbox/Editor/CryEditDoc.cpp +++ b/Code/Sandbox/Editor/CryEditDoc.cpp @@ -42,7 +42,6 @@ #include "Settings.h" #include "PluginManager.h" -#include "Mission.h" #include "ViewManager.h" #include "DisplaySettings.h" #include "GameEngine.h" @@ -57,7 +56,6 @@ #include "CheckOutDialog.h" #include "GameExporter.h" #include "MainWindow.h" -#include "ITimeOfDay.h" #include "LevelFileDialog.h" #include "StatObjBus.h" @@ -123,7 +121,6 @@ CCryEditDoc::CCryEditDoc() // The right way would require us to save to the level folder the export status of the // level. , m_boLevelExported(true) - , m_mission(NULL) , m_modified(false) , m_envProbeHeight(200.0f) , m_envProbeSliceRelativePath("EngineAssets/Slices/DefaultLevelSetup.slice") @@ -158,7 +155,6 @@ CCryEditDoc::CCryEditDoc() CCryEditDoc::~CCryEditDoc() { GetIEditor()->SetDocument(nullptr); - ClearMissions(); delete m_pLevelShaderCache; @@ -255,17 +251,6 @@ bool CCryEditDoc::Save() return OnSaveDocument(GetActivePathName()); } -void CCryEditDoc::ChangeMission() -{ - GetIEditor()->Notify(eNotify_OnMissionChange); - - // Notify listeners. - for (std::list::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) - { - (*it)->OnMissionChange(); - } -} - void CCryEditDoc::DeleteContents() { m_hasErrors = false; @@ -295,10 +280,6 @@ void CCryEditDoc::DeleteContents() // Delete all objects from Object Manager. GetIEditor()->GetObjectManager()->DeleteAllObjects(); - ClearMissions(); - - GetIEditor()->GetGameEngine()->ResetResources(); - // Load scripts data SetModifiedFlag(FALSE); SetModifiedModules(eModifiedNothing); @@ -341,7 +322,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr) if (!isPrefabEnabled) { CAutoDocNotReady autoDocNotReady; - QString currentMissionName; if (arrXmlAr[DMAS_GENERAL] != NULL) { @@ -356,8 +336,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr) // Fog settings /////////////////////////////////////////////////////// SerializeFogSettings((*arrXmlAr[DMAS_GENERAL])); - // Serialize Missions ////////////////////////////////////////////////// - SerializeMissions(arrXmlAr, currentMissionName, false); SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA])); SerializeNameSelection((*arrXmlAr[DMAS_GENERAL])); @@ -404,7 +382,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename) HEAP_CHECK CLogFile::FormatLine("Loading from %s...", szFilename.toUtf8().data()); - QString currentMissionName; QString szLevelPath = Path::GetPath(szFilename); { @@ -482,27 +459,9 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename) Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData); } - HEAP_CHECK - - if (!isPrefabEnabled) - { - // multiple missions are no longer supported, only load the current mission (last used) - SerializeMissions(arrXmlAr, currentMissionName, false); - } - - HEAP_CHECK - - if (GetIEditor()->Get3DEngine()) - { - if (!isPrefabEnabled) - { - GetIEditor()->Get3DEngine()->LoadCompiledOctreeForEditor(); - } - } - { CAutoLogTime logtime("Game Engine level load"); - GetIEditor()->GetGameEngine()->LoadLevel(currentMissionName, true, true); + GetIEditor()->GetGameEngine()->LoadLevel(true, true); } if (!isPrefabEnabled) @@ -523,27 +482,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename) SerializeFogSettings((*arrXmlAr[DMAS_GENERAL])); } - { - QByteArray str; - str = tr("Activating Mission %1").arg(currentMissionName).toUtf8(); - - CAutoLogTime logtime(str.data()); - - // Select current mission. - m_mission = FindMission(currentMissionName); - - if (m_mission) - { - SyncCurrentMissionContent(true); - } - else - { - GetCurrentMission(); - } - } - - ForceSkyUpdate(); - if (!isPrefabEnabled) { // Serialize Shader Cache. @@ -730,94 +668,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr) } } -void CCryEditDoc::SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMissionName, bool bPartsInXml) -{ - bool bLoading = IsLoadingXmlArArray(arrXmlAr); - - if (bLoading) - { - // Loading - CLogFile::WriteLine("Loading missions..."); - // Clear old layers - ClearMissions(); - // Load shared objects and layers. - XmlNodeRef objectsNode = arrXmlAr[DMAS_GENERAL]->root->findChild("Objects"); - XmlNodeRef objectLayersNode = arrXmlAr[DMAS_GENERAL]->root->findChild("ObjectLayers"); - // Load the layer count - XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->findChild("Missions"); - - if (!node) - { - return; - } - - QString current; - node->getAttr("Current", current); - currentMissionName = current; - - // Read all node - for (int i = 0; i < node->getChildCount(); i++) - { - CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]); - ar.root = node->getChild(i); - CMission* mission = new CMission(this); - mission->Serialize(ar); - if (bPartsInXml) - { - mission->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]); - mission->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]); - } - else - { - mission->LoadParts(); - } - - // Timur[9/11/2002] For backward compatibility with shared objects - if (objectsNode) - { - mission->AddObjectsNode(objectsNode); - } - if (objectLayersNode) - { - mission->SetLayersNode(objectLayersNode); - } - - AddMission(mission); - } - } - else - { - // Storing - CLogFile::WriteLine("Storing missions..."); - // Save contents of current mission. - SyncCurrentMissionContent(false); - - XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->newChild("Missions"); - - //! Store current mission name. - currentMissionName = GetCurrentMission()->GetName(); - node->setAttr("Current", currentMissionName.toUtf8().data()); - - // Write all surface types. - for (int i = 0; i < m_missions.size(); i++) - { - CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]); - ar.root = node->newChild("Mission"); - m_missions[i]->Serialize(ar, false); - if (bPartsInXml) - { - m_missions[i]->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]); - m_missions[i]->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]); - } - else - { - m_missions[i]->SaveParts(); - } - } - CLogFile::WriteString("Done"); - } -} - void CCryEditDoc::SerializeShaderCache(CXmlArchive& xmlAr) { if (xmlAr.bLoading) @@ -2089,58 +1939,6 @@ void CCryEditDoc::SaveAutoBackup(bool bForce) isInProgress = false; } - -CMission* CCryEditDoc::GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent /* = false */) -{ - if (m_mission) - { - return m_mission; - } - - if (!m_missions.empty()) - { - // Choose first available mission. - SetCurrentMission(m_missions[0]); - return m_mission; - } - - // Create initial mission. - m_mission = new CMission(this); - m_mission->SetName("Mission0"); - AddMission(m_mission); - m_mission->SyncContent(true, false, bSkipLoadingAIWhenSyncingContent); - return m_mission; -} - -void CCryEditDoc::SetCurrentMission(CMission* mission) -{ - if (mission != m_mission) - { - QWaitCursor wait; - - if (m_mission) - { - m_mission->SyncContent(false, false); - } - - m_mission = mission; - m_mission->SyncContent(true, false); - - GetIEditor()->GetGameEngine()->LoadMission(m_mission->GetName()); - } -} - -void CCryEditDoc::ClearMissions() -{ - for (int i = 0; i < m_missions.size(); i++) - { - delete m_missions[i]; - } - - m_missions.clear(); - m_mission = 0; -} - bool CCryEditDoc::IsLevelExported() const { return m_boLevelExported; @@ -2151,37 +1949,6 @@ void CCryEditDoc::SetLevelExported(bool boExported) m_boLevelExported = boExported; } -CMission* CCryEditDoc::FindMission(const QString& name) const -{ - for (int i = 0; i < m_missions.size(); i++) - { - if (QString::compare(name, m_missions[i]->GetName(), Qt::CaseInsensitive) == 0) - { - return m_missions[i]; - } - } - return 0; -} - -void CCryEditDoc::AddMission(CMission* mission) -{ - assert(std::find(m_missions.begin(), m_missions.end(), mission) == m_missions.end()); - m_missions.push_back(mission); - GetIEditor()->Notify(eNotify_OnInvalidateControls); -} - -void CCryEditDoc::RemoveMission(CMission* mission) -{ - // if deleting current mission. - if (mission == m_mission) - { - m_mission = 0; - } - - m_missions.erase(std::find(m_missions.begin(), m_missions.end(), mission)); - GetIEditor()->Notify(eNotify_OnInvalidateControls); -} - void CCryEditDoc::RegisterListener(IDocListener* listener) { if (listener == nullptr) @@ -2287,19 +2054,6 @@ void CCryEditDoc::OnStartLevelResourceList() gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level)->Clear(); } -void CCryEditDoc::ForceSkyUpdate() -{ - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr; - CMission* pCurMission = GetIEditor()->GetDocument()->GetCurrentMission(); - - if (pTimeOfDay && pCurMission) - { - pTimeOfDay->SetTime(pCurMission->GetTime(), gSettings.bForceSkyUpdate); - pCurMission->SetTime(pCurMission->GetTime()); - GetIEditor()->Notify(eNotify_OnTimeOfDayChange); - } -} - BOOL CCryEditDoc::DoFileSave() { if (GetEditMode() == CCryEditDoc::DocumentEditingMode::LevelEdit) @@ -2361,27 +2115,11 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU ////////////////////////////////////////////////////////////////////////// if (!GetIEditor()->IsInPreviewMode()) { - // Make new mission. GetIEditor()->ReloadTemplates(); m_environmentTemplate = GetIEditor()->FindTemplate("Environment"); - GetCurrentMission(true); // true = skip loading the AI in case the content needs to get synchronized (otherwise it would attempt to load AI stuff from the previously loaded level (!) which might give confusing warnings) - GetIEditor()->GetGameEngine()->SetMissionName(GetCurrentMission()->GetName()); GetIEditor()->GetGameEngine()->SetLevelCreated(true); - GetIEditor()->GetGameEngine()->ReloadEnvironment(); GetIEditor()->GetGameEngine()->SetLevelCreated(false); - - // Default time of day. - auto defaultTimeOfDayPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Assets" / "Editor" / "default_time_of_day.xml"; - XmlNodeRef root = GetISystem()->LoadXmlFromFile(defaultTimeOfDayPath.c_str()); - if (root) - { - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr; - if (pTimeOfDay) - { - pTimeOfDay->Serialize(root, true); - } - } } { @@ -2469,8 +2207,6 @@ void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar) pVar->Get(value); childNode->setAttr("value", value.toUtf8().data()); } - - GetIEditor()->GetGameEngine()->ReloadEnvironment(); } QString CCryEditDoc::GetCryIndexPath(const LPCTSTR levelFilePath) @@ -2523,12 +2259,6 @@ void CCryEditDoc::ReleaseXmlArchiveArray(TDocMultiArchive& arrXmlAr) SAFE_DELETE(arrXmlAr[0]); } - -void CCryEditDoc::SyncCurrentMissionContent(bool bRetrieve) -{ - GetCurrentMission()->SyncContent(bRetrieve, false); -} - ////////////////////////////////////////////////////////////////////////// // AzToolsFramework::EditorEntityContextNotificationBus interface implementation void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/) diff --git a/Code/Sandbox/Editor/CryEditDoc.h b/Code/Sandbox/Editor/CryEditDoc.h index 481e9fa046..be8a5fcec7 100644 --- a/Code/Sandbox/Editor/CryEditDoc.h +++ b/Code/Sandbox/Editor/CryEditDoc.h @@ -22,7 +22,6 @@ #include #endif -class CMission; class CLevelShaderCache; class CClouds; struct LightingSettings; @@ -124,18 +123,6 @@ public: // Create from serialization only const char* GetTemporaryLevelName() const; void DeleteTemporaryLevel(); - void ChangeMission(); - //! Return currently active Mission. - CMission* GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent = false); - //! Get number of missions on Map. - int GetMissionCount() const { return m_missions.size(); } - //! Get Mission by index. - CMission* GetMission(int index) const { return m_missions[index]; } - //! Find Mission by name. - CMission* FindMission(const QString& name) const; - //! Makes specified mission current. - void SetCurrentMission(CMission* mission); - CLevelShaderCache* GetShaderCache() { return m_pLevelShaderCache; } CClouds* GetClouds() { return m_pClouds; } void SetWaterColor(const QColor& col) { m_waterColor = col; } @@ -167,7 +154,6 @@ protected: virtual void Load(TDocMultiArchive& arrXmlAr, const QString& szFilename); virtual void StartStreamingLoad(){} - virtual void SyncCurrentMissionContent(bool bRetrieve); void Save(CXmlArchive& xmlAr); void Load(CXmlArchive& xmlAr, const QString& szFilename); @@ -179,14 +165,8 @@ protected: bool LoadEntitiesFromSlice(const QString& sliceFile); void SerializeFogSettings(CXmlArchive& xmlAr); virtual void SerializeViewSettings(CXmlArchive& xmlAr); - void SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMission, bool bPartsInXml); void SerializeShaderCache(CXmlArchive& xmlAr); void SerializeNameSelection(CXmlArchive& xmlAr); - void ForceSkyUpdate(); - //! Add new mission to map. - void AddMission(CMission* mission); - //! Remove existing mission from map. - void RemoveMission(CMission* mission); void LogLoadTime(int time); struct TSaveDocContext @@ -200,10 +180,8 @@ protected: virtual bool OnSaveDocument(const QString& lpszPathName); virtual void OnFileSaveAs(); - void LoadTemplates(); //! called immediately after saving the level. void AfterSave(); - void ClearMissions(); void RegisterConsoleVariables(); void OnStartLevelResourceList(); static void OnValidateSurfaceTypesChanged(ICVar*); @@ -220,9 +198,7 @@ protected: QColor m_waterColor; XmlNodeRef m_fogTemplate; XmlNodeRef m_environmentTemplate; - CMission* m_mission; CClouds* m_pClouds; - std::vector m_missions; std::list m_listeners; bool m_bDocumentReady; CLevelShaderCache* m_pLevelShaderCache; diff --git a/Code/Sandbox/Editor/DisplaySettings.cpp b/Code/Sandbox/Editor/DisplaySettings.cpp index 75e5c54ae9..6454471a80 100644 --- a/Code/Sandbox/Editor/DisplaySettings.cpp +++ b/Code/Sandbox/Editor/DisplaySettings.cpp @@ -86,11 +86,6 @@ void CDisplaySettings::PostInitApply() void CDisplaySettings::SetRenderFlags(int flags) { m_renderFlags = flags; - - if (!GetIEditor()->Get3DEngine()) - { - return; - } } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/EditorDefs.h b/Code/Sandbox/Editor/EditorDefs.h index dd86bdf07a..8c78e9644f 100644 --- a/Code/Sandbox/Editor/EditorDefs.h +++ b/Code/Sandbox/Editor/EditorDefs.h @@ -132,7 +132,6 @@ #include #include #include -#include #include #include #include diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index a127203071..d9344746a2 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -54,7 +54,6 @@ #include // CryCommon -#include #include // AzFramework @@ -97,6 +96,10 @@ #include +#include +#include +#include + AZ_CVAR( bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Output the timing of the new IVisibilitySystem query"); @@ -250,11 +253,6 @@ void EditorViewportWidget::resizeEvent(QResizeEvent* event) gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height()); - if (gEnv->pRenderer) - { - gEnv->pRenderer->EF_DisableTemporalEffects(); - } - // We queue the window resize event because the render overlay may be hidden. // If the render overlay is not visible, the native window that is backing it will // also be hidden, and it will not resize until it becomes visible. @@ -320,8 +318,8 @@ AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMous using namespace AzToolsFramework::ViewportInteraction; MousePick mousePick; - mousePick.m_screenCoordinates = AzFramework::ScreenPoint(point.x(), point.y()); - const auto& ray = m_renderViewport->ViewportScreenToWorldRay(point); + mousePick.m_screenCoordinates = ScreenPointFromQPoint(point); + const auto& ray = m_renderViewport->ViewportScreenToWorldRay(mousePick.m_screenCoordinates); if (ray.has_value()) { mousePick.m_rayOrigin = ray.value().origin; @@ -520,9 +518,6 @@ void EditorViewportWidget::Update() // Render { // TODO: Move out this logic to a controller and refactor to work with Atom - // m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f)); - // 3D engine stats - GetIEditor()->GetSystem()->RenderBegin(); OnRender(); @@ -547,8 +542,6 @@ void EditorViewportWidget::Update() } } - GetIEditor()->GetSystem()->RenderEnd(m_bRenderStats); - gEnv->pSystem->SetViewCamera(CurCamera); } @@ -1131,14 +1124,14 @@ float EditorViewportWidget::AngleStep() return GetViewManager()->GetGrid()->GetAngleSnap(); } -AZ::Vector3 EditorViewportWidget::PickTerrain(const QPoint& point) +AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point) { FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true)); + return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true)); } -AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point) +AZ::EntityId EditorViewportWidget::PickEntity(const AzFramework::ScreenPoint& point) { FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); @@ -1147,7 +1140,7 @@ AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point) AZ::EntityId entityId; HitContext hitInfo; hitInfo.view = this; - if (HitTest(point, hitInfo)) + if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo)) { if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY)) { @@ -1173,7 +1166,7 @@ void EditorViewportWidget::FindVisibleEntities(AZStd::vector& visi visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End()); } -QPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition) +AzFramework::ScreenPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition) { return m_renderViewport->ViewportWorldToScreen(worldPosition); } @@ -1305,26 +1298,8 @@ namespace AZ::ViewportHelpers ////////////////////////////////////////////////////////////////////////// void EditorViewportWidget::OnTitleMenu(QMenu* menu) { - const int nWireframe = gEnv->pConsole->GetCVar("r_wireframe")->GetIVal(); - QAction* action = menu->addAction(tr("Wireframe")); - connect(action, &QAction::triggered, action, []() - { - ICVar* piVar(gEnv->pConsole->GetCVar("r_wireframe")); - int nRenderMode = piVar->GetIVal(); - if (nRenderMode != R_WIREFRAME_MODE) - { - piVar->Set(R_WIREFRAME_MODE); - } - else - { - piVar->Set(R_SOLID_MODE); - } - }); - action->setCheckable(true); - action->setChecked(nWireframe == R_WIREFRAME_MODE); - const bool bDisplayLabels = GetIEditor()->GetDisplaySettings()->IsDisplayLabels(); - action = menu->addAction(tr("Labels")); + QAction* action = menu->addAction(tr("Labels")); connect(action, &QAction::triggered, this, [bDisplayLabels] {GetIEditor()->GetDisplaySettings()->DisplayLabels(!bDisplayLabels); }); action->setCheckable(true); @@ -1556,7 +1531,6 @@ void EditorViewportWidget::ToggleCameraObject() { if (m_viewSourceType == ViewSourceType::SequenceCamera) { - gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f); ResetToViewSourceType(ViewSourceType::LegacyCamera); } else @@ -2001,7 +1975,7 @@ Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nF ////////////////////////////////////////////////////////////////////////// QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const { - return m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)); + return AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp))); } ////////////////////////////////////////////////////////////////////////// QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width, int height) const @@ -2023,7 +1997,8 @@ QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width } ////////////////////////////////////////////////////////////////////////// -Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const +Vec3 EditorViewportWidget::ViewToWorld( + const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const { AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); @@ -2034,7 +2009,7 @@ Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrai AZ_UNUSED(bSkipVegetation) AZ_UNUSED(collideWithObject) - auto ray = m_renderViewport->ViewportScreenToWorldRay(vp); + auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp)); if (!ray.has_value()) { return Vec3(0, 0, 0); @@ -2135,23 +2110,29 @@ bool EditorViewportWidget::AdjustObjectPosition(const ray_hit& hit, Vec3& outNor ////////////////////////////////////////////////////////////////////////// bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const { - SRayHitInfo hitInfo; + AZ_UNUSED(pRenderMesh); + AZ_UNUSED(vInPos); + AZ_UNUSED(vInDir); + AZ_UNUSED(vOutPos); + AZ_UNUSED(vOutNormal); + return false; + /*SRayHitInfo hitInfo; hitInfo.bUseCache = false; hitInfo.bInFirstHit = false; hitInfo.inRay.origin = vInPos; hitInfo.inRay.direction = vInDir.GetNormalized(); hitInfo.inReferencePoint = vInPos; hitInfo.fMaxHitDistance = 0; - bool bRes = GetIEditor()->Get3DEngine()->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr); + bool bRes = ???->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr); vOutPos = hitInfo.vHitPos; vOutNormal = hitInfo.vHitNormal; - return bRes; + return bRes;*/ } void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const { AZ::Vector3 wp; - wp = m_renderViewport->ViewportScreenToWorld({(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp); + wp = m_renderViewport->ViewportScreenToWorld(AzFramework::ScreenPoint{(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp); *px = wp.GetX(); *py = wp.GetY(); *pz = wp.GetZ(); @@ -2159,9 +2140,9 @@ void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, flo void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const { - QPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz}); - *sx = screenPosition.x(); - *sy = screenPosition.y(); + AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz}); + *sx = screenPosition.m_x; + *sy = screenPosition.m_y; *sz = 0.f; } @@ -2416,10 +2397,6 @@ void EditorViewportWidget::SetDefaultCamera() return; } ResetToViewSourceType(ViewSourceType::None); - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f); - } GetViewManager()->SetCameraObjectId(m_cameraObjectId); SetName(m_defaultViewName); SetViewTM(m_defaultViewTM); diff --git a/Code/Sandbox/Editor/EditorViewportWidget.h b/Code/Sandbox/Editor/EditorViewportWidget.h index 472f7e3c62..09474200f1 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.h +++ b/Code/Sandbox/Editor/EditorViewportWidget.h @@ -196,15 +196,15 @@ public: bool ShowGrid(); bool AngleSnappingEnabled(); float AngleStep(); - QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition); + AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition); // AzToolsFramework::ViewportFreezeRequestBus bool IsViewportInputFrozen() override; void FreezeViewportInput(bool freeze) override; // AzToolsFramework::MainEditorViewportInteractionRequestBus - AZ::EntityId PickEntity(const QPoint& point) override; - AZ::Vector3 PickTerrain(const QPoint& point) override; + AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override; + AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override; float TerrainHeight(const AZ::Vector2& position) override; void FindVisibleEntities(AZStd::vector& visibleEntitiesOut) override; bool ShowingWorldSpace() override; @@ -481,10 +481,6 @@ protected: OBB m_GroundOBB; Vec3 m_GroundOBBPos; - //------------------------------------------- - // Render options. - bool m_bRenderStats = true; - // Index of camera objects. mutable GUID m_cameraObjectId; mutable AZ::EntityId m_viewEntityId; @@ -557,8 +553,7 @@ private: void PushDisableRendering(); void PopDisableRendering(); bool IsRenderingDisabled() const; - AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal( - const QPoint& point) const; + AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(const QPoint& point) const; void RestoreViewportAfterGameMode(); void UpdateCameraFromViewportContext(); diff --git a/Code/Sandbox/Editor/EnvironmentPanel.cpp b/Code/Sandbox/Editor/EnvironmentPanel.cpp deleted file mode 100644 index f71babbff6..0000000000 --- a/Code/Sandbox/Editor/EnvironmentPanel.cpp +++ /dev/null @@ -1,53 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "EnvironmentPanel.h" - -// Editor -#include "GameEngine.h" -#include "CryEditDoc.h" - -AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING -#include -AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -///////////////////////////////////////////////////////////////////////////// -// CEnvironmentPanel dialog - -CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/) - : QWidget(pParent) - , ui(new Ui::CEnvironmentPanel) -{ - XmlNodeRef node = GetIEditor()->GetDocument()->GetEnvironmentTemplate(); - - m_onSetCallback = AZStd::bind(&CCryEditDoc::OnEnvironmentPropertyChanged, GetIEditor()->GetDocument(), AZStd::placeholders::_1); - - ui->setupUi(this); - ui->m_wndProps->Setup(); - ui->m_wndProps->CreateItems(node, m_varBlock, &m_onSetCallback, true); - ui->m_wndProps->RebuildCtrl(false); - ui->m_wndProps->ExpandAll(); - connect(ui->APPLYBTN, &QPushButton::clicked, this, &CEnvironmentPanel::OnBnClickedApply); -} - -CEnvironmentPanel::~CEnvironmentPanel() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CEnvironmentPanel::OnBnClickedApply() -{ - GetIEditor()->GetGameEngine()->ReloadEnvironment(); -} diff --git a/Code/Sandbox/Editor/EnvironmentPanel.h b/Code/Sandbox/Editor/EnvironmentPanel.h deleted file mode 100644 index ff4594a502..0000000000 --- a/Code/Sandbox/Editor/EnvironmentPanel.h +++ /dev/null @@ -1,53 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H -#define CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H - -#pragma once -// EnvironmentPanel.h : header file -// - -#include "Util/Variable.h" - -#include -#include - -///////////////////////////////////////////////////////////////////////////// -// CEnvironmentPanel dialog -namespace Ui { - class CEnvironmentPanel; -} - -class CEnvironmentPanel - : public QWidget -{ - // Construction -public: - CEnvironmentPanel(QWidget* pParent = nullptr); // standard constructor - ~CEnvironmentPanel(); - - // Implementation -protected: - CVarBlockPtr m_varBlock; - -public: - void OnBnClickedApply(); - -private: - QScopedPointer ui; - - IVariable::OnSetCallback m_onSetCallback; -}; - -#endif // CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H diff --git a/Code/Sandbox/Editor/EnvironmentPanel.ui b/Code/Sandbox/Editor/EnvironmentPanel.ui deleted file mode 100644 index b808fc93fc..0000000000 --- a/Code/Sandbox/Editor/EnvironmentPanel.ui +++ /dev/null @@ -1,56 +0,0 @@ - - - CEnvironmentPanel - - - - 0 - 0 - 264 - 259 - - - - - - - - 0 - 200 - - - - - - - - Apply - - - - - - - Qt::Horizontal - - - - 162 - 20 - - - - - - - - - ReflectedPropertyControl - QWidget -
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h
- 1 -
-
- - -
diff --git a/Code/Sandbox/Editor/Export/ExportManager.cpp b/Code/Sandbox/Editor/Export/ExportManager.cpp index 638977b191..2d0f784647 100644 --- a/Code/Sandbox/Editor/Export/ExportManager.cpp +++ b/Code/Sandbox/Editor/Export/ExportManager.cpp @@ -22,7 +22,6 @@ #include // Editor -#include "Geometry/EdGeometry.h" #include "ViewManager.h" #include "OBJExporter.h" #include "OCMExporter.h" @@ -41,6 +40,9 @@ #include "Resource.h" #include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h" +#include +#include + namespace { void SetTexture(Export::TPath& outName, IRenderShaderResources* pRes, int nSlot) @@ -494,53 +496,6 @@ bool CExportManager::AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matri bool CExportManager::AddMeshes(Export::CObject* pObj) { - CEdGeometry* pEdGeom = m_pBaseObj->GetGeometry(); - IIndexedMesh* pIndMesh = 0; - - if (pEdGeom) - { - size_t idx = 0; - size_t nextIdx = 0; - do - { - pIndMesh = 0; - if (m_isOccluder) - { - if (pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(2)) - { - pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(2)->GetIndexedMesh(true); - } - if (!pIndMesh && pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(1)) - { - pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(1)->GetIndexedMesh(true); - } - } - - if (!pIndMesh) - { - pIndMesh = pEdGeom->GetIndexedMesh(idx); - nextIdx++; - } - - if (!pIndMesh) - { - break; - } - - Matrix34 tm; - pEdGeom->GetTM(&tm, idx); - Matrix34A objTM = tm; - AddMesh(pObj, pIndMesh, &objTM); - idx = nextIdx; - } - while (pIndMesh && idx); - - if (idx > 0) - { - return true; - } - } - if (m_pBaseObj->GetType() == OBJTYPE_AZENTITY) { CEntityObject* pEntityObject = (CEntityObject*)m_pBaseObj; @@ -548,11 +503,7 @@ bool CExportManager::AddMeshes(Export::CObject* pObj) if (pEngineNode) { - if (m_isPrecaching) - { - GetIEditor()->Get3DEngine()->PrecacheRenderNode(pEngineNode, 0); - } - else + if (!m_isPrecaching) { for (int i = 0; i < pEngineNode->GetSlotCount(); ++i) { @@ -1091,35 +1042,6 @@ bool CExportManager::AddSelectedEntityObjects() return true; } - -bool CExportManager::AddSelectedObjects() -{ - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - - int numObjects = pSelection->GetCount(); - if (numObjects > m_data.m_objects.size()) - { - m_data.m_objects.reserve(numObjects + 1); // +1 for terrain - } - // First run pipeline to precache geometry - m_isPrecaching = true; - for (int i = 0; i < numObjects; i++) - { - AddObject(pSelection->GetObject(i)); - } - - GetIEditor()->Get3DEngine()->ProposeContentPrecache(); - - // Repeat pipeline to collect geometry - m_isPrecaching = false; - for (int i = 0; i < numObjects; i++) - { - AddObject(pSelection->GetObject(i)); - } - - return true; -} - bool CExportManager::AddSelectedRegionObjects() { AABB box; @@ -1144,8 +1066,6 @@ bool CExportManager::AddSelectedRegionObjects() AddObject(objects[i]); } - GetIEditor()->Get3DEngine()->ProposeContentPrecache(); - // Repeat pipeline to collect geometry m_isPrecaching = false; for (size_t i = 0; i < numObjects; ++i) @@ -1185,7 +1105,7 @@ bool CExportManager::ExportToFile(const char* filename, bool bClearDataAfterExpo } -bool CExportManager::Export(const char* defaultName, const char* defaultExt, const char* defaultPath, bool isSelectedObjects, bool isSelectedRegionObjects, bool isOccluder, bool bAnimationExport) +bool CExportManager::Export(const char* defaultName, const char* defaultExt, const char* defaultPath, [[maybe_unused]] bool isSelectedObjects, bool isSelectedRegionObjects, bool isOccluder, bool bAnimationExport) { m_bAnimationExport = bAnimationExport; @@ -1229,10 +1149,6 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con if (m_bAnimationExport || CFileUtil::SelectSaveFile(filters, defaultExt, defaultPath, newFilename)) { WaitCursor wait; - if (isSelectedObjects) - { - AddSelectedObjects(); - } if (isSelectedRegionObjects) { AddSelectedRegionObjects(); diff --git a/Code/Sandbox/Editor/Export/ExportManager.h b/Code/Sandbox/Editor/Export/ExportManager.h index a27e54b085..04ee5f73ca 100644 --- a/Code/Sandbox/Editor/Export/ExportManager.h +++ b/Code/Sandbox/Editor/Export/ExportManager.h @@ -128,10 +128,6 @@ public: bool Export(const char* defaultName, const char* defaultExt = "", const char* defaultPath = "", bool isSelectedObjects = true, bool isSelectedRegionObjects = false, bool isOccluder = false, bool bAnimationExport = false); - //! Add to Export Data geometry from selected objects - //! return true if succeed, otherwise false - bool AddSelectedObjects(); - bool AddSelectedEntityObjects(); //! Add to Export Data geometry from objects inside selected region volume diff --git a/Code/Sandbox/Editor/GameEngine.cpp b/Code/Sandbox/Editor/GameEngine.cpp index d5aec9e7d4..073684eaad 100644 --- a/Code/Sandbox/Editor/GameEngine.cpp +++ b/Code/Sandbox/Editor/GameEngine.cpp @@ -34,15 +34,11 @@ // Editor #include "IEditorImpl.h" #include "CryEditDoc.h" -#include "Geometry/EdMesh.h" -#include "Mission.h" #include "Settings.h" // CryCommon -#include #include #include -#include #include #include @@ -283,7 +279,6 @@ AZ_POP_DISABLE_WARNING AZ::Interface::Unregister(this); GetIEditor()->UnregisterNotifyListener(this); m_pISystem->GetIMovieSystem()->SetCallback(NULL); - CEdMesh::ReleaseAll(); if (m_gameDll) { @@ -493,13 +488,6 @@ AZ::Outcome CGameEngine::Init( SetEditorCoreEnvironment(gEnv); - if (gEnv - && gEnv->p3DEngine - && gEnv->p3DEngine->GetTimeOfDay()) - { - gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode(); - } - if (gEnv && gEnv->pMovieSystem) { gEnv->pMovieSystem->EnablePhysicsEvents(m_bSimulationMode); @@ -549,26 +537,14 @@ void CGameEngine::SetLevelPath(const QString& path) { m_levelExtension = defaultExtension; } - - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->SetLevelPath(m_levelPath.toUtf8().data()); - } -} - -void CGameEngine::SetMissionName(const QString& mission) -{ - m_missionName = mission; } bool CGameEngine::LoadLevel( - const QString& mission, [[maybe_unused]] bool bDeleteAIGraph, bool bReleaseResources) { LOADING_TIME_PROFILE_SECTION(GetIEditor()->GetSystem()); m_bLevelLoaded = false; - m_missionName = mission; CLogFile::FormatLine("Loading map '%s' into engine...", m_levelPath.toUtf8().data()); // Switch the current directory back to the Primary CD folder first. // The engine might have trouble to find some files when the current @@ -607,30 +583,17 @@ bool CGameEngine::LoadLevel( } - // Load level in 3d engine. - if (gEnv->p3DEngine && !gEnv->p3DEngine->InitLevelForEditor(m_levelPath.toUtf8().data(), m_missionName.toUtf8().data())) - { - CLogFile::WriteLine("ERROR: Can't load level !"); - QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("ERROR: Can't load level !")); - return false; - } - // Audio: notify audio of level loading start? GetIEditor()->GetObjectManager()->SendEvent(EVENT_REFRESH); m_bLevelLoaded = true; - if (!bReleaseResources) - { - ReloadEnvironment(); - } - return true; } bool CGameEngine::ReloadLevel() { - if (!LoadLevel(GetMissionName(), false, false)) + if (!LoadLevel(false, false)) { return false; } @@ -638,61 +601,8 @@ bool CGameEngine::ReloadLevel() return true; } -bool CGameEngine::LoadMission(const QString& mission) -{ - if (!IsLevelLoaded()) - { - return false; - } - - if (mission != m_missionName) - { - m_missionName = mission; - gEnv->p3DEngine->LoadMissionDataFromXMLNode(m_missionName.toUtf8().data()); - } - - return true; -} - -bool CGameEngine::ReloadEnvironment() -{ - if (!gEnv->p3DEngine) - { - return false; - } - - if (!IsLevelLoaded() && !m_bJustCreated) - { - return false; - } - - if (!GetIEditor()->GetDocument()) - { - return false; - } - - XmlNodeRef env = XmlHelpers::CreateXmlNode("Environment"); - CXmlTemplate::SetValues(GetIEditor()->GetDocument()->GetEnvironmentTemplate(), env); - - // Notify mission that environment may be changed. - GetIEditor()->GetDocument()->GetCurrentMission()->OnEnvironmentChange(); - - QString xmlStr = QString::fromLatin1(env->getXML()); - - // Reload level data in engine. - gEnv->p3DEngine->LoadEnvironmentSettingsFromXML(env); - - return true; -} - void CGameEngine::SwitchToInGame() { - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->DisablePostEffects(); - gEnv->p3DEngine->ResetPostEffects(); - } - auto streamer = AZ::Interface::Get(); if (streamer) { @@ -707,11 +617,6 @@ void CGameEngine::SwitchToInGame() m_pISystem->SetThreadState(ESubsys_Physics, false); - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->ResetParticlesAndDecals(); - } - m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true); m_bInGameMode = true; @@ -721,10 +626,6 @@ void CGameEngine::SwitchToInGame() pRuler->SetActive(false); } - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->GetTimeOfDay()->EndEditMode(); - } gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM); // Disable accelerators. @@ -760,24 +661,9 @@ void CGameEngine::SwitchToInEditor() m_pISystem->SetThreadState(ESubsys_Physics, false); - if (gEnv->p3DEngine) - { - // Reset 3d engine effects - gEnv->p3DEngine->DisablePostEffects(); - gEnv->p3DEngine->ResetPostEffects(); - gEnv->p3DEngine->ResetParticlesAndDecals(); - } - CViewport* pGameViewport = GetIEditor()->GetViewManager()->GetGameViewport(); m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(m_bSimulationMode); - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode(); - - // this has to be done before the RemoveSink() call, or else some entities may not be removed - gEnv->p3DEngine->GetDeferredPhysicsEventManager()->ClearDeferredEvents(); - } // Enable accelerators. GetIEditor()->EnableAcceleratos(true); @@ -865,7 +751,6 @@ void CGameEngine::SetGameMode(bool bInGame) // Ignore updates while changing in and out of game mode m_bIgnoreUpdates = true; - LockResources(); // Switching modes will destroy the current AzFramework::EntityConext which may contain // data the queued events hold on to, so execute all queued events before switching. @@ -891,7 +776,6 @@ void CGameEngine::SetGameMode(bool bInGame) GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED, bInGame, 0); - UnlockResources(); m_bIgnoreUpdates = false; GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_GAME_MODE_SWITCH_END, bInGame, 0); @@ -906,11 +790,6 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics) m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(enabled); - if (!bOnlyPhysics) - { - LockResources(); - } - if (enabled) { CRuler* pRuler = GetIEditor()->GetRuler(); @@ -935,35 +814,12 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics) if (m_bSimulationMode) { - if (!bOnlyPhysics) - { - if (m_pISystem->GetI3DEngine()) - { - m_pISystem->GetI3DEngine()->ResetPostEffects(); - } - - GetIEditor()->SetConsoleVar("ai_ignoreplayer", 1); - //GetIEditor()->SetConsoleVar( "ai_soundperception",0 ); - } - // [Anton] the order of the next 3 calls changed, since, EVENT_INGAME loads physics state (if any), // and Reset should be called before it GetIEditor()->GetObjectManager()->SendEvent(EVENT_INGAME); } else { - if (!bOnlyPhysics) - { - GetIEditor()->SetConsoleVar("ai_ignoreplayer", 0); - //GetIEditor()->SetConsoleVar( "ai_soundperception",1 ); - - if (m_pISystem->GetI3DEngine()) - { - m_pISystem->GetI3DEngine()->ResetPostEffects(); - } - } - - GetIEditor()->GetObjectManager()->SendEvent(EVENT_OUTOFGAME); } @@ -983,23 +839,9 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics) AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequestBus::Events::StartPlayInEditor); } - if (!bOnlyPhysics) - { - UnlockResources(); - } - AzFramework::InputChannelRequestBus::Broadcast(&AzFramework::InputChannelRequests::ResetState); } -void CGameEngine::ResetResources() -{ - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->UnloadLevel(); - } - -} - void CGameEngine::SetPlayerViewMatrix(const Matrix34& tm, [[maybe_unused]] bool bEyePos) { m_playerViewTM = tm; @@ -1107,24 +949,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event) { switch (event) { - case eNotify_OnBeginNewScene: - case eNotify_OnBeginSceneOpen: - { - ResetResources(); - } - break; - case eNotify_OnEndSceneOpen: - case eNotify_OnEndTerrainRebuild: - { - } - case eNotify_OnEndNewScene: // intentional fall-through? - { - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->PostLoadLevel(); - } - } - break; case eNotify_OnSplashScreenDestroyed: { if (m_pSystemUserCallback != NULL) @@ -1136,22 +960,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event) } } -void CGameEngine::LockResources() -{ - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->LockCGFResources(); - } -} - -void CGameEngine::UnlockResources() -{ - if (gEnv->p3DEngine) - { - gEnv->p3DEngine->UnlockCGFResources(); - } -} - void CGameEngine::OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain) { INavigationSystem* pNavigationSystem = nullptr; // INavigationSystem will be converted to an AZInterface (LY-111343) diff --git a/Code/Sandbox/Editor/GameEngine.h b/Code/Sandbox/Editor/GameEngine.h index 366ec42f72..b59e2c9ac8 100644 --- a/Code/Sandbox/Editor/GameEngine.h +++ b/Code/Sandbox/Editor/GameEngine.h @@ -89,15 +89,10 @@ public: //! Load new terrain level into 3d engine. //! Also load AI triangulation for this level. bool LoadLevel( - const QString& mission, bool bDeleteAIGraph, bool bReleaseResources); //!* Reload level if it was already loaded. bool ReloadLevel(); - //! Load new mission. - bool LoadMission(const QString& mission); - //! Reload environment settings in currently loaded level. - bool ReloadEnvironment(); //! Request to switch In/Out of game mode on next update. //! The switch will happen when no sub systems are currently being updated. //! @param inGame When true editor switch to game mode. @@ -111,14 +106,10 @@ public: bool IsLevelLoaded() const { return m_bLevelLoaded; }; //! Assign new level path name. void SetLevelPath(const QString& path); - //! Assign new current mission name. - void SetMissionName(const QString& mission); //! Return name of currently loaded level. const QString& GetLevelName() const { return m_levelName; }; //! Return extension of currently loaded level. const QString& GetLevelExtension() const { return m_levelExtension; }; - //! Return name of currently active mission. - const QString& GetMissionName() const { return m_missionName; }; //! Get fully specified level path. const QString& GetLevelPath() const { return m_levelPath; }; //! Query if engine is in game mode. @@ -142,9 +133,6 @@ public: //! Called every frame. void Update(); virtual void OnEditorNotifyEvent(EEditorNotifyEvent event); - void LockResources(); - void UnlockResources(); - void ResetResources(); void OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain); void OnAreaModified(const AABB& modifiedArea); @@ -179,7 +167,6 @@ private: CLogFile m_logFile; QString m_levelName; QString m_levelExtension; - QString m_missionName; QString m_levelPath; QString m_MOD; bool m_bLevelLoaded; diff --git a/Code/Sandbox/Editor/GameExporter.cpp b/Code/Sandbox/Editor/GameExporter.cpp index 64e1fc6514..31f3fafe84 100644 --- a/Code/Sandbox/Editor/GameExporter.cpp +++ b/Code/Sandbox/Editor/GameExporter.cpp @@ -24,7 +24,6 @@ #include "GameExporter.h" #include "GameEngine.h" #include "CryEditDoc.h" -#include "Mission.h" #include "ShaderCache.h" #include "UsedResources.h" #include "WaitProgress.h" @@ -131,13 +130,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE m_levelPath = Path::RemoveBackslash(sLevelPath); QString rootLevelPath = Path::AddSlash(pGameEngine->GetLevelPath()); - // Make sure we unload any unused CGFs before exporting so that they don't end up in - // the level data. - if (pEditor->Get3DEngine()) - { - pEditor->Get3DEngine()->FreeUnusedCGFResources(); - } - CCryEditDoc* pDocument = pEditor->GetDocument(); if (flags & eExp_Fast) @@ -191,8 +183,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE //////////////////////////////////////////////////////////////////////// if (exportSuccessful) { - ExportVisAreas(sLevelPath.toUtf8().data(), eExportEndian); - //////////////////////////////////////////////////////////////////////// // Exporting map setttings //////////////////////////////////////////////////////////////////////// @@ -254,47 +244,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE return exportSuccessful; } - -////////////////////////////////////////////////////////////////////////// -void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndian) -{ - char szFileOutputPath[_MAX_PATH]; - - // export visareas - IEditor* pEditor = GetIEditor(); - - // remove old files - sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME); - m_levelPak.m_pakFile.RemoveFile(szFileOutputPath); - - SHotUpdateInfo exportInfo; - I3DEngine* p3DEngine = pEditor->Get3DEngine(); - - if (p3DEngine && (eExportEndian == GetPlatformEndian())) // skip second export, this data is common for PC and consoles - { - std::vector* pTempBrushTable = NULL; - std::vector<_smart_ptr>* pTempMatsTable = NULL; - std::vector* pTempVegGroupTable = NULL; - - // export visareas - CLogFile::WriteLine("Exporting indoors..."); - pEditor->SetStatusText("Exporting indoors..."); - if (IVisAreaManager* pVisAreaManager = p3DEngine->GetIVisAreaManager()) - { - if (int nSize = pVisAreaManager->GetCompiledDataSize()) - { // get visareas data from 3dengine and save it into file - uint8* pData = new uint8[nSize]; - pVisAreaManager->GetCompiledData(pData, nSize, &pTempBrushTable, &pTempMatsTable, &pTempVegGroupTable, eExportEndian); - sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME); - CCryMemFile visareasCompiledFile; - visareasCompiledFile.Write(pData, nSize); - m_levelPak.m_pakFile.UpdateFile(szFileOutputPath, visareasCompiledFile); - delete[] pData; - } - } - } -} - ////////////////////////////////////////////////////////////////////////// void CGameExporter::ExportOcclusionMesh(const char* pszGamePath) { @@ -319,7 +268,7 @@ void CGameExporter::ExportOcclusionMesh(const char* pszGamePath) } ////////////////////////////////////////////////////////////////////////// -void CGameExporter::ExportLevelData(const QString& path, bool bExportMission) +void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/) { IEditor* pEditor = GetIEditor(); pEditor->SetStatusText(QObject::tr("Exporting LevelData.xml...")); @@ -332,49 +281,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission) XmlNodeRef rootAction = XmlHelpers::CreateXmlNode("LevelDataAction"); rootAction->setAttr("SandboxVersion", versionString); - ExportMapInfo(root); - - CCryEditDoc* pDocument = pEditor->GetDocument(); - CMission* pCurrentMission = 0; - - if (bExportMission) - { - pCurrentMission = pDocument->GetCurrentMission(); - // Save contents of current mission. - } - - ////////////////////////////////////////////////////////////////////////// - // Export missions tag. - ////////////////////////////////////////////////////////////////////////// - XmlNodeRef missionsNode = rootAction->newChild("Missions"); - QString missionFileName; - QString currentMissionFileName; - I3DEngine* p3DEngine = pEditor->Get3DEngine(); - if (p3DEngine) - { - for (int i = 0; i < pDocument->GetMissionCount(); i++) - { - CMission* pMission = pDocument->GetMission(i); - - QString name = pMission->GetName(); - name.replace(' ', '_'); - missionFileName = QStringLiteral("Mission_%1.xml").arg(name); - - XmlNodeRef missionDescNode = missionsNode->newChild("Mission"); - missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data()); - missionDescNode->setAttr("File", missionFileName.toUtf8().data()); - missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount()); - - int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount(); - missionDescNode->setAttr("ProgressBarRange", nProgressBarRange); - - if (pMission == pCurrentMission) - { - currentMissionFileName = missionFileName; - } - } - } - ////////////////////////////////////////////////////////////////////////// // Save Level Data XML ////////////////////////////////////////////////////////////////////////// @@ -389,41 +295,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission) CCryMemFile fileAction; fileAction.Write(xmlDataAction.c_str(), xmlDataAction.length()); m_levelPak.m_pakFile.UpdateFile(levelDataActionFile.toUtf8().data(), fileAction); - - if (bExportMission) - { - XmlNodeRef objectsNode = NULL; - ////////////////////////////////////////////////////////////////////////// - // Export current mission file. - ////////////////////////////////////////////////////////////////////////// - XmlNodeRef missionNode = rootAction->createNode("Mission"); - pCurrentMission->Export(missionNode, objectsNode); - - if (p3DEngine) - { - missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount()); - } - - //if (!CFileUtil::OverwriteFile( path+currentMissionFileName )) - // return; - - AZStd::vector entitySaveBuffer; - AZ::IO::ByteContainerStream > entitySaveStream(&entitySaveBuffer); - bool savedEntities = false; - EBUS_EVENT_RESULT(savedEntities, AzToolsFramework::EditorEntityContextRequestBus, SaveToStreamForGame, entitySaveStream, AZ::DataStream::ST_BINARY); - if (savedEntities) - { - QString entitiesFile; - entitiesFile = QStringLiteral("%1%2.entities_xml").arg(path, pCurrentMission ? pCurrentMission->GetName() : ""); - m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size()); - } - - _smart_ptr pXmlStrData = missionNode->getXMLData(5000000); - - CCryMemFile fileMission; - fileMission.Write(pXmlStrData->GetString(), pXmlStrData->GetStringLength()); - m_levelPak.m_pakFile.UpdateFile((path + currentMissionFileName).toUtf8().data(), fileMission); - } } ////////////////////////////////////////////////////////////////////////// @@ -446,18 +317,6 @@ void CGameExporter::ExportLevelInfo(const QString& path) const int compiledHeightmapSize = static_cast(terrainAabb.GetXExtent() / terrainGridResolution.GetX()); root->setAttr("HeightmapSize", compiledHeightmapSize); - // Save all missions in this level. - XmlNodeRef missionsNode = root->newChild("Missions"); - int numMissions = pEditor->GetDocument()->GetMissionCount(); - for (int i = 0; i < numMissions; i++) - { - CMission* pMission = pEditor->GetDocument()->GetMission(i); - XmlNodeRef missionNode = missionsNode->newChild("Mission"); - missionNode->setAttr("Name", pMission->GetName().toUtf8().data()); - missionNode->setAttr("Description", pMission->GetDescription().toUtf8().data()); - } - - ////////////////////////////////////////////////////////////////////////// // Save LevelInfo file. ////////////////////////////////////////////////////////////////////////// @@ -469,38 +328,6 @@ void CGameExporter::ExportLevelInfo(const QString& path) m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file); } -////////////////////////////////////////////////////////////////////////// -void CGameExporter::ExportMapInfo(XmlNodeRef& node) -{ - if (!GetIEditor()->Get3DEngine()) - { - return; - } - - XmlNodeRef info = node->newChild("LevelInfo"); - - IEditor* pEditor = GetIEditor(); - info->setAttr("Name", QFileInfo(pEditor->GetDocument()->GetTitle()).completeBaseName()); - - auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler(); - const AZ::Aabb terrainAabb = terrain ? terrain->GetTerrainAabb() : AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero()); - const AZ::Vector2 terrainGridResolution = terrain ? terrain->GetTerrainGridResolution() : AZ::Vector2::CreateOne(); - - const int terrainSizeInMeters = static_cast(terrainAabb.GetXExtent()); - const int terrainUnitSizeInMeters = static_cast(terrainGridResolution.GetX()); - info->setAttr("HeightmapSize", terrainSizeInMeters / terrainUnitSizeInMeters); - info->setAttr("HeightmapUnitSize", terrainUnitSizeInMeters); - //! Default Max Height value. - constexpr int HEIGHTMAP_MAX_HEIGHT = 150; //This is the default max height in CHeightmap - info->setAttr("HeightmapMaxHeight", HEIGHTMAP_MAX_HEIGHT); - info->setAttr("WaterLevel", pEditor->Get3DEngine()->GetWaterLevel()); - - // Serialize surface types. - CXmlArchive xmlAr; - xmlAr.bLoading = false; - xmlAr.root = node; -} - ////////////////////////////////////////////////////////////////////////// void CGameExporter::ExportLevelResourceList(const QString& path) { diff --git a/Code/Sandbox/Editor/GameExporter.h b/Code/Sandbox/Editor/GameExporter.h index a428046f0a..18ec79189a 100644 --- a/Code/Sandbox/Editor/GameExporter.h +++ b/Code/Sandbox/Editor/GameExporter.h @@ -91,9 +91,7 @@ private: void ExportLevelData(const QString& path, bool bExportMission = true); void ExportLevelInfo(const QString& path); - void ExportVisAreas(const char* pszGamePath, EEndian eExportEndian); void ExportOcclusionMesh(const char* pszGamePath); - void ExportMapInfo(XmlNodeRef& node); void ExportLevelResourceList(const QString& path); void ExportLevelUsedResourceList(const QString& path); diff --git a/Code/Sandbox/Editor/Geometry/EdGeometry.cpp b/Code/Sandbox/Editor/Geometry/EdGeometry.cpp deleted file mode 100644 index 13e8dd96ba..0000000000 --- a/Code/Sandbox/Editor/Geometry/EdGeometry.cpp +++ /dev/null @@ -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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "EdGeometry.h" diff --git a/Code/Sandbox/Editor/Geometry/EdGeometry.h b/Code/Sandbox/Editor/Geometry/EdGeometry.h deleted file mode 100644 index 3def344a35..0000000000 --- a/Code/Sandbox/Editor/Geometry/EdGeometry.h +++ /dev/null @@ -1,84 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H -#define CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H -#pragma once - -struct IIndexedMesh; -struct DisplayContext; -struct HitContext; -struct SSubObjSelectionModifyContext; -class CObjectArchive; - -// Basic supported geometry types. -enum EEdGeometryType -{ - GEOM_TYPE_MESH = 0, // Mesh geometry. - GEOM_TYPE_BRUSH, // Solid brush geometry. - GEOM_TYPE_PATCH, // Bezier patch surface geometry. - GEOM_TYPE_NURB, // Nurbs surface geometry. -}; - -////////////////////////////////////////////////////////////////////////// -// Description: -// CEdGeometry is a base class for all supported editable geometries. -////////////////////////////////////////////////////////////////////////// -class CRYEDIT_API CEdGeometry - : public CRefCountBase -{ -public: - CEdGeometry() {}; - - // Query the type of the geometry mesh. - virtual EEdGeometryType GetType() const = 0; - - // Serialize geometry. - virtual void Serialize(CObjectArchive& ar) = 0; - - // Return geometry axis aligned bounding box. - virtual void GetBounds(AABB& box) = 0; - - // Clones Geometry, returns exact copy of the original geometry. - virtual CEdGeometry* Clone() = 0; - - // Access to the indexed mesh. - // Return false if geometry can not be represented by an indexed mesh. - virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0) = 0; - virtual IStatObj* GetIStatObj() const = 0; - virtual void GetTM(Matrix34* pTM, size_t idx = 0) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Advanced geometry interface for SubObject selection and modification. - ////////////////////////////////////////////////////////////////////////// - virtual void SetModified(bool bModified = true) = 0; - virtual bool IsModified() const = 0; - virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags) = 0; - virtual void EndSubObjSelection() = 0; - - // Display geometry for sub object selection. - virtual void Display(DisplayContext& dc) = 0; - - // Sub geometry hit testing and selection. - virtual bool HitTest(HitContext& hit) = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true) = 0; - // Called when selection modification is accepted. - virtual void AcceptModifySelection() = 0; - -protected: - ~CEdGeometry() {}; -}; - -#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H diff --git a/Code/Sandbox/Editor/Geometry/EdMesh.cpp b/Code/Sandbox/Editor/Geometry/EdMesh.cpp deleted file mode 100644 index 466c07ece7..0000000000 --- a/Code/Sandbox/Editor/Geometry/EdMesh.cpp +++ /dev/null @@ -1,1548 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Implementation of CEdMesh class. - - -#include "EditorDefs.h" - -// CryCommon -#include - -// Editor -#include "EdMesh.h" -#include "Viewport.h" -#include "ViewManager.h" -#include "Util/PakFile.h" -#include "Include/HitContext.h" -#include "Include/ITransformManipulator.h" -#include "Objects/ObjectLoader.h" -#include "Undo/IUndoObject.h" -#include "Util/fastlib.h" - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//! Undo object for Editable Mesh. -class CUndoEdMesh - : public IUndoObject -{ -public: - CUndoEdMesh(CEdMesh* pEdMesh, int nCopyFlags, const char* undoDescription) - { - // Stores the current state of this object. - assert(pEdMesh != 0); - m_nCopyFlags = nCopyFlags; - m_undoDescription = undoDescription; - m_pEdMesh = pEdMesh; - pEdMesh->CopyToMesh(undoMesh, nCopyFlags); - } -protected: - virtual int GetSize() - { - // sizeof(undoMesh) + sizeof(redoMesh); - return sizeof(*this); - } - virtual QString GetDescription() { return m_undoDescription; }; - - virtual void Undo(bool bUndo) - { - if (bUndo) - { - m_pEdMesh->CopyToMesh(redoMesh, m_nCopyFlags); - } - // Undo object state. - m_pEdMesh->CopyFromMesh(undoMesh, m_nCopyFlags, bUndo); - } - virtual void Redo() - { - m_pEdMesh->CopyFromMesh(redoMesh, m_nCopyFlags, true); - } - -private: - QString m_undoDescription; - int m_nCopyFlags; - _smart_ptr m_pEdMesh; - CTriMesh undoMesh; - CTriMesh redoMesh; -}; - -////////////////////////////////////////////////////////////////////////// -// Static member of CEdMesh. -////////////////////////////////////////////////////////////////////////// -CEdMesh::MeshMap CEdMesh::m_meshMap; - -////////////////////////////////////////////////////////////////////////// -CEdMesh::CEdMesh() -{ - m_pStatObj = 0; - m_pSubObjCache = 0; - m_nUserCount = 0; - m_bModified = false; -} - - -////////////////////////////////////////////////////////////////////////// -CEdMesh::CEdMesh(IStatObj* pGeom) -{ - assert(pGeom); - if (pGeom) - { - m_pStatObj = pGeom; - m_pStatObj->AddRef(); - } - m_pSubObjCache = 0; - m_nUserCount = 0; - m_bModified = false; -} - -////////////////////////////////////////////////////////////////////////// -CEdMesh::~CEdMesh() -{ - for (auto ppIndexedMeshes = m_tempIndexedMeshes.begin(); ppIndexedMeshes != m_tempIndexedMeshes.end(); ++ppIndexedMeshes) - { - SAFE_RELEASE(*ppIndexedMeshes); - } - - SAFE_RELEASE(m_pStatObj); - // Remove this object from map. - m_meshMap.erase(m_filename); - if (m_pSubObjCache) - { - if (m_pSubObjCache->pTriMesh) - { - delete m_pSubObjCache->pTriMesh; - } - delete m_pSubObjCache; - } -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::Serialize(CObjectArchive& ar) -{ - if (ar.bUndo) - { - return; - } - if (ar.bLoading) - { - } - else - { - if (m_bModified) - { - CBaseObject* pObj = ar.GetCurrentObject(); - if (pObj) - { - QString levelPath = Path::AddPathSlash(GetIEditor()->GetLevelFolder()); - CPakFile* pPakFile = ar.GetGeometryPak((levelPath + "\\Geometry.pak").toUtf8().data()); - if (pPakFile) - { - SaveToCGF(m_filename.toUtf8().data(), pPakFile); - } - } - SetModified(false); - } - } -} - -////////////////////////////////////////////////////////////////////////// -// CEdMesh implementation. -////////////////////////////////////////////////////////////////////////// -CEdMesh* CEdMesh::LoadMesh(const char* filename) -{ - if (strlen(filename) == 0) - { - return 0; - } - - // If object created see if its not yet registered. - CEdMesh* pMesh = stl::find_in_map(m_meshMap, filename, (CEdMesh*)0); - if (pMesh) - { - // Found, return it. - return pMesh; - } - - // Make new. - IStatObj* pGeom = GetIEditor()->Get3DEngine()->LoadStatObjUnsafeManualRef(filename); - if (!pGeom) - { - return 0; - } - - // Not found, Make new. - pMesh = new CEdMesh(pGeom); - pMesh->m_filename = filename; - m_meshMap[filename] = pMesh; - return pMesh; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::AddUser() -{ - m_nUserCount++; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::RemoveUser() -{ - m_nUserCount--; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::ReloadAllGeometries() -{ - for (MeshMap::iterator it = m_meshMap.begin(); it != m_meshMap.end(); ++it) - { - CEdMesh* pMesh = it->second; - if (pMesh) - { - pMesh->ReloadGeometry(); - } - } -} - -void CEdMesh::ReleaseAll() -{ - m_meshMap.clear(); -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::ReloadGeometry() -{ - // Reload mesh. - if (m_pStatObj) - { - m_pStatObj->Refresh(FRO_GEOMETRY); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::IsSameObject(const char* filename) -{ - return QString::compare(m_filename, filename, Qt::CaseInsensitive) == 0; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::GetBounds(AABB& box) -{ - assert(m_pStatObj); - - if (m_pStatObj) - { - box.min = m_pStatObj->GetBoxMin(); - box.max = m_pStatObj->GetBoxMax(); - } -} - -////////////////////////////////////////////////////////////////////////// -CEdGeometry* CEdMesh::Clone() -{ - if (m_pStatObj) - { - // Clone StatObj. - IStatObj* pStatObj = m_pStatObj->Clone(true, true, false); - pStatObj->AddRef(); - CEdMesh* pNewMesh = new CEdMesh(pStatObj); - return pNewMesh; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::SetFilename(const QString& filename) -{ - if (!m_filename.isEmpty()) - { - m_meshMap.erase(m_filename); - } - m_filename = Path::MakeGamePath(filename); - m_meshMap[m_filename] = this; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::Render(SRendParams& rp, const SRenderingPassInfo& passInfo) -{ - if (m_pStatObj) - { - m_pStatObj->Render(rp, passInfo); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::IsDefaultObject() -{ - if (m_pStatObj) - { - return m_pStatObj->IsDefaultObject(); - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -IIndexedMesh* CEdMesh::GetIndexedMesh(size_t idx) -{ - if (m_tempIndexedMeshes.size() == 0 && m_pStatObj) - { - if (m_pStatObj->GetIndexedMesh()) - { - if (idx == 0) - { - return m_pStatObj->GetIndexedMesh(); - } - - return nullptr; - } - else - { - // Load from CGF. - QString sFilename = m_pStatObj->GetFilePath(); - CContentCGF cgf(sFilename.toUtf8().data()); - if (gEnv->p3DEngine->LoadChunkFileContent(&cgf, sFilename.toUtf8().data())) - { - for (int i = 0; i < cgf.GetNodeCount(); ++i) - { - CNodeCGF* pNode = cgf.GetNode(i); - if (pNode->type == CNodeCGF::NODE_MESH) - { - CMesh* pMesh = pNode->pMesh; - if (pMesh) - { - IIndexedMesh* pTempIndexedMesh = GetIEditor()->Get3DEngine()->CreateIndexedMesh(); - pTempIndexedMesh->SetMesh(*pMesh); - m_tempIndexedMeshes.push_back(pTempIndexedMesh); - - Matrix34 tm = pNode->localTM; - CNodeCGF* pParent = pNode->pParent; - while (pParent) - { - tm = pParent->localTM * tm; - pParent = pParent->pParent; - } - m_tempMatrices.push_back(tm); - } - } - } - } - } - } - - if (idx < m_tempIndexedMeshes.size()) - { - return m_tempIndexedMeshes[idx]; - } - - return nullptr; -} - -void CEdMesh::GetTM(Matrix34* pTM, size_t idx) -{ - if (idx < m_tempMatrices.size()) - { - *pTM = m_tempMatrices[idx]; - } - else - { - pTM->SetIdentity(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::AcceptModifySelection() -{ - // Implement - UpdateIndexedMeshFromCache(true); -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::UpdateIndexedMeshFromCache(bool bFast) -{ - // Implement - if (m_pSubObjCache) - { - if (bFast) - { - if (g_SubObjSelOptions.displayType == SO_DISPLAY_GEOMETRY) - { - m_pSubObjCache->pTriMesh->UpdateIndexedMesh(GetIndexedMesh()); - if (m_pStatObj) - { - m_pStatObj->Invalidate(); - } - } - } - else - { - m_pSubObjCache->pTriMesh->UpdateIndexedMesh(GetIndexedMesh()); - if (m_pStatObj) - { - m_pStatObj->Invalidate(); - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, [[maybe_unused]] int nFlags) -{ - IIndexedMesh* pIndexedMesh = GetIndexedMesh(); - if (!pIndexedMesh) - { - return false; - } - CMesh& mesh = *pIndexedMesh->GetMesh(); - - if (!m_pSubObjCache) - { - m_pSubObjCache = new SubObjCache; - } - m_pSubObjCache->worldTM = nodeWorldTM; - m_pSubObjCache->invWorldTM = nodeWorldTM.GetInverted(); - - if (!m_pSubObjCache->pTriMesh) - { - m_pSubObjCache->pTriMesh = new CTriMesh; - m_pSubObjCache->pTriMesh->SetFromMesh(mesh); - } - UpdateSubObjCache(); - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - triMesh.selectionType = elemType; - - m_pSubObjCache->bNoDisplay = false; - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::SetModified(bool bModified) -{ - if (m_pSubObjCache && bModified) - { - // Update xformed vertices. - UpdateSubObjCache(); - } - m_bModified = bModified; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::UpdateSubObjCache() -{ - Matrix34& wtm = m_pSubObjCache->worldTM; - - SetWorldTM(wtm); -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::EndSubObjSelection() -{ - if (!m_pSubObjCache) - { - return; - } - - UpdateIndexedMeshFromCache(false); - - if (m_pSubObjCache->pTriMesh) - { - delete m_pSubObjCache->pTriMesh; - } - delete m_pSubObjCache; - m_pSubObjCache = 0; - - if (m_pStatObj) - { - if (m_bModified) - { - m_pStatObj->Invalidate(true); - } - // Clear hidden flag from geometry. - m_pStatObj->SetFlags(m_pStatObj->GetFlags() & (~STATIC_OBJECT_HIDDEN)); - } -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::Display(DisplayContext& dc) -{ - if (!m_pSubObjCache || m_pSubObjCache->bNoDisplay) - { - return; - } - - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - if (!triMesh.pWSVertices) - { - return; - } - - if (m_pStatObj) - { - int nStatObjFlags = m_pStatObj->GetFlags(); - if (g_SubObjSelOptions.displayType == SO_DISPLAY_GEOMETRY) - { - nStatObjFlags &= ~STATIC_OBJECT_HIDDEN; - } - else - { - nStatObjFlags |= STATIC_OBJECT_HIDDEN; - } - m_pStatObj->SetFlags(nStatObjFlags); - } - - const Matrix34& worldTM = m_pSubObjCache->worldTM; - Vec3 vWSCameraVector = m_pSubObjCache->worldTM.GetTranslation() - dc.view->GetViewTM().GetTranslation(); - Vec3 vOSCameraVector = m_pSubObjCache->invWorldTM.TransformVector(vWSCameraVector).GetNormalized(); // Object space camera vector. - - // Render geometry vertices. - uint32 nPrevState = dc.GetState(); - - ////////////////////////////////////////////////////////////////////////// - // Calculate front facing vertices. - ////////////////////////////////////////////////////////////////////////// - triMesh.frontFacingVerts.resize(triMesh.GetVertexCount()); - triMesh.frontFacingVerts.clear(); - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - if (vOSCameraVector.Dot(face.normal) < 0) - { - triMesh.frontFacingVerts[face.v[0]] = true; - triMesh.frontFacingVerts[face.v[1]] = true; - triMesh.frontFacingVerts[face.v[2]] = true; - } - } - - ////////////////////////////////////////////////////////////////////////// - // Display flat shaded object. - ////////////////////////////////////////////////////////////////////////// - if (g_SubObjSelOptions.displayType == SO_DISPLAY_FLAT) - { - ColorB faceColor(0, 250, 250, 255); - ColorB col = faceColor; - dc.SetDrawInFrontMode(false); - dc.SetFillMode(e_FillModeSolid); - dc.CullOn(); - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - if (triMesh.selectionType != SO_ELEM_FACE || !triMesh.faceSel[i]) - { - ColorB col2 = faceColor; - float dt = -face.normal.Dot(vOSCameraVector); - dt = max(0.4f, dt); - dt = min(1.0f, dt); - col2.r = ftoi(faceColor.r * dt); - col2.g = ftoi(faceColor.g * dt); - col2.b = ftoi(faceColor.b * dt); - col2.a = faceColor.a; - dc.pRenderAuxGeom->DrawTriangle( - triMesh.pWSVertices[face.v[0]], col2, - triMesh.pWSVertices[face.v[1]], col2, - triMesh.pWSVertices[face.v[2]], col2 - ); - } - } - } - - // Draw selected triangles. - ColorB edgeColor(255, 255, 255, 155); - if (triMesh.StreamHaveSelection(CTriMesh::FACES)) - { - if (g_SubObjSelOptions.bDisplayBackfacing) - { - dc.CullOff(); - } - else - { - dc.CullOn(); - } - dc.SetDrawInFrontMode(true); - dc.SetFillMode(e_FillModeWireframe); - // Draw triangles. - //dc.pRenderAuxGeom->DrawTriangles( triMesh.pVertices,triMesh.GetVertexCount(), mesh.m_pIndices,mesh.GetIndexCount(),edgeColor ); - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - if (!triMesh.faceSel[i]) - { - dc.pRenderAuxGeom->DrawTriangle( - triMesh.pWSVertices[face.v[0]], edgeColor, - triMesh.pWSVertices[face.v[1]], edgeColor, - triMesh.pWSVertices[face.v[2]], edgeColor - ); - } - } - } - - if (g_SubObjSelOptions.bDisplayNormals) - { - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - Vec3 p1 = triMesh.pWSVertices[face.v[0]]; - Vec3 p2 = triMesh.pWSVertices[face.v[1]]; - Vec3 p3 = triMesh.pWSVertices[face.v[2]]; - Vec3 midp = (p1 + p2 + p3) * (1.0f / 3.0f); - dc.pRenderAuxGeom->DrawLine(midp, edgeColor, midp + worldTM.TransformVector(face.normal) * g_SubObjSelOptions.fNormalsLength, edgeColor); - } - } - - if (triMesh.selectionType == SO_ELEM_VERTEX || triMesh.StreamHaveSelection(CTriMesh::VERTICES)) - { - ColorB pointColor(0, 255, 255, 255); - - float fClrAdd = (g_SubObjSelOptions.bSoftSelection) ? 0 : 1; - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - bool bSelected = triMesh.vertSel[i] || triMesh.pWeights[i] != 0; - if (bSelected) - { - int clr = (triMesh.pWeights[i] + fClrAdd) * 255; - dc.pRenderAuxGeom->DrawPoint(triMesh.pWSVertices[i], ColorB(clr, 255 - clr, 255 - clr, 255), 8); - } - else if (!g_SubObjSelOptions.bDisplayBackfacing || triMesh.frontFacingVerts[i]) - { - dc.pRenderAuxGeom->DrawPoint(triMesh.pWSVertices[i], pointColor, 5); - } - } - } - - // Draw edges. - if (triMesh.selectionType == SO_ELEM_EDGE || triMesh.StreamHaveSelection(CTriMesh::EDGES)) - { - ColorB edgeColor2(200, 255, 200, 255); - ColorB selEdgeColor(255, 0, 0, 255); - - // Draw selected edges. - for (int i = 0; i < triMesh.GetEdgeCount(); i++) - { - CTriEdge& edge = triMesh.pEdges[i]; - if (triMesh.edgeSel[i]) - { - const Vec3& p1 = triMesh.pWSVertices[edge.v[0]]; - const Vec3& p2 = triMesh.pWSVertices[edge.v[1]]; - dc.pRenderAuxGeom->DrawLine(p1, selEdgeColor, p2, selEdgeColor, 6); - } - else if (!g_SubObjSelOptions.bDisplayBackfacing || ( - triMesh.frontFacingVerts[edge.v[0]] && triMesh.frontFacingVerts[edge.v[1]])) - { - const Vec3& p1 = triMesh.pWSVertices[edge.v[0]]; - const Vec3& p2 = triMesh.pWSVertices[edge.v[1]]; - dc.pRenderAuxGeom->DrawLine(p1, edgeColor2, p2, edgeColor2); - } - } - } - - if (triMesh.selectionType == SO_ELEM_FACE) - { - ColorB pointColor(0, 255, 255, 255); - ColorB selFaceColor(255, 0, 0, 180); - - // Draw selected faces and face points. - dc.CullOff(); - dc.SetFillMode(e_FillModeSolid); - - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - const Vec3& p1 = triMesh.pWSVertices[face.v[0]]; - const Vec3& p2 = triMesh.pWSVertices[face.v[1]]; - const Vec3& p3 = triMesh.pWSVertices[face.v[2]]; - if (triMesh.faceSel[i]) - { - dc.pRenderAuxGeom->DrawTriangle(p1, selFaceColor, p2, selFaceColor, p3, selFaceColor); - } - - if (!g_SubObjSelOptions.bDisplayBackfacing && vOSCameraVector.Dot(face.normal) > 0) - { - continue; // Backfacing. - } - Vec3 midp = (p1 + p2 + p3) * (1.0f / 3.0f); - dc.pRenderAuxGeom->DrawPoint(midp, pointColor, 4); - } - } - else if (triMesh.StreamHaveSelection(CTriMesh::FACES)) - { - ColorB pointColor(0, 255, 255, 255); - ColorB selFaceColor(255, 0, 0, 180); - - // Draw selected faces and face points. - dc.CullOff(); - dc.SetFillMode(e_FillModeSolid); - - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - const Vec3& p1 = triMesh.pWSVertices[face.v[0]]; - const Vec3& p2 = triMesh.pWSVertices[face.v[1]]; - const Vec3& p3 = triMesh.pWSVertices[face.v[2]]; - if (triMesh.faceSel[i]) - { - dc.pRenderAuxGeom->DrawTriangle(p1, selFaceColor, p2, selFaceColor, p3, selFaceColor); - } - } - } - - dc.SetState(nPrevState); // Restore render state. -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::HitTestVertex(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result) -{ - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - - // This make sure that bit array size matches num vertices, front facing should be calculated in Display method. - triMesh.frontFacingVerts.resize(triMesh.GetVertexCount()); - - float minDist = FLT_MAX; - int closestElem = -1; - - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - if (env.bIgnoreBackfacing && !triMesh.frontFacingVerts[i]) - { - continue; - } - QPoint p = hit.view->WorldToView(triMesh.pWSVertices[i]); - if (p.x() >= hit.rect.left() && p.x() <= hit.rect.right() && - p.y() >= hit.rect.top() && p.y() <= hit.rect.bottom()) - { - if (env.bHitTestNearest) - { - float dist = env.vWSCameraPos.GetDistance(triMesh.pWSVertices[i]); - if (dist < minDist) - { - closestElem = i; - minDist = dist; - } - } - else - { - result.elems.push_back(i); - } - } - } - ////////////////////////////////////////////////////////////////////////// - if (closestElem >= 0) - { - result.minDistance = minDist; - result.elems.push_back(closestElem); - } - return !result.elems.empty(); -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::HitTestEdge(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result) -{ - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - // This make sure that bit array size matches num vertices, front facing should be calculated in Display method. - triMesh.frontFacingVerts.resize(triMesh.GetVertexCount()); - - float minDist = FLT_MAX; - int closestElem = -1; - - for (int i = 0; i < triMesh.GetEdgeCount(); i++) - { - CTriEdge& edge = triMesh.pEdges[i]; - if (!env.bIgnoreBackfacing || - (triMesh.frontFacingVerts[edge.v[0]] && triMesh.frontFacingVerts[edge.v[1]])) - { - if (hit.view->HitTestLine(triMesh.pWSVertices[edge.v[0]], triMesh.pWSVertices[edge.v[1]], hit.point2d, 5)) - { - if (env.bHitTestNearest) - { - float dist = env.vWSCameraPos.GetDistance(triMesh.pWSVertices[edge.v[0]]); - if (dist < minDist) - { - closestElem = i; - minDist = dist; - } - } - else - { - result.elems.push_back(i); - } - } - } - } - ////////////////////////////////////////////////////////////////////////// - if (closestElem >= 0) - { - result.minDistance = minDist; - result.elems.push_back(closestElem); - } - return !result.elems.empty(); -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::HitTestFace(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result) -{ - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - float minDist = FLT_MAX; - int closestElem = -1; - - Vec3 vOut(0, 0, 0); - Ray hitRay(hit.raySrc, hit.rayDir); - - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - CTriFace& face = triMesh.pFaces[i]; - - if (env.bIgnoreBackfacing && env.vOSCameraVector.Dot(face.normal) > 0) - { - continue; // Back facing. - } - Vec3 p1 = triMesh.pWSVertices[face.v[0]]; - Vec3 p2 = triMesh.pWSVertices[face.v[1]]; - Vec3 p3 = triMesh.pWSVertices[face.v[2]]; - - if (!env.bHitTestNearest) - { - // Hit test face middle point in rectangle. - Vec3 midp = (p1 + p2 + p3) * (1.0f / 3.0f); - - QPoint p = hit.view->WorldToView(midp); - if (p.x() >= hit.rect.left() && p.x() <= hit.rect.right() && - p.y() >= hit.rect.top() && p.y() <= hit.rect.bottom()) - { - result.elems.push_back(i); - } - } - else - { - // Hit test ray/triangle. - if (Intersect::Ray_Triangle(hitRay, p1, p3, p2, vOut)) - { - float dist = hitRay.origin.GetSquaredDistance(vOut); - if (dist < minDist) - { - closestElem = i; - minDist = dist; - } - } - } - } - ////////////////////////////////////////////////////////////////////////// - if (closestElem >= 0) - { - result.minDistance = (float)sqrt(minDist); - result.elems.push_back(closestElem); - } - return !result.elems.empty(); -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::SelectSubObjElements(SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result) -{ - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - - bool bSelChanged = false; - if (env.bSelectOnHit && !result.elems.empty()) - { - CBitArray* streamSel = triMesh.GetStreamSelection(result.stream); - if (streamSel) - { - // Select on hit. - for (int i = 0, num = result.elems.size(); i < num; i++) - { - int elem = result.elems[i]; - if ((*streamSel)[elem] != env.bSelectValue) - { - bSelChanged = true; - (*streamSel)[elem] = env.bSelectValue; - } - } - if (bSelChanged) - { - if (env.bSelectValue) - { - triMesh.streamSelMask |= (1 << result.stream); - } - else if (!env.bSelectValue && streamSel->is_zero()) - { - triMesh.streamSelMask &= ~(1 << result.stream); - } - } - } - } - return bSelChanged; -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::IsHitTestResultSelected(SSubObjHitTestResult& result) -{ - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - - if (!result.elems.empty()) - { - CBitArray* streamSel = triMesh.GetStreamSelection(result.stream); - if (streamSel) - { - // check if first result element is selected. - if ((*streamSel)[ result.elems[0] ]) - { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::HitTest(HitContext& hit) -{ - if (hit.nSubObjFlags & SO_HIT_NO_EDIT) - // This is for a 'move-by-face-normal'. Prepare the mesh and set the 'bNoDisplay'to true - // so that the normal rendering happens instead of the edit-mode rendering. - { - StartSubObjSelection(hit.object->GetWorldTM(), SO_ELEM_FACE, 0); - m_pSubObjCache->bNoDisplay = true; - } - - if (!m_pSubObjCache) - { - return false; - } - - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - - SSubObjHitTestEnvironment env; - env.vWSCameraPos = hit.view->GetViewTM().GetTranslation(); - env.vWSCameraVector = m_pSubObjCache->worldTM.GetTranslation() - hit.view->GetViewTM().GetTranslation(); - env.vOSCameraVector = m_pSubObjCache->invWorldTM.TransformVector(env.vWSCameraVector).GetNormalized(); // Object space camera vector. - - env.bHitTestNearest = hit.nSubObjFlags & SO_HIT_POINT; - env.bHitTestSelected = hit.nSubObjFlags & SO_HIT_TEST_SELECTED; - env.bSelectOnHit = hit.nSubObjFlags & SO_HIT_SELECT; - env.bAdd = hit.nSubObjFlags & SO_HIT_SELECT_ADD; - env.bRemove = hit.nSubObjFlags & SO_HIT_SELECT_REMOVE; - env.bSelectValue = !env.bRemove; - env.bHighlightOnly = hit.nSubObjFlags & SO_HIT_HIGHLIGHT_ONLY; - env.bIgnoreBackfacing = g_SubObjSelOptions.bIgnoreBackfacing && !env.bHitTestNearest; - - int nHitTestWhat = (hit.nSubObjFlags & SO_HIT_ELEM_ALL); - if (nHitTestWhat == 0) - { - if (g_SubObjSelOptions.bSelectByVertex) - { - nHitTestWhat |= SO_HIT_ELEM_VERTEX; - } - switch (triMesh.selectionType) - { - case SO_ELEM_VERTEX: - nHitTestWhat |= SO_HIT_ELEM_VERTEX; - break; - case SO_ELEM_EDGE: - nHitTestWhat |= SO_HIT_ELEM_EDGE; - break; - case SO_ELEM_FACE: - nHitTestWhat |= SO_HIT_ELEM_FACE; - break; - case SO_ELEM_POLYGON: - nHitTestWhat |= SO_HIT_ELEM_POLYGON; - break; - } - } - - IUndoObject* pUndoObj = NULL; - if (env.bSelectOnHit) - { - if (CUndo::IsRecording() && !(hit.nSubObjFlags & SO_HIT_NO_EDIT)) - { - switch (triMesh.selectionType) - { - case SO_ELEM_VERTEX: - pUndoObj = new CUndoEdMesh(this, CTriMesh::COPY_VERT_SEL | CTriMesh::COPY_WEIGHTS, "Select Vertex(s)"); - break; - case SO_ELEM_EDGE: - pUndoObj = new CUndoEdMesh(this, CTriMesh::COPY_EDGE_SEL | CTriMesh::COPY_WEIGHTS, "Select Edge(s)"); - break; - case SO_ELEM_FACE: - pUndoObj = new CUndoEdMesh(this, CTriMesh::COPY_FACE_SEL | CTriMesh::COPY_WEIGHTS, "Select Face(s)"); - break; - } - } - } - - bool bSelChanged = false; - bool bAnyHit = false; - ////////////////////////////////////////////////////////////////////////// - if (env.bSelectOnHit && !env.bAdd && !env.bRemove) - { - bSelChanged = triMesh.ClearSelection(); - } - ////////////////////////////////////////////////////////////////////////// - - SSubObjHitTestResult result[4]; - result[0].stream = CTriMesh::VERTICES; - result[1].stream = CTriMesh::EDGES; - result[2].stream = CTriMesh::FACES; - - if (nHitTestWhat & SO_HIT_ELEM_VERTEX) - { - if (HitTestVertex(hit, env, result[0])) - { - bAnyHit = true; - } - } - - if (nHitTestWhat & SO_HIT_ELEM_EDGE) - { - if (HitTestEdge(hit, env, result[1])) - { - bAnyHit = true; - } - } - - if (nHitTestWhat & SO_HIT_ELEM_FACE) - { - if (HitTestFace(hit, env, result[2])) - { - bAnyHit = true; - } - } - - if (bAnyHit && !env.bSelectOnHit && !env.bHitTestSelected) - { - // Return distance to the first hit element. - hit.dist = min(min(result[0].minDistance, result[1].minDistance), result[2].minDistance); - return true; - } - if (bAnyHit && !env.bSelectOnHit && env.bHitTestSelected) - { - // check if we hit selected item. - if (IsHitTestResultSelected(result[0]) || - IsHitTestResultSelected(result[1]) || - IsHitTestResultSelected(result[2])) - { - hit.dist = min(min(result[0].minDistance, result[1].minDistance), result[2].minDistance); - return true; - } - // If not hit selected. - return false; - } - if (bAnyHit) - { - // Find closest hit. - int n = 0; - if (!result[0].elems.empty()) - { - n = 0; - } - else if (!result[1].elems.empty()) - { - n = 1; - } - else if (!result[2].elems.empty()) - { - n = 2; - } - - hit.dist = result[n].minDistance; - - if (env.bSelectOnHit && - g_SubObjSelOptions.bSelectByVertex && - !result[0].elems.empty() && - !env.bHighlightOnly && - triMesh.selectionType != SO_HIT_ELEM_VERTEX) - { - // When selecting elements by vertex. - switch (triMesh.selectionType) - { - case SO_ELEM_EDGE: - n = 1; - triMesh.GetEdgesByVertex(result[0].elems, result[1].elems); - break; - case SO_ELEM_FACE: - n = 2; - triMesh.GetFacesByVertex(result[0].elems, result[2].elems); - break; - case SO_ELEM_POLYGON: - n = 2; - triMesh.GetFacesByVertex(result[0].elems, result[2].elems); - break; - } - } - if (env.bSelectOnHit && SelectSubObjElements(env, result[n])) - { - bSelChanged = true; - } - } - if (bSelChanged) - { - hit.nSubObjFlags |= SO_HIT_SELECTION_CHANGED; - } - else - { - hit.nSubObjFlags &= ~SO_HIT_SELECTION_CHANGED; - } - - bool bSelectionNotEmpty = false; - if (env.bSelectOnHit && bSelChanged && !env.bHighlightOnly) - { - if (CUndo::IsRecording() && pUndoObj) - { - CUndo::Record(pUndoObj); - } - - bSelectionNotEmpty = triMesh.UpdateSelection(); - if (g_SubObjSelOptions.bSoftSelection) - { - triMesh.SoftSelection(g_SubObjSelOptions); - } - - OnSelectionChange(); - } - else - { - if (pUndoObj) - { - pUndoObj->Release(); - } - } - - return bSelectionNotEmpty; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::OnSelectionChange() -{ - Matrix34 localRefFrame; - if (!GetSelectionReferenceFrame(localRefFrame)) - { - GetIEditor()->ShowTransformManipulator(false); - } - else - { - ITransformManipulator* pManipulator = GetIEditor()->ShowTransformManipulator(true); - - // In local space orient axis gizmo by first object. - localRefFrame = m_pSubObjCache->worldTM * localRefFrame; - - Matrix34 parentTM = m_pSubObjCache->worldTM; - Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix(); - parentTM.SetTranslation(localRefFrame.GetTranslation()); - userTM.SetTranslation(localRefFrame.GetTranslation()); - //tm.SetTranslation( m_selectionCenter ); - pManipulator->SetTransformation(COORDS_LOCAL, localRefFrame); - pManipulator->SetTransformation(COORDS_PARENT, parentTM); - pManipulator->SetTransformation(COORDS_USERDEFINED, userTM); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CEdMesh::GetSelectionReferenceFrame(Matrix34& refFrame) -{ - if (!m_pSubObjCache) - { - return false; - } - - bool bAnySelected = false; - - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - - Vec3 normal(0, 0, 0); - - refFrame.SetIdentity(); - - if (triMesh.selectionType == SO_ELEM_VERTEX) - { - // Average all selected vertex normals. - int numNormals = 0; - int nFaces = triMesh.GetFacesCount(); - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - if (triMesh.vertSel[i]) - { - bAnySelected = true; - int nVertexIndex = i; - for (int j = 0; j < nFaces; j++) - { - CTriFace& face = triMesh.pFaces[j]; - for (int k = 0; k < 3; k++) - { - if (face.v[k] == nVertexIndex) - { - normal += face.n[k]; - numNormals++; - } - } - } - } - } - if (numNormals > 0) - { - normal = normal / numNormals; - if (!normal.IsZero()) - { - normal.Normalize(); - } - } - } - else if (triMesh.selectionType == SO_ELEM_EDGE) - { - int nNormals = 0; - // Average face normals of a the selected edges. - for (int i = 0; i < triMesh.GetEdgeCount(); i++) - { - if (triMesh.edgeSel[i]) - { - bAnySelected = true; - CTriEdge& edge = triMesh.pEdges[i]; - for (int j = 0; j < 2; j++) - { - if (edge.face[j] >= 0) - { - normal = normal + triMesh.pFaces[edge.face[j]].normal; - nNormals++; - } - } - } - } - if (nNormals > 0) - { - normal = normal / nNormals; - if (!normal.IsZero()) - { - normal.Normalize(); - } - } - } - else if (triMesh.selectionType == SO_ELEM_FACE) - { - // Average all face normals. - int nNormals = 0; - for (int i = 0; i < triMesh.GetFacesCount(); i++) - { - if (triMesh.faceSel[i]) - { - bAnySelected = true; - CTriFace& face = triMesh.pFaces[i]; - normal = normal + face.normal; - nNormals++; - } - } - if (nNormals > 0) - { - normal = normal / nNormals; - if (!normal.IsZero()) - { - normal.Normalize(); - } - } - } - - if (bAnySelected) - { - Vec3 pos(0, 0, 0); - int numSel = 0; - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - if (triMesh.pWeights[i] == 1.0f) - { - pos = pos + triMesh.pVertices[i].pos; - numSel++; - } - } - if (numSel > 0) - { - pos = pos / numSel; // Average position. - } - refFrame.SetTranslation(pos); - - if (!normal.IsZero()) - { - Vec3 xAxis(1, 0, 0), yAxis(0, 1, 0), zAxis(0, 0, 1); - if (normal.IsEquivalent(zAxis) || normal.IsEquivalent(-zAxis)) - { - zAxis = xAxis; - } - xAxis = normal.Cross(zAxis).GetNormalized(); - yAxis = xAxis.Cross(normal).GetNormalized(); - refFrame.SetFromVectors(xAxis, yAxis, normal, pos); - } - } - - return bAnySelected; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::ModifySelection(SSubObjSelectionModifyContext& modCtx, [[maybe_unused]] bool isUndo) -{ - if (!m_pSubObjCache) - { - return; - } - - IIndexedMesh* pIndexedMesh = GetIndexedMesh(); - if (!pIndexedMesh) - { - return; - } - - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - - if (modCtx.type == SO_MODIFY_UNSELECT) - { - IUndoObject* pUndoObj = NULL; - if (CUndo::IsRecording()) - { - pUndoObj = new CUndoEdMesh(this, CTriMesh::COPY_VERT_SEL | CTriMesh::COPY_WEIGHTS, "Move Vertices"); - } - bool bChanged = triMesh.ClearSelection(); - if (bChanged) - { - OnSelectionChange(); - } - if (CUndo::IsRecording() && bChanged) - { - CUndo::Record(pUndoObj); - } - else if (pUndoObj) - { - pUndoObj->Release(); - } - return; - } - - Matrix34 worldTM = m_pSubObjCache->worldTM; - Matrix34 invTM = worldTM.GetInverted(); - - // Change modify reference frame to object space. - Matrix34 modRefFrame = invTM * modCtx.worldRefFrame; - Matrix34 modRefFrameInverse = modCtx.worldRefFrame.GetInverted() * worldTM; - - if (modCtx.type == SO_MODIFY_MOVE) - { - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoEdMesh(this, CTriMesh::COPY_VERTICES, "Move Vertices")); - } - - Vec3 vOffset = modCtx.vValue; - vOffset = modCtx.worldRefFrame.GetInverted().TransformVector(vOffset); // Offset in local space. - - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - CTriVertex& vtx = triMesh.pVertices[i]; - if (triMesh.pWeights[i] != 0) - { - Matrix34 tm = modRefFrame * Matrix34::CreateTranslationMat(vOffset * triMesh.pWeights[i]) * modRefFrameInverse; - vtx.pos = tm.TransformPoint(vtx.pos); - } - } - OnSelectionChange(); - } - else if (modCtx.type == SO_MODIFY_ROTATE) - { - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoEdMesh(this, CTriMesh::COPY_VERTICES, "Rotate Vertices")); - } - - Ang3 angles = Ang3(modCtx.vValue); - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - CTriVertex& vtx = triMesh.pVertices[i]; - if (triMesh.pWeights[i] != 0) - { - Matrix34 tm = modRefFrame * Matrix33::CreateRotationXYZ(angles * triMesh.pWeights[i]) * modRefFrameInverse; - vtx.pos = tm.TransformPoint(vtx.pos); - } - } - } - else if (modCtx.type == SO_MODIFY_SCALE) - { - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoEdMesh(this, CTriMesh::COPY_VERTICES, "Scale Vertices")); - } - - Vec3 vScale = modCtx.vValue; - for (int i = 0; i < triMesh.GetVertexCount(); i++) - { - CTriVertex& vtx = triMesh.pVertices[i]; - if (triMesh.pWeights[i] != 0) - { - Vec3 scl = Vec3(1.0f, 1.0f, 1.0f) * (1.0f - triMesh.pWeights[i]) + vScale * triMesh.pWeights[i]; - Matrix34 tm = modRefFrame * Matrix33::CreateScale(scl) * modRefFrameInverse; - vtx.pos = tm.TransformPoint(vtx.pos); - } - } - } - - SetModified(); -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::CopyToMesh(CTriMesh& toMesh, int nCopyFlags) -{ - if (!m_pSubObjCache) - { - return; - } - - toMesh.Copy(*m_pSubObjCache->pTriMesh, nCopyFlags); -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::CopyFromMesh(CTriMesh& fromMesh, int nCopyFlags, bool bUndo) -{ - if (m_pSubObjCache) - { - m_pSubObjCache->pTriMesh->Copy(fromMesh, nCopyFlags); - } - else - { - /* - CMesh mesh; - CTriMesh triMesh; - triMesh.Copy( fromMesh ); - trimesh.void CopyToMeshFast( CMesh &mesh ); - */ - } - if (bUndo) - { - UpdateIndexedMeshFromCache(true); - OnSelectionChange(); - } - - if (m_pSubObjCache) - { - UpdateSubObjCache(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::SaveToCGF(const char* sFilename, CPakFile* pPakFile, _smart_ptr pMaterial) -{ - if (m_pStatObj) - { - // Save this EdMesh to CGF file. - m_filename = Path::MakeGamePath(sFilename); - - _smart_ptr pOriginalMaterial = m_pStatObj->GetMaterial(); - if (pMaterial) - { - m_pStatObj->SetMaterial(pMaterial); - } - - if (!pPakFile) - { - m_pStatObj->SaveToCGF(sFilename); - } - else - { - IChunkFile* pChunkFile = NULL; - if (m_pStatObj->SaveToCGF(sFilename, &pChunkFile)) - { - void* pMemFile = NULL; - int nFileSize = 0; - - pChunkFile->WriteToMemoryBuffer(&pMemFile, &nFileSize); - pPakFile->UpdateFile(sFilename, pMemFile, nFileSize, true, AZ::IO::INestedArchive::LEVEL_FASTER); - pChunkFile->Release(); - } - } - - // Restore original material. - if (pMaterial) - { - m_pStatObj->SetMaterial(pOriginalMaterial); - } - } -} - -////////////////////////////////////////////////////////////////////////// -CTriMesh* CEdMesh::GetMesh() -{ - if (m_pSubObjCache) - { - return m_pSubObjCache->pTriMesh; - } - return 0; -} - -////////////////////////////////////////////////////////////////////////// -CEdMesh* CEdMesh::CreateMesh(const char* name) -{ - IStatObj* pStatObj = gEnv->p3DEngine->CreateStatObj(); - if (pStatObj) - { - CEdMesh* pEdMesh = new CEdMesh; - pEdMesh->m_pStatObj = pStatObj; - pEdMesh->m_pStatObj->AddRef(); - - // Force create of indexed mesh. - pEdMesh->m_pStatObj->GetIndexedMesh(true); - - // Not found, Make new. - pEdMesh->m_filename = name; - - if (!pEdMesh->m_pSubObjCache) - { - pEdMesh->m_pSubObjCache = new SubObjCache; - pEdMesh->m_pSubObjCache->pTriMesh = new CTriMesh; - pEdMesh->m_pSubObjCache->worldTM.SetIdentity(); - pEdMesh->m_pSubObjCache->invWorldTM.SetIdentity(); - } - return pEdMesh; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::InvalidateMesh() -{ - if (m_pSubObjCache) - { - UpdateIndexedMeshFromCache(false); - } - if (m_pStatObj) - { - m_pStatObj->Invalidate(true); - } -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::SetWorldTM(const Matrix34& worldTM) -{ - if (!m_pSubObjCache) - { - return; - } - - m_pSubObjCache->worldTM = worldTM; - m_pSubObjCache->invWorldTM = worldTM.GetInverted(); - - ////////////////////////////////////////////////////////////////////////// - // Transform vertices and normals to world space and store in cached mesh. - ////////////////////////////////////////////////////////////////////////// - CTriMesh& triMesh = *m_pSubObjCache->pTriMesh; - int nVerts = triMesh.GetVertexCount(); - triMesh.ReallocStream(CTriMesh::WS_POSITIONS, nVerts); - for (int i = 0; i < nVerts; i++) - { - triMesh.pWSVertices[i] = worldTM.TransformPoint(triMesh.pVertices[i].pos); - } -} - -////////////////////////////////////////////////////////////////////////// -void CEdMesh::DebugDraw(const SGeometryDebugDrawInfo& info, float fExtrdueScale) -{ - if (m_pStatObj) - { - m_pStatObj->DebugDraw(info, fExtrdueScale); - } -} diff --git a/Code/Sandbox/Editor/Geometry/EdMesh.h b/Code/Sandbox/Editor/Geometry/EdMesh.h deleted file mode 100644 index 52dc1fc25d..0000000000 --- a/Code/Sandbox/Editor/Geometry/EdMesh.h +++ /dev/null @@ -1,194 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Editor structure that wraps access to IStatObj - - -#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H -#define CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H -#pragma once - -#include "EdGeometry.h" -#include "Objects/SubObjSelection.h" -#include "TriMesh.h" - -// Flags that can be set on CEdMesh. -enum CEdMeshFlags -{ -}; - -////////////////////////////////////////////////////////////////////////// -// Description: -// CEdMesh is a Geometry kind representing simple mesh. -// Holds IStatObj interface from the 3D Engine. -////////////////////////////////////////////////////////////////////////// -class CRYEDIT_API CEdMesh - : public CEdGeometry -{ -public: - ////////////////////////////////////////////////////////////////////////// - // CEdGeometry implementation. - ////////////////////////////////////////////////////////////////////////// - virtual EEdGeometryType GetType() const { return GEOM_TYPE_MESH; }; - virtual void Serialize(CObjectArchive& ar); - - virtual void GetBounds(AABB& box); - virtual CEdGeometry* Clone(); - virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0); - virtual void GetTM(Matrix34* pTM, size_t idx = 0); - virtual void SetModified(bool bModified = true); - virtual bool IsModified() const { return m_bModified; }; - virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags); - virtual void EndSubObjSelection(); - virtual void Display(DisplayContext& dc); - virtual bool HitTest(HitContext& hit); - bool GetSelectionReferenceFrame(Matrix34& refFrame); - virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true); - virtual void AcceptModifySelection(); - ////////////////////////////////////////////////////////////////////////// - - ~CEdMesh(); - - // Return filename of mesh. - const QString& GetFilename() const { return m_filename; }; - void SetFilename(const QString& filename); - - //! Reload geometry of mesh. - void ReloadGeometry(); - void AddUser(); - void RemoveUser(); - int GetUserCount() const { return m_nUserCount; }; - - ////////////////////////////////////////////////////////////////////////// - void SetFlags(int nFlags) { m_nFlags = nFlags; }; - int GetFlags() { return m_nFlags; } - ////////////////////////////////////////////////////////////////////////// - - //! Access stored IStatObj. - IStatObj* GetIStatObj() const { return m_pStatObj; } - - //! Returns true if filename and geomname refer to the same object as this one. - bool IsSameObject(const char* filename); - - //! RenderMesh. - void Render(SRendParams& rp, const SRenderingPassInfo& passInfo); - - //! Make new CEdMesh, if same IStatObj loaded, and CEdMesh for this IStatObj is allocated. - //! This instance of CEdMesh will be returned. - static CEdMesh* LoadMesh(const char* filename); - - // Creates a new mesh not from a file. - // Create a new StatObj and IndexedMesh. - static CEdMesh* CreateMesh(const char* name); - - //! Reload all geometries. - static void ReloadAllGeometries(); - static void ReleaseAll(); - - //! Check if default object was loaded. - bool IsDefaultObject(); - - ////////////////////////////////////////////////////////////////////////// - // Copy EdMesh data to the specified mesh. - void CopyToMesh(CTriMesh& toMesh, int nCopyFlags); - // Copy EdMesh data from the specified mesh. - void CopyFromMesh(CTriMesh& fromMesh, int nCopyFlags, bool bUndo); - - // Retrieve mesh class. - CTriMesh* GetMesh(); - - ////////////////////////////////////////////////////////////////////////// - void InvalidateMesh(); - void SetWorldTM(const Matrix34& worldTM); - - // Save mesh into the file. - // Optionally can provide pointer to the pak file where to save files into. - void SaveToCGF(const char* sFilename, CPakFile* pPakFile = NULL, _smart_ptr pMaterial = NULL); - - // Draw debug representation of this mesh. - void DebugDraw(const SGeometryDebugDrawInfo& info, float fExtrdueScale = 0.01f); - -private: - ////////////////////////////////////////////////////////////////////////// - CEdMesh(IStatObj* pGeom); - CEdMesh(); - void UpdateSubObjCache(); - void UpdateIndexedMeshFromCache(bool bFast); - void OnSelectionChange(); - - ////////////////////////////////////////////////////////////////////////// - struct SSubObjHitTestEnvironment - { - Vec3 vWSCameraPos; - Vec3 vWSCameraVector; - Vec3 vOSCameraVector; - - bool bHitTestNearest; - bool bHitTestSelected; - bool bSelectOnHit; - bool bAdd; - bool bRemove; - bool bSelectValue; - bool bHighlightOnly; - bool bIgnoreBackfacing; - }; - struct SSubObjHitTestResult - { - CTriMesh::EStream stream; // To What stream of the TriMesh this result apply. - MeshElementsArray elems; // List of hit elements. - float minDistance; // Minimal distance to the hit. - SSubObjHitTestResult() { minDistance = FLT_MAX; } - }; - bool HitTestVertex(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result); - bool HitTestEdge(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result); - bool HitTestFace(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result); - - // Return`s true if selection changed. - bool SelectSubObjElements(SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result); - bool IsHitTestResultSelected(SSubObjHitTestResult& result); - - ////////////////////////////////////////////////////////////////////////// - //! CGF filename. - QString m_filename; - IStatObj* m_pStatObj; - int m_nUserCount; - int m_nFlags; - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - typedef std::map > MeshMap; - static MeshMap m_meshMap; - - // This cache is created when sub object selection is needed. - struct SubObjCache - { - // Cache of data in geometry. - // World space mesh. - CTriMesh* pTriMesh; - Matrix34 worldTM; - Matrix34 invWorldTM; - CBitArray m_tempBitArray; - bool bNoDisplay; - - SubObjCache() - : pTriMesh(0) - , bNoDisplay(false) {}; - }; - SubObjCache* m_pSubObjCache; - bool m_bModified; - - std::vector m_tempIndexedMeshes; - std::vector m_tempMatrices; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - -#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H diff --git a/Code/Sandbox/Editor/Grid.cpp b/Code/Sandbox/Editor/Grid.cpp index aa9e980069..50702f8cb2 100644 --- a/Code/Sandbox/Editor/Grid.cpp +++ b/Code/Sandbox/Editor/Grid.cpp @@ -136,31 +136,10 @@ Matrix34 CGrid::GetMatrix() const Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0); tm = Matrix33::CreateRotationXYZ(angles); - - if (gSettings.snap.bGridGetFromSelected) - { - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (sel->GetCount() > 0) - { - CBaseObject* obj = sel->GetObject(0); - tm = obj->GetWorldTM(); - tm.OrthonormalizeFast(); - tm.SetTranslation(Vec3(0, 0, 0)); - } - } } else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL) { tm.SetIdentity(); - - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (sel->GetCount() > 0) - { - CBaseObject* obj = sel->GetObject(0); - tm = obj->GetWorldTM(); - tm.OrthonormalizeFast(); - tm.SetTranslation(Vec3(0, 0, 0)); - } } else { diff --git a/Code/Sandbox/Editor/GridSettingsDialog.cpp b/Code/Sandbox/Editor/GridSettingsDialog.cpp index b16dbe4197..ecabdc4e6a 100644 --- a/Code/Sandbox/Editor/GridSettingsDialog.cpp +++ b/Code/Sandbox/Editor/GridSettingsDialog.cpp @@ -39,8 +39,6 @@ CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/) connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined); connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject); - connect(ui->m_getAnglesFromObject, &QPushButton::clicked, this, &CGridSettingsDialog::OnBnGetAngles); - connect(ui->m_getTranslationFromObject, &QPushButton::clicked, this, &CGridSettingsDialog::OnBnGetTranslation); auto doubleSpinBoxValueChanged = static_cast(&QDoubleSpinBox::valueChanged); @@ -115,39 +113,6 @@ void CGridSettingsDialog::OnBnGetFromObject() EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked()); } -void CGridSettingsDialog::OnBnGetAngles() -{ - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (sel->GetCount() > 0) - { - CBaseObject* obj = sel->GetObject(0); - Matrix34 tm = obj->GetWorldTM(); - AffineParts ap; - ap.SpectralDecompose(tm); - - Vec3 rotation = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot)))); - - ui->m_angleX->setValue(rotation.x); - ui->m_angleY->setValue(rotation.y); - ui->m_angleZ->setValue(rotation.z); - } -} - -void CGridSettingsDialog::OnBnGetTranslation() -{ - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (sel->GetCount() > 0) - { - CBaseObject* obj = sel->GetObject(0); - Matrix34 tm = obj->GetWorldTM(); - Vec3 translation = tm.GetTranslation(); - - ui->m_translationX->setValue(translation.x); - ui->m_translationY->setValue(translation.y); - ui->m_translationZ->setValue(translation.z); - } -} - void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject) { ui->m_getFromObject->setEnabled(isUserDefined == true); diff --git a/Code/Sandbox/Editor/GridSettingsDialog.h b/Code/Sandbox/Editor/GridSettingsDialog.h index f82278ccb7..fe5934ec7e 100644 --- a/Code/Sandbox/Editor/GridSettingsDialog.h +++ b/Code/Sandbox/Editor/GridSettingsDialog.h @@ -51,8 +51,6 @@ private slots: void accept() override; void OnBnUserDefined(); void OnBnGetFromObject(); - void OnBnGetAngles(); - void OnBnGetTranslation(); void OnValueUpdate(); private: diff --git a/Code/Sandbox/Editor/IEditor.h b/Code/Sandbox/Editor/IEditor.h index c03b99e128..f11beacf10 100644 --- a/Code/Sandbox/Editor/IEditor.h +++ b/Code/Sandbox/Editor/IEditor.h @@ -85,7 +85,6 @@ namespace WinWidget } struct ISystem; -struct I3DEngine; struct IRenderer; struct AABB; struct IEventLoopHook; @@ -137,7 +136,6 @@ enum EEditorNotifyEvent eNotify_OnEndLayerExport, // Sent after a layer have been exported. eNotify_OnCloseScene, // Send when the document is about to close. eNotify_OnSceneClosed, // Send when the document is closed. - eNotify_OnMissionChange, // Send when the current mission changes. eNotify_OnBeginLoad, // Sent when the document is start to load. eNotify_OnEndLoad, // Sent when the document loading is finished @@ -180,8 +178,6 @@ enum EEditorNotifyEvent eNotify_OnDisplayRenderUpdate, // Sent when editor finish terrain texture generation. - eNotify_OnTimeOfDayChange, // Time of day parameters where modified. - eNotify_OnDataBaseUpdate, // DataBase Library was modified. eNotify_OnLayerImportBegin, //layer import was started @@ -241,8 +237,6 @@ struct IDocListener virtual void OnLoadDocument() = 0; //! Called when document is being closed. virtual void OnCloseDocument() = 0; - //! Called when mission changes. - virtual void OnMissionChange() = 0; }; //! Derive from this class if you want to register for getting global editor notifications. @@ -431,7 +425,6 @@ struct IEditor virtual void DeleteThis() = 0; //! Access to Editor ISystem interface. virtual ISystem* GetSystem() = 0; - virtual I3DEngine* Get3DEngine() = 0; virtual IRenderer* GetRenderer() = 0; //! Access to class factory. virtual IEditorClassFactory* GetClassFactory() = 0; @@ -739,8 +732,6 @@ struct IEditor typedef AZStd::function TContextMenuExtensionFunc; virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) = 0; - virtual void SetCurrentMissionTime(float time) = 0; - virtual SSystemGlobalEnvironment* GetEnv() = 0; virtual IImageUtil* GetImageUtil() = 0; // Vladimir@conffx virtual SEditorSettings* GetEditorSettings() = 0; diff --git a/Code/Sandbox/Editor/IEditorImpl.cpp b/Code/Sandbox/Editor/IEditorImpl.cpp index 61d24db90c..53a2c120c4 100644 --- a/Code/Sandbox/Editor/IEditorImpl.cpp +++ b/Code/Sandbox/Editor/IEditorImpl.cpp @@ -71,7 +71,6 @@ AZ_POP_DISABLE_WARNING #include "BackgroundTaskManager.h" #include "BackgroundScheduleManager.h" #include "EditorFileMonitor.h" -#include "Mission.h" #include "MainStatusBar.h" #include "SettingsBlock.h" @@ -116,29 +115,6 @@ static CCryEditDoc * theDocument; #undef GetCommandLine -namespace -{ - bool SelectionContainsComponentEntities() - { - bool result = false; - CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection(); - if (pSelection) - { - CBaseObject* selectedObj = nullptr; - for (int selectionCounter = 0; selectionCounter < pSelection->GetCount(); ++selectionCounter) - { - selectedObj = pSelection->GetObject(selectionCounter); - if (selectedObj->GetType() == OBJTYPE_AZENTITY) - { - result = true; - break; - } - } - } - return result; - } -} - const char* CEditorImpl::m_crashLogFileName = "SessionStatus/editor_statuses.json"; CEditorImpl::CEditorImpl() @@ -464,15 +440,6 @@ ISystem* CEditorImpl::GetSystem() return m_pSystem; } -I3DEngine* CEditorImpl::Get3DEngine() -{ - if (gEnv) - { - return gEnv->p3DEngine; - } - return nullptr; -} - IRenderer* CEditorImpl::GetRenderer() { if (gEnv) @@ -1739,13 +1706,6 @@ void CEditorImpl::RegisterObjectContextMenuExtension(TContextMenuExtensionFunc f m_objectContextMenuExtensions.push_back(func); } -void CEditorImpl::SetCurrentMissionTime(float time) -{ - if (CMission* pMission = GetIEditor()->GetDocument()->GetCurrentMission()) - { - pMission->SetTime(time); - } -} // Vladimir@Conffx SSystemGlobalEnvironment* CEditorImpl::GetEnv() { diff --git a/Code/Sandbox/Editor/IEditorImpl.h b/Code/Sandbox/Editor/IEditorImpl.h index d17a94807f..bbef338cb2 100644 --- a/Code/Sandbox/Editor/IEditorImpl.h +++ b/Code/Sandbox/Editor/IEditorImpl.h @@ -116,7 +116,6 @@ public: bool IsInitialized() const{ return m_bInitialized; } bool SaveDocument(); ISystem* GetSystem(); - I3DEngine* Get3DEngine(); IRenderer* GetRenderer(); void WriteToConsole(const char* string) { CLogFile::WriteLine(string); }; void WriteToConsole(const QString& string) { CLogFile::WriteLine(string); }; @@ -321,7 +320,6 @@ public: void OnObjectContextMenuOpened(QMenu* pMenu, const CBaseObject* pObject); virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) override; - virtual void SetCurrentMissionTime(float time); virtual SSystemGlobalEnvironment* GetEnv() override; virtual IBaseLibraryManager* GetMaterialManagerLibrary() override; // Vladimir@Conffx virtual IEditorMaterialManager* GetIEditorMaterialManager() override; // Vladimir@Conffx diff --git a/Code/Sandbox/Editor/IconManager.cpp b/Code/Sandbox/Editor/IconManager.cpp index 828a7cdfcc..e06b89b38e 100644 --- a/Code/Sandbox/Editor/IconManager.cpp +++ b/Code/Sandbox/Editor/IconManager.cpp @@ -25,6 +25,7 @@ #include "Util/Image.h" #include "Util/ImageUtil.h" +#include #define HELPER_MATERIAL "Objects/Helper" @@ -76,12 +77,11 @@ void CIconManager::Done() ////////////////////////////////////////////////////////////////////////// void CIconManager::Reset() { - I3DEngine* pEngine = GetIEditor()->Get3DEngine(); // Do not unload objects. but clears them. int i; for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++) { - if (m_objects[i] && pEngine) + if (m_objects[i]) { m_objects[i]->Release(); } @@ -130,39 +130,10 @@ int CIconManager::GetIconTexture(EIcon icon) return m_icons[icon]; } - ////////////////////////////////////////////////////////////////////////// -_smart_ptr CIconManager::GetHelperMaterial() +IStatObj* CIconManager::GetObject(EStatObject) { - if (!m_pHelperMtl) - { - m_pHelperMtl = GetIEditor()->Get3DEngine()->GetMaterialManager()->LoadMaterial(HELPER_MATERIAL); - } - return m_pHelperMtl; -}; - -////////////////////////////////////////////////////////////////////////// -IStatObj* CIconManager::GetObject(EStatObject object) -{ - assert(object >= 0 && object < eStatObject_COUNT); - - if (m_objects[object]) - { - return m_objects[object]; - } - - // Try to load this object. - m_objects[object] = GetIEditor()->Get3DEngine()->LoadStatObjUnsafeManualRef(g_ObjectNames[object], NULL, NULL, false); - if (!m_objects[object]) - { - CLogFile::FormatLine("Error: Load Failed: %s", g_ObjectNames[object]); - } - m_objects[object]->AddRef(); - if (GetHelperMaterial()) - { - m_objects[object]->SetMaterial(GetHelperMaterial()); - } - return m_objects[object]; + return nullptr; } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/IconManager.h b/Code/Sandbox/Editor/IconManager.h index 641e3f70a7..6c86627f3a 100644 --- a/Code/Sandbox/Editor/IconManager.h +++ b/Code/Sandbox/Editor/IconManager.h @@ -51,7 +51,6 @@ public: virtual IStatObj* GetObject(EStatObject object); virtual int GetIconTexture(const char* iconName); - virtual _smart_ptr GetHelperMaterial(); ////////////////////////////////////////////////////////////////////////// // Icon bitmaps. @@ -64,14 +63,11 @@ public: virtual void OnNewDocument() { Reset(); }; virtual void OnLoadDocument() { Reset(); }; virtual void OnCloseDocument() { Reset(); }; - virtual void OnMissionChange() { Reset(); }; ////////////////////////////////////////////////////////////////////////// private: StdMap m_textures; - _smart_ptr m_pHelperMtl; - IStatObj* m_objects[eStatObject_COUNT]; int m_icons[eIcon_COUNT]; diff --git a/Code/Sandbox/Editor/Include/IIconManager.h b/Code/Sandbox/Editor/Include/IIconManager.h index 115d998be3..15ef37e23b 100644 --- a/Code/Sandbox/Editor/Include/IIconManager.h +++ b/Code/Sandbox/Editor/Include/IIconManager.h @@ -61,7 +61,6 @@ struct IIconManager virtual IStatObj* GetObject(EStatObject object) = 0; virtual int GetIconTexture(EIcon icon) = 0; virtual int GetIconTexture(const char* iconName) = 0; - virtual _smart_ptr GetHelperMaterial() = 0; virtual QImage* GetIconBitmap(const char* filename, bool& haveAlpha, uint32 effects = 0) = 0; // Register an Icon for the specific command virtual void RegisterCommandIcon([[maybe_unused]] const char* filename, [[maybe_unused]] int nCommandId) {} diff --git a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h index 6659e41122..4a20bd6b60 100644 --- a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h +++ b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h @@ -32,7 +32,6 @@ public: public: MOCK_METHOD0(DeleteThis, void()); MOCK_METHOD0(GetSystem, ISystem*()); - MOCK_METHOD0(Get3DEngine, I3DEngine* ()); MOCK_METHOD0(GetRenderer, IRenderer* ()); MOCK_METHOD0(GetClassFactory, IEditorClassFactory* ()); MOCK_METHOD0(GetCommandManager, CEditorCommandManager*()); @@ -191,7 +190,6 @@ public: MOCK_METHOD0(GetBackgroundScheduleManager, struct IBackgroundScheduleManager* ()); MOCK_METHOD1(ShowStatusText, void(bool )); MOCK_METHOD1(RegisterObjectContextMenuExtension, void(TContextMenuExtensionFunc )); - MOCK_METHOD1(SetCurrentMissionTime, void(float )); MOCK_METHOD0(GetEnv, SSystemGlobalEnvironment* ()); MOCK_METHOD0(GetImageUtil, IImageUtil* ()); MOCK_METHOD0(GetEditorSettings, SEditorSettings* ()); diff --git a/Code/Sandbox/Editor/LyViewPaneNames.h b/Code/Sandbox/Editor/LyViewPaneNames.h index fdbf8bf90c..e95191ce06 100644 --- a/Code/Sandbox/Editor/LyViewPaneNames.h +++ b/Code/Sandbox/Editor/LyViewPaneNames.h @@ -44,7 +44,6 @@ namespace LyViewPane static const char* const TerrainTool = "Terrain Tool"; static const char* const TerrainTextureLayers = "Terrain Texture Layers"; static const char* const ParticleEditor = "Particle Editor"; - static const char* const TimeOfDayEditor = "Time Of Day"; static const char* const AudioControlsEditor = "Audio Controls Editor"; static const char* const SubstanceEditor = "Substance Editor"; static const char* const VegetationEditor = "Vegetation Editor"; diff --git a/Code/Sandbox/Editor/MainWindow.cpp b/Code/Sandbox/Editor/MainWindow.cpp index c266d37282..e9bfd96a1d 100644 --- a/Code/Sandbox/Editor/MainWindow.cpp +++ b/Code/Sandbox/Editor/MainWindow.cpp @@ -90,7 +90,6 @@ AZ_POP_DISABLE_WARNING #include "TrackView/TrackViewDialog.h" #include "ErrorReportDialog.h" -#include "TimeOfDayDialog.h" #include "Dialogs/PythonScriptsDialog.h" #include "EngineSettingsManager.h" @@ -884,9 +883,6 @@ void MainWindow::InitActions() .SetStatusTip(tr("Restore saved state (Fetch)")); // Modify actions - am->AddAction(ID_EDIT_RENAMEOBJECT, tr("Rename Object(s)...")) - .SetStatusTip(tr("Rename Object")); - am->AddAction(ID_EDITMODE_MOVE, tr("Move")) .SetIcon(Style::icon("Move")) .SetApplyHoverEffect() @@ -1081,8 +1077,6 @@ void MainWindow::InitActions() // Tools actions am->AddAction(ID_RELOAD_TEXTURES, tr("Reload Textures/Shaders")) .SetStatusTip(tr("Reload all textures.")); - am->AddAction(ID_RELOAD_GEOMETRY, tr("Reload Geometry")) - .SetStatusTip(tr("Reload all geometries.")); am->AddAction(ID_TOOLS_ENABLEFILECHANGEMONITORING, tr("Enable File Change Monitoring")); am->AddAction(ID_CLEAR_REGISTRY, tr("Clear Registry Data")) .SetStatusTip(tr("Clear Registry Data")); @@ -1333,7 +1327,7 @@ QToolButton* MainWindow::CreateDebugModeButton() QWidget* MainWindow::CreateSpacerRightWidget() { - QWidget* spacer = new QWidget(); + QWidget* spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); spacer->setVisible(true); return spacer; @@ -1355,12 +1349,6 @@ void MainWindow::InitEnvironmentModeMenu(CVarMenu* environmentModeMenu) environmentModeMenu->AddCVarToggleItem({ "r_ssdo", tr("Hide Screen Space Directional Occlusion"), 0, 1 }); environmentModeMenu->AddCVarToggleItem({ "e_DynamicLights", tr("Hide All Dynamic Lights"), 0, 1 }); environmentModeMenu->AddSeparator(); - environmentModeMenu->AddCVarValuesItem("e_TimeOfDay", tr("Time of Day"), - { - {tr("Day (1:00 pm)"), 13}, - {tr("Night (9:00 pm)"), 21} - }, 9); - environmentModeMenu->AddSeparator(); environmentModeMenu->AddCVarToggleItem({ "e_Entities", tr("Hide Entities"), 0, 1 }); environmentModeMenu->AddSeparator(); environmentModeMenu->AddCVarToggleItem({ "e_Vegetation", tr("Hide Vegetation"), 0, 1 }); diff --git a/Code/Sandbox/Editor/Mission.cpp b/Code/Sandbox/Editor/Mission.cpp deleted file mode 100644 index b9668f1c80..0000000000 --- a/Code/Sandbox/Editor/Mission.cpp +++ /dev/null @@ -1,364 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : CMission class implementation. - -#include "EditorDefs.h" - -#include "Mission.h" - -// cryCommon -#include -#include - -// Editor -#include "CryEditDoc.h" -#include "GameEngine.h" -#include "Include/IObjectManager.h" - - -namespace -{ - const char* kTimeOfDayFile = "TimeOfDay.xml"; - const char* kTimeOfDayRoot = "TimeOfDay"; - const char* kEnvironmentFile = "Environment.xml"; - const char* kEnvironmentRoot = "Environment"; -}; - - -////////////////////////////////////////////////////////////////////////// -CMission::CMission(CCryEditDoc* doc) -{ - m_doc = doc; - m_objects = XmlHelpers::CreateXmlNode("Objects"); - m_layers = XmlHelpers::CreateXmlNode("ObjectLayers"); - //m_exportData = XmlNodeRef( "ExportData" ); - m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay"); - m_environment = XmlHelpers::CreateXmlNode("Environment"); - CXmlTemplate::SetValues(m_doc->GetEnvironmentTemplate(), m_environment); - - m_time = 12; // 12 PM by default. - - m_numCGFObjects = 0; - - m_reentrancyProtector = false; -} - -////////////////////////////////////////////////////////////////////////// -CMission::~CMission() -{ -} - -////////////////////////////////////////////////////////////////////////// -CMission* CMission::Clone() -{ - CMission* m = new CMission(m_doc); - m->SetName(m_name); - m->SetDescription(m_description); - m->m_objects = m_objects->clone(); - m->m_layers = m_layers->clone(); - m->m_environment = m_environment->clone(); - m->m_time = m_time; - return m; -} - -////////////////////////////////////////////////////////////////////////// -void CMission::Serialize(CXmlArchive& ar, bool bParts) -{ - if (ar.bLoading) - { - // Load. - ar.root->getAttr("Name", m_name); - ar.root->getAttr("Description", m_description); - - XmlNodeRef objects = ar.root->findChild("Objects"); - if (objects) - { - m_objects = objects; - } - - XmlNodeRef layers = ar.root->findChild("ObjectLayers"); - if (layers) - { - m_layers = layers; - } - - SerializeTimeOfDay(ar); - - m_Animations = ar.root->findChild("MovieData"); - - SerializeEnvironment(ar); - } - else - { - ar.root->setAttr("Name", m_name.toUtf8().data()); - ar.root->setAttr("Description", m_description.toUtf8().data()); - - QString timeStr; - int nHour = floor(m_time); - int nMins = (m_time - floor(m_time)) * 60.0f; - timeStr = QStringLiteral("%1:%2").arg(nHour, 2, 10, QLatin1Char('0')).arg(nMins, 2, 10, QLatin1Char('0')); - ar.root->setAttr("MissionTime", timeStr.toUtf8().data()); - - // Saving. - XmlNodeRef layers = m_layers->clone(); - layers->setTag("ObjectLayers"); - ar.root->addChild(layers); - - ///XmlNodeRef objects = m_objects->clone(); - m_objects->setTag("Objects"); - ar.root->addChild(m_objects); - - if (bParts) - { - SerializeTimeOfDay(ar); - SerializeEnvironment(ar); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CMission::Export(XmlNodeRef& root, XmlNodeRef& objectsNode) -{ - // Also save exported objects data. - root->setAttr("Name", m_name.toUtf8().data()); - root->setAttr("Description", m_description.toUtf8().data()); - - QString timeStr; - int nHour = floor(m_time); - int nMins = (m_time - floor(m_time)) * 60.0f; - timeStr = QStringLiteral("%1:%2").arg(nHour, 2, 10, QLatin1Char('0')).arg(nMins, 2, 10, QLatin1Char('0')); - root->setAttr("Time", timeStr.toUtf8().data()); - - // Saving. - //XmlNodeRef objects = m_exportData->clone(); - //objects->setTag( "Objects" ); - //root->addChild( objects ); - - XmlNodeRef envNode = m_environment->clone(); - root->addChild(envNode); - - m_timeOfDay->setAttr("Time", m_time); - root->addChild(m_timeOfDay); - - IObjectManager* pObjMan = GetIEditor()->GetObjectManager(); - - ////////////////////////////////////////////////////////////////////////// - // Serialize objects. - ////////////////////////////////////////////////////////////////////////// - QString path = QDir::toNativeSeparators(QFileInfo(m_doc->GetLevelPathName()).absolutePath()); - if (!path.endsWith(QDir::separator())) - path += QDir::separator(); - - objectsNode = root->newChild("Objects"); - pObjMan->Export(path, objectsNode, true); // Export shared. - pObjMan->Export(path, objectsNode, false); // Export not shared. -} - -////////////////////////////////////////////////////////////////////////// -void CMission::SyncContent(bool bRetrieve, bool bIgnoreObjects, [[maybe_unused]] bool bSkipLoadingAI /* = false */) -{ - // The function may take a longer time when executing objMan->Serialize, which uses CWaitProgress internally - // Adding a sync flag to prevent the function from being re-entered after the data is modified by OnEnvironmentChange - if (m_reentrancyProtector) - { - return; - } - m_reentrancyProtector = true; - - // Save data from current Document to Mission. - IObjectManager* objMan = GetIEditor()->GetObjectManager(); - if (bRetrieve) - { - // Activating this mission. - CGameEngine* gameEngine = GetIEditor()->GetGameEngine(); - - if (!bIgnoreObjects) - { - // Retrieve data from Mission and put to document. - XmlNodeRef root = XmlHelpers::CreateXmlNode("Root"); - root->addChild(m_objects); - root->addChild(m_layers); - objMan->Serialize(root, true, SERIALIZE_ONLY_NOTSHARED); - } - - m_doc->GetFogTemplate() = m_environment; - - CXmlTemplate::GetValues(m_doc->GetEnvironmentTemplate(), m_environment); - - gameEngine->ReloadEnvironment(); - - objMan->SendEvent(EVENT_MISSION_CHANGE); - m_doc->ChangeMission(); - - if (GetIEditor()->Get3DEngine()) - { - m_numCGFObjects = GetIEditor()->Get3DEngine()->GetLoadedObjectCount(); - - // Load time of day. - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, true); - } - } - else - { - // Save time of day. - if (GetIEditor()->Get3DEngine()) - { - m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay"); - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, false); - } - - if (!bIgnoreObjects) - { - XmlNodeRef root = XmlHelpers::CreateXmlNode("Root"); - objMan->Serialize(root, false, SERIALIZE_ONLY_NOTSHARED); - m_objects = root->findChild("Objects"); - XmlNodeRef layers = root->findChild("ObjectLayers"); - if (layers) - { - m_layers = layers; - } - } - } - - m_reentrancyProtector = false; -} - -////////////////////////////////////////////////////////////////////////// -void CMission::OnEnvironmentChange() -{ - // Only execute the reload function if there is no ongoing SyncContent. - if (m_reentrancyProtector) - { - return; - } - m_reentrancyProtector = true; - m_environment = XmlHelpers::CreateXmlNode("Environment"); - CXmlTemplate::SetValues(m_doc->GetEnvironmentTemplate(), m_environment); - m_reentrancyProtector = false; -} - -////////////////////////////////////////////////////////////////////////// -void CMission::AddObjectsNode(XmlNodeRef& node) -{ - for (int i = 0; i < node->getChildCount(); i++) - { - m_objects->addChild(node->getChild(i)->clone()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMission::SetLayersNode(XmlNodeRef& node) -{ - m_layers = node->clone(); -} - -////////////////////////////////////////////////////////////////////////// -void CMission::SaveParts() -{ - // Save Time of Day - { - CTempFileHelper helper((GetIEditor()->GetLevelDataFolder() + kTimeOfDayFile).toUtf8().data()); - - m_timeOfDay->saveToFile(helper.GetTempFilePath().toUtf8().data()); - - if (!helper.UpdateFile(false)) - { - return; - } - } - - - // Save Environment - { - CTempFileHelper helper((GetIEditor()->GetLevelDataFolder() + kEnvironmentFile).toUtf8().data()); - - XmlNodeRef root = m_environment->clone(); - root->setTag(kEnvironmentRoot); - root->saveToFile(helper.GetTempFilePath().toUtf8().data()); - - if (!helper.UpdateFile(false)) - { - return; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CMission::LoadParts() -{ - // Load Time of Day - { - QString filename = GetIEditor()->GetLevelDataFolder() + kTimeOfDayFile; - XmlNodeRef root = XmlHelpers::LoadXmlFromFile(filename.toUtf8().data()); - if (root && !_stricmp(root->getTag(), kTimeOfDayRoot)) - { - m_timeOfDay = root; - m_timeOfDay->getAttr("Time", m_time); - } - } - - // Load Environment - { - QString filename = GetIEditor()->GetLevelDataFolder() + kEnvironmentFile; - XmlNodeRef root = XmlHelpers::LoadXmlFromFile(filename.toUtf8().data()); - if (root && !_stricmp(root->getTag(), kEnvironmentRoot)) - { - m_environment = root; - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CMission::SerializeTimeOfDay(CXmlArchive& ar) -{ - if (ar.bLoading) - { - XmlNodeRef todNode = ar.root->findChild("TimeOfDay"); - if (todNode) - { - m_timeOfDay = todNode; - todNode->getAttr("Time", m_time); - } - else - { - m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay"); - } - } - else - { - m_timeOfDay->setAttr("Time", m_time); - ar.root->addChild(m_timeOfDay); - } -} - -////////////////////////////////////////////////////////////////////////// -void CMission::SerializeEnvironment(CXmlArchive& ar) -{ - if (ar.bLoading) - { - XmlNodeRef env = ar.root->findChild("Environment"); - if (env) - { - m_environment = env; - } - } - else - { - XmlNodeRef env = m_environment->clone(); - env->setTag("Environment"); - ar.root->addChild(env); - } -} - diff --git a/Code/Sandbox/Editor/Mission.h b/Code/Sandbox/Editor/Mission.h deleted file mode 100644 index f0773a0be7..0000000000 --- a/Code/Sandbox/Editor/Mission.h +++ /dev/null @@ -1,105 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Mission class definition. - -#pragma once - - -/*! - CMission represent single Game Mission on same map. - Multiple Missions share same map, and stored in one .cry or .ly file. - - */ -class CMission -{ -public: - //! Ctor of mission. - CMission(CCryEditDoc* doc); - //! Dtor of mission. - virtual ~CMission(); - - void SetName(const QString& name) { m_name = name; } - const QString& GetName() const { return m_name; } - - void SetDescription(const QString& dsc) { m_description = dsc; } - const QString& GetDescription() const { return m_description; } - - XmlNodeRef GetEnvironment() { return m_environment; }; - - void SetTime(float time) { m_time = time; }; - float GetTime() const { return m_time; }; - - //! Called when this mission must be synchonized with current data in Document. - //! if bRetrieve is true, data is retrieved from Mission to global structures. - void SyncContent(bool bRetrieve, bool bIgnoreObjects, bool bSkipLoadingAI = false); - - //! Create clone of this mission. - CMission* Clone(); - - //! Serialize mission. - void Serialize(CXmlArchive& ar, bool bParts = true); - - //! Serialize time of day - void SerializeTimeOfDay(CXmlArchive& ar); - - //! Serialize environment - void SerializeEnvironment(CXmlArchive& ar); - - //! Save some elements of mission to separate files - void SaveParts(); - - //! Load some elements of mission from separate files - void LoadParts(); - - //! Export mission to game. - void Export(XmlNodeRef& root, XmlNodeRef& objectsNode); - - //! Add shared objects to mission objects. - void AddObjectsNode(XmlNodeRef& node); - void SetLayersNode(XmlNodeRef& node); - - void OnEnvironmentChange(); - int GetNumCGFObjects() const { return m_numCGFObjects; }; - -private: - //! Document owner of this mission. - CCryEditDoc* m_doc; - - QString m_name; - QString m_description; - - //! Mission time; - float m_time; - - //! Root node of objects defined only in this mission. - XmlNodeRef m_objects; - - //! Object layers. - XmlNodeRef m_layers; - - //! Exported data of this mission. - XmlNodeRef m_exportData; - - //! Environment settings of this mission. - XmlNodeRef m_environment; - - XmlNodeRef m_Animations; // backward compatibility. - - XmlNodeRef m_timeOfDay; - - int m_numCGFObjects; - - bool m_reentrancyProtector; -}; - diff --git a/Code/Sandbox/Editor/ModelViewport.cpp b/Code/Sandbox/Editor/ModelViewport.cpp deleted file mode 100644 index 2e00adb4fc..0000000000 --- a/Code/Sandbox/Editor/ModelViewport.cpp +++ /dev/null @@ -1,961 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "ModelViewport.h" - -// Qt -#include -#include - -// CryCommon -#include - -#include "CryPhysicsDeprecation.h" - - -// Editor -#include "ThumbnailGenerator.h" // for CThumbnailGenerator -#include "FileTypeUtils.h" // for IsPreviewableFileType -#include "ErrorRecorder.h" - - - - - -uint32 g_ypos = 0; - -#define SKYBOX_NAME "InfoRedGal" - -///////////////////////////////////////////////////////////////////////////// -// CModelViewport - -CModelViewport::CModelViewport(const char* settingsPath, QWidget* parent) - : CRenderViewport(tr("Model View"), parent) -{ - m_settingsPath = QString::fromLatin1(settingsPath); - - m_bPaused = false; - - m_Camera.SetFrustum(800, 600, 3.14f / 4.0f, 0.02f, 10000); - - m_bInRotateMode = false; - m_bInMoveMode = false; - - m_object = 0; - - - m_weaponModel = 0; - - m_camRadius = 10; - - m_moveSpeed = 0.1f; - m_LightRotationRadian = 0.0f; - - m_weaponIK = false; - - m_pRESky = 0; - m_pSkyboxName = 0; - m_pSkyBoxShader = NULL; - - m_attachBone = QStringLiteral("weapon_bone"); - - // Init variable. - mv_objectAmbientColor = Vec3(0.25f, 0.25f, 0.25f); - mv_backgroundColor = Vec3(0.25f, 0.25f, 0.25f); - - mv_lightDiffuseColor = Vec3(0.70f, 0.70f, 0.70f); - mv_lightMultiplier = 3.0f; - mv_lightOrbit = 15.0f; - mv_lightRadius = 400.0f; - mv_lightSpecMultiplier = 1.0f; - - mv_showPhysics = false; - - m_GridOrigin = Vec3(ZERO); - m_arrAnimatedCharacterPath.resize(0x200, ZERO); - m_arrSmoothEntityPath.resize(0x200, ZERO); - - m_arrRunStrafeSmoothing.resize(0x100); - SetPlayerPos(); - - // cache all the variable callbacks, must match order of enum defined in header - m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnCharPhysics, this, AZStd::placeholders::_1)); - m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnLightColor, this, AZStd::placeholders::_1)); - m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnLightMultiplier, this, AZStd::placeholders::_1)); - m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnShowShaders, this, AZStd::placeholders::_1)); - - //-------------------------------------------------- - // Register variables. - //-------------------------------------------------- - m_vars.AddVariable(mv_showPhysics, "Display Physics"); - m_vars.AddVariable(mv_useCharPhysics, "Use Character Physics", &m_onSetCallbacksCache[VariableCallbackIndex::OnCharPhysics]); - mv_useCharPhysics = true; - m_vars.AddVariable(mv_showGrid, "ShowGrid"); - mv_showGrid = true; - m_vars.AddVariable(mv_showBase, "ShowBase"); - mv_showBase = false; - m_vars.AddVariable(mv_showLocator, "ShowLocator"); - mv_showLocator = 0; - m_vars.AddVariable(mv_InPlaceMovement, "InPlaceMovement"); - mv_InPlaceMovement = false; - m_vars.AddVariable(mv_StrafingControl, "StrafingControl"); - mv_StrafingControl = false; - - m_vars.AddVariable(mv_lighting, "Lighting"); - mv_lighting = true; - m_vars.AddVariable(mv_animateLights, "AnimLights"); - - m_vars.AddVariable(mv_backgroundColor, "BackgroundColor", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightColor], IVariable::DT_COLOR); - m_vars.AddVariable(mv_objectAmbientColor, "ObjectAmbient", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightColor], IVariable::DT_COLOR); - - m_vars.AddVariable(mv_lightDiffuseColor, "LightDiffuse", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightColor], IVariable::DT_COLOR); - m_vars.AddVariable(mv_lightMultiplier, "Light Multiplier", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE); - m_vars.AddVariable(mv_lightSpecMultiplier, "Light Specular Multiplier", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE); - m_vars.AddVariable(mv_lightRadius, "Light Radius", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE); - m_vars.AddVariable(mv_lightOrbit, "Light Orbit", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE); - - m_vars.AddVariable(mv_showWireframe1, "ShowWireframe1"); - m_vars.AddVariable(mv_showWireframe2, "ShowWireframe2"); - m_vars.AddVariable(mv_showTangents, "ShowTangents"); - m_vars.AddVariable(mv_showBinormals, "ShowBinormals"); - m_vars.AddVariable(mv_showNormals, "ShowNormals"); - - m_vars.AddVariable(mv_showSkeleton, "ShowSkeleton"); - m_vars.AddVariable(mv_showJointNames, "ShowJointNames"); - m_vars.AddVariable(mv_showJointsValues, "ShowJointsValues"); - m_vars.AddVariable(mv_showStartLocation, "ShowInvStartLocation"); - m_vars.AddVariable(mv_showMotionParam, "ShowMotionParam"); - m_vars.AddVariable(mv_printDebugText, "PrintDebugText"); - - m_vars.AddVariable(mv_UniformScaling, "UniformScaling"); - mv_UniformScaling = 1.0f; - mv_UniformScaling.SetLimits(0.01f, 2.0f); - m_vars.AddVariable(mv_forceLODNum, "ForceLODNum"); - mv_forceLODNum = 0; - mv_forceLODNum.SetLimits(0, 10); - m_vars.AddVariable(mv_showShaders, "ShowShaders", &m_onSetCallbacksCache[VariableCallbackIndex::OnShowShaders]); - m_vars.AddVariable(mv_AttachCamera, "AttachCamera"); - - m_vars.AddVariable(mv_fov, "FOV"); - mv_fov = 60; - mv_fov.SetLimits(1, 120); - - RestoreDebugOptions(); - - m_camRadius = 10; - - //YPR_Angle = Ang3(0,-1.0f,0); - //SetViewTM( Matrix34(CCamera::CreateOrientationYPR(YPR_Angle), Vec3(0,-m_camRadius,0)) ); - Vec3 camPos = Vec3(10, 10, 10); - Matrix34 tm = Matrix33::CreateRotationVDir((Vec3(0, 0, 0) - camPos).GetNormalized()); - tm.SetTranslation(camPos); - SetViewTM(tm); - - - m_AABB.Reset(); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::SaveDebugOptions() const -{ - QSettings settings; - for (auto g : m_settingsPath.split('\\')) - settings.beginGroup(g); - - CVarBlock* vb = GetVarObject()->GetVarBlock(); - int32 vbCount = vb->GetNumVariables(); - - settings.setValue("iDebugOptionCount", vbCount); - - char keyType[64], keyValue[64]; - for (int32 i = 0; i < vbCount; ++i) - { - IVariable* var = vb->GetVariable(i); - IVariable::EType vType = var->GetType(); - sprintf_s(keyType, "DebugOption_%s_type", var->GetName().toUtf8().data()); - sprintf_s(keyValue, "DebugOption_%s_value", var->GetName().toUtf8().data()); - switch (vType) - { - case IVariable::UNKNOWN: - { - break; - } - case IVariable::INT: - { - int32 value = 0; - var->Get(value); - settings.setValue(keyType, IVariable::INT); - settings.setValue(keyValue, value); - - break; - } - case IVariable::BOOL: - { - bool value = 0; - var->Get(value); - settings.setValue(keyType, IVariable::BOOL); - settings.setValue(keyValue, value); - break; - } - case IVariable::FLOAT: - { - f32 value = 0; - var->Get(value); - settings.setValue(keyType, IVariable::FLOAT); - settings.setValue(keyValue, value); - break; - } - case IVariable::VECTOR: - { - Vec3 value; - var->Get(value); - f32 valueArray[3]; - valueArray[0] = value.x; - valueArray[1] = value.y; - valueArray[2] = value.z; - settings.setValue(keyType, IVariable::VECTOR); - settings.setValue(keyValue, QByteArray(reinterpret_cast(&value), 3 * sizeof(f32))); - - break; - } - case IVariable::QUAT: - { - Quat value; - var->Get(value); - f32 valueArray[4]; - valueArray[0] = value.w; - valueArray[1] = value.v.x; - valueArray[2] = value.v.y; - valueArray[3] = value.v.z; - - settings.setValue(keyType, IVariable::QUAT); - settings.setValue(keyValue, QByteArray(reinterpret_cast(&value), 4 * sizeof(f32))); - - break; - } - case IVariable::STRING: - { - QString value; - var->Get(value); - settings.setValue(keyType, IVariable::STRING); - settings.setValue(keyValue, value); - - break; - } - case IVariable::ARRAY: - { - break; - } - default: - break; - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::RestoreDebugOptions() -{ - QSettings settings; - for (auto g : m_settingsPath.split('\\')) - settings.beginGroup(g); - - QString strRead = ""; - int32 iRead = 0; - BOOL bRead = FALSE; - f32 fRead = .0f; - QByteArray pbtData; - - CVarBlock* vb = m_vars.GetVarBlock(); - int32 vbCount = vb->GetNumVariables(); - - char keyType[64], keyValue[64]; - for (int32 i = 0; i < vbCount; ++i) - { - IVariable* var = vb->GetVariable(i); - sprintf_s(keyType, "DebugOption_%s_type", var->GetName().toUtf8().data()); - - int32 iType = settings.value(keyType, 0).toInt(); - - sprintf_s(keyValue, "DebugOption_%s_value", var->GetName().toUtf8().data()); - switch (iType) - { - case IVariable::UNKNOWN: - { - break; - } - case IVariable::INT: - { - iRead = settings.value(keyValue, 0).toInt(); - var->Set(iRead); - break; - } - case IVariable::BOOL: - { - bRead = settings.value(keyValue, FALSE).toBool(); - var->Set(bRead); - break; - } - case IVariable::FLOAT: - { - fRead = settings.value(keyValue).toDouble(); - var->Set(fRead); - break; - } - case IVariable::VECTOR: - { - pbtData = settings.value(keyValue).toByteArray(); - assert(pbtData.count() == 3 * sizeof(f32)); - f32* pfRead = reinterpret_cast(pbtData.data()); - - Vec3 vecRead(pfRead[0], pfRead[1], pfRead[2]); - var->Set(vecRead); - break; - } - case IVariable::QUAT: - { - pbtData = settings.value(keyValue).toByteArray(); - assert(pbtData.count() == 4 * sizeof(f32)); - f32* pfRead = reinterpret_cast(pbtData.data()); - - Quat valueRead(pfRead[0], pfRead[1], pfRead[2], pfRead[3]); - var->Set(valueRead); - break; - } - case IVariable::STRING: - { - strRead = settings.value(keyValue, "").toString(); - var->Set(strRead); - break; - } - case IVariable::ARRAY: - { - break; - } - default: - break; - } - } -} - -////////////////////////////////////////////////////////////////////////// -CModelViewport::~CModelViewport() -{ - OnDestroy(); - ReleaseObject(); - - GetIEditor()->FlushUndo(); - - SaveDebugOptions(); - - // helper offset?? - CRY_PHYSICS_REPLACEMENT_ASSERT(); - GetIEditor()->SetConsoleVar("ca_UsePhysics", 1); -} - -///////////////////////////////////////////////////////////////////////////// -// CModelViewport message handlers -///////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -void CModelViewport::ReleaseObject() -{ - if (m_object) - { - m_object->Release(); - m_object = NULL; - } - - if (m_weaponModel) - { - m_weaponModel->Release(); - m_weaponModel = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::LoadObject(const QString& fileName, [[maybe_unused]] float scale) -{ - m_bPaused = false; - - // Load object. - QString file = Path::MakeGamePath(fileName); - - bool reload = false; - if (m_loadedFile == file) - { - reload = true; - } - m_loadedFile = file; - - SetName(tr("Model View - %1").arg(file)); - - ReleaseObject(); - - // Enables display of warning after model have been loaded. - CErrorsRecorder errRecorder; - - if (IsPreviewableFileType(file.toUtf8().data())) - { - const QString fileExt = QFileInfo(file).completeSuffix(); - // Try Load character. - const bool isSKEL = (0 == fileExt.compare(CRY_SKEL_FILE_EXT, Qt::CaseInsensitive)); - const bool isSKIN = (0 == fileExt.compare(CRY_SKIN_FILE_EXT, Qt::CaseInsensitive)); - const bool isCGA = (0 == fileExt.compare(CRY_ANIM_GEOMETRY_FILE_EXT, Qt::CaseInsensitive)); - const bool isCDF = (0 == fileExt.compare(CRY_CHARACTER_DEFINITION_FILE_EXT, Qt::CaseInsensitive)); - if (isSKEL || isSKIN || isCGA || isCDF) - { - } - else - { - LoadStaticObject(file); - } - } - else - { - QMessageBox::warning(this, tr("Preview Error"), tr("Preview of this file type not supported.")); - return; - } - - //-------------------------------------------------------------------------------- - - if (!reload) - { - Vec3 v = m_AABB.max - m_AABB.min; - float radius = v.GetLength() / 2.0f; - m_camRadius = radius * 2; - } - - if (GetIEditor()->IsInPreviewMode()) - { - Physicalize(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::LoadStaticObject(const QString& file) -{ - if (m_object) - { - m_object->Release(); - } - - // Load Static object. - m_object = m_engine->LoadStatObjUnsafeManualRef(file.toUtf8().data(), 0, 0, false); - - if (!m_object) - { - CLogFile::WriteLine("Loading of object failed."); - return; - } - m_object->AddRef(); - - // Generate thumbnail for this cgf. - CThumbnailGenerator thumbGen; - thumbGen.GenerateForFile(file); - - m_AABB.min = m_object->GetBoxMin(); - m_AABB.max = m_object->GetBoxMax(); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnRender() -{ - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - - const QRect rc = contentsRect(); - ProcessKeys(); - if (m_renderer) - { - PreWidgetRendering(); - - m_Camera.SetFrustum(m_Camera.GetViewSurfaceX(), m_Camera.GetViewSurfaceZ(), m_Camera.GetFov(), 0.02f, 10000, m_Camera.GetPixelAspectRatio()); - const int w = rc.width(); - const int h = rc.height(); - m_Camera.SetFrustum(w, h, DEG2RAD(mv_fov), 0.0101f, 10000.0f); - - if (GetIEditor()->IsInPreviewMode()) - { - GetISystem()->SetViewCamera(m_Camera); - } - - Vec3 clearColor = mv_backgroundColor; - m_renderer->SetClearColor(clearColor); - m_renderer->SetCamera(m_Camera); - - auto colorf = ColorF(clearColor, 1.0f); - m_renderer->ClearTargetsImmediately(FRT_CLEAR | FRT_CLEAR_IMMEDIATE, colorf); - m_renderer->ResetToDefault(); - - SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera, SRenderingPassInfo::DEFAULT_FLAGS, true); - - { - CScopedWireFrameMode scopedWireFrame(m_renderer, mv_showWireframe1 ? R_WIREFRAME_MODE : R_SOLID_MODE); - DrawModel(passInfo); - } - - PostWidgetRendering(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::DrawSkyBox(const SRenderingPassInfo& passInfo) -{ - CRenderObject* pObj = m_renderer->EF_GetObject_Temp(passInfo.ThreadID()); - pObj->m_II.m_Matrix.SetTranslationMat(GetViewTM().GetTranslation()); - - if (m_pSkyboxName) - { - SShaderItem skyBoxShaderItem(m_pSkyBoxShader); - m_renderer->EF_AddEf(m_pRESky, skyBoxShaderItem, pObj, passInfo, EFSLIST_GENERAL, 1, SRendItemSorter::CreateRendItemSorter(passInfo)); - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnAnimBack() -{ - // TODO: Add your command handler code here -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnAnimFastBack() -{ - // TODO: Add your command handler code here -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnAnimFastForward() -{ - // TODO: Add your command handler code here -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnAnimFront() -{ - // TODO: Add your command handler code here -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnAnimPlay() -{ - // TODO: Add your command handler code here -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::mouseDoubleClickEvent(QMouseEvent* event) -{ - // TODO: Add your message handler code here and/or call default - - CRenderViewport::mouseDoubleClickEvent(event); - if (event->button() != Qt::LeftButton) - { - return; - } - Matrix34 tm; - tm.SetIdentity(); - SetViewTM(tm); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnLightColor([[maybe_unused]] IVariable* var) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnShowNormals([[maybe_unused]] IVariable* var) -{ - bool enable = mv_showNormals; - GetIEditor()->SetConsoleVar("r_ShowNormals", (enable) ? 1 : 0); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnShowTangents([[maybe_unused]] IVariable* var) -{ - bool enable = mv_showTangents; - GetIEditor()->SetConsoleVar("r_ShowTangents", (enable) ? 1 : 0); -} - - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnCharPhysics([[maybe_unused]] IVariable* var) -{ - bool enable = mv_useCharPhysics; - GetIEditor()->SetConsoleVar("ca_UsePhysics", enable); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnShowShaders([[maybe_unused]] IVariable* var) -{ - bool bEnable = mv_showShaders; - GetIEditor()->SetConsoleVar("r_ProfileShaders", bEnable); -} - -void CModelViewport::OnDestroy() -{ - ReleaseObject(); - if (m_pRESky) - { - m_pRESky->Release(false); - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnActivate() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnDeactivate() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::Update() -{ - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - - CRenderViewport::Update(); - - DrawInfo(); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::DrawInfo() const -{ - if (GetIEditor()->Get3DEngine()) - { - ICVar* pDisplayInfo = gEnv->pConsole->GetCVar("r_DisplayInfo"); - if (pDisplayInfo && pDisplayInfo->GetIVal() != 0) - { - const float fps = gEnv->pTimer->GetFrameRate(); - const float x = (float)gEnv->pRenderer->GetWidth() - 5.0f; - - gEnv->p3DEngine->DrawTextRightAligned(x, 1, "FPS: %.2f", fps); - - int nPolygons, nShadowVolPolys; - gEnv->pRenderer->GetPolyCount(nPolygons, nShadowVolPolys); - int nDrawCalls = gEnv->pRenderer->GetCurrentNumberOfDrawCalls(); - gEnv->p3DEngine->DrawTextRightAligned(x, 20, "Tris:%2d,%03d - DP:%d", nPolygons / 1000, nPolygons % 1000, nDrawCalls); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CModelViewport::CanDrop([[maybe_unused]] const QPoint& point, IDataBaseItem* pItem) -{ - if (!pItem) - { - return false; - } - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::Drop([[maybe_unused]] const QPoint& point, [[maybe_unused]] IDataBaseItem* pItem) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::Physicalize() -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::RePhysicalize() -{ - Physicalize(); -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::SetPaused(bool bPaused) -{ - //return; - if (m_bPaused != bPaused) - { - m_bPaused = bPaused; - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::DrawModel(const SRenderingPassInfo& passInfo) -{ - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - - m_vCamPos = GetCamera().GetPosition(); - const QRect rc = contentsRect(); - //GetISystem()->SetViewCamera( m_Camera ); - IRenderAuxGeom* pAuxGeom = m_renderer->GetIRenderAuxGeom(); - m_renderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID()); - m_renderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID()); - m_renderer->EF_ClearSkinningDataPool(); - m_renderer->EF_StartEf(passInfo); - - ////////////////////////////////////////////////////////////////////////// - // Draw lights. - ////////////////////////////////////////////////////////////////////////// - if (mv_lighting == true) - { - pAuxGeom->DrawSphere(m_VPLight.m_Origin, 0.2f, ColorB(255, 255, 0, 255)); - } - - gEnv->pConsole->GetCVar("ca_DrawWireframe")->Set(mv_showWireframe2); - gEnv->pConsole->GetCVar("ca_DrawTangents")->Set(mv_showTangents); - gEnv->pConsole->GetCVar("ca_DrawBinormals")->Set(mv_showBinormals); - gEnv->pConsole->GetCVar("ca_DrawNormals")->Set(mv_showNormals); - - DrawLights(passInfo); - - - //----------------------------------------------------------------------------- - //----- Render Static Object (handled by 3DEngine) ---- - //----------------------------------------------------------------------------- - // calculate LOD - - f32 fDistance = GetViewTM().GetTranslation().GetLength(); - SRendParams rp; - rp.fDistance = fDistance; - - Matrix34 tm; - tm.SetIdentity(); - rp.pMatrix = &tm; - rp.pPrevMatrix = &tm; - - Vec3 vAmbient; - mv_objectAmbientColor.Get(vAmbient); - - rp.AmbientColor.r = vAmbient.x * mv_lightMultiplier; - rp.AmbientColor.g = vAmbient.y * mv_lightMultiplier; - rp.AmbientColor.b = vAmbient.z * mv_lightMultiplier; - rp.AmbientColor.a = 1; - - rp.nDLightMask = 7; - if (mv_lighting == false) - { - rp.nDLightMask = 0; - } - - rp.dwFObjFlags = 0; - - //----------------------------------------------------------------------------- - //----- Render Static Object (handled by 3DEngine) ---- - //----------------------------------------------------------------------------- - if (m_object) - { - m_object->Render(rp, passInfo); - if (mv_showGrid) - { - DrawFloorGrid(Quat(IDENTITY), Vec3(ZERO), Matrix33(IDENTITY)); - } - - if (mv_showBase) - { - DrawCoordSystem(IDENTITY, 10.0f); - } - } - - m_renderer->EF_EndEf3D(SHDF_STREAM_SYNC, -1, -1, passInfo); -} - - -void CModelViewport::DrawLights(const SRenderingPassInfo& passInfo) -{ - if (mv_animateLights) - { - m_LightRotationRadian += m_AverageFrameTime; - } - - if (m_LightRotationRadian > gf_PI) - { - m_LightRotationRadian = -gf_PI; - } - - Matrix33 LightRot33 = Matrix33::CreateRotationZ(m_LightRotationRadian); - - Vec3 LPos0 = Vec3(-mv_lightOrbit, mv_lightOrbit, mv_lightOrbit); - m_VPLight.SetPosition(LightRot33 * LPos0 + m_PhysicalLocation.t); - Vec3 d = mv_lightDiffuseColor; - m_VPLight.SetLightColor(ColorF(d.x * mv_lightMultiplier, d.y * mv_lightMultiplier, d.z * mv_lightMultiplier, 0)); - m_VPLight.SetSpecularMult(mv_lightSpecMultiplier); - m_VPLight.m_fRadius = mv_lightRadius; - m_VPLight.m_Flags = DLF_SUN | DLF_DIRECTIONAL; - - if (mv_lighting == true) - { - m_renderer->EF_ADDDlight(&m_VPLight, passInfo); - } -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::PlayAnimation([[maybe_unused]] const char* szName) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::DrawFloorGrid(const Quat& m33, const Vec3& vPhysicalLocation, const Matrix33& rGridRot) -{ - if (!m_renderer) - { - return; - } - - float XR = 45; - float YR = 45; - - - - - - IRenderAuxGeom* pAuxGeom = m_renderer->GetIRenderAuxGeom(); - pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags); - - Vec3 axis = m33.GetColumn0(); - - Matrix33 SlopeMat33 = rGridRot; - uint32 GroundAlign = 1; - if (GroundAlign == 0) - { - SlopeMat33 = Matrix33::CreateRotationAA(m_absCurrentSlope, axis); - } - - - m_GridOrigin = Vec3(floorf(vPhysicalLocation.x), floorf(vPhysicalLocation.y), vPhysicalLocation.z); - - - Matrix33 ScaleMat33 = IDENTITY; - Vec3 rh = Matrix33::CreateRotationY(m_absCurrentSlope) * Vec3(1.0f, 0.0f, 0.0f); - if (rh.x) - { - Vec3 xback = SlopeMat33.GetRow(0); - Vec3 yback = SlopeMat33.GetRow(1); - f32 ratiox = 1.0f / Vec3(xback.x, xback.y, 0.0f).GetLength(); - f32 ratioy = 1.0f / Vec3(yback.x, yback.y, 0.0f).GetLength(); - - f32 ratio = 1.0f / rh.x; - // Vec3 h=Vec3((m_GridOrigin.x-vPhysicalLocation.x)*ratiox,(m_GridOrigin.y-vPhysicalLocation.y)*ratioy,0.0f); - Vec3 h = Vec3(m_GridOrigin.x - vPhysicalLocation.x, m_GridOrigin.y - vPhysicalLocation.y, 0.0f); - Vec3 nh = SlopeMat33 * h; - m_GridOrigin.z += nh.z * ratio; - - ScaleMat33 = Matrix33::CreateScale(Vec3(ratiox, ratioy, 0.0f)); - - // float color1[4] = {0,1,0,1}; - // m_renderer->Draw2dLabel(12,g_ypos,1.6f,color1,false,"h: %f %f %f h.z: %f ratio: %f ratiox: %f ratioy: %f",h.x,h.y,h.z, nh.z,ratio,ratiox,ratioy); - // g_ypos+=18; - } - - Matrix33 _m33; - _m33.SetIdentity(); - AABB aabb1 = AABB(Vec3(-0.03f, -YR, -0.001f), Vec3(0.03f, YR, 0.001f)); - OBB _obb1 = OBB::CreateOBBfromAABB(SlopeMat33, aabb1); - AABB aabb2 = AABB(Vec3(-XR, -0.03f, -0.001f), Vec3(XR, 0.03f, 0.001f)); - OBB _obb2 = OBB::CreateOBBfromAABB(SlopeMat33, aabb2); - - SlopeMat33 = SlopeMat33 * ScaleMat33; - // Draw grid. - float step = 0.25f; - for (float x = -XR; x < XR; x += step) - { - Vec3 p0 = Vec3(x, -YR, 0); - Vec3 p1 = Vec3(x, YR, 0); - //pAuxGeom->DrawLine( SlopeMat33*p0,RGBA8(0x7f,0x7f,0x7f,0x00), SlopeMat33*p1,RGBA8(0x7f,0x7f,0x7f,0x00) ); - int32 intx = int32(x); - if (fabsf(intx - x) < 0.001f) - { - pAuxGeom->DrawOBB(_obb1, SlopeMat33 * Vec3(x, 0.0f, 0.0f) + m_GridOrigin, 1, RGBA8(0x9f, 0x9f, 0x9f, 0x00), eBBD_Faceted); - } - else - { - pAuxGeom->DrawLine(SlopeMat33 * p0 + m_GridOrigin, RGBA8(0x7f, 0x7f, 0x7f, 0x00), SlopeMat33 * p1 + m_GridOrigin, RGBA8(0x7f, 0x7f, 0x7f, 0x00)); - } - } - - for (float y = -YR; y < YR; y += step) - { - Vec3 p0 = Vec3(-XR, y, 0); - Vec3 p1 = Vec3(XR, y, 0); - // pAuxGeom->DrawLine( SlopeMat33*p0,RGBA8(0x7f,0x7f,0x7f,0x00), SlopeMat33*p1,RGBA8(0x7f,0x7f,0x7f,0x00) ); - int32 inty = int32(y); - if (fabsf(inty - y) < 0.001f) - { - pAuxGeom->DrawOBB(_obb2, SlopeMat33 * Vec3(0.0f, y, 0.0f) + m_GridOrigin, 1, RGBA8(0x9f, 0x9f, 0x9f, 0x00), eBBD_Faceted); - } - else - { - pAuxGeom->DrawLine(SlopeMat33 * p0 + m_GridOrigin, RGBA8(0x7f, 0x7f, 0x7f, 0x00), SlopeMat33 * p1 + m_GridOrigin, RGBA8(0x7f, 0x7f, 0x7f, 0x00)); - } - } - - // TODO - the grid should probably be an IRenderNode at some point - // flushing grid geometry now so it will not override transparent - // objects later in the render pipeline. - pAuxGeom->Commit(); -} - - -//-------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------- -void CModelViewport::DrawCoordSystem(const QuatT& location, f32 length) -{ - IRenderAuxGeom* pAuxGeom = m_renderer->GetIRenderAuxGeom(); - SAuxGeomRenderFlags renderFlags(e_Def3DPublicRenderflags); - pAuxGeom->SetRenderFlags(renderFlags); - - Vec3 absAxisX = location.q.GetColumn0(); - Vec3 absAxisY = location.q.GetColumn1(); - Vec3 absAxisZ = location.q.GetColumn2(); - - const f32 scale = 3.0f; - const f32 size = 0.009f; - AABB xaabb = AABB(Vec3(-length * scale, -size * scale, -size * scale), Vec3(length * scale, size * scale, size * scale)); - AABB yaabb = AABB(Vec3(-size * scale, -length * scale, -size * scale), Vec3(size * scale, length * scale, size * scale)); - AABB zaabb = AABB(Vec3(-size * scale, -size * scale, -length * scale), Vec3(size * scale, size * scale, length * scale)); - - OBB obb; - obb = OBB::CreateOBBfromAABB(Matrix33(location.q), xaabb); - pAuxGeom->DrawOBB(obb, location.t, 1, RGBA8(0xff, 0x00, 0x00, 0xff), eBBD_Extremes_Color_Encoded); - pAuxGeom->DrawCone(location.t + absAxisX * length * scale, absAxisX, 0.03f * scale, 0.15f * scale, RGBA8(0xff, 0x00, 0x00, 0xff)); - - obb = OBB::CreateOBBfromAABB(Matrix33(location.q), yaabb); - pAuxGeom->DrawOBB(obb, location.t, 1, RGBA8(0x00, 0xff, 0x00, 0xff), eBBD_Extremes_Color_Encoded); - pAuxGeom->DrawCone(location.t + absAxisY * length * scale, absAxisY, 0.03f * scale, 0.15f * scale, RGBA8(0x00, 0xff, 0x00, 0xff)); - - obb = OBB::CreateOBBfromAABB(Matrix33(location.q), zaabb); - pAuxGeom->DrawOBB(obb, location.t, 1, RGBA8(0x00, 0x00, 0xff, 0xff), eBBD_Extremes_Color_Encoded); - pAuxGeom->DrawCone(location.t + absAxisZ * length * scale, absAxisZ, 0.03f * scale, 0.15f * scale, RGBA8(0x00, 0x00, 0xff, 0xff)); -} - - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::OnLightMultiplier([[maybe_unused]] IVariable* var) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CModelViewport::SetSelected(bool const bSelect) -{ - // If a modelviewport gets activated, and listeners will be activated, disable the main viewport listener and re-enable when you lose focus. - if (gEnv->pSystem) - { - IViewSystem* const pIViewSystem = gEnv->pSystem->GetIViewSystem(); - - if (pIViewSystem) - { - pIViewSystem->SetControlAudioListeners(!bSelect); - } - } -} - -#include diff --git a/Code/Sandbox/Editor/ModelViewport.h b/Code/Sandbox/Editor/ModelViewport.h deleted file mode 100644 index a5d1ac2a26..0000000000 --- a/Code/Sandbox/Editor/ModelViewport.h +++ /dev/null @@ -1,258 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#pragma once -//////////////////////////////////////////////////////////////////////////// -// -// Crytek Engine Source File. -// Copyright (C), Crytek Studios, 2001. -// ------------------------------------------------------------------------- -// File name: ModelViewport.h -// Version: v1.00 -// Created: 8/10/2001 by Timur. -// Compilers: Visual C++ 6.0 -// Description: -// ------------------------------------------------------------------------- -// History: -// -//////////////////////////////////////////////////////////////////////////// -#ifndef CRYINCLUDE_EDITOR_MODELVIEWPORT_H -#define CRYINCLUDE_EDITOR_MODELVIEWPORT_H - -#if !defined(Q_MOC_RUN) -#include "RenderViewport.h" -#include "Util/Variable.h" -#endif - -struct IPhysicalEntity; - -///////////////////////////////////////////////////////////////////////////// -AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING -// CModelViewport window -class SANDBOX_API CModelViewport - : public CRenderViewport -{ -AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING - Q_OBJECT - // Construction -public: - CModelViewport(const char* settingsPath = "Settings\\CharacterEditorUserOptions", QWidget* parent = nullptr); - virtual ~CModelViewport(); - - virtual EViewportType GetType() const { return ET_ViewportModel; } - virtual void SetType([[maybe_unused]] EViewportType type) { assert(type == ET_ViewportModel); }; - - virtual void LoadObject(const QString& obj, float scale); - - virtual void OnActivate(); - virtual void OnDeactivate(); - - virtual bool CanDrop(const QPoint& point, IDataBaseItem* pItem); - virtual void Drop(const QPoint& point, IDataBaseItem* pItem); - - virtual void SetSelected(bool const bSelect); - - // Callbacks. - void OnShowShaders(IVariable* var); - void OnShowNormals(IVariable* var); - void OnShowTangents(IVariable* var); - - void OnShowPortals(IVariable* var); - void OnShowShadowVolumes(IVariable* var); - void OnShowTextureUsage(IVariable* var); - void OnCharPhysics(IVariable* var); - void OnShowOcclusion(IVariable* var); - - void OnLightColor(IVariable* var); - void OnLightMultiplier(IVariable* var); - void OnDisableVisibility(IVariable* var); - - IStatObj* GetStaticObject(){ return m_object; } - - void GetOnDisableVisibility(IVariable* var); - - const CVarObject* GetVarObject() const { return &m_vars; } - CVarObject* GetVarObject() { return &m_vars; } - - virtual void Update(); - - - void UseWeaponIK([[maybe_unused]] bool val) { m_weaponIK = true; } - - void ReleaseObject(); - void RePhysicalize(); - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - Vec3 m_GridOrigin; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - void SetPaused(bool bPaused); - bool GetPaused() {return m_bPaused; } - - bool IsCameraAttached() const{ return mv_AttachCamera; } - - virtual void PlayAnimation(const char* szName); - - const QString& GetLoadedFileName() const { return m_loadedFile; } - - void Physicalize(); - -protected: - - void LoadStaticObject(const QString& file); - - // Called to render stuff. - virtual void OnRender(); - - virtual void DrawFloorGrid(const Quat& tmRotation, const Vec3& MotionTranslation, const Matrix33& rGridRot); - void DrawCoordSystem(const QuatT& q, f32 length); - - void SaveDebugOptions() const; - void RestoreDebugOptions(); - - virtual void DrawModel(const SRenderingPassInfo& passInfo); - virtual void DrawLights(const SRenderingPassInfo& passInfo); - virtual void DrawSkyBox(const SRenderingPassInfo& passInfo); - - void DrawInfo() const; - - void SetConsoleVar(const char* var, int value); - - void OnEditorNotifyEvent(EEditorNotifyEvent event) - { - if (event != eNotify_OnBeginGameMode) - { - // the base class responds to this by forcing itself to be the current context. - // we don't want that to be the case for previewer viewports. - CRenderViewport::OnEditorNotifyEvent(event); - } - } - - IStatObj* m_object; - IStatObj* m_weaponModel; - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - - QString m_attachBone; - AABB m_AABB; - - struct BBox - { - OBB obb; - Vec3 pos; - ColorB col; - }; - std::vector m_arrBBoxes; - - // Camera control. - float m_camRadius; - - // True to show grid. - bool m_bGrid; - bool m_bBase; - - QString m_settingsPath; - - bool m_weaponIK; - - QString m_loadedFile; - CDLight m_VPLight; - - f32 m_LightRotationRadian; - - class CRESky* m_pRESky; - struct ICVar* m_pSkyboxName; - IShader* m_pSkyBoxShader; - - //--------------------------------------------------- - //--- debug options --- - //--------------------------------------------------- - CVariable mv_showGrid; - CVariable mv_showBase; - CVariable mv_showLocator; - CVariable mv_InPlaceMovement; - CVariable mv_StrafingControl; - - CVariable mv_showWireframe1; //draw wireframe instead of solid-geometry. - CVariable mv_showWireframe2; //this one is software-wireframe rendered on top of the solid geometry - CVariable mv_showTangents; - CVariable mv_showBinormals; - CVariable mv_showNormals; - - CVariable mv_showSkeleton; - CVariable mv_showJointNames; - CVariable mv_showJointsValues; - CVariable mv_showStartLocation; - CVariable mv_showMotionParam; - CVariable mv_UniformScaling; - - CVariable mv_printDebugText; - CVariable mv_AttachCamera; - - CVariable mv_showShaders; - - CVariable mv_lighting; - CVariable mv_animateLights; - - CVariable mv_backgroundColor; - CVariable mv_objectAmbientColor; - - CVariable mv_lightDiffuseColor; - CVariable mv_lightMultiplier; - CVariable mv_lightSpecMultiplier; - CVariable mv_lightRadius; - CVariable mv_lightOrbit; - - CVariable mv_fov; - CVariable mv_showPhysics; - CVariable mv_useCharPhysics; - CVariable mv_showPhysicsTetriders; - CVariable mv_forceLODNum; - - CVariableArray mv_advancedTable; - - CVarObject m_vars; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -public slots: - virtual void OnAnimPlay(); - virtual void OnAnimBack(); - virtual void OnAnimFastBack(); - virtual void OnAnimFastForward(); - virtual void OnAnimFront(); -protected: - bool m_bPaused; - - void OnDestroy(); - void mouseDoubleClickEvent(QMouseEvent* event) override; - -private: - struct VariableCallbackIndex - { - enum : unsigned char - { - OnCharPhysics = 0, - OnLightColor, - OnLightMultiplier, - OnShowShaders, - - // must be at the end - Count, - }; - }; -AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - AZStd::fixed_vector< IVariable::OnSetCallback, VariableCallbackIndex::Count > m_onSetCallbacksCache; -AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - -#endif // CRYINCLUDE_EDITOR_MODELVIEWPORT_H diff --git a/Code/Sandbox/Editor/ModelViewportDC.cpp b/Code/Sandbox/Editor/ModelViewportDC.cpp deleted file mode 100644 index 9424a12c0c..0000000000 --- a/Code/Sandbox/Editor/ModelViewportDC.cpp +++ /dev/null @@ -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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - - - - - - - - - - diff --git a/Code/Sandbox/Editor/Objects/BaseObject.cpp b/Code/Sandbox/Editor/Objects/BaseObject.cpp index 109b28798f..3ec505172e 100644 --- a/Code/Sandbox/Editor/Objects/BaseObject.cpp +++ b/Code/Sandbox/Editor/Objects/BaseObject.cpp @@ -37,6 +37,8 @@ #include "ViewManager.h" #include "IEditorImpl.h" #include "GameEngine.h" +#include +#include // To use the Andrew's algorithm in order to make convex hull from the points, this header is needed. #include "Util/GeometryUtil.h" @@ -821,9 +823,8 @@ void CBaseObject::GetLocalBounds(AABB& box) } ////////////////////////////////////////////////////////////////////////// -void CBaseObject::SetModified(bool boModifiedTransformOnly) +void CBaseObject::SetModified(bool) { - ((CObjectManager*)GetObjectManager())->OnObjectModified(this, false, boModifiedTransformOnly); } void CBaseObject::DrawDefault(DisplayContext& dc, const QColor& labelColor) diff --git a/Code/Sandbox/Editor/Objects/BaseObject.h b/Code/Sandbox/Editor/Objects/BaseObject.h index 44df1e5757..5d6f800a58 100644 --- a/Code/Sandbox/Editor/Objects/BaseObject.h +++ b/Code/Sandbox/Editor/Objects/BaseObject.h @@ -35,7 +35,6 @@ class CUndoBaseObject; class CObjectManager; class CGizmo; class CObjectArchive; -class CEdGeometry; struct SSubObjSelectionModifyContext; struct SRayHitInfo; class ISubObjectSelectionReferenceFrameCalculator; @@ -580,10 +579,6 @@ public: virtual void ModifySubObjSelection([[maybe_unused]] SSubObjSelectionModifyContext& modCtx) {}; virtual void AcceptSubObjectModify() {}; - // Request a geometry pointer from the object. - // Return NULL if geometry can not be retrieved or object does not support geometries. - virtual CEdGeometry* GetGeometry() { return 0; }; - //! In This function variables of the object must be initialized. virtual void InitVariables() {}; diff --git a/Code/Sandbox/Editor/Objects/DisplayContext.h b/Code/Sandbox/Editor/Objects/DisplayContext.h index a8181e1d1b..13363a923e 100644 --- a/Code/Sandbox/Editor/Objects/DisplayContext.h +++ b/Code/Sandbox/Editor/Objects/DisplayContext.h @@ -33,7 +33,6 @@ struct IDisplayViewport; struct IRenderer; struct IRenderAuxGeom; struct IIconManager; -struct I3DEngine; class CDisplaySettings; class CCamera; @@ -70,7 +69,6 @@ struct SANDBOX_API DisplayContext IRenderer* renderer; IRenderAuxGeom* pRenderAuxGeom; IIconManager* pIconManager; - I3DEngine* engine; CCamera* camera; AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING AABB box; // Bounding box of volume that need to be repainted. diff --git a/Code/Sandbox/Editor/Objects/DisplayContextShared.inl b/Code/Sandbox/Editor/Objects/DisplayContextShared.inl index dd5c248357..4d284faea7 100644 --- a/Code/Sandbox/Editor/Objects/DisplayContextShared.inl +++ b/Code/Sandbox/Editor/Objects/DisplayContextShared.inl @@ -18,8 +18,6 @@ #include "Include/IIconManager.h" #include "Include/IDisplayViewport.h" -#include - #include #include @@ -32,7 +30,6 @@ DisplayContext::DisplayContext() { view = 0; renderer = 0; - engine = 0; flags = 0; settings = 0; pIconManager = 0; @@ -981,27 +978,8 @@ void DisplayContext::RenderObject(int objectType, const Vec3& pos, float scale) } ////////////////////////////////////////////////////////////////////////// -void DisplayContext::RenderObject(int objectType, const Matrix34& tm) +void DisplayContext::RenderObject(int, const Matrix34&) { - IStatObj* object = pIconManager ? pIconManager->GetObject((EStatObject)objectType) : 0; - if (object) - { - float color[4]; - color[0] = m_color4b.r * (1.0f / 255.0f); - color[1] = m_color4b.g * (1.0f / 255.0f); - color[2] = m_color4b.b * (1.0f / 255.0f); - color[3] = m_color4b.a * (1.0f / 255.0f); - - SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(GetIEditor()->GetSystem()->GetViewCamera()); - - Matrix34 xform = m_matrixStack[m_currentMatrix] * tm; - SRendParams rp; - rp.pMatrix = &xform; - rp.AmbientColor = ColorF(color[0], color[1], color[2], 1); - rp.fAlpha = color[3]; - - object->Render(rp, passInfo); - } } ///////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Objects/EntityObject.cpp b/Code/Sandbox/Editor/Objects/EntityObject.cpp index 0b2627091c..17e9fdda5c 100644 --- a/Code/Sandbox/Editor/Objects/EntityObject.cpp +++ b/Code/Sandbox/Editor/Objects/EntityObject.cpp @@ -32,6 +32,8 @@ #include "HitContext.h" #include "Objects/SelectionGroup.h" +#include +#include ////////////////////////////////////////////////////////////////////////// //! Undo Entity Link @@ -1926,55 +1928,6 @@ void CEntityObject::OnContextMenu(QMenu* pMenu) CBaseObject::OnContextMenu(pMenu); } -////////////////////////////////////////////////////////////////////////// -IOpticsElementBasePtr CEntityObject::GetOpticsElement() -{ - CDLight* pLight = GetLightProperty(); - if (pLight == NULL) - { - return NULL; - } - return pLight->GetLensOpticsElement(); -} - -////////////////////////////////////////////////////////////////////////// -void CEntityObject::SetOpticsName(const QString& opticsFullName) -{ - if (opticsFullName.isEmpty()) - { - CDLight* pLight = GetLightProperty(); - if (pLight) - { - pLight->SetLensOpticsElement(NULL); - } - } -} - -////////////////////////////////////////////////////////////////////////// -CDLight* CEntityObject::GetLightProperty() const -{ - const PodArray* pLightEntities = GetIEditor()->Get3DEngine()->GetLightEntities(); - if (pLightEntities == NULL) - { - return NULL; - } - for (int i = 0, iLightSize(pLightEntities->Count()); i < iLightSize; ++i) - { - ILightSource* pLightSource = pLightEntities->GetAt(i); - if (pLightSource == NULL) - { - continue; - } - CDLight& lightProperty = pLightSource->GetLightProperties(); - if (GetName() != lightProperty.m_sName) - { - continue; - } - return &lightProperty; - } - return NULL; -} - ////////////////////////////////////////////////////////////////////////// void CEntityObject::PreInitLightProperty() { diff --git a/Code/Sandbox/Editor/Objects/EntityObject.h b/Code/Sandbox/Editor/Objects/EntityObject.h index a287cd8828..85368f7804 100644 --- a/Code/Sandbox/Editor/Objects/EntityObject.h +++ b/Code/Sandbox/Editor/Objects/EntityObject.h @@ -214,8 +214,6 @@ public: QString GetLightAnimation() const; IVariable* GetLightVariable(const char* name) const; - IOpticsElementBasePtr GetOpticsElement(); - void SetOpticsName(const QString& opticsFullName); void PreInitLightProperty(); void UpdateLightProperty(); @@ -230,8 +228,6 @@ public: void RegisterListener(IEntityObjectListener* pListener); void UnregisterListener(IEntityObjectListener* pListener); - CDLight* GetLightProperty() const; - protected: template void SetEntityProperty(const char* name, T value); diff --git a/Code/Sandbox/Editor/Objects/ObjectManager.cpp b/Code/Sandbox/Editor/Objects/ObjectManager.cpp index 39174774be..d383fb0e1b 100644 --- a/Code/Sandbox/Editor/Objects/ObjectManager.cpp +++ b/Code/Sandbox/Editor/Objects/ObjectManager.cpp @@ -400,8 +400,6 @@ void CObjectManager::DeleteObject(CBaseObject* obj) CUndo::Record(new CUndoBaseObjectDelete(obj)); } - OnObjectModified(obj, true, false); - AABB objAAB; obj->GetBoundBox(objAAB); GetIEditor()->GetGameEngine()->OnAreaModified(objAAB); @@ -2477,17 +2475,6 @@ IGizmoManager* CObjectManager::GetGizmoManager() return m_gizmoManager; } -////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -void CObjectManager::OnObjectModified(CBaseObject* pObject, [[maybe_unused]] bool bDelete, [[maybe_unused]] bool boModifiedTransformOnly) -{ - if (IRenderNode* pRenderNode = pObject->GetEngineNode()) - { - GetIEditor()->Get3DEngine()->OnObjectModified(pRenderNode, pRenderNode->GetRndFlags()); - } -} - ////////////////////////////////////////////////////////////////////////// bool CObjectManager::IsLightClass(CBaseObject* pObject) { diff --git a/Code/Sandbox/Editor/Objects/ObjectManager.h b/Code/Sandbox/Editor/Objects/ObjectManager.h index 26905c47cd..4939fdeefc 100644 --- a/Code/Sandbox/Editor/Objects/ObjectManager.h +++ b/Code/Sandbox/Editor/Objects/ObjectManager.h @@ -326,9 +326,6 @@ public: // Gathers all resources used by all objects. void GatherUsedResources(CUsedResources& resources); - // Called when object gets modified. - void OnObjectModified(CBaseObject* pObject, bool bDelete, bool boModifiedTransformOnly); - virtual bool IsLightClass(CBaseObject* pObject); virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue); diff --git a/Code/Sandbox/Editor/Objects/SelectionGroup.cpp b/Code/Sandbox/Editor/Objects/SelectionGroup.cpp index 08abf8f763..98e00645ee 100644 --- a/Code/Sandbox/Editor/Objects/SelectionGroup.cpp +++ b/Code/Sandbox/Editor/Objects/SelectionGroup.cpp @@ -22,6 +22,7 @@ #include "ViewManager.h" #include "Include/IObjectManager.h" +#include ////////////////////////////////////////////////////////////////////////// CSelectionGroup::CSelectionGroup() diff --git a/Code/Sandbox/Editor/PanelPreview.cpp b/Code/Sandbox/Editor/PanelPreview.cpp deleted file mode 100644 index fe5ea7be9b..0000000000 --- a/Code/Sandbox/Editor/PanelPreview.cpp +++ /dev/null @@ -1,42 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "PanelPreview.h" - -// Qt -#include - -// CPanelPreview dialog - -CPanelPreview::CPanelPreview(QWidget* pParent /*=nullptr*/) - : QWidget(pParent) - , m_previewCtrl(new CPreviewModelCtrl(this)) -{ - QBoxLayout* layout = new QHBoxLayout; - layout->setMargin(0); - layout->addWidget(m_previewCtrl); - setLayout(layout); -} - -////////////////////////////////////////////////////////////////////////// -void CPanelPreview::LoadFile(const QString& filename) -{ - if (!filename.isEmpty()) - { - m_previewCtrl->EnableUpdate(false); - m_previewCtrl->LoadFile(filename, false); - } -} - diff --git a/Code/Sandbox/Editor/PanelPreview.h b/Code/Sandbox/Editor/PanelPreview.h deleted file mode 100644 index d2c951ba4e..0000000000 --- a/Code/Sandbox/Editor/PanelPreview.h +++ /dev/null @@ -1,40 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_PANELPREVIEW_H -#define CRYINCLUDE_EDITOR_PANELPREVIEW_H -#pragma once - -// CPanelPreview dialog - -#include "Controls/PreviewModelCtrl.h" - - -class CPanelPreview - : public QWidget -{ -public: - CPanelPreview(QWidget* pParent = nullptr); // standard constructor - - void LoadFile(const QString& filename); - - QSize sizeHint() const override - { - return QSize(130, 240); - } - -protected: - CPreviewModelCtrl* m_previewCtrl; -}; - -#endif // CRYINCLUDE_EDITOR_PANELPREVIEW_H diff --git a/Code/Sandbox/Editor/RenderViewport.cpp b/Code/Sandbox/Editor/RenderViewport.cpp index 3e726f2468..49064b5bc5 100644 --- a/Code/Sandbox/Editor/RenderViewport.cpp +++ b/Code/Sandbox/Editor/RenderViewport.cpp @@ -55,7 +55,6 @@ // CryCommon -#include #include // AzFramework @@ -89,6 +88,10 @@ #include +#include +#include +#include + AZ_CVAR( bool, ed_visibility_use, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Enable/disable using the new IVisibilitySystem for Entity visibility determination"); @@ -249,10 +252,6 @@ CRenderViewport::~CRenderViewport() ////////////////////////////////////////////////////////////////////////// int CRenderViewport::OnCreate() { - m_renderer = GetIEditor()->GetRenderer(); - m_engine = GetIEditor()->Get3DEngine(); - assert(m_engine); - CreateRenderContext(); return 0; @@ -1033,7 +1032,7 @@ void CRenderViewport::Update() return; } - if (!m_renderer || !m_engine || m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode()) + if (!m_renderer || m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode()) { return; } @@ -1101,7 +1100,7 @@ void CRenderViewport::Update() AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; AzFramework::DebugDisplayRequestBus::Bind( - debugDisplayBus, AzToolsFramework::ViewportInteraction::g_mainViewportEntityDebugDisplayId); + debugDisplayBus, AzFramework::g_defaultSceneEntityDebugDisplayId); AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus."); AzFramework::DebugDisplayRequests* debugDisplay = @@ -1156,9 +1155,6 @@ void CRenderViewport::Update() m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f)); - // 3D engine stats - GetIEditor()->GetSystem()->RenderBegin(); - InitDisplayContext(); OnRender(); @@ -1184,8 +1180,6 @@ void CRenderViewport::Update() } } - GetIEditor()->GetSystem()->RenderEnd(m_bRenderStats); - gEnv->pSystem->SetViewCamera(CurCamera); } @@ -1421,8 +1415,6 @@ void CRenderViewport::OnRender() // This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation // are still able to manipulate the current logical camera position, even if nothing is rendered. GetIEditor()->GetSystem()->SetViewCamera(m_Camera); - GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera()); - m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__); return; } @@ -1495,7 +1487,7 @@ void CRenderViewport::OnRender() } } - m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance()); + m_Camera.SetFrustum(w, h, fov, fNearZ); } GetIEditor()->GetSystem()->SetViewCamera(m_Camera); @@ -1531,7 +1523,7 @@ void CRenderViewport::OnRender() AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; AzFramework::DebugDisplayRequestBus::Bind( - debugDisplayBus, AzToolsFramework::ViewportInteraction::g_mainViewportEntityDebugDisplayId); + debugDisplayBus, AzFramework::g_defaultSceneEntityDebugDisplayId); AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus."); AzFramework::DebugDisplayRequests* debugDisplay = @@ -1556,11 +1548,6 @@ void CRenderViewport::OnRender() m_renderer->ClearTargetsLater(FRT_CLEAR_COLOR, viewportBackgroundColor); DrawBackground(); } - - if (!m_renderer->IsStereoEnabled()) - { - GetIEditor()->GetSystem()->RenderStatistics(); - } } ////////////////////////////////////////////////////////////////////////// @@ -1590,7 +1577,6 @@ void CRenderViewport::InitDisplayContext() displayContext.settings = GetIEditor()->GetDisplaySettings(); displayContext.view = this; displayContext.renderer = m_renderer; - displayContext.engine = m_engine; displayContext.box.min = Vec3(-100000.0f, -100000.0f, -100000.0f); displayContext.box.max = Vec3(100000.0f, 100000.0f, 100000.0f); displayContext.camera = &m_Camera; @@ -1669,7 +1655,7 @@ void CRenderViewport::RenderAll() AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; AzFramework::DebugDisplayRequestBus::Bind( - debugDisplayBus, AzToolsFramework::ViewportInteraction::g_mainViewportEntityDebugDisplayId); + debugDisplayBus, AzFramework::g_defaultSceneEntityDebugDisplayId); AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus."); AzFramework::DebugDisplayRequests* debugDisplay = @@ -2031,14 +2017,14 @@ float CRenderViewport::AngleStep() return GetViewManager()->GetGrid()->GetAngleSnap(); } -AZ::Vector3 CRenderViewport::PickTerrain(const QPoint& point) +AZ::Vector3 CRenderViewport::PickTerrain(const AzFramework::ScreenPoint& point) { FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true)); + return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true)); } -AZ::EntityId CRenderViewport::PickEntity(const QPoint& point) +AZ::EntityId CRenderViewport::PickEntity(const AzFramework::ScreenPoint& point) { FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); @@ -2047,7 +2033,7 @@ AZ::EntityId CRenderViewport::PickEntity(const QPoint& point) AZ::EntityId entityId; HitContext hitInfo; hitInfo.view = this; - if (HitTest(point, hitInfo)) + if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo)) { if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY)) { @@ -2088,12 +2074,13 @@ void CRenderViewport::FindVisibleEntities(AZStd::vector& visibleEn } } -QPoint CRenderViewport::ViewportWorldToScreen(const AZ::Vector3& worldPosition) +AzFramework::ScreenPoint CRenderViewport::ViewportWorldToScreen(const AZ::Vector3& worldPosition) { FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); PreWidgetRendering(); - const QPoint screenPosition = WorldToView(AZVec3ToLYVec3(worldPosition)); + const AzFramework::ScreenPoint screenPosition = + AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(WorldToView(AZVec3ToLYVec3(worldPosition))); PostWidgetRendering(); return screenPosition; @@ -2466,7 +2453,6 @@ void CRenderViewport::ToggleCameraObject() { if (m_viewSourceType == ViewSourceType::SequenceCamera) { - gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f); ResetToViewSourceType(ViewSourceType::LegacyCamera); } else @@ -2788,11 +2774,6 @@ void CRenderViewport::SetViewTM(const Matrix34& viewTM, bool bMoveOnly) ////////////////////////////////////////////////////////////////////////// void CRenderViewport::RenderSelectedRegion() { - if (!m_engine) - { - return; - } - AABB box; GetIEditor()->GetSelectedRegion(box); if (box.IsEmpty()) @@ -3384,19 +3365,9 @@ bool CRenderViewport::AdjustObjectPosition(const ray_hit& hit, Vec3& outNormal, } ////////////////////////////////////////////////////////////////////////// -bool CRenderViewport::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const +bool CRenderViewport::RayRenderMeshIntersection(IRenderMesh*, const Vec3&, const Vec3&, Vec3&, Vec3&) const { - SRayHitInfo hitInfo; - hitInfo.bUseCache = false; - hitInfo.bInFirstHit = false; - hitInfo.inRay.origin = vInPos; - hitInfo.inRay.direction = vInDir.GetNormalized(); - hitInfo.inReferencePoint = vInPos; - hitInfo.fMaxHitDistance = 0; - bool bRes = GetIEditor()->Get3DEngine()->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr); - vOutPos = hitInfo.vHitPos; - vOutNormal = hitInfo.vHitNormal; - return bRes; + return false; } ////////////////////////////////////////////////////////////////////////// @@ -3681,7 +3652,6 @@ void CRenderViewport::SetDefaultCamera() return; } ResetToViewSourceType(ViewSourceType::None); - gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f); GetViewManager()->SetCameraObjectId(m_cameraObjectId); SetName(m_defaultViewName); SetViewTM(m_defaultViewTM); @@ -3860,23 +3830,8 @@ void CRenderViewport::SetViewAndMovementLockFromEntityPerspective(const AZ::Enti bool CRenderViewport::GetActiveCameraPosition(AZ::Vector3& cameraPos) { - if (m_pPrimaryViewport == this) - { - if (GetIEditor()->IsInGameMode()) - { - const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition(); - cameraPos = LYVec3ToAZVec3(camPos); - } - else - { - // Use viewTM, which is synced with the camera and guaranteed to be up-to-date - cameraPos = LYVec3ToAZVec3(m_viewTM.GetTranslation()); - } - - return true; - } - - return false; + cameraPos = LYVec3ToAZVec3(m_viewTM.GetTranslation()); + return true; } bool CRenderViewport::GetActiveCameraState(AzFramework::CameraState& cameraState) @@ -3885,9 +3840,7 @@ bool CRenderViewport::GetActiveCameraState(AzFramework::CameraState& cameraState { if (GetIEditor()->IsInGameMode()) { - const auto& renderingCamera = m_engine->GetRenderingCamera(); - cameraState = CameraStateFromCCamera( - renderingCamera, renderingCamera.GetFov(), m_rcClient.width(), m_rcClient.height()); + return false; } else { @@ -3959,18 +3912,6 @@ void CRenderViewport::RenderConstructionPlane() Ang3 angles = Ang3(pGrid->rotationAngles.x * gf_PI / 180.0, pGrid->rotationAngles.y * gf_PI / 180.0, pGrid->rotationAngles.z * gf_PI / 180.0); Matrix34 tm = Matrix33::CreateRotationXYZ(angles); - if (gSettings.snap.bGridGetFromSelected) - { - CSelectionGroup* sel = GetIEditor()->GetSelection(); - if (sel->GetCount() > 0) - { - CBaseObject* obj = sel->GetObject(0); - tm = obj->GetWorldTM(); - tm.OrthonormalizeFast(); - tm.SetTranslation(Vec3(0, 0, 0)); - } - } - u = tm * u; v = tm * v; } @@ -4025,11 +3966,6 @@ void CRenderViewport::RenderConstructionPlane() void CRenderViewport::RenderSnappingGrid() { // First, Check whether we should draw the grid or not. - CSelectionGroup* pSelGroup = GetIEditor()->GetSelection(); - if (pSelGroup == nullptr || pSelGroup->GetCount() != 1) - { - return; - } CGrid* pGrid = GetViewManager()->GetGrid(); if (pGrid->IsEnabled() == false && pGrid->IsAngleSnapEnabled() == false) { diff --git a/Code/Sandbox/Editor/RenderViewport.h b/Code/Sandbox/Editor/RenderViewport.h index 2edbd86770..d70dd59b98 100644 --- a/Code/Sandbox/Editor/RenderViewport.h +++ b/Code/Sandbox/Editor/RenderViewport.h @@ -190,17 +190,24 @@ public: bool ShowGrid() override; bool AngleSnappingEnabled() override; float AngleStep() override; - QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override; - AZStd::optional ViewportScreenToWorld(const QPoint&, float) override { return {}; } - AZStd::optional ViewportScreenToWorldRay(const QPoint&) override { return {}; } + AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override; + AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint&, float) override + { + return {}; + } + AZStd::optional ViewportScreenToWorldRay( + const AzFramework::ScreenPoint&) override + { + return {}; + } // AzToolsFramework::ViewportFreezeRequestBus bool IsViewportInputFrozen() override; void FreezeViewportInput(bool freeze) override; // AzToolsFramework::MainEditorViewportInteractionRequestBus - AZ::EntityId PickEntity(const QPoint& point) override; - AZ::Vector3 PickTerrain(const QPoint& point) override; + AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override; + AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override; float TerrainHeight(const AZ::Vector2& position) override; void FindVisibleEntities(AZStd::vector& visibleEntitiesOut) override; bool ShowingWorldSpace() override; @@ -431,7 +438,6 @@ protected: //! Assigned renderer. IRenderer* m_renderer = nullptr; - I3DEngine* m_engine = nullptr; bool m_bRenderContextCreated = false; bool m_bInRotateMode = false; bool m_bInMoveMode = false; @@ -518,10 +524,6 @@ protected: OBB m_GroundOBB; Vec3 m_GroundOBBPos; - //------------------------------------------- - // Render options. - bool m_bRenderStats = true; - // Index of camera objects. mutable GUID m_cameraObjectId = GUID_NULL; mutable AZ::EntityId m_viewEntityId; diff --git a/Code/Sandbox/Editor/Resource.h b/Code/Sandbox/Editor/Resource.h index 51f9b1f3e9..ea8ec828cf 100644 --- a/Code/Sandbox/Editor/Resource.h +++ b/Code/Sandbox/Editor/Resource.h @@ -75,7 +75,6 @@ #define IDC_PLATFORM_SALEM 2759 #define IDC_GROUPBOX_GLOBALTAGS 2916 #define IDC_GROUPBOX_FRAGMENTTAGS 2917 -#define ID_RESOURCES_GENERATECGFTHUMBNAILS 32894 #define ID_RESOURCES_REDUCEWORKINGSET 32896 #define ID_EDIT_HIDE 32898 #define ID_EDIT_UNHIDEALL 32899 @@ -91,7 +90,6 @@ #define ID_EXPORT_INDOORS 32915 #define ID_VIEW_CYCLE2DVIEWPORT 32916 #define ID_SNAPANGLE 32917 -#define ID_EDIT_RENAMEOBJECT 32925 #define ID_CHANGEMOVESPEED_INCREASE 32928 #define ID_CHANGEMOVESPEED_DECREASE 32929 #define ID_CHANGEMOVESPEED_CHANGESTEP 32930 @@ -134,7 +132,6 @@ #define ID_FILE_EDITEDITORINI 33543 #define ID_FILE_EDITLOGFILE 33544 #define ID_PREFERENCES 33546 -#define ID_RELOAD_GEOMETRY 33549 #define ID_REDO 33550 #define ID_SWITCH_PHYSICS 33555 #define ID_REF_COORDS_SYS 33556 diff --git a/Code/Sandbox/Editor/Settings.cpp b/Code/Sandbox/Editor/Settings.cpp index 99a801eedc..15d3e793a5 100644 --- a/Code/Sandbox/Editor/Settings.cpp +++ b/Code/Sandbox/Editor/Settings.cpp @@ -252,8 +252,6 @@ SEditorSettings::SEditorSettings() gui.hSystemFontBold = QFont("Ms Shell Dlg 2", lfHeight, QFont::Bold); gui.hSystemFontItalic = QFont("Ms Shell Dlg 2", lfHeight, QFont::Normal, true); - bForceSkyUpdate = true; - backgroundUpdatePeriod = 0; g_TemporaryLevelName = nullptr; @@ -647,8 +645,6 @@ void SEditorSettings::Save() SaveValue("Settings\\ObjectColors", "GeometryAlpha", objectColorSettings.fGeomAlpha); SaveValue("Settings\\ObjectColors", "ChildGeometryAlpha", objectColorSettings.fChildGeomAlpha); - SaveValue("Settings", "ForceSkyUpdate", gSettings.bForceSkyUpdate); - ////////////////////////////////////////////////////////////////////////// // Smart file open settings ////////////////////////////////////////////////////////////////////////// @@ -873,8 +869,6 @@ void SEditorSettings::Load() LoadValue("Settings\\ObjectColors", "GeometryAlpha", objectColorSettings.fGeomAlpha); LoadValue("Settings\\ObjectColors", "ChildGeometryAlpha", objectColorSettings.fChildGeomAlpha); - LoadValue("Settings", "ForceSkyUpdate", gSettings.bForceSkyUpdate); - ////////////////////////////////////////////////////////////////////////// // Smart file open settings ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Settings.h b/Code/Sandbox/Editor/Settings.h index 511bbb9bbe..93e61bc1ed 100644 --- a/Code/Sandbox/Editor/Settings.h +++ b/Code/Sandbox/Editor/Settings.h @@ -467,8 +467,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING bool bSettingsManagerMode; - bool bForceSkyUpdate; - bool bAutoSaveTagPoints; bool bNavigationContinuousUpdate; diff --git a/Code/Sandbox/Editor/ThumbnailGenerator.cpp b/Code/Sandbox/Editor/ThumbnailGenerator.cpp deleted file mode 100644 index c2f03a1944..0000000000 --- a/Code/Sandbox/Editor/ThumbnailGenerator.cpp +++ /dev/null @@ -1,198 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "ThumbnailGenerator.h" - -// Editor -#include "Util/Image.h" -#include "Util/ImageUtil.h" // for CUmageUtil -#include "WaitProgress.h" // for CWaitProgress - -#if defined(AZ_PLATFORM_MAC) || defined(AZ_PLATFORM_LINUX) -#include -#include -#endif - - - -CThumbnailGenerator::CThumbnailGenerator(void) -{ -} - -CThumbnailGenerator::~CThumbnailGenerator(void) -{ -} - -// Get directory contents. -static bool scan_directory(const QString& root, const QString& path, const QString& file, QStringList& files, bool recursive) -{ - QString fullPath = root + path + file; - QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; - if (recursive) - { - flags = QDirIterator::Subdirectories; - } - QDirIterator dirIterator(fullPath, {file}, QDir::Files, flags); - if (!dirIterator.hasNext()) - { - return false; - } - else - { - // Find the rest of the .c files. - while (dirIterator.hasNext()) - { - files.push_back(dirIterator.next()); - //FileInfo fi; - //fi.attrib = c_file.attrib; - //fi.name = path + c_file.name; - /* - // Add . after file name without extension. - if (fi.name.find('.') == CString::npos) { - fi.name.append( "." ); - } - */ - //fi.size = c_file.size; - //fi.time = c_file.time_write; - //files.push_back( fi ); - } - } - return true; -} - -#if defined(AZ_PLATFORM_WINDOWS) -#define FileTimeType FILETIME - -inline void GetThumbFileTime(const char* fileName, FILETIME& time) -{ - HANDLE hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE != hFile) - { - GetFileTime(hFile, NULL, NULL, &time); - CloseHandle(hFile); - } -} - -inline void SetThumbFileTime(const char* fileName, FILETIME& time) -{ - HANDLE hFile = CreateFile(fileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE != hFile) - { - SetFileTime(hFile, NULL, NULL, &time); - CloseHandle(hFile); - } -} - -inline bool ThumbFileTimeIsEqual(const FILETIME& ft1, const FILETIME& ft2) -{ - return ft1.dwHighDateTime == ft2.dwHighDateTime && ft1.dwLowDateTime == ft2.dwLowDateTime; -} -#elif defined(AZ_PLATFORM_MAC) || defined(AZ_PLATFORM_LINUX) -#define FileTimeType utimbuf - -inline void GetThumbFileTime(const char* fileName, utimbuf& times) -{ - struct stat sb; - if (stat(fileName, &sb) == 0) - { - times.actime = sb.st_atime; - times.modtime = sb.st_mtime; - } -} - -inline void SetThumbFileTime(const char* fileName, const utimbuf& times) -{ - utime(fileName, ×); -} - -inline bool ThumbFileTimeIsEqual(const utimbuf& ft1, const utimbuf& ft2) -{ - return ft1.modtime == ft2.modtime; -} -#endif - -void CThumbnailGenerator::GenerateForDirectory(const QString& path) -{ - return; - - ////////////////////////////////////////////////////////////////////////// - QStringList files; - //CString dir = GetIEditor()->GetPrimaryCDFolder(); - QString dir = path; - scan_directory(dir, "", "*.*", files, true); - - I3DEngine* engine = GetIEditor()->Get3DEngine(); - - int thumbSize = 128; - CImageEx image; - image.Allocate(thumbSize, thumbSize); - - char drive[_MAX_DRIVE]; - char fdir[_MAX_DIR]; - char fname[_MAX_FNAME]; - char fext[_MAX_EXT]; - char bmpFile[1024]; - - GetIEditor()->ShowConsole(true); - CWaitProgress wait("Generating CGF Thumbnails"); - for (int i = 0; i < files.size(); i++) - { - QString file = dir + files[i]; - _splitpath_s(file.toUtf8().data(), drive, fdir, fname, fext); - - //if (_stricmp(fext,".cgf") != 0 && _stricmp(fext,".bld") != 0) - if (_stricmp(fext, ".cgf") != 0) - { - continue; - } - - if (!wait.Step(100 * i / files.size())) - { - break; - } - - _makepath_s(bmpFile, drive, fdir, fname, ".tmb"); - - FileTimeType ft1, ft2; - GetThumbFileTime(file.toUtf8().data(), ft1); - GetThumbFileTime(bmpFile, ft2); - // Both cgf and bmp have same time stamp. - if (ThumbFileTimeIsEqual(ft1, ft2)) - { - continue; - } - - //CLogFile::FormatLine( "Generating thumbnail for %s...",file ); - - _smart_ptr obj = engine->LoadStatObjAutoRef(file.toUtf8().data(), NULL, NULL, false); - if (obj) - { - assert(!"IStatObj::MakeObjectPicture does not exist anymore"); - // obj->MakeObjectPicture( (unsigned char*)image.GetData(),thumbSize ); - - CImageUtil::SaveBitmap(bmpFile, image); - SetThumbFileTime(bmpFile, ft1); -#if defined(AZ_PLATFORM_WINDOWS) - SetFileAttributes(bmpFile, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED); -#endif - obj->Release(); - } - } - //GetIEditor()->ShowConsole( false ); -} - -void CThumbnailGenerator::GenerateForFile([[maybe_unused]] const QString& fileName) -{ -} diff --git a/Code/Sandbox/Editor/ThumbnailGenerator.h b/Code/Sandbox/Editor/ThumbnailGenerator.h deleted file mode 100644 index ef5a833e60..0000000000 --- a/Code/Sandbox/Editor/ThumbnailGenerator.h +++ /dev/null @@ -1,30 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_THUMBNAILGENERATOR_H -#define CRYINCLUDE_EDITOR_THUMBNAILGENERATOR_H - -#pragma once - - -class CThumbnailGenerator -{ -public: - CThumbnailGenerator(void); - ~CThumbnailGenerator(void); - - void GenerateForDirectory(const QString& path); - void GenerateForFile(const QString& fileName); -}; - -#endif // CRYINCLUDE_EDITOR_THUMBNAILGENERATOR_H diff --git a/Code/Sandbox/Editor/TimeOfDay.qrc b/Code/Sandbox/Editor/TimeOfDay.qrc deleted file mode 100644 index 7f45cf485f..0000000000 --- a/Code/Sandbox/Editor/TimeOfDay.qrc +++ /dev/null @@ -1,34 +0,0 @@ - - - TimeOfDay/main-00.png - TimeOfDay/main-01.png - TimeOfDay/main-02.png - TimeOfDay/main-03.png - TimeOfDay/main-04.png - TimeOfDay/main-05.png - TimeOfDay/main-06.png - TimeOfDay/main-07.png - TimeOfDay/main-08.png - TimeOfDay/main-09.png - TimeOfDay/main-10.png - TimeOfDay/main-11.png - TimeOfDay/main-12.png - Common/spline_edit-00.png - Common/spline_edit-01.png - Common/spline_edit-02.png - Common/spline_edit-03.png - Common/spline_edit-04.png - Common/spline_edit-05.png - Common/spline_edit-06.png - Common/spline_edit-07.png - Common/spline_edit-08.png - Common/spline_edit-09.png - Common/spline_edit-10.png - Common/spline_edit-11.png - Common/spline_edit-12.png - Common/spline_edit-13.png - Common/spline_edit-14.png - Common/spline_edit-15.png - Common/spline_edit-16.png - - diff --git a/Code/Sandbox/Editor/TimeOfDayDialog.cpp b/Code/Sandbox/Editor/TimeOfDayDialog.cpp deleted file mode 100644 index 80aa4d5172..0000000000 --- a/Code/Sandbox/Editor/TimeOfDayDialog.cpp +++ /dev/null @@ -1,1443 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "TimeOfDayDialog.h" - -// Qt -#include - -// AzToolsFramework -#include - -// CryCommon -#include - -// Editor -#include "Settings.h" -#include "Controls/CurveEditorCtrl.h" -#include "Mission.h" -#include "CryEditDoc.h" -#include "Clipboard.h" -#include "QtViewPaneManager.h" -#include "Undo/Undo.h" -#include "LyViewPaneNames.h" - -AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING -#include -AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -#define PANE_LAYOUT_SECTION _T("DockingPaneLayouts\\TimeOfDay") -#define PANE_LAYOUT_VERSION_ENTRY _T("PaneLayoutVersion") - -namespace TimeOfDayDetails -{ - const float kEpsilon = 0.00001f; - - const int kTimeOfDayDialogLayoutVersion = 0x0002; // bump this up on every substantial pane layout change - - static void SetKeyTangentType(ISplineInterpolator* pSpline, int key, ESplineKeyTangentType type) - { - int flags = (pSpline->GetKeyFlags(key) & ~SPLINE_KEY_TANGENT_IN_MASK) & ~SPLINE_KEY_TANGENT_OUT_MASK; - pSpline->SetKeyFlags(key, flags | (type << SPLINE_KEY_TANGENT_IN_SHIFT) | (type << SPLINE_KEY_TANGENT_OUT_SHIFT)); - } - - static QTime qTimeFromFloat(float time) - { - // The float time goes from 0.0 - 23.98 (since max time is 23:59), so - // convert this to seconds so we can construct a QTime object from that - int seconds = (time * 60.0f) * 60; - return QTime(0, 0).addSecs(seconds); - } - - static float floatFromQTime(const QTime& time) - { - return static_cast(time.msecsSinceStartOfDay() / 60000) / 60.0; - } - - AZ_INLINE static bool SkipUserInterface(int value) - { - // Check for obsolete parameters that we still want to keep around to migrate legacy data to new data - // but don't want to display in the UI - const ITimeOfDay::ETimeOfDayParamID enumValue = static_cast(value); - - // Split the check into two parts to try to keep the logic clear. - // The First set of parameters are always checked... - bool skipParameter = (enumValue == ITimeOfDay::PARAM_HDR_DYNAMIC_POWER_FACTOR) || - (enumValue == ITimeOfDay::PARAM_TERRAIN_OCCL_MULTIPLIER) || - (enumValue == ITimeOfDay::PARAM_SUN_COLOR_MULTIPLIER); - - return skipParameter; - } -} - -CHDRPane::CHDRPane(CTimeOfDayDialog* pTODDlg) - : QWidget(pTODDlg) - , m_pTODDlg(pTODDlg) - , m_pVars(new CVarBlock) -{ - assert(m_pTODDlg); -#if !defined(NDEBUG) - bool ok = -#endif - Init(); - assert(ok); -} - -bool CHDRPane::Init() -{ - m_filmCurveCtrl = new CCurveEditorCtrl(this); - m_filmCurveCtrl->SetControlPointCount(21); - m_filmCurveCtrl->SetMouseEnable(false); - m_filmCurveCtrl->SetPadding(16); - m_filmCurveCtrl->SetFlags( - CCurveEditorCtrl::eFlag_ShowVerticalRuler | - CCurveEditorCtrl::eFlag_ShowHorizontalRuler | - CCurveEditorCtrl::eFlag_ShowCursorAlways | - CCurveEditorCtrl::eFlag_ShowVerticalRulerText | - CCurveEditorCtrl::eFlag_ShowHorizontalRulerText | - CCurveEditorCtrl::eFlag_ShowPaddingBorder); - m_filmCurveCtrl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - m_propsCtrl = new ReflectedPropertyControl(this); - m_propsCtrl->Setup(); - - QVBoxLayout* l = new QVBoxLayout; - l->setMargin(0); - l->addWidget(m_filmCurveCtrl); - l->addWidget(m_propsCtrl); - setLayout(l); - - m_propsCtrl->SetSelChangeCallback(AZStd::bind(&CHDRPane::OnPropertySelected, this, AZStd::placeholders::_1)); - - return true; -} - -void CHDRPane::OnPropertySelected(IVariable *pVar) -{ - if (pVar && pVar->GetType() == IVariable::ARRAY) - { - pVar = nullptr; - } - - emit propertySelected(pVar); -} - -bool CHDRPane::GetFilmCurveParams(float& shoulderScale, float& midScale, float& toeScale, float& whitePoint) const -{ - int checked = 0; - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - - for (int i = 0; pTimeOfDay->GetVariableCount(); ++i) - { - ITimeOfDay::SVariableInfo varInfo; - bool ok = pTimeOfDay->GetVariableInfo(i, varInfo); - if (ok == false) - { - continue; - } - if (TimeOfDayDetails::SkipUserInterface(varInfo.nParamId)) - { - continue; - } - - switch (varInfo.nParamId) - { - case ITimeOfDay::PARAM_HDR_FILMCURVE_SHOULDER_SCALE: - shoulderScale = varInfo.fValue[0]; - ++checked; - break; - case ITimeOfDay::PARAM_HDR_FILMCURVE_LINEAR_SCALE: - midScale = varInfo.fValue[0]; - ++checked; - break; - case ITimeOfDay::PARAM_HDR_FILMCURVE_TOE_SCALE: - toeScale = varInfo.fValue[0]; - ++checked; - break; - case ITimeOfDay::PARAM_HDR_FILMCURVE_WHITEPOINT: - whitePoint = varInfo.fValue[0]; - ++checked; - break; - } - - if (checked == 4) - { - return true; - } - } - - return false; -} - -static float EvalFilmCurve(float x, float ss, float ms, float ts) -{ - return (x * (ss * 6.2f * x + 0.5f * ms)) / max((x * (ss * 6.2f * x + 1.7f) + ts * 0.06f), TimeOfDayDetails::kEpsilon); -} - -void CHDRPane::UpdateFilmCurve() -{ - float shoulderScale = 0, midScale = 0, toeScale = 0, whitePoint = 0; -#if !defined(NDEBUG) - bool ok = -#endif - GetFilmCurveParams(shoulderScale, midScale, toeScale, whitePoint); - assert(ok); - const float minX = -4.0f, minY = 0.0f, maxX = 4.0f; - float maxY = 1.0f, stepY = 0.1f; - - int numSamplePoints = m_filmCurveCtrl->GetControlPointCount(); - - for (int i = 0; i < numSamplePoints; ++i) - { - float t = static_cast(i) / (numSamplePoints - 1); - float logX = minX + ((maxX - minX) * t); - float x = powf(10.0f, logX); // Conventionally, the x domain is logarithmic. - - float v = EvalFilmCurve(x, shoulderScale, midScale, toeScale) / - max(EvalFilmCurve(whitePoint, shoulderScale, midScale, toeScale), TimeOfDayDetails::kEpsilon); - v = powf(v, 2.2f); // converting to a linear space - - // Update the maximum Y so that a proper domain can be set later. - if (v > maxY) - { - maxY = ceil(v / stepY) * stepY; - } - - m_filmCurveCtrl->SetControlPoint(i, Vec2(logX, v)); - } - - // maxY is not fixed, so adjust Y grid count properly according to it. - const UINT gridX = 4; // X grid is fixed. - UINT gridY = static_cast(maxY / stepY); - while (gridY > 20) // > 20 means too many, so reduce the count properly. - { - gridY = (gridY + 9) / 10; - stepY *= 10.0f; - } - maxY = stepY * gridY; - // Also prepare labels for the grid since the default labeling is improper - // especially for the X axis due to its log scale. - QStringList labelsX, labelsY; - for (int i = 0; i <= gridX; ++i) - { - QString label; - label.asprintf("%.4g", powf(10.0f, minX + (maxX - minX) * static_cast(i) / gridX)); - labelsX.push_back(label); - } - for (int i = 0; i <= gridY; ++i) - { - QString label; - label.asprintf("%.1f", i * stepY); - labelsY.push_back(label); - } - m_filmCurveCtrl->SetGrid(gridX, gridY, labelsX, labelsY); - m_filmCurveCtrl->MarkY(1.0f); // Mark the output of 1 so that users can quickly recognize where the clamping happens. - m_filmCurveCtrl->SetDomainBounds(minX, minY, maxX, maxY); - - m_filmCurveCtrl->update(); -} -////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -// Adapter for Multi element interpolators that allow to split it to several -// different interpolators for each element separately. -////////////////////////////////////////////////////////////////////////// -class CMultiElementSplineInterpolatorAdapter - : public ISplineInterpolator -{ -public: - CMultiElementSplineInterpolatorAdapter() - : m_pInterpolator(0) - , m_element(0) {} - CMultiElementSplineInterpolatorAdapter(ISplineInterpolator* pSpline, int element) - { - m_pInterpolator = pSpline; - m_element = element; - } - // Dimension of the spline from 0 to 3, number of parameters used in ValueType. - virtual int GetNumDimensions() { return m_pInterpolator->GetNumDimensions(); } - virtual int InsertKey(float time, ValueType value) - { - ValueType v = {0, 0, 0, 0}; - v[m_element] = value[0]; - return m_pInterpolator->InsertKey(time, v); - }; - virtual void RemoveKey(int key) { m_pInterpolator->RemoveKey(key); }; - - virtual void FindKeysInRange(float startTime, float endTime, int& firstFoundKey, int& numFoundKeys) - { m_pInterpolator->FindKeysInRange(startTime, endTime, firstFoundKey, numFoundKeys); } - virtual void RemoveKeysInRange(float startTime, float endTime) { m_pInterpolator->RemoveKeysInRange(startTime, endTime); } - - virtual int GetKeyCount() { return m_pInterpolator->GetKeyCount(); } - virtual void SetKeyTime(int key, float time) { return m_pInterpolator->SetKeyTime(key, time); }; - virtual float GetKeyTime(int key) { return m_pInterpolator->GetKeyTime(key); } - - virtual void SetKeyValue(int key, ValueType value) - { - ValueType v = {0, 0, 0, 0}; - m_pInterpolator->GetKeyValue(key, v); - v[m_element] = value[0]; - m_pInterpolator->SetKeyValue(key, v); - } - virtual bool GetKeyValue(int key, ValueType& value) - { - ValueType v = {0, 0, 0, 0}; - v[m_element] = value[0]; - return m_pInterpolator->GetKeyValue(key, value); - value[0] = v[m_element]; - } - - virtual void SetKeyInTangent([[maybe_unused]] int key, [[maybe_unused]] ValueType tin) {}; - virtual void SetKeyOutTangent([[maybe_unused]] int key, [[maybe_unused]] ValueType tout) {}; - virtual void SetKeyTangents([[maybe_unused]] int key, [[maybe_unused]] ValueType tin, [[maybe_unused]] ValueType tout) {}; - virtual bool GetKeyTangents([[maybe_unused]] int key, [[maybe_unused]] ValueType& tin, [[maybe_unused]] ValueType& tout) { return false; }; - - // Changes key flags, @see ESplineKeyFlags - virtual void SetKeyFlags(int key, int flags) { return m_pInterpolator->SetKeyFlags(key, flags); }; - // Retrieve key flags, @see ESplineKeyFlags - virtual int GetKeyFlags(int key) { return m_pInterpolator->GetKeyFlags(key); } - - virtual void Interpolate(float time, ValueType& value) - { - m_pInterpolator->Interpolate(time, value); - value[0] = value[m_element]; - }; - - virtual void SerializeSpline(XmlNodeRef& node, bool bLoading) { return m_pInterpolator->SerializeSpline(node, bLoading); }; - - virtual ISplineBackup* Backup() { return m_pInterpolator->Backup(); }; - virtual void Restore(ISplineBackup* pBackup) { return m_pInterpolator->Restore(pBackup); }; - -public: - ISplineInterpolator* m_pInterpolator; - int m_element; -}; - -////////////////////////////////////////////////////////////////////////// -class CTimeOfDaySplineSet - : public ISplineSet -{ -public: - void AddSpline(ISplineInterpolator* pSpline) { m_splines.push_back(pSpline); }; - void RemoveAllSplines() { m_splines.clear(); } - - virtual ISplineInterpolator* GetSplineFromID(const string& id) - { - int i = atoi(id.c_str()); - if (i >= 0 && i < (int)m_splines.size()) - { - return m_splines[i]; - } - return 0; - }; - virtual string GetIDFromSpline(ISplineInterpolator* pSpline) - { - for (int i = 0; i < (int)m_splines.size(); i++) - { - if (m_splines[i] == pSpline) - { - string s; - s.Format("%d", i); - return s; - } - } - return ""; - } - virtual int GetSplineCount() const { return (int)m_splines.size(); } - virtual int GetKeyCountAtTime(float time, float threshold) const - { - int count = 0; - for (int i = 0; i < (int)m_splines.size(); i++) - { - if (m_splines[i]->FindKey(time, threshold) > 0) - { - count++; - } - } - return count; - } - -public: - std::vector m_splines; -}; - -////////////////////////////////////////////////////////////////////////// -CTimeOfDayDialog::CTimeOfDayDialog(QWidget* parent /* = nullptr */) - : QMainWindow(parent) - , m_ui(new Ui::TimeOfDayDialog) - , m_timelineCtrl(new TimelineWidget(this)) - , m_pHDRPane(new CHDRPane(this)) -{ - gEnv->pSystem->GetISystemEventDispatcher()->RegisterListener(this); - GetIEditor()->RegisterNotifyListener(this); - - m_ui->setupUi(this); - m_ui->parameters->Setup(); - splitDockWidget(m_ui->hdrPaneDock, m_ui->tasksDock, Qt::Horizontal); - - // Calculate our maximum time from the slider (23:59) - m_maxTime = m_ui->timelineSlider->maximum() / 60.0f; - - Init(); -} - -////////////////////////////////////////////////////////////////////////// -CTimeOfDayDialog::~CTimeOfDayDialog() -{ - m_alive = false; - GetIEditor()->UnregisterNotifyListener(this); - GetIEditor()->GetUndoManager()->RemoveListener(this); - - gEnv->pSystem->GetISystemEventDispatcher()->RemoveListener(this); - - QSettings settings; - settings.beginGroup(QStringLiteral("EnvironmentEditor")); - settings.setValue(QStringLiteral("state"), saveState()); -} - -const GUID& CTimeOfDayDialog::GetClassID() -{ - // {85FB1272-D858-4ca5-ABB4-04D484ABF51E} - static const GUID guid = { - 0x85fb1272, 0xd858, 0x4ca5, { 0xab, 0xb4, 0x4, 0xd4, 0x84, 0xab, 0xf5, 0x1e } - }; - return guid; -} - -void CTimeOfDayDialog::RegisterViewClass() -{ - AzToolsFramework::ViewPaneOptions options; - options.paneRect = QRect(100, 100, 1500, 800); - options.canHaveMultipleInstances = true; - options.isDockable = true; - - AzToolsFramework::RegisterViewPane(LyViewPane::TimeOfDayEditor, LyViewPane::CategoryOther, options); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::UpdateValues() -{ - if (!m_alive) - { - return; - } - - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - - RefreshPropertiesValues(); - - SetTimeRange(advInfo.fStartTime, advInfo.fEndTime, advInfo.fAnimSpeed); - UpdateUI(false); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnSystemEvent(ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam) -{ - - - switch (event) - { - case ESYSTEM_EVENT_TIME_OF_DAY_SET: - // We update the UI in response to a system event (instead of with direct callbacks in the dialog) because time could be set by any of the dialog, - // e_TimeOfDay cvar, a Flow Graph Node or Track View. - UpdateUI(); - break; - default: - // do nothing - break; - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::Init() -{ - // Load toolbar images for the main toolbar - m_ui->actionUndo->setIcon(QIcon(":/TimeOfDay/main-00.png")); - m_ui->actionRedo->setIcon(QIcon(":/TimeOfDay/main-01.png")); - m_ui->actionImportFile->setIcon(QIcon(":/TimeOfDay/main-02.png")); - m_ui->actionExportFile->setIcon(QIcon(":/TimeOfDay/main-03.png")); - m_ui->actionPlayPause->setIcon(QIcon(":/TimeOfDay/main-04.png")); - m_ui->actionSetTimeTo0000->setIcon(QIcon(":/TimeOfDay/main-05.png")); - m_ui->actionSetTimeTo0600->setIcon(QIcon(":/TimeOfDay/main-06.png")); - m_ui->actionSetTimeTo1200->setIcon(QIcon(":/TimeOfDay/main-07.png")); - m_ui->actionSetTimeTo1800->setIcon(QIcon(":/TimeOfDay/main-08.png")); - m_ui->actionSetTimeTo2400->setIcon(QIcon(":/TimeOfDay/main-09.png")); - m_ui->actionStartStopRecording->setIcon(QIcon(":/TimeOfDay/main-10.png")); - m_ui->actionHold->setIcon(QIcon(":/TimeOfDay/main-11.png")); - m_ui->actionFetch->setIcon(QIcon(":/TimeOfDay/main-12.png")); - - // Load the images for the spline edit toolbar - m_ui->tangentsToAutoButton->setIcon(QIcon(":/Common/spline_edit-00.png")); - m_ui->inTangentToZeroButton->setIcon(QIcon(":/Common/spline_edit-01.png")); - m_ui->inTangentToStepButton->setIcon(QIcon(":/Common/spline_edit-02.png")); - m_ui->inTangentToLinearButton->setIcon(QIcon(":/Common/spline_edit-03.png")); - m_ui->outTangentToZerobutton->setIcon(QIcon(":/Common/spline_edit-04.png")); - m_ui->outTangentToStepButton->setIcon(QIcon(":/Common/spline_edit-05.png")); - m_ui->outTangentToLinearButton->setIcon(QIcon(":/Common/spline_edit-06.png")); - m_ui->fitSplinesHorizontalButton->setIcon(QIcon(":/Common/spline_edit-07.png")); - m_ui->fitSplinesVerticalButton->setIcon(QIcon(":/Common/spline_edit-08.png")); - m_ui->splineSnapGridX->setIcon(QIcon(":/Common/spline_edit-09.png")); - m_ui->splineSnapGridY->setIcon(QIcon(":/Common/spline_edit-10.png")); - m_ui->previousKeyButton->setIcon(QIcon(":/Common/spline_edit-14.png")); - m_ui->nextKeyButton->setIcon(QIcon(":/Common/spline_edit-15.png")); - m_ui->removeAllExceptSelectedButton->setIcon(QIcon(":/Common/spline_edit-16.png")); - - m_timelineCtrl->SetTicksTextScale(24.0f); - m_timelineCtrl->SetTimeRange(Range(0, 1)); - - m_ui->spline->SetDefaultKeyTangentType(SPLINE_KEY_TANGENT_LINEAR); - m_ui->spline->SetTimelineCtrl(m_timelineCtrl); - m_ui->spline->SetTimeRange(Range(0, 1.0f)); - m_ui->spline->SetValueRange(Range(-1.0f, 1.0f)); - m_ui->spline->SetMinTimeEpsilon(0.00001f); - m_ui->spline->SetTooltipValueScale(24, 1); - - m_ui->colorGradient->SetNoZoom(false); - m_ui->colorGradient->SetTimeRange(0, 1.0f); - m_ui->colorGradient->LockFirstAndLastKeys(true); - m_ui->colorGradient->SetTooltipValueScale(24, 1); - - CreateProperties(); - UpdateValues(); - UpdateUI(); - - QSettings settings; - settings.beginGroup(QStringLiteral("EnvironmentEditor")); - QByteArray state = settings.value(QStringLiteral("state")).toByteArray(); - if (!state.isEmpty()) - { - restoreState(state); - } - - ResetSpline(0); - - m_ui->hdrPaneDock->setWidget(m_pHDRPane); - m_pHDRPane->UpdateFilmCurve(); - - QString copyAllLabel(tr("Copy All Parameters")); - QString pasteAllLabel(tr("Paste All Parameters")); - m_ui->parameters->AddCustomPopupMenuItem(copyAllLabel, AZStd::bind(&CTimeOfDayDialog::CopyAllProperties, this)); - m_ui->parameters->AddCustomPopupMenuItem(pasteAllLabel, AZStd::bind(&CTimeOfDayDialog::PasteAllProperties, this)); - m_pHDRPane->properties().AddCustomPopupMenuItem(copyAllLabel, AZStd::bind(&CTimeOfDayDialog::CopyAllProperties, this)); - m_pHDRPane->properties().AddCustomPopupMenuItem(pasteAllLabel, AZStd::bind(&CTimeOfDayDialog::PasteAllProperties, this)); - - m_ui->parameters->SetSelChangeCallback(AZStd::bind(&CTimeOfDayDialog::OnPropertySelected, this, AZStd::placeholders::_1)); - connect(m_pHDRPane, &CHDRPane::propertySelected, this, &CTimeOfDayDialog::HdrPropertySelected); - m_pHDRPane->properties().SetUpdateCallback(AZStd::bind(&CTimeOfDayDialog::OnUpdateProperties, this, AZStd::placeholders::_1)); - m_ui->parameters->SetUpdateCallback(AZStd::bind(&CTimeOfDayDialog::OnUpdateProperties, this, AZStd::placeholders::_1)); - - connect(m_ui->importFromFileClickable, &QLabel::linkActivated, this, &CTimeOfDayDialog::OnImport); - connect(m_ui->exportToFileClickable, &QLabel::linkActivated, this, &CTimeOfDayDialog::OnExport); - connect(m_ui->resetValuesClickable, &QLabel::linkActivated, this, &CTimeOfDayDialog::OnResetToDefaultValues); - connect(m_ui->expandAllClickable, &QLabel::linkActivated, this, &CTimeOfDayDialog::OnExpandAll); - connect(m_ui->collapseAllClickable, &QLabel::linkActivated, this, &CTimeOfDayDialog::OnCollapseAll); - - connect(m_ui->currentTimeEdit, &QTimeEdit::timeChanged, this, [=](const QTime& time) { SetTime(TimeOfDayDetails::floatFromQTime(time)); }); - connect(m_ui->startTimeEdit, &QTimeEdit::timeChanged, this, &CTimeOfDayDialog::StartTimeChanged); - connect(m_ui->endTimeEdit, &QTimeEdit::timeChanged, this, &CTimeOfDayDialog::EndTimeChanged); - auto doubleValueChanged = static_cast(&QDoubleSpinBox::valueChanged); - connect(m_ui->playSpeedDoubleSpinBox, doubleValueChanged, this, &CTimeOfDayDialog::OnChangeTimeAnimSpeed); - - connect(m_ui->playClickable, &QLabel::linkActivated, this, [=]() { m_ui->actionPlayPause->setChecked(true); }); - connect(m_ui->stopClickable, &QLabel::linkActivated, this, [=]() { m_ui->actionPlayPause->setChecked(false); }); - - connect(m_ui->forceSkyUpdateCheckBox, &QCheckBox::stateChanged, this, [=](int state) { gSettings.bForceSkyUpdate = state == Qt::Checked; }); - - connect(m_ui->actionUndo, &QAction::triggered, this, &CTimeOfDayDialog::OnUndo); - connect(m_ui->actionRedo, &QAction::triggered, this, &CTimeOfDayDialog::OnRedo); - connect(m_ui->actionImportFile, &QAction::triggered, this, &CTimeOfDayDialog::OnImport); - connect(m_ui->actionExportFile, &QAction::triggered, this, &CTimeOfDayDialog::OnExport); - - connect(m_ui->actionSetTimeTo0000, &QAction::triggered, this, [=]() { SetTime(0); }); - connect(m_ui->actionSetTimeTo0600, &QAction::triggered, this, [=]() { SetTime(6); }); - connect(m_ui->actionSetTimeTo1200, &QAction::triggered, this, [=]() { SetTime(12); }); - connect(m_ui->actionSetTimeTo1800, &QAction::triggered, this, [=]() { SetTime(18); }); - connect(m_ui->actionSetTimeTo2400, &QAction::triggered, this, [=]() { SetTime(m_maxTime); }); - - connect(m_ui->actionHold, &QAction::triggered, this, &CTimeOfDayDialog::OnHold); - connect(m_ui->actionFetch, &QAction::triggered, this, &CTimeOfDayDialog::OnFetch); - - connect(m_ui->tangentsToAutoButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_AUTO); }); - connect(m_ui->inTangentToZeroButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_IN_ZERO); }); - connect(m_ui->inTangentToStepButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_IN_STEP); }); - connect(m_ui->inTangentToLinearButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_IN_LINEAR); }); - connect(m_ui->outTangentToZerobutton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_OUT_ZERO); }); - connect(m_ui->outTangentToStepButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_OUT_STEP); }); - connect(m_ui->outTangentToLinearButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_TANGENT_OUT_LINEAR); }); - connect(m_ui->fitSplinesHorizontalButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_FIT_X); }); - connect(m_ui->fitSplinesVerticalButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_FIT_Y); }); - connect(m_ui->splineSnapGridX, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_SNAP_GRID_X); }); - connect(m_ui->splineSnapGridY, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_SNAP_GRID_Y); }); - connect(m_ui->previousKeyButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_PREVIOUS_KEY); }); - connect(m_ui->nextKeyButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_NEXT_KEY); }); - connect(m_ui->removeAllExceptSelectedButton, &QAbstractButton::clicked, this, [=]() { m_ui->spline->OnUserCommand(ID_SPLINE_FLATTEN_ALL); }); - - connect(m_ui->timelineSlider, &AzQtComponents::SliderInt::valueChanged, this, [=](int value) { SetTime(value / 60.0f); }); - - connect(m_ui->spline, &SplineWidget::beforeChange, this, &CTimeOfDayDialog::OnBeforeSplineChange); - connect(m_ui->spline, &SplineWidget::change, this, [=]() { OnSplineChange(m_ui->spline); }); - connect(m_ui->spline, &SplineWidget::scrollZoomRequested, this, &CTimeOfDayDialog::OnSplineCtrlScrollZoom); - connect(m_ui->spline, &SplineWidget::timeChange, this, &CTimeOfDayDialog::OnTimelineCtrlChange); - connect(m_ui->spline, &SplineWidget::keySelectionChange, this, [=]() { SetTimeFromActiveKey(); }); - - connect(m_ui->colorGradient, &CColorGradientCtrl::beforeChange, this, &CTimeOfDayDialog::OnBeforeSplineChange); - connect(m_ui->colorGradient, &CColorGradientCtrl::change, this, [=]() { OnSplineChange(m_ui->colorGradient); }); - connect(m_ui->colorGradient, &CColorGradientCtrl::activeKeyChange, this, [=]() { SetTimeFromActiveKey(true); }); - //connect(m_timelineCtrl.data(), &TimelineWidget::startChange, this, &CTimeOfDayDialog::OnBeforeSplineChange); - connect(m_timelineCtrl, &TimelineWidget::change, this, &CTimeOfDayDialog::OnTimelineCtrlChange); - - //ITimeOfDay *pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - //m_ui->currentTimeEdit->setTime(qTimeFromFloat(pTimeOfDay->GetTime())); - - GetIEditor()->GetUndoManager()->AddListener(this); -} - -void CTimeOfDayDialog::HdrPropertySelected(IVariable* v) -{ - if (v) - { - m_ui->parameters->ClearSelection(); - } - ResetSpline(v); -} - -void CTimeOfDayDialog::StartTimeChanged([[maybe_unused]] const QTime& time) -{ - float converted = TimeOfDayDetails::floatFromQTime(m_ui->startTimeEdit->time()); - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - advInfo.fStartTime = converted; - pTimeOfDay->SetAdvancedInfo(advInfo); -} - -void CTimeOfDayDialog::EndTimeChanged([[maybe_unused]] const QTime& time) -{ - float converted = TimeOfDayDetails::floatFromQTime(m_ui->endTimeEdit->time()); - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - advInfo.fEndTime = converted; - pTimeOfDay->SetAdvancedInfo(advInfo); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::CreateProperties() -{ - m_pVars = new CVarBlock; - - std::map groups; - - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - for (int i = 0; i < pTimeOfDay->GetVariableCount(); i++) - { - ITimeOfDay::SVariableInfo varInfo; - if (!pTimeOfDay->GetVariableInfo(i, varInfo)) - { - continue; - } - - if (TimeOfDayDetails::SkipUserInterface(varInfo.nParamId)) - { - continue; - } - - if (!varInfo.pInterpolator) - { - continue; - } - - IVariable* pGroupVar = stl::find_in_map(groups, varInfo.group, 0); - if (!pGroupVar) - { - // Create new group - pGroupVar = new CVariableArray(); - pGroupVar->SetName(varInfo.group); - pGroupVar->SetUserData(-1); - if (strcmp(varInfo.group, "HDR") == 0) // HDR parameters should go into the separate HDR pane. - { - m_pHDRPane->variables()->AddVariable(pGroupVar); - } - else - { - m_pVars->AddVariable(pGroupVar); - } - groups[varInfo.group] = pGroupVar; - } - - IVariable* pVar = 0; - if (varInfo.type == ITimeOfDay::TYPE_COLOR) - { - ////////////////////////////////////////////////////////////////////////// - // Add Var. - pVar = new CVariable(); - pVar->SetDataType(IVariable::DT_COLOR); - pVar->Set(Vec3(varInfo.fValue[0], varInfo.fValue[1], varInfo.fValue[2])); - } - else if (varInfo.type == ITimeOfDay::TYPE_FLOAT) - { - // Add Var. - pVar = new CVariable(); - pVar->Set(varInfo.fValue[0]); - pVar->SetLimits(varInfo.fValue[1], varInfo.fValue[2]); - } - - if (pVar) - { - pVar->SetName(varInfo.name); - pVar->SetHumanName(varInfo.displayName); - pGroupVar->AddVariable(pVar); - pVar->SetUserData(i); - } - } - - m_ui->parameters->AddVarBlock(m_pVars); - m_ui->parameters->ExpandAll(); - m_ui->parameters->EnableNotifyWithoutValueChange(true); - - m_pHDRPane->properties().AddVarBlock(m_pHDRPane->variables()); - m_pHDRPane->properties().ExpandAll(); - m_pHDRPane->properties().EnableNotifyWithoutValueChange(true); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnBeforeSplineChange() -{ - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoTimeOfDayObject()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnSplineChange(const QWidget* source) -{ - RefreshPropertiesValues(); - - if (source == m_ui->spline) - { - // Update the time of day settings on spline changes (e.g. keys being moved) - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - bool bForceUpdate = m_ui->forceSkyUpdateCheckBox->isChecked(); - pTimeOfDay->Update(true, bForceUpdate); - - m_timelineCtrl->update(); - m_ui->colorGradient->update(); - } - else if (source == m_timelineCtrl) - { - m_ui->colorGradient->update(); - m_ui->spline->update(); - } - else - { - m_ui->spline->SplinesChanged(); - m_ui->spline->update(); - m_timelineCtrl->update(); - } - - - if (m_ui->spline->GetSplineCount() > 0) - { - ISplineInterpolator* pSpline = m_ui->spline->GetSpline(0); - if (NULL != pSpline) - { - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - const uint numVars = pTimeOfDay->GetVariableCount(); - for (uint i = 0; i < numVars; ++i) - { - ITimeOfDay::SVariableInfo varInfo; - pTimeOfDay->GetVariableInfo(i, varInfo); - } - } - } -} - -/** - * Update our time based on the currently active key - */ -void CTimeOfDayDialog::SetTimeFromActiveKey(bool useColorGradient) -{ - if (m_ui->spline->GetSplineCount() < 1) - { - return; - } - - ISplineInterpolator* pSpline = m_ui->spline->GetSpline(0); - if (!pSpline) - { - return; - } - - int activeKey = -1; - if (useColorGradient) - { - // If this method was triggered from our color gradient control, then - // retrieve its active key - activeKey = m_ui->colorGradient->GetActiveKey(); - } - else - { - // Otherwise this method was triggered from our main spline control, so - // we need to find the selected key by cycling through its keys - int numKeys = pSpline->GetKeyCount(); - for (int i = 0; i < numKeys; ++i) - { - if (pSpline->IsKeySelectedAtAnyDimension(i)) - { - activeKey = i; - break; - } - } - } - - if (activeKey == -1) - { - return; - } - - SetTime(pSpline->GetKeyTime(activeKey) * m_maxTime); -} - -////////////////////////////////////////////////////////////////////////// -float CTimeOfDayDialog::GetTime() const -{ - // This used to get the time from GetIEditor()->GetDocument()->GetCurrentMission()->GetTime(); but that seems like legacy CryEngine, so we're - // switching to grabbing it from the 3DEngine if possible - float time = .0f; - if (gEnv->p3DEngine->GetTimeOfDay()) - { - time = gEnv->p3DEngine->GetTimeOfDay()->GetTime(); - } - return time; -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::SetTimeRange(float fTimeStart, float fTimeEnd, float fSpeed) -{ - m_ui->startTimeEdit->setTime(TimeOfDayDetails::qTimeFromFloat(fTimeStart)); - m_ui->endTimeEdit->setTime(TimeOfDayDetails::qTimeFromFloat(fTimeEnd)); - - m_ui->playSpeedDoubleSpinBox->setValue(fSpeed); - - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - advInfo.fStartTime = fTimeStart; - advInfo.fEndTime = fTimeEnd; - advInfo.fAnimSpeed = fSpeed; - pTimeOfDay->SetAdvancedInfo(advInfo); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::RefreshPropertiesValues() -{ - m_ui->parameters->EnableUpdateCallback(false); - m_pHDRPane->properties().EnableUpdateCallback(false); - - // Interpolate internal values - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - for (int i = 0, numVars = pTimeOfDay->GetVariableCount(); i < numVars; i++) - { - ITimeOfDay::SVariableInfo varInfo; - if (!pTimeOfDay->GetVariableInfo(i, varInfo)) - { - continue; - } - if (TimeOfDayDetails::SkipUserInterface(varInfo.nParamId)) - { - continue; - } - - IVariable* pVar = FindVariable(varInfo.name); - - if (!pVar) - { - continue; - } - - switch (varInfo.type) - { - case ITimeOfDay::TYPE_FLOAT: - pVar->Set(varInfo.fValue[0]); - break; - case ITimeOfDay::TYPE_COLOR: - pVar->Set(Vec3(varInfo.fValue[0], varInfo.fValue[1], varInfo.fValue[2])); - break; - } - } - m_ui->parameters->EnableUpdateCallback(true); - m_pHDRPane->properties().EnableUpdateCallback(true); - - m_pHDRPane->UpdateFilmCurve(); - - // Notify that time of day values changed. - GetIEditor()->Notify(eNotify_OnTimeOfDayChange); -} - -void CTimeOfDayDialog::UpdateUI(bool updateProperties) -{ - float timeOfDayInHours = GetTime(); - - // update the Current Time edit field and Time Of Day Time Slider - QTime qTime = TimeOfDayDetails::qTimeFromFloat(timeOfDayInHours); - - QSignalBlocker sliderBlocker(m_ui->timelineSlider); - QSignalBlocker editBlocker(m_ui->currentTimeEdit); - - int v = qTime.msecsSinceStartOfDay(); - v /= 60000; - m_ui->timelineSlider->setValue(v); - m_ui->currentTimeEdit->setTime(qTime); - - m_ui->spline->SetTimeMarker(timeOfDayInHours / m_maxTime); - m_ui->colorGradient->SetTimeMarker(timeOfDayInHours / m_maxTime); - - if (updateProperties) - { - RefreshPropertiesValues(); - } - else - { - GetIEditor()->Notify(eNotify_OnTimeOfDayChange); - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::SetTime(float time) -{ - const bool bForceUpdate = m_ui->forceSkyUpdateCheckBox->isChecked(); - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - - // This is probably legacy and deprecated, but leaving it here just in case it's needed by some legacy game. - if (GetIEditor()->GetDocument()->GetCurrentMission()) - { - GetIEditor()->GetDocument()->GetCurrentMission()->SetTime(time); - } - - // pTimeOfDay->SetTime will trigger a ESYSTEM_EVENT_TIME_OF_DAY_SET, which in turn will result in UpdateUI() being called - pTimeOfDay->SetTime(time, bForceUpdate); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnEditorNotifyEvent(EEditorNotifyEvent event) -{ - switch (event) - { - case eNotify_OnCloseScene: - case eNotify_OnBeginNewScene: - case eNotify_OnBeginSceneOpen: - { - // prevent crash during redraw which can happen before eNotify_OnEndSceneOpen - m_ui->spline->RemoveAllSplines(); - m_ui->colorGradient->SetSpline(0); - } - break; - case eNotify_OnEndSceneOpen: - case eNotify_OnEndNewScene: - { - UpdateValues(); - - m_pHDRPane->properties().ClearSelection(); - if (ReflectedPropertyItem* pSelectedItem = m_ui->parameters->GetSelectedItem()) - { - if (IVariable* pVar = pSelectedItem->GetVariable()) - { - ResetSpline(pVar); - } - } - } - break; - - case eNotify_OnIdleUpdate: - if (m_ui->actionPlayPause->isChecked()) - { - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - float fHour = pTimeOfDay->GetTime(); - - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - // get the TOD cycle speed from UI - advInfo.fAnimSpeed = m_ui->playSpeedDoubleSpinBox->value(); - float dt = gEnv->pTimer->GetFrameTime(); - float fTime = fHour + dt * advInfo.fAnimSpeed; - if (fTime > advInfo.fEndTime) - { - fTime = advInfo.fStartTime; - } - if (fTime < advInfo.fStartTime) - { - fTime = advInfo.fEndTime; - } - SetTime(fTime); - } - break; - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnTimelineCtrlChange() -{ - float fTime = m_timelineCtrl->GetTimeMarker(); - SetTime(fTime * m_maxTime); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnChangeTimeAnimSpeed(double value) -{ - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - // set current speed based on if we animating it currently or not - advInfo.fAnimSpeed = value; - pTimeOfDay->SetAdvancedInfo(advInfo); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnSplineCtrlScrollZoom() -{ - if (m_ui->spline && m_ui->colorGradient) - { - m_ui->colorGradient->SetZoom(m_ui->spline->GetZoom().x); - m_ui->colorGradient->SetOrigin(m_ui->spline->GetScrollOffset().x); - m_ui->colorGradient->update(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnImport() -{ - char szFilters[] = "Time Of Day Settings (*.xml);;Time Of Day Settings Old (*.tod)"; - QString fileName; - - if (CFileUtil::SelectFile(szFilters, GetIEditor()->GetLevelFolder(), fileName)) - { - XmlNodeRef root = GetISystem()->LoadXmlFromFile(fileName.toStdString().c_str()); - if (root) - { - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - float fTime = GetTime(); - pTimeOfDay->Serialize(root, true); - pTimeOfDay->SetTime(fTime, true); - - UpdateValues(); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnExport() -{ - char szFilters[] = "Time Of Day Settings (*.xml)"; - QString fileName; - if (CFileUtil::SelectSaveFile(szFilters, "xml", GetIEditor()->GetLevelFolder(), fileName)) - { - // Write the light settings into the archive - XmlNodeRef node = XmlHelpers::CreateXmlNode("TimeOfDay"); - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - pTimeOfDay->Serialize(node, false); - XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), node, fileName.toStdString().c_str()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnExpandAll() -{ - m_ui->parameters->ExpandAll(); - m_pHDRPane->properties().ExpandAll(); -} -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnResetToDefaultValues() -{ - auto answer = QMessageBox::question(QApplication::activeWindow(), "Reset Values", "Are you sure you want to reset all values to their default values?"); - - if (answer == QMessageBox::Yes) - { - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - - // Load the default time of day settings and use those to reset the time of day. - XmlNodeRef root = GetISystem()->LoadXmlFromFile("default_time_of_day.xml"); - if (root) - { - pTimeOfDay->Serialize(root, true); - } - else - { - QMessageBox::warning(QApplication::activeWindow(), "Reset Values", "Unable to read default time of day file (Editor/default_time_of_day.xml), initializing variables to default values.", QMessageBox::Ok); - - // If for some reason the file is missing or corrupted, recreate the variables with their default states. - // Note that these variables may be out of sync with the default_time_of_day.xml file. - pTimeOfDay->ResetVariables(); - } - - ITimeOfDay::SAdvancedInfo advInfo; - pTimeOfDay->GetAdvancedInfo(advInfo); - SetTimeRange(advInfo.fStartTime, advInfo.fEndTime, advInfo.fAnimSpeed); - RefreshPropertiesValues(); - - m_pHDRPane->properties().ClearSelection(); - ReflectedPropertyItem* selectedItem = m_ui->parameters->GetSelectedItem(); - if (selectedItem) - { - IVariable* var = selectedItem->GetVariable(); - if (var) - { - ResetSpline(var); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnCollapseAll() -{ - m_ui->parameters->CollapseAll(); - m_pHDRPane->properties().CollapseAll(); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnUpdateProperties(IVariable* pVar) -{ - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - - int nIndex = -1; - if (pVar) - { - nIndex = pVar->GetUserData().toInt(); - } - - if (nIndex != -1) - { - ITimeOfDay::SVariableInfo varInfo; - if (pTimeOfDay->GetVariableInfo(nIndex, varInfo)) - { - float fTime = GetTime(); - float fSplineTime = fTime / m_maxTime; - - const float cNearestKeySearchEpsilon = 0.00001f; - int nKey = varInfo.pInterpolator->FindKey(fSplineTime, cNearestKeySearchEpsilon); - int nLastKey = varInfo.pInterpolator->GetKeyCount() - 1; - - if (CUndo::IsRecording()) - { - CUndo::Record(new CUndoTimeOfDayObject()); - } - - switch (varInfo.type) - { - case ITimeOfDay::TYPE_FLOAT: - { - float fVal = 0; - pVar->Get(fVal); - if (m_ui->actionStartStopRecording->isChecked()) - { - if (nKey < 0) - { - nKey = varInfo.pInterpolator->InsertKeyFloat(fSplineTime, fVal); - } - else - { - varInfo.pInterpolator->SetKeyValueFloat(nKey, fVal); - if (nKey == 0) - { - varInfo.pInterpolator->SetKeyValueFloat(nLastKey, fVal); - } - else if (nKey == nLastKey) - { - varInfo.pInterpolator->SetKeyValueFloat(0, fVal); - } - } - if (m_ui->spline && m_ui->spline->GetDefaultKeyTangentType() != SPLINE_KEY_TANGENT_NONE) - { - TimeOfDayDetails::SetKeyTangentType(varInfo.pInterpolator, nKey, m_ui->spline->GetDefaultKeyTangentType()); - } - } - - float v3[3] = {fVal, varInfo.fValue[1], varInfo.fValue[2]}; - pTimeOfDay->SetVariableValue(nIndex, v3); - } - break; - case ITimeOfDay::TYPE_COLOR: - { - Vec3 vVal; - pVar->Get(vVal); - float v3[3] = {vVal.x, vVal.y, vVal.z}; - if (m_ui->actionStartStopRecording->isChecked()) - { - if (nKey < 0) - { - nKey = varInfo.pInterpolator->InsertKeyFloat3(fSplineTime, v3); - } - else - { - varInfo.pInterpolator->SetKeyValueFloat3(nKey, v3); - if (nKey == 0) - { - varInfo.pInterpolator->SetKeyValueFloat3(nLastKey, v3); - } - else if (nKey == nLastKey) - { - varInfo.pInterpolator->SetKeyValueFloat3(0, v3); - } - } - if (m_ui->spline && m_ui->spline->GetDefaultKeyTangentType() != SPLINE_KEY_TANGENT_NONE) - { - TimeOfDayDetails::SetKeyTangentType(varInfo.pInterpolator, nKey, m_ui->spline->GetDefaultKeyTangentType()); - } - } - pTimeOfDay->SetVariableValue(nIndex, v3); - - m_ui->colorGradient->update(); - } - break; - } - - if (m_ui->spline) - { - m_ui->spline->update(); - } - - if (varInfo.nParamId == ITimeOfDay::PARAM_HDR_FILMCURVE_SHOULDER_SCALE - || varInfo.nParamId == ITimeOfDay::PARAM_HDR_FILMCURVE_LINEAR_SCALE - || varInfo.nParamId == ITimeOfDay::PARAM_HDR_FILMCURVE_TOE_SCALE - || varInfo.nParamId == ITimeOfDay::PARAM_HDR_FILMCURVE_WHITEPOINT) - { - m_pHDRPane->UpdateFilmCurve(); - } - - bool bForceUpdate = m_ui->forceSkyUpdateCheckBox->isChecked(); - pTimeOfDay->Update(false, bForceUpdate); - - GetIEditor()->Notify(eNotify_OnTimeOfDayChange); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnPropertySelected(IVariable *pVar) -{ - if (pVar) - { - m_pHDRPane->properties().ClearSelection(); - } - - if (pVar && pVar->GetType() == IVariable::ARRAY) - { - pVar = nullptr; - } - - ResetSpline(pVar); -} - - -void CTimeOfDayDialog::ResetSpline(IVariable* pVar) -{ - if (pVar) - { - ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay(); - ITimeOfDay::SVariableInfo varInfo; - int index = pVar->GetUserData().toInt(); - if (!pTimeOfDay->GetVariableInfo(index, varInfo)) - { - return; - } - - m_ui->spline->SetTimeRange(Range(0, 1.0f)); - m_ui->spline->RemoveAllSplines(); - - if (varInfo.type == ITimeOfDay::TYPE_COLOR) - { - QColor afColorArray[4]; - afColorArray[0] = QColor(255, 0, 0); - afColorArray[1] = QColor(0, 255, 0); - afColorArray[2] = QColor(0, 0, 255); - afColorArray[3] = QColor(255, 0, 255); //Pink... so you know it's wrong if you see it. - m_ui->spline->AddSpline(varInfo.pInterpolator, 0, afColorArray); - m_ui->spline->SetValueRange(Range(0, 1)); - - m_ui->colorGradient->SetSpline(varInfo.pInterpolator, TRUE); - m_ui->colorGradient->setEnabled(true); - m_ui->colorGradient->update(); - } - else - { - m_ui->colorGradient->setEnabled(false); - m_ui->colorGradient->SetSpline(0); - m_ui->colorGradient->update(); - - m_ui->spline->SetValueRange(Range(varInfo.fValue[1], varInfo.fValue[2])); - m_ui->spline->AddSpline(varInfo.pInterpolator, 0, QColor(0, 255, 0)); - } - m_ui->spline->SetSplineSet(0); - m_ui->spline->FitSplineToViewWidth(); - m_ui->spline->FitSplineHeightToValueRange(); - } - else - { - m_ui->spline->RemoveAllSplines(); - m_ui->colorGradient->setEnabled(false); - m_ui->colorGradient->SetSpline(0); - } - m_ui->spline->update(); -} - - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnHold() -{ - XmlNodeRef node = XmlHelpers::CreateXmlNode("TimeOfDay"); - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(node, false); - node->saveToFile((Path::GetUserSandboxFolder() + "TimeOfDayHold.xml").toUtf8().data()); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnFetch() -{ - XmlNodeRef node = XmlHelpers::LoadXmlFromFile((Path::GetUserSandboxFolder() + "TimeOfDayHold.xml").toUtf8().data()); - if (node) - { - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(node, true); - UpdateValues(); - UpdateUI(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnUndo() -{ - GetIEditor()->Undo(); - m_ui->spline->update(); - m_ui->colorGradient->update(); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::OnRedo() -{ - GetIEditor()->Redo(); - m_ui->spline->update(); - m_ui->colorGradient->update(); -} - -////////////////////////////////////////////////////////////////////////// -IVariable* CTimeOfDayDialog::FindVariable(const char* name) const -{ - IVariable* pVar = m_pVars->FindVariable(name); - if (!pVar) - { - pVar = m_pHDRPane->variables()->FindVariable(name); - } - - return pVar; -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::CopyAllProperties() -{ - CClipboard clipboard(this); - XmlNodeRef collectionNode = XmlHelpers::CreateXmlNode("PropertyCtrls"); - - ReflectedPropertyItem* pRoot = m_ui->parameters->GetRootItem(); - if (pRoot) // Main properties - { - XmlNodeRef rootNode = collectionNode->newChild("PropertyCtrl"); - for (int i = 0; i < pRoot->GetChildCount(); ++i) - { - m_ui->parameters->CopyItem(rootNode, pRoot->GetChild(i), true); - } - } - - pRoot = m_pHDRPane->properties().GetRootItem(); - if (pRoot) // HDR properties - { - XmlNodeRef rootNode = collectionNode->newChild("PropertyCtrl"); - for (int i = 0; i < pRoot->GetChildCount(); ++i) - { - m_pHDRPane->properties().CopyItem(rootNode, pRoot->GetChild(i), true); - } - } - - clipboard.Put(collectionNode); -} - -////////////////////////////////////////////////////////////////////////// -void CTimeOfDayDialog::PasteAllProperties() -{ - CClipboard clipboard(this); - CUndo undo("Paste Properties"); - - XmlNodeRef collectionNode = clipboard.Get(); - if (collectionNode != NULL && collectionNode->isTag("PropertyCtrls") - && collectionNode->getChildCount() == 2) - { - // Main properties - XmlNodeRef rootNode = collectionNode->getChild(0); - m_ui->parameters->SetValuesFromNode(rootNode); - - // HDR properties - rootNode = collectionNode->getChild(1); - m_pHDRPane->properties().SetValuesFromNode(rootNode); - } -} - -void CTimeOfDayDialog::SignalNumUndoRedo(const unsigned int& numUndo, const unsigned int& numRedo) -{ - m_ui->actionUndo->setEnabled(numUndo > 0); - m_ui->actionRedo->setEnabled(numRedo > 0); -} - -void CTimeOfDayDialog::resizeEvent([[maybe_unused]] QResizeEvent* event) -{ - if (m_ui->spline->GetSplineCount() == 0) - { - m_ui->spline->FitSplineToViewWidth(); - m_ui->spline->FitSplineToViewHeight(); - } -} - -CUndoTimeOfDayObject::CUndoTimeOfDayObject() -{ - m_undo = XmlHelpers::CreateXmlNode("Undo"); - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_undo, false); -} - -void CUndoTimeOfDayObject::Undo(bool bUndo) -{ - if (bUndo) - { - m_redo = XmlHelpers::CreateXmlNode("Redo"); - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_redo, false); - } - - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_undo, true); - UpdateTimeOfDayDialog(); -} - -void CUndoTimeOfDayObject::Redo() -{ - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_redo, true); - UpdateTimeOfDayDialog(); -} - -void CUndoTimeOfDayObject::UpdateTimeOfDayDialog() -{ - CTimeOfDayDialog* targetDialog = FindViewPane(CTimeOfDayDialog::ClassName()); - if (targetDialog != nullptr) - { - targetDialog->UpdateValues(); - } -} - -#include diff --git a/Code/Sandbox/Editor/TimeOfDayDialog.h b/Code/Sandbox/Editor/TimeOfDayDialog.h deleted file mode 100644 index 8e9a9e92a8..0000000000 --- a/Code/Sandbox/Editor/TimeOfDayDialog.h +++ /dev/null @@ -1,182 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_TIMEOFDAYDIALOG_H -#define CRYINCLUDE_EDITOR_TIMEOFDAYDIALOG_H -#pragma once - -#if !defined(Q_MOC_RUN) -#include "Controls/TimelineCtrl.h" -#include -#include "Undo/IUndoManagerListener.h" -#include "LyViewPaneNames.h" -#include -#endif - -////////////////////////////////////////////////////////////////////////// - -class QResizeEvent; -class CCurveEditorCtrl; -class CHDRPane; - -namespace Ui { - class TimeOfDayDialog; -} - -AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING -////////////////////////////////////////////////////////////////////////// -// Window that holds effector info. -////////////////////////////////////////////////////////////////////////// -class SANDBOX_API CTimeOfDayDialog - : public QMainWindow - , public IEditorNotifyListener - , public ISystemEventListener - , public IUndoManagerListener -{ -AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING - Q_OBJECT -public: - static const char* ClassName() { return LyViewPane::TimeOfDayEditor; } - static const GUID& GetClassID(); - - CTimeOfDayDialog(QWidget* parent = nullptr); - ~CTimeOfDayDialog(); - - static void RegisterViewClass(); - void UpdateValues(); - - // overrides from ISystemEventListener - void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override; - -protected: - void OnBeforeSplineChange(); - void OnSplineChange(const QWidget* source); - void OnPlayAnimFrom0(); - void OnChangeTimeAnimSpeed(double speed); - - void OnImport(); - void OnExport(); - void OnExpandAll(); - void OnResetToDefaultValues(); - void OnCollapseAll(); - - void OnHold(); - void OnFetch(); - void OnUndo(); - void OnRedo(); - - void OnPropertySelected(IVariable* node); - void OnSplineCtrlScrollZoom(); - void OnTimelineCtrlChange(); - - void Init(); - - void OnUpdateProperties(IVariable* var); - - void CreateProperties(); - - void SetTime(float time); - void SetTimeRange(float fTimeStart, float fTimeEnd, float fSpeed); - float GetTime() const; - - void RefreshPropertiesValues(); - void ResetSpline(IVariable* var); - - IVariable* FindVariable(const char* name) const; - - void CopyAllProperties(); - void PasteAllProperties(); - - void HdrPropertySelected(IVariable* v); - void StartTimeChanged(const QTime& time); - void EndTimeChanged(const QTime& time); - - ////////////////////////////////////////////////////////////////////////// - // IEditorNotifyListener - ////////////////////////////////////////////////////////////////////////// - virtual void OnEditorNotifyEvent(EEditorNotifyEvent event); - ////////////////////////////////////////////////////////////////////////// - - // IUndoManagerListener - void SignalNumUndoRedo(const unsigned int& numUndo, const unsigned int& numRedo) override; - - void resizeEvent(QResizeEvent* event) override; - -private: - void UpdateUI(bool updateProperties=true); - void SetTimeFromActiveKey(bool useColorGradient = false); - - bool m_alive = true; - - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - QScopedPointer m_ui; - - CHDRPane* m_pHDRPane; - CVarBlockPtr m_pVars; - - TimelineWidget* m_timelineCtrl; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - float m_maxTime; -}; - -class CHDRPane - : public QWidget -{ - Q_OBJECT -public: - CHDRPane(CTimeOfDayDialog* pTODDlg); - - ReflectedPropertyControl& properties() { return *m_propsCtrl; } - CVarBlockPtr variables() { return m_pVars; } - - void UpdateFilmCurve(); - -signals: - void propertySelected(IVariable* variable); - -protected: - bool Init(); - void OnPropertySelected(IVariable*); - - bool GetFilmCurveParams(float& shoulderScale, float& midScale, float& toeScale, float& whitePoint) const; - - CTimeOfDayDialog* m_pTODDlg; - CCurveEditorCtrl* m_filmCurveCtrl; - ReflectedPropertyControl* m_propsCtrl; - CVarBlockPtr m_pVars; -}; - -/** Undo object stored when track is modified. -*/ -class CUndoTimeOfDayObject - : public IUndoObject -{ -public: - CUndoTimeOfDayObject(); - -protected: - virtual int GetSize() { return sizeof(*this); } - virtual QString GetDescription() { return "Time of Day"; }; - - virtual void Undo(bool bUndo); - virtual void Redo(); - -private: - void UpdateTimeOfDayDialog(); - - XmlNodeRef m_undo; - XmlNodeRef m_redo; -}; - -#endif // CRYINCLUDE_EDITOR_TIMEOFDAYDIALOG_H diff --git a/Code/Sandbox/Editor/TimeOfDayDialog.ui b/Code/Sandbox/Editor/TimeOfDayDialog.ui deleted file mode 100644 index 35e8e483a0..0000000000 --- a/Code/Sandbox/Editor/TimeOfDayDialog.ui +++ /dev/null @@ -1,980 +0,0 @@ - - - TimeOfDayDialog - - - - 0 - 0 - 1073 - 600 - - - - MainWindow - - - QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks - - - - - 2 - - - - - - 1 - 0 - - - - - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Set In/Out Tangents to Auto - - - - - - - 18 - 18 - - - - true - - - - - - - Qt::Vertical - - - - - - - Set In Tangent to Zero - - - - - - - 18 - 18 - - - - true - - - - - - - Set In Tangent to Step - - - - - - - 18 - 18 - - - - true - - - - - - - Set In Tangent to Linear - - - - - - - 18 - 18 - - - - true - - - - - - - Qt::Vertical - - - - - - - Set Out Tangent to Zero - - - - - - - 18 - 18 - - - - true - - - - - - - Set Out Tangent to Step - - - - - - - 18 - 18 - - - - true - - - - - - - Set Out Tangent to Linear - - - - - - - 18 - 18 - - - - true - - - - - - - Qt::Vertical - - - - - - - Fit Splines to the Visible Width - - - - - - - 18 - 18 - - - - true - - - - - - - Fit Splines to the Visible Height - - - - - - - 18 - 18 - - - - true - - - - - - - Qt::Vertical - - - - - - - Snap to time grid - - - - 18 - 18 - - - - true - - - true - - - - - - - Snap to value grid - - - - 18 - 18 - - - - true - - - true - - - - - - - Qt::Vertical - - - - - - - Previous Key - - - - - - - 18 - 18 - - - - true - - - - - - - Qt::Vertical - - - - - - - Next Key - - - - - - - 18 - 18 - - - - true - - - - - - - Remove all Keys BUT This - - - - - - - 18 - 18 - - - - true - - - - - - - Qt::Horizontal - - - - 69 - 20 - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 35 - - - - - - - - - - - - 1 - 1 - - - - - - - - - 0 - - - - - Timeline - - - - 6 - - - 0 - - - - - 23:59 - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - - - - 00:00 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 12:00 - - - Qt::AlignHCenter|Qt::AlignTop - - - - - - - Qt::WheelFocus - - - 1439 - - - - - - - - - - - - - - - - - toolBar - - - - 32 - 32 - - - - false - - - TopToolBarArea - - - false - - - - - - - - - - - - - - - - - - - - - - - 350 - 40 - - - - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable - - - Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea - - - HDR Settings - - - 1 - - - - - 0 - 0 - - - - - 150 - 0 - - - - - - - - - 0 - 0 - - - - - 450 - 50 - - - - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable - - - Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea - - - Parameters - - - 2 - - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - - - - - - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable - - - Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea - - - Time of Day Tasks - - - 1 - - - - - - - - 0 - 0 - - - - - 0 - - - - - Tasks - - - - - - Import From File - - - - - - - Export To File - - - - - - - Reset Values - - - - - - - Expand All - - - - - - - Collapse All - - - - - - - - - - Time - - - - - - Current Time - - - currentTimeEdit - - - - - - - - - - Start Time - - - startTimeEdit - - - - - - - - - - End Time - - - endTimeEdit - - - - - - - - - - Play Speed - - - playSpeedDoubleSpinBox - - - - - - - 0.001000000000000 - - - - - - - - - - Update Tasks - - - - - - Play - - - - - - - Stop - - - - - - - Force sky update - - - true - - - - - - - - - - Qt::Vertical - - - - 20 - 139 - - - - - - - - - - - - - false - - - Undo - - - Undo - - - - - false - - - Redo - - - Redo - - - - - Import File - - - Import File - - - - - Export File - - - Export File - - - - - true - - - Play/Pause - - - Play/Pause - - - - - 00 - - - Set Time to 00:00 - - - - - 06 - - - Set Time to 06:00 - - - - - 12 - - - Set Time to 12:00 - - - - - 18 - - - Set Time to 18:00 - - - - - 24 - - - Set Time to 23:59 - - - - - true - - - true - - - Start/Stop Recording - - - Start/Stop Recording - - - - - Hold - - - Hold - - - - - Fetch - - - Fetch - - - - - - ReflectedPropertyControl - QWidget -
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h
- 1 -
- - QCollapsibleGroupBox - QGroupBox -
QtUI/QCollapsibleGroupBox.h
- 1 -
- - ClickableLabel - QLabel -
QtUI/ClickableLabel.h
-
- - SplineWidget - QWidget -
Controls/SplineCtrlEx.h
- 1 -
- - CColorGradientCtrl - QWidget -
Controls/ColorGradientCtrl.h
- 1 -
- - AzQtComponents::DoubleSpinBox - QDoubleSpinBox -
AzQtComponents/Components/Widgets/SpinBox.h
-
- - TimeOfDaySlider - QWidget -
Controls/TimeOfDaySlider.h
- 1 -
-
- - timelineSlider - - - -
diff --git a/Code/Sandbox/Editor/TrackView/TrackViewDialog.cpp b/Code/Sandbox/Editor/TrackView/TrackViewDialog.cpp index 06184c0fc3..0179b779e8 100644 --- a/Code/Sandbox/Editor/TrackView/TrackViewDialog.cpp +++ b/Code/Sandbox/Editor/TrackView/TrackViewDialog.cpp @@ -1505,12 +1505,6 @@ void CTrackViewDialog::OnEditorNotifyEvent(EEditorNotifyEvent event) m_bIgnoreUpdates = false; OnGameOrSimModeLock(false); break; - case eNotify_OnMissionChange: - if (!m_bIgnoreUpdates) - { - ReloadSequences(); - } - break; case eNotify_OnReloadTrackView: if (!m_bIgnoreUpdates) { diff --git a/Code/Sandbox/Editor/TrackView/TrackViewNodes.cpp b/Code/Sandbox/Editor/TrackView/TrackViewNodes.cpp index 3979bf3cca..0bde26edf1 100644 --- a/Code/Sandbox/Editor/TrackView/TrackViewNodes.cpp +++ b/Code/Sandbox/Editor/TrackView/TrackViewNodes.cpp @@ -832,32 +832,7 @@ void CTrackViewNodesCtrl::UpdateAnimNodeRecord(CRecord* record, CTrackViewAnimNo } else if (nodeType == AnimNodeType::Material) { - // Check if a valid material can be found by the node name. - _smart_ptr pMaterial = nullptr; - QString matName; - int subMtlIndex = GetMatNameAndSubMtlIndexFromName(matName, animNode->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) - { - record->setForeground(0, TextColorForInvalidMaterial); - } - else - { - // set to default color from palette - // materials that originally pointed to material groups and are changed to sub-materials need this to reset their color - record->setForeground(0, palette().color(foregroundRole())); - } + record->setForeground(0, TextColorForInvalidMaterial); } // Mark the active director and other directors properly. @@ -2163,43 +2138,6 @@ int CTrackViewNodesCtrl::ShowPopupMenuSingleSelection(SContextMenu& contextMenu, bAppended = true; } - // Sub material menu - if (bOnNode && animNode->GetType() == AnimNodeType::Material) - { - QString matName; - int subMtlIndex = GetMatNameAndSubMtlIndexFromName(matName, animNode->GetName()); - _smart_ptr 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 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; - } - // Delete track menu if (bOnTrackNotSub) { diff --git a/Code/Sandbox/Editor/Util/CubemapUtils.cpp b/Code/Sandbox/Editor/Util/CubemapUtils.cpp index a143b7e5ce..bd650abaa8 100644 --- a/Code/Sandbox/Editor/Util/CubemapUtils.cpp +++ b/Code/Sandbox/Editor/Util/CubemapUtils.cpp @@ -30,6 +30,7 @@ #include "Util/ImageTIF.h" #include "Objects/BaseObject.h" +#include class CubemapSizeModel : public QAbstractListModel diff --git a/Code/Sandbox/Editor/Util/FileUtil.cpp b/Code/Sandbox/Editor/Util/FileUtil.cpp index fc5eca1952..8dd379f096 100644 --- a/Code/Sandbox/Editor/Util/FileUtil.cpp +++ b/Code/Sandbox/Editor/Util/FileUtil.cpp @@ -2088,7 +2088,6 @@ void CFileUtil::GatherAssetFilenamesFromLevel(std::set& rOutFilenames, rOutFilenames.clear(); CBaseObjectsArray objArr; CUsedResources usedRes; - IMaterialManager* pMtlMan = GetIEditor()->Get3DEngine()->GetMaterialManager(); GetIEditor()->GetObjectManager()->GetObjects(objArr); @@ -2116,66 +2115,6 @@ void CFileUtil::GatherAssetFilenamesFromLevel(std::set& rOutFilenames, rOutFilenames.insert(tmpStr); } } - - uint32 mtlCount = 0; - - pMtlMan->GetLoadedMaterials(NULL, mtlCount); - - if (mtlCount > 0) - { - AZStd::vector<_smart_ptr> arrMtls; - - arrMtls.resize(mtlCount); - pMtlMan->GetLoadedMaterials(&arrMtls, mtlCount); - - for (size_t i = 0; i < mtlCount; ++i) - { - _smart_ptr pMtl = arrMtls[i]; - - size_t subMtls = pMtl->GetSubMtlCount(); - - // for the main material - IRenderShaderResources* pShaderRes = pMtl->GetShaderItem().m_pShaderResources; - - // add the material filename - rOutFilenames.insert(pMtl->GetName()); - - if (pShaderRes) - { - for ( auto iter= pShaderRes->GetTexturesResourceMap()->begin() ; - iter!= pShaderRes->GetTexturesResourceMap()->end() ; ++iter ) - { - SEfResTexture* pTex = &(iter->second); - // add the texture filename - rOutFilenames.insert(pTex->m_Name.c_str()); - } - } - - // for the submaterials - for (size_t s = 0; s < subMtls; ++s) - { - _smart_ptr pSubMtl = pMtl->GetSubMtl(s); - - // fill up dependencies - if (pSubMtl) - { - IRenderShaderResources* pShaderRes2 = pSubMtl->GetShaderItem().m_pShaderResources; - - rOutFilenames.insert(pSubMtl->GetName()); - - if (pShaderRes2) - { - for (auto iter = pShaderRes2->GetTexturesResourceMap()->begin(); - iter != pShaderRes2->GetTexturesResourceMap()->end(); ++iter) - { - SEfResTexture* pTex = &(iter->second); - rOutFilenames.insert(pTex->m_Name.c_str()); - } - } - } - } - } - } } uint32 CFileUtil::GetAttributes(const char* filename, bool bUseSourceControl /*= true*/) diff --git a/Code/Sandbox/Editor/Util/KDTree.cpp b/Code/Sandbox/Editor/Util/KDTree.cpp index b407305a93..71ec798005 100644 --- a/Code/Sandbox/Editor/Util/KDTree.cpp +++ b/Code/Sandbox/Editor/Util/KDTree.cpp @@ -14,6 +14,8 @@ #include "KDTree.h" +#include + class KDTreeNode { public: diff --git a/Code/Sandbox/Editor/Util/VariableTypeInfo.cpp b/Code/Sandbox/Editor/Util/VariableTypeInfo.cpp deleted file mode 100644 index 206131e5a9..0000000000 --- a/Code/Sandbox/Editor/Util/VariableTypeInfo.cpp +++ /dev/null @@ -1,445 +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 "EditorDefs.h" - -#include "VariableTypeInfo.h" -#include "TypeInfo_impl.h" -#include "IShader_info.h" - -#ifndef AZ_MONOLITHIC_BUILD -#include "I3DEngine_info.h" -#endif - -#include "Variable.h" -#include "UIEnumsDatabase.h" - -// CryCommon -#include - - -IVariable* CVariableTypeInfo::Create(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault) -{ - pAddress = VarInfo.GetAddress(pAddress); - pAddressDefault = VarInfo.GetAddress(pAddressDefault); - - EType eType = GetType(VarInfo.Type); - if (eType == ARRAY) - { - return new CVariableTypeInfoStruct(VarInfo, pAddress, pAddressDefault); - } - - if (VarInfo.Type.EnumElem(0)) - { - return new CVariableTypeInfoEnum(VarInfo, pAddress, pAddressDefault); - } - - ISplineInterpolator* pSpline = 0; - if (VarInfo.Type.ToValue(pAddress, pSpline)) - { - return new CVariableTypeInfoSpline(VarInfo, pAddress, pAddressDefault, pSpline); - } - - return new CVariableTypeInfo(VarInfo, pAddress, pAddressDefault, eType); -} - -CVariableTypeInfo::EType CVariableTypeInfo::GetType(CTypeInfo const& typeInfo) -{ - // Translation to editor type values is currently done with some clunky type and name testing. - if (typeInfo.HasSubVars()) - { - if (typeInfo.IsType() && !typeInfo.NextSubVar(0)->Type.IsType()) - { - // This is a vector type (and not a sub-classed vector type) - return IVariable::VECTOR; - } - else - { - return IVariable::ARRAY; - } - } - else if (typeInfo.IsType()) - { - return IVariable::BOOL; - } - else if (typeInfo.IsType() || typeInfo.IsType()) - { - return IVariable::INT; - } - else if (typeInfo.IsType()) - { - return IVariable::FLOAT; - } - return IVariable::STRING; -} - -CVariableTypeInfo::CVariableTypeInfo(CTypeInfo::CVarInfo const& VarInfo, - void* pAddress, const void* pAddressDefault, EType eType) - : m_pVarInfo(&VarInfo) - , m_pData(pAddress) - , m_pDefaultData(pAddressDefault) -{ - SetName(SpacedName(VarInfo.GetName())); - SetTypes(VarInfo.Type, eType); - SetFlags(IVariable::UI_UNSORTED | IVariable::UI_HIGHLIGHT_EDITED); - SetDescription(VarInfo.GetComment()); -} - -void CVariableTypeInfo::SetTypes(CTypeInfo const& TypeInfo, EType eType) -{ - m_pTypeInfo = &TypeInfo; - m_eType = eType; - - SetDataType(DT_SIMPLE); - if (m_eType == VECTOR) - { - if (m_name == "Color") - { - SetDataType(DT_COLOR); - } - } - else if (m_eType == STRING) - { - if (m_name == "Texture" || m_name == "Glow Map" || m_name == "Normal Map" || m_name == "Trail Fading") - { - SetDataType(DT_TEXTURE); - } - else if (m_name == "Geometry") - { - SetDataType(DT_OBJECT); - } - else if (m_name == "Start Trigger" || m_name == "Stop Trigger") - { - SetDataType(DT_AUDIO_TRIGGER); - } - else if (m_name == "GeomCache") - { - SetDataType(DT_GEOM_CACHE); - } - } -} - -// IVariable implementation. -CVariableTypeInfo::EType CVariableTypeInfo::GetType() const -{ - return m_eType; -} - -int CVariableTypeInfo::GetSize() const -{ - return m_pTypeInfo->Size; -} - -void CVariableTypeInfo::GetLimits(float& fMin, float& fMax, float& fStep, bool& bHardMin, bool& bHardMax) -{ - // Get hard limits from variable type, or vector element type. - const CTypeInfo* pLimitType = m_pTypeInfo; - if ((m_eType == VECTOR || m_eType == VECTOR2) && m_pTypeInfo->NextSubVar(0)) - { - pLimitType = &m_pTypeInfo->NextSubVar(0)->Type; - } - bHardMin = pLimitType->GetLimit(eLimit_Min, fMin); - bHardMax = pLimitType->GetLimit(eLimit_Max, fMax); - pLimitType->GetLimit(eLimit_Step, fStep); - - // Check var attrs for additional limits. - if (m_pVarInfo->GetAttr("SoftMin", fMin)) - { - bHardMin = false; - } - else if (m_pVarInfo->GetAttr("Min", fMin)) - { - bHardMin = true; - } - - if (m_pVarInfo->GetAttr("SoftMax", fMax)) - { - bHardMax = false; - } - else if (m_pVarInfo->GetAttr("Max", fMax)) - { - bHardMax = true; - } -} - -void CVariableTypeInfo::Set(const char* value) -{ - m_pTypeInfo->FromString(m_pData, value); - OnSetValue(false); -} - -void CVariableTypeInfo::Set(const QString& value) -{ - Set(value.toUtf8().data()); -} - -void CVariableTypeInfo::Set(float value) -{ - m_pTypeInfo->FromValue(m_pData, value); - OnSetValue(false); -} - -void CVariableTypeInfo::Set(int value) -{ - m_pTypeInfo->FromValue(m_pData, value); - OnSetValue(false); -} - -void CVariableTypeInfo::Set(bool value) -{ - m_pTypeInfo->FromValue(m_pData, value); - OnSetValue(false); -} - -void CVariableTypeInfo::Set(const Vec2& value) -{ - m_pTypeInfo->FromValue(m_pData, value); - OnSetValue(false); -} - -void CVariableTypeInfo::Set(const Vec3& value) -{ - m_pTypeInfo->FromValue(m_pData, value); - OnSetValue(false); -} - -void CVariableTypeInfo::Get(QString& value) const -{ - value = (const char*)m_pTypeInfo->ToString(m_pData); -} - -void CVariableTypeInfo::Get(float& value) const -{ - m_pTypeInfo->ToValue(m_pData, value); -} - -void CVariableTypeInfo::Get(int& value) const -{ - m_pTypeInfo->ToValue(m_pData, value); -} - -void CVariableTypeInfo::Get(bool& value) const -{ - m_pTypeInfo->ToValue(m_pData, value); -} - -void CVariableTypeInfo::Get(Vec2& value) const -{ - m_pTypeInfo->ToValue(m_pData, value); -} - -void CVariableTypeInfo::Get(Vec3& value) const -{ - m_pTypeInfo->ToValue(m_pData, value); -} - -bool CVariableTypeInfo::HasDefaultValue() const -{ - return m_pTypeInfo->ValueEqual(m_pData, m_pDefaultData); -} - -void CVariableTypeInfo::ResetToDefault() -{ - QString strVal = m_pTypeInfo->ToString(m_pDefaultData).c_str(); - Set(strVal); -} - -IVariable* CVariableTypeInfo::Clone([[maybe_unused]] bool bRecursive) const -{ - // Simply use a string var for universal conversion. - IVariable* pClone = new CVariable(); - QString str; - Get(str); - pClone->Set(str); - - //add extra information for the clone: Name, DataType - pClone->SetName(GetName()); - pClone->SetDataType(GetDataType()); - //use UserData to save eType since String Variable's GetType always return STRING - pClone->SetUserData(GetType()); - - return pClone; -} - -void CVariableTypeInfo::CopyValue(IVariable* fromVar) -{ - assert(fromVar); - QString str; - fromVar->Get(str); - Set(str); -} - -CVariableTypeInfoEnum::CTypeInfoEnumList::CTypeInfoEnumList(CTypeInfo const& info) - : TypeInfo(info) -{ -} - -QString CVariableTypeInfoEnum::CTypeInfoEnumList::GetItemName(uint index) -{ - return TypeInfo.EnumElem(index); -} - -CVariableTypeInfoEnum::CVariableTypeInfoEnum(CTypeInfo::CVarInfo const& VarInfo, - void* pAddress, const void* pAddressDefault, IVarEnumList* pEnumList) - : CVariableTypeInfo(VarInfo, pAddress, pAddressDefault, UNKNOWN) -{ - // Use custom enum, or enum defined in TypeInfo. - m_enumList = pEnumList ? pEnumList : new CTypeInfoEnumList(VarInfo.Type); -} - -IVarEnumList* CVariableTypeInfoEnum::GetEnumList() const -{ - return m_enumList; -} - -CVariableTypeInfoSpline::CVariableTypeInfoSpline(CTypeInfo::CVarInfo const& VarInfo, - void* pAddress, const void* pAddressDefault, ISplineInterpolator* pSpline) - : CVariableTypeInfo(VarInfo, pAddress, pAddressDefault, STRING) - , m_pSpline(pSpline) -{ - if (m_pSpline && m_pSpline->GetNumDimensions() == 3) - { - SetDataType(DT_CURVE | DT_COLOR); - } - else - { - SetDataType(DT_CURVE | DT_PERCENT); - } -} - -CVariableTypeInfoSpline::~CVariableTypeInfoSpline() -{ - delete m_pSpline; -} - -ISplineInterpolator* CVariableTypeInfoSpline::GetSpline() -{ - //if m_pSpline wasn't created or the data used to create spline was changed, we need create the m_pSpline - int flags = GetFlags(); - if (m_pSpline == nullptr || flags & UI_CREATE_SPLINE) - { - if (m_pSpline != nullptr) - { - delete m_pSpline; - m_pSpline = nullptr; - } - m_pTypeInfo->ToValue(m_pData, m_pSpline); - flags &= ~UI_CREATE_SPLINE; - SetFlags(flags); - } - return m_pSpline; -} - -void CVariableTypeInfoSpline::OnSetValue(bool bRecursive) -{ - m_pTypeInfo->ToValue(m_pData, m_pSpline); - CVariableTypeInfo::OnSetValue(bRecursive); -} - -CVariableTypeInfoStruct::CVariableTypeInfoStruct(CTypeInfo::CVarInfo const& VarInfo, - void* pAddress, const void* pAddressDefault) - : CVariableTypeInfo(VarInfo, pAddress, pAddressDefault, ARRAY) -{ - ProcessSubStruct(VarInfo, pAddress, pAddressDefault); -} - -void CVariableTypeInfoStruct::ProcessSubStruct(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault) -{ - for AllSubVars(pSubVar, VarInfo.Type) - { - if (!*pSubVar->GetName()) - { - EType eType = GetType(pSubVar->Type); - if (eType == ARRAY) - { - // Recursively process nameless or base struct. - ProcessSubStruct(*pSubVar, pSubVar->GetAddress(pAddress), pSubVar->GetAddress(pAddressDefault)); - } - else if (pSubVar == VarInfo.Type.NextSubVar(0)) - { - // Inline edit first sub-var in main field. - SetTypes(pSubVar->Type, eType); - } - } - else - { - IVariable* pVar = CVariableTypeInfo::Create(*pSubVar, pAddress, pAddressDefault); - m_Vars.push_back(pVar); - } - } -} - -QString CVariableTypeInfoStruct::GetDisplayValue() const -{ - return (const char*)m_pTypeInfo->ToString(m_pData); -} - -void CVariableTypeInfoStruct::OnSetValue(bool bRecursive) -{ - CVariableBase::OnSetValue(bRecursive); - if (bRecursive) - { - for (Vars::iterator it = m_Vars.begin(); it != m_Vars.end(); ++it) - { - (*it)->OnSetValue(true); - } - } -} - -void CVariableTypeInfoStruct::SetFlagRecursive(EFlags flag) -{ - CVariableBase::SetFlagRecursive(flag); - for (Vars::iterator it = m_Vars.begin(); it != m_Vars.end(); ++it) - { - (*it)->SetFlagRecursive(flag); - } -} - -void CVariableTypeInfoStruct::CopyValue(IVariable* fromVar) -{ - assert(fromVar); - if (fromVar->GetType() != IVariable::ARRAY) - { - CVariableTypeInfo::CopyValue(fromVar); - } - - int numSrc = fromVar->GetNumVariables(); - int numTrg = m_Vars.size(); - for (int i = 0; i < numSrc && i < numTrg; i++) - { - // Copy Every child variable. - m_Vars[i]->CopyValue(fromVar->GetVariable(i)); - } -} - -int CVariableTypeInfoStruct::GetNumVariables() const -{ - return m_Vars.size(); -} - -IVariable* CVariableTypeInfoStruct::GetVariable(int index) const -{ - return m_Vars[index]; -} - -CUIEnumsDBList::CUIEnumsDBList(CUIEnumsDatabase_SEnum const* pEnumList) - : m_pEnumList(pEnumList) -{ -} - -QString CUIEnumsDBList::GetItemName(uint index) -{ - if (index >= m_pEnumList->strings.size()) - { - return NULL; - } - return m_pEnumList->strings[index]; -} diff --git a/Code/Sandbox/Editor/Util/VariableTypeInfo.h b/Code/Sandbox/Editor/Util/VariableTypeInfo.h deleted file mode 100644 index 1e36d1ca96..0000000000 --- a/Code/Sandbox/Editor/Util/VariableTypeInfo.h +++ /dev/null @@ -1,221 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_UTIL_VARIABLETYPEINFO_H -#define CRYINCLUDE_EDITOR_UTIL_VARIABLETYPEINFO_H -#pragma once - -#include "Variable.h" -#include "UIEnumsDatabase.h" -#include "VariableTypeInfo.h" - -#include - -////////////////////////////////////////////////////////////////////////// -// Adaptors for TypeInfo-defined variables to IVariable - -inline QString SpacedName(const char* sName) -{ - // Split name with spaces. - QString sSpacedName = sName; - for (int i = 1; i < sSpacedName.length(); i++) - { - if (sSpacedName[i].isUpper() && sSpacedName[i - 1].isLower()) - { - sSpacedName.insert(i, ' '); - i++; - } - } - return sSpacedName; -} - -////////////////////////////////////////////////////////////////////////// -// Scalar variable -////////////////////////////////////////////////////////////////////////// - -class EDITOR_CORE_API CVariableTypeInfo - : public CVariableBase -{ -public: - // Dynamic constructor function - static IVariable* Create(CTypeInfo::CVarInfo const& VarInfo, void* pBaseAddress, const void* pBaseAddressDefault); - - static EType GetType(CTypeInfo const& TypeInfo); - - CVariableTypeInfo(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault, EType eType); - - void SetTypes(CTypeInfo const& TypeInfo, EType eType); - - // IVariable implementation. - virtual EType GetType() const; - virtual int GetSize() const; - - virtual void GetLimits(float& fMin, float& fMax, float& fStep, bool& bHardMin, bool& bHardMax); - - ////////////////////////////////////////////////////////////////////////// - // Access operators. - ////////////////////////////////////////////////////////////////////////// - - virtual void Set(const char* value); - - virtual void Set(const QString& value); - - virtual void Set(float value); - - virtual void Set(int value); - - virtual void Set(bool value); - - virtual void Set(const Vec2& value); - - virtual void Set(const Vec3& value); - - virtual void Get(QString& value) const; - - virtual void Get(float& value) const; - - virtual void Get(int& value) const; - - virtual void Get(bool& value) const; - - virtual void Get(Vec2& value) const; - - virtual void Get(Vec3& value) const; - - virtual bool HasDefaultValue() const; - - virtual void ResetToDefault(); - - virtual IVariable* Clone(bool bRecursive) const; - - // To do: This could be more efficient ? - virtual void CopyValue(IVariable* fromVar); - -protected: - CTypeInfo::CVarInfo const* m_pVarInfo; - CTypeInfo const* m_pTypeInfo; // TypeInfo system structure for this var. - void* m_pData; // Existing address in memory. Directly modified. - const void* m_pDefaultData; // Address of default data for this var. - EType m_eType; // Type info for editor. - IEditor* m_pEditor; -}; - -////////////////////////////////////////////////////////////////////////// -// Enum variable -////////////////////////////////////////////////////////////////////////// - -class EDITOR_CORE_API CVariableTypeInfoEnum - : public CVariableTypeInfo -{ - struct CTypeInfoEnumList - : IVarEnumList - { - CTypeInfo const& TypeInfo; - - CTypeInfoEnumList(CTypeInfo const& info); - - virtual QString GetItemName(uint index); - }; - -public: - - // Constructor. - CVariableTypeInfoEnum(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault, IVarEnumList* pEnumList = 0); - - ////////////////////////////////////////////////////////////////////////// - // Additional IVariable implementation. - ////////////////////////////////////////////////////////////////////////// - - IVarEnumList* GetEnumList() const; - -protected: - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - TSmartPtr m_enumList; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - -////////////////////////////////////////////////////////////////////////// -// Spline variable -////////////////////////////////////////////////////////////////////////// - -class EDITOR_CORE_API CVariableTypeInfoSpline - : public CVariableTypeInfo -{ - -public: - - // Constructor. - CVariableTypeInfoSpline(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault, ISplineInterpolator* pSpline); - - ~CVariableTypeInfoSpline(); - - virtual ISplineInterpolator* GetSpline(); - - //! Overrides CVariableTypeInfo to keep m_pSpline in sync with CVariableTypeInfo::m_pData - //! when Set(value) functions are called - void OnSetValue(bool bRecursive) override; - -private: - ISplineInterpolator* m_pSpline; -}; - -////////////////////////////////////////////////////////////////////////// -// Struct variable -// Inherits implementation from CVariableArray -////////////////////////////////////////////////////////////////////////// - -class EDITOR_CORE_API CVariableTypeInfoStruct - : public CVariableTypeInfo -{ -public: - // Constructor. - CVariableTypeInfoStruct(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault); - - void ProcessSubStruct(CTypeInfo::CVarInfo const& VarInfo, void* pAddress, const void* pAddressDefault); - - ////////////////////////////////////////////////////////////////////////// - // IVariable implementation. - ////////////////////////////////////////////////////////////////////////// - - virtual QString GetDisplayValue() const; - - virtual void OnSetValue(bool bRecursive); - - void SetFlagRecursive(EFlags flag) override; - - void CopyValue(IVariable* fromVar); - - int GetNumVariables() const; - - IVariable* GetVariable(int index) const; - -protected: - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - typedef std::vector Vars; - Vars m_Vars; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -}; - -AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING -struct EDITOR_CORE_API CUIEnumsDBList - : IVarEnumList -{ -AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING - CUIEnumsDatabase_SEnum const* m_pEnumList; - - CUIEnumsDBList(CUIEnumsDatabase_SEnum const* pEnumList); - - virtual QString GetItemName(uint index); -}; - -#endif // CRYINCLUDE_EDITOR_UTIL_VARIABLETYPEINFO_H diff --git a/Code/Sandbox/Editor/ViewportManipulatorController.cpp b/Code/Sandbox/Editor/ViewportManipulatorController.cpp index fc376b27d0..43d2fb1f2c 100644 --- a/Code/Sandbox/Editor/ViewportManipulatorController.cpp +++ b/Code/Sandbox/Editor/ViewportManipulatorController.cpp @@ -112,8 +112,7 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram m_state.m_mousePick.m_screenCoordinates = screenPosition; AZStd::optional ray; ViewportInteractionRequestBus::EventResult( - ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, - QPoint(screenPosition.m_x, screenPosition.m_y)); + ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPosition); if (ray.has_value()) { diff --git a/Code/Sandbox/Editor/editor_core_files.cmake b/Code/Sandbox/Editor/editor_core_files.cmake index 85db7ec86b..1aecbd03f6 100644 --- a/Code/Sandbox/Editor/editor_core_files.cmake +++ b/Code/Sandbox/Editor/editor_core_files.cmake @@ -54,13 +54,11 @@ set(FILES Util/MemoryBlock.cpp Util/Variable.cpp Util/UndoUtil.cpp - Util/VariableTypeInfo.cpp Util/VariablePropertyType.cpp Clipboard.h Util/MemoryBlock.h Util/Variable.h Util/UndoUtil.h - Util/VariableTypeInfo.h Util/VariablePropertyType.h Util/RefCountBase.h Util/PathUtil.h diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index a0c22c9a14..f6537909e9 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -323,11 +323,6 @@ set(FILES AzAssetBrowser/AzAssetBrowserWindow.cpp AzAssetBrowser/AzAssetBrowserWindow.h AzAssetBrowser/AzAssetBrowserWindow.ui - AzAssetBrowser/Preview/LegacyPreviewer.cpp - AzAssetBrowser/Preview/LegacyPreviewer.h - AzAssetBrowser/Preview/LegacyPreviewer.ui - AzAssetBrowser/Preview/LegacyPreviewerFactory.cpp - AzAssetBrowser/Preview/LegacyPreviewerFactory.h AssetDatabase/AssetDatabaseLocationListener.h AssetDatabase/AssetDatabaseLocationListener.cpp AssetImporter/AssetImporterManager/AssetImporterDragAndDropHandler.cpp @@ -376,8 +371,7 @@ set(FILES Controls/MultiMonHelper.h Controls/NumberCtrl.cpp Controls/NumberCtrl.h - Controls/PreviewModelCtrl.cpp - Controls/PreviewModelCtrl.h + Controls/NumberCtrl.h Controls/SplineCtrl.cpp Controls/SplineCtrl.h Controls/SplineCtrlEx.cpp @@ -386,8 +380,6 @@ set(FILES Controls/TextEditorCtrl.h Controls/TimelineCtrl.cpp Controls/TimelineCtrl.h - Controls/TimeOfDaySlider.cpp - Controls/TimeOfDaySlider.h Controls/WndGridHelper.h Controls/ReflectedPropertyControl/PropertyAnimationCtrl.cpp Controls/ReflectedPropertyControl/PropertyAnimationCtrl.h @@ -460,8 +452,6 @@ set(FILES LevelFileDialog.qrc LevelFileDialog.h LevelFileDialog.ui - PanelPreview.cpp - PanelPreview.h QuickAccessBar.cpp QuickAccessBar.h QuickAccessBar.ui @@ -495,10 +485,6 @@ set(FILES IconListDialog.ui UndoDropDown.cpp UndoDropDown.h - TimeOfDayDialog.cpp - TimeOfDayDialog.h - TimeOfDayDialog.ui - TimeOfDay.qrc DimensionsDialog.cpp DimensionsDialog.h DimensionsDialog.ui @@ -528,11 +514,7 @@ set(FILES GameResourcesExporter.cpp GameExporter.h GameResourcesExporter.h - Geometry/EdGeometry.cpp - Geometry/EdMesh.cpp Geometry/TriMesh.cpp - Geometry/EdGeometry.h - Geometry/EdMesh.h Geometry/TriMesh.h AboutDialog.h AboutDialog.ui @@ -560,8 +542,6 @@ set(FILES LevelIndependentFileMan.h LogFileImpl.cpp LogFileImpl.h - Mission.cpp - Mission.h Objects/ClassDesc.cpp Objects/ClassDesc.h Objects/IEntityObjectListener.h @@ -654,8 +634,6 @@ set(FILES LightmapCompiler/SimpleTriangleRasterizer.cpp ResourceSelectorHost.cpp ResourceSelectorHost.h - ThumbnailGenerator.cpp - ThumbnailGenerator.h ToolBox.cpp TrackViewNewSequenceDialog.cpp TrackViewNewSequenceDialog.ui @@ -687,9 +665,6 @@ set(FILES ShaderEnum.h SurfaceTypeValidator.cpp SurfaceTypeValidator.h - EnvironmentPanel.cpp - EnvironmentPanel.h - EnvironmentPanel.ui TrackView/AtomOutputFrameCapture.cpp TrackView/AtomOutputFrameCapture.h TrackView/TrackViewDialog.qrc @@ -881,9 +856,6 @@ set(FILES Grid.h LayoutWnd.cpp LayoutWnd.h - ModelViewport.cpp - ModelViewport.h - ModelViewportDC.cpp EditorViewportWidget.cpp EditorViewportWidget.h ViewportManipulatorController.cpp diff --git a/Code/Sandbox/Plugins/CMakeLists.txt b/Code/Sandbox/Plugins/CMakeLists.txt index 5b940921c1..0f83a98aa1 100644 --- a/Code/Sandbox/Plugins/CMakeLists.txt +++ b/Code/Sandbox/Plugins/CMakeLists.txt @@ -11,7 +11,6 @@ add_subdirectory(EditorCommon) add_subdirectory(ComponentEntityEditorPlugin) -add_subdirectory(FBXPlugin) add_subdirectory(FFMPEGPlugin) add_subdirectory(ProjectSettingsTool) add_subdirectory(PerforcePlugin) diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp index 692bb92bf7..c85ed1248f 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp @@ -905,7 +905,7 @@ void CComponentEntityObject::Display(DisplayContext& dc) AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; AzFramework::DebugDisplayRequestBus::Bind( - debugDisplayBus, AzToolsFramework::ViewportInteraction::g_mainViewportEntityDebugDisplayId); + debugDisplayBus, AzFramework::g_defaultSceneEntityDebugDisplayId); AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus."); AzFramework::DebugDisplayRequests* debugDisplay = diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp index cd423535f2..49d56f67df 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp @@ -1473,13 +1473,14 @@ void OutlinerListModel::OnEntityInfoUpdatedRemoveChildBegin(AZ::EntityId parentI emit EnableSelectionUpdates(false); auto parentIndex = GetIndexFromEntity(parentId); auto childIndex = GetIndexFromEntity(childId); - beginRemoveRows(parentIndex, childIndex.row(), childIndex.row()); + beginResetModel(); } void OutlinerListModel::OnEntityInfoUpdatedRemoveChildEnd(AZ::EntityId parentId, AZ::EntityId childId) { (void)childId; AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); + endRemoveRows(); //must refresh partial lock/visibility of parents diff --git a/Code/Sandbox/Plugins/EditorCommon/ManipScene.cpp b/Code/Sandbox/Plugins/EditorCommon/ManipScene.cpp index 5aa5301693..5b76ca8804 100644 --- a/Code/Sandbox/Plugins/EditorCommon/ManipScene.cpp +++ b/Code/Sandbox/Plugins/EditorCommon/ManipScene.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include "../EditorCommon/QViewport.h" diff --git a/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp b/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp index 362452a67e..2d9598ba83 100644 --- a/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp +++ b/Code/Sandbox/Plugins/EditorCommon/QViewport.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -108,114 +107,6 @@ struct QViewport::SPreviousContext bool isMainViewport; }; -static void DrawGridLine(IRenderAuxGeom& aux, ColorB col, const float alpha, const float alphaFalloff, const float slide, const float halfSlide, [[maybe_unused]] const float maxSlide, const Vec3& stepDir, const Vec3& orthoDir, const SViewportState& state, const SViewportGridSettings& gridSettings) -{ - ColorB colEnd = col; - - float weight = 1.0f - (slide / halfSlide); - if (slide > halfSlide) - { - weight = (slide - halfSlide) / halfSlide; - } - - float orthoWeight = 1.0f; - - if (gridSettings.circular) - { - float invWeight = 1.0f - weight; - orthoWeight = sqrtf((invWeight * 2) - (invWeight * invWeight)); - } - else - { - orthoWeight = 1.0f; - } - - col.a = aznumeric_cast((1.0f - (weight * (1.0f - alphaFalloff))) * alpha); - colEnd.a = aznumeric_cast(alphaFalloff * alpha); - - Vec3 orthoStep = state.gridOrigin.q * (orthoDir * halfSlide * orthoWeight); - - Vec3 point = state.gridOrigin * (-(stepDir * halfSlide) + (stepDir * slide)); - Vec3 points[3] = { - point, - point - orthoStep, - point + orthoStep - }; - - aux.DrawLine(points[0], col, points[1], colEnd); - aux.DrawLine(points[0], col, points[2], colEnd); -} - -static void DrawGridLines(IRenderAuxGeom& aux, const uint count, const uint interStepCount, const Vec3& stepDir, const float stepSize, const Vec3& orthoDir, const float offset, const SViewportState& state, const SViewportGridSettings& gridSettings) -{ - const uint countHalf = count / 2; - Vec3 step = stepDir * stepSize; - Vec3 orthoStep = orthoDir * aznumeric_cast(countHalf); - Vec3 maxStep = step * aznumeric_cast(countHalf);// + stepDir*fabs(offset); - const float maxStepLen = count * stepSize; - const float halfStepLen = countHalf * stepSize; - - float interStepSize = interStepCount > 0 ? (stepSize / interStepCount) : stepSize; - const float alphaMulMain = (float)gridSettings.mainColor.a; - const float alphaMulInter = (float)gridSettings.middleColor.a; - const float alphaFalloff = 1.0f - (gridSettings.alphaFalloff / 100.0f); - - for (int i = 0; i < count + 2; i++) - { - float pointSlide = i * stepSize + offset; - if (pointSlide > 0.0f && pointSlide < maxStepLen) - { - DrawGridLine(aux, gridSettings.mainColor, alphaMulMain, alphaFalloff, pointSlide, halfStepLen, maxStepLen, stepDir, orthoDir, state, gridSettings); - } - - for (int d = 1; d < interStepCount; d++) - { - float interSlide = ((i - 1) * stepSize) + offset + (d * interStepSize); - if (interSlide > 0.0f && interSlide < maxStepLen) - { - DrawGridLine(aux, gridSettings.middleColor, alphaMulInter, alphaFalloff, interSlide, halfStepLen, maxStepLen, stepDir, orthoDir, state, gridSettings); - } - } - } -} - -static void DrawGrid(IRenderAuxGeom& aux, const SViewportState& state, const SViewportGridSettings& gridSettings) -{ - const uint count = gridSettings.count * 2; - const float gridSize = gridSettings.spacing * gridSettings.count * 2.0f; - const float halfGridSize = gridSettings.spacing * gridSettings.count; - - const float stepSize = gridSize / count; - DrawGridLines(aux, count, gridSettings.interCount, Vec3(1.0f, 0.0f, 0.0f), stepSize, Vec3(0.0f, 1.0f, 0.0f), state.gridCellOffset.x, state, gridSettings); - DrawGridLines(aux, count, gridSettings.interCount, Vec3(0.0f, 1.0f, 0.0f), stepSize, Vec3(1.0f, 0.0f, 0.0f), state.gridCellOffset.y, state, gridSettings); -} - -static void DrawOrigin(IRenderAuxGeom& aux, const ColorB& col) -{ - const float scale = 0.3f; - const float lineWidth = 4.0f; - aux.DrawLine(Vec3(-scale, 0, 0), col, Vec3(scale, 0, 0), col, lineWidth); - aux.DrawLine(Vec3(0, -scale, 0), col, Vec3(0, scale, 0), col, lineWidth); - aux.DrawLine(Vec3(0, 0, -scale), col, Vec3(0, 0, scale), col, lineWidth); -} - -static void DrawOrigin(IRenderAuxGeom& aux, const int left, const int top, const float scale, const Matrix34 cameraTM) -{ - Vec3 originPos = Vec3(aznumeric_cast(left), aznumeric_cast(top), 0); - Quat originRot = Quat(0.707107f, 0.707107f, 0, 0) * Quat(cameraTM).GetInverted(); - Vec3 x = originPos + originRot * Vec3(1, 0, 0) * scale; - Vec3 y = originPos + originRot * Vec3(0, 1, 0) * scale; - Vec3 z = originPos + originRot * Vec3(0, 0, 1) * scale; - ColorF xCol(1, 0, 0); - ColorF yCol(0, 1, 0); - ColorF zCol(0, 0, 1); - const float lineWidth = 2.0f; - - aux.DrawLine(originPos, xCol, x, xCol, lineWidth); - aux.DrawLine(originPos, yCol, y, yCol, lineWidth); - aux.DrawLine(originPos, zCol, z, zCol, lineWidth); -} - struct QViewport::SPrivate { CDLight m_VPLight0; @@ -494,49 +385,6 @@ void QViewport::Update() { m_averageFrameTime = 0.01f * m_lastFrameTime + 0.99f * m_averageFrameTime; } - - if (GetIEditor()->GetEnv()->pRenderer == 0 || - GetIEditor()->GetEnv()->p3DEngine == 0) - { - return; - } - - if (!isVisible()) - { - return; - } - - if (!m_renderContextCreated) - { - return; - } - - if (m_updating) - { - return; - } - - AutoBool updating(&m_updating); - - if (m_resizeWindowEvent) - { - HWND windowHandle = reinterpret_cast(QWidget::winId()); - AzFramework::WindowNotificationBus::Event(windowHandle, &AzFramework::WindowNotificationBus::Handler::OnWindowResized, m_width, m_height); - m_resizeWindowEvent = false; - } - - if (hasFocus()) - { - ProcessMouse(); - ProcessKeys(); - } - - if ((m_width <= 0) || (m_height <= 0)) - { - return; - } - - RenderInternal(); } void QViewport::CaptureMouse() @@ -860,210 +708,16 @@ void QViewport::PreRender() m_state->lastCameraParentFrame = m_state->cameraParentFrame; m_state->lastCameraTarget = currentTM; - m_camera->SetFrustum(m_width, m_height, fov, m_settings->camera.nearClip, GetIEditor()->GetEnv()->p3DEngine->GetMaxViewDistance()); + m_camera->SetFrustum(m_width, m_height, fov, m_settings->camera.nearClip); m_camera->SetMatrix(Matrix34(m_state->cameraParentFrame * currentTM)); } void QViewport::Render() { - IRenderAuxGeom* aux = GetIEditor()->GetEnv()->pRenderer->GetIRenderAuxGeom(); - SAuxGeomRenderFlags oldFlags = aux->GetRenderFlags(); - - if (m_settings->grid.showGrid) - { - aux->SetRenderFlags(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeNone | e_DepthWriteOff | e_DepthTestOn); - DrawGrid(*aux, *m_state, m_settings->grid); - } - - if (m_settings->grid.origin) - { - aux->SetRenderFlags(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeNone | e_DepthWriteOff | e_DepthTestOn); - DrawOrigin(*aux, m_settings->grid.originColor); - } - - if (m_settings->camera.showViewportOrientation) - { - aux->SetRenderFlags(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeNone | e_DepthWriteOn | e_DepthTestOn); - TransformationMatrices backupSceneMatrices; - GetIEditor()->GetEnv()->pRenderer->Set2DMode(m_width, m_height, backupSceneMatrices); - DrawOrigin(*aux, 50, m_height - 50, 20.0f, m_camera->GetMatrix()); - GetIEditor()->GetEnv()->pRenderer->Unset2DMode(backupSceneMatrices); - } - - // Force grid, origin and viewport orientation to render by calling Flush(). This ensures that they are always drawn behind other geometry - aux->Flush(); - aux->SetRenderFlags(oldFlags); - - // wireframe mode - CScopedWireFrameMode scopedWireFrame(GetIEditor()->GetEnv()->pRenderer, m_settings->rendering.wireframe ? R_WIREFRAME_MODE : R_SOLID_MODE); - - SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(*m_camera, SRenderingPassInfo::DEFAULT_FLAGS, true); - GetIEditor()->GetEnv()->pRenderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID()); - GetIEditor()->GetEnv()->pRenderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID()); - GetIEditor()->GetEnv()->pRenderer->EF_ClearSkinningDataPool(); - GetIEditor()->GetEnv()->pRenderer->EF_StartEf(passInfo); - - SRendParams rp; - - - //--------------------------------------------------------------------------------------- - //---- add light ------------------------------------------------------------- - //--------------------------------------------------------------------------------------- - ///////////////////////////////////////////////////////////////////////////////////// - // Confetti Start - ///////////////////////////////////////////////////////////////////////////////////// - // If time of day enabled, add sun light to preview - Confetti Vera. - if (m_settings->rendering.sunlight) - { - rp.AmbientColor.r = GetIEditor()->Get3DEngine()->GetSunColor().x / 255.0f * m_settings->lighting.m_brightness; - rp.AmbientColor.g = GetIEditor()->Get3DEngine()->GetSunColor().y / 255.0f * m_settings->lighting.m_brightness; - rp.AmbientColor.b = GetIEditor()->Get3DEngine()->GetSunColor().z / 255.0f * m_settings->lighting.m_brightness; - - m_private->m_sun.SetPosition(passInfo.GetCamera().GetPosition() + GetIEditor()->Get3DEngine()->GetSunDir()); - // The radius value respect the sun radius settings in Engine. - // Please refer to the function C3DEngine::UpdateSun(const SRenderingPassInfo &passInfo). -- Vera, Confetti - m_private->m_sun.m_fRadius = 100000000; //Radius of the sun from Engine. - m_private->m_sun.SetLightColor(GetIEditor()->Get3DEngine()->GetSunColor()); - m_private->m_sun.SetSpecularMult(GetIEditor()->Get3DEngine()->GetGlobalParameter(E3DPARAM_SUN_SPECULAR_MULTIPLIER)); - m_private->m_sun.m_Flags |= DLF_DIRECTIONAL | DLF_SUN | DLF_THIS_AREA_ONLY | DLF_LM | DLF_SPECULAROCCLUSION | - ((GetIEditor()->Get3DEngine()->IsSunShadows() && passInfo.RenderShadows()) ? DLF_CASTSHADOW_MAPS : 0); - m_private->m_sun.m_sName = "Sun"; - - GetIEditor()->GetEnv()->pRenderer->EF_ADDDlight(&m_private->m_sun, passInfo); - } - ///////////////////////////////////////////////////////////////////////////////////// - // Confetti End - ///////////////////////////////////////////////////////////////////////////////////// - else // Add directional light - { - rp.AmbientColor.r = m_settings->lighting.m_ambientColor.r / 255.0f * m_settings->lighting.m_brightness; - rp.AmbientColor.g = m_settings->lighting.m_ambientColor.g / 255.0f * m_settings->lighting.m_brightness; - rp.AmbientColor.b = m_settings->lighting.m_ambientColor.b / 255.0f * m_settings->lighting.m_brightness; - - // Directional light - if (m_settings->lighting.m_useLightRotation) - { - m_LightRotationRadian += m_averageFrameTime; - } - if (m_LightRotationRadian > gf_PI) - { - m_LightRotationRadian = -gf_PI; - } - - Matrix33 LightRot33 = Matrix33::CreateRotationZ(m_LightRotationRadian); - - f32 lightMultiplier = m_settings->lighting.m_lightMultiplier; - f32 lightSpecMultiplier = m_settings->lighting.m_lightSpecMultiplier; - - f32 lightOrbit = 15.0f; - Vec3 LPos0 = Vec3(-lightOrbit, lightOrbit, lightOrbit / 2); - m_private->m_VPLight0.SetPosition(LightRot33 * LPos0); - - Vec3 d0; - d0.x = f32(m_settings->lighting.m_directionalLightColor.r) / 255.0f; - d0.y = f32(m_settings->lighting.m_directionalLightColor.g) / 255.0f; - d0.z = f32(m_settings->lighting.m_directionalLightColor.b) / 255.0f; - m_private->m_VPLight0.SetLightColor(ColorF(d0.x * lightMultiplier, d0.y * lightMultiplier, d0.z * lightMultiplier, 0)); - m_private->m_VPLight0.SetSpecularMult(lightSpecMultiplier); - - m_private->m_VPLight0.m_Flags = DLF_SUN | DLF_DIRECTIONAL; - GetIEditor()->GetEnv()->pRenderer->EF_ADDDlight(&m_private->m_VPLight0, passInfo); - } - - //--------------------------------------------------------------------------------------- - - Matrix34 tm(IDENTITY); - rp.pMatrix = &tm; - rp.pPrevMatrix = &tm; - - rp.dwFObjFlags = 0; - - SRenderContext rc; - rc.camera = m_camera.get(); - rc.viewport = this; - rc.passInfo = &passInfo; - rc.renderParams = &rp; - - - for (size_t i = 0; i < m_consumers.size(); ++i) - { - m_consumers[i]->OnViewportRender(rc); - } - SignalRender(rc); - - if ((m_settings->rendering.fps == true) && (m_averageFrameTime != 0.0f)) - { - GetIEditor()->GetEnv()->pRenderer->Draw2dLabel(12.0f, 12.0f, 1.25f, ColorF(1, 1, 1, 1), false, "FPS: %.2f", 1.0f / m_averageFrameTime); - } - - GetIEditor()->GetEnv()->pRenderer->EF_EndEf3D(SHDF_STREAM_SYNC, -1, -1, passInfo); - - if (m_mouseMovementsSinceLastFrame > 0) - { - m_mouseMovementsSinceLastFrame = 0; - - // Make sure we deliver at least last mouse movement event - OnMouseEvent(m_pendingMouseMoveEvent); - } } void QViewport::RenderInternal() { - { - threadID mainThread = 0; - threadID renderThread = 0; - GetIEditor()->GetEnv()->pRenderer->GetThreadIDs(mainThread, renderThread); - const threadID currentThreadId = CryGetCurrentThreadId(); - - // I'm not sure if this criteria is right. It might not be restrictive enough, but it's at least strict enough to prevent - // the crash we encountered. - const uint32 workerThreadId = AZ::JobContext::GetGlobalContext()->GetJobManager().GetWorkerThreadId(); - const bool isValidThread = (workerThreadId != AZ::JobManager::InvalidWorkerThreadId) || mainThread == currentThreadId || renderThread == currentThreadId; - - if (!isValidThread) - { - AZ_Assert(false, "Attempting to render QViewport on unsupported thread %" PRI_THREADID, currentThreadId); - return; - } - } - - - SetCurrentContext(); - GetIEditor()->GetEnv()->pSystem->RenderBegin(); - - ColorF viewportBackgroundColor(m_settings->background.topColor.r / 255.0f, m_settings->background.topColor.g / 255.0f, m_settings->background.topColor.b / 255.0f); - GetIEditor()->GetEnv()->pRenderer->ClearTargetsImmediately(FRT_CLEAR, viewportBackgroundColor); - GetIEditor()->GetEnv()->pRenderer->ResetToDefault(); - - // Call PreRender to interpolate the new camera position - PreRender(); - GetIEditor()->GetEnv()->pRenderer->SetCamera(*m_camera); - - IRenderAuxGeom* aux = GetIEditor()->GetEnv()->pRenderer->GetIRenderAuxGeom(); - SAuxGeomRenderFlags oldFlags = aux->GetRenderFlags(); - - if (m_settings->background.useGradient) - { - Vec3 frustumVertices[8]; - m_camera->GetFrustumVertices(frustumVertices); - Vec3 lt = Vec3::CreateLerp(frustumVertices[0], frustumVertices[4], 0.10f); - Vec3 lb = Vec3::CreateLerp(frustumVertices[1], frustumVertices[5], 0.10f); - Vec3 rb = Vec3::CreateLerp(frustumVertices[2], frustumVertices[6], 0.10f); - Vec3 rt = Vec3::CreateLerp(frustumVertices[3], frustumVertices[7], 0.10f); - aux->SetRenderFlags(e_Mode3D | e_AlphaNone | e_FillModeSolid | e_CullModeNone | e_DepthWriteOff | e_DepthTestOn); - ColorB topColor = m_settings->background.topColor; - ColorB bottomColor = m_settings->background.bottomColor; - aux->DrawTriangle(lt, topColor, rt, topColor, rb, bottomColor); - aux->DrawTriangle(lb, bottomColor, rb, bottomColor, lt, topColor); - aux->Flush(); - } - aux->SetRenderFlags(oldFlags); - - Render(); - - bool renderStats = false; - GetIEditor()->GetEnv()->pSystem->RenderEnd(renderStats, false); - RestorePreviousContext(); } void QViewport::GetImageOffscreen(CImageEx& image, const QSize& customSize) diff --git a/Code/Sandbox/Plugins/EditorCommon/QViewport.h b/Code/Sandbox/Plugins/EditorCommon/QViewport.h index 2b18724d01..72b2024bc4 100644 --- a/Code/Sandbox/Plugins/EditorCommon/QViewport.h +++ b/Code/Sandbox/Plugins/EditorCommon/QViewport.h @@ -28,7 +28,6 @@ struct SRenderingPassInfo; struct SRendParams; struct Ray; struct IRenderer; -struct I3DEngine; struct SSystemGlobalEnvironment; namespace Serialization { class IArchive; diff --git a/Code/Sandbox/Plugins/FBXPlugin/CMakeLists.txt b/Code/Sandbox/Plugins/FBXPlugin/CMakeLists.txt deleted file mode 100644 index 4c433b9cd6..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/CMakeLists.txt +++ /dev/null @@ -1,48 +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. -# - -if(NOT PAL_TRAIT_BUILD_HOST_TOOLS) - return() -endif() - -include(Platform/${PAL_PLATFORM_NAME}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) -if(NOT PAL_TRAIT_BUILD_FBX_PLUGIN_SUPPORTED) - return() -endif() - -ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) - -ly_add_target( - NAME FBXPlugin MODULE - NAMESPACE Legacy - OUTPUT_SUBDIRECTORY EditorPlugins - AUTOMOC - AUTOUIC - AUTORCC - FILES_CMAKE - fbxplugin_files.cmake - ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake - COMPILE_DEFINITIONS - PRIVATE - PLUGIN_EXPORTS - BUILD_DEPENDENCIES - PRIVATE - 3rdParty::Qt::Core - 3rdParty::Qt::Gui - 3rdParty::Qt::Widgets - 3rdParty::FbxSdk - Legacy::CryCommon - Legacy::Editor.Headers - Legacy::EditorCore -) - -ly_add_dependencies(Editor FBXPlugin) -set_property(GLOBAL APPEND PROPERTY LY_EDITOR_PLUGINS $) diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXExporter.cpp b/Code/Sandbox/Plugins/FBXPlugin/FBXExporter.cpp deleted file mode 100644 index 9aa46e78c4..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXExporter.cpp +++ /dev/null @@ -1,924 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "FBXPlugin_precompiled.h" - - -// FBX SDK Help: http://download.autodesk.com/global/docs/fbxsdk2012/en_us/index.html - -#include "FBXExporter.h" -#include "FBXSettingsDlg.h" - -#include "IEditor.h" - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// constants used to convert cameras to and from Maya - -static const float s_CONVERSION_BAKING_SAMPLE_RATE = 30.0f; - -// IMPORT_PRE/POST_ROTATIONS determined by experimentation with fbx2015 in Maya and Max. -// We are transforming a Z-axis forward (Max/Maya) to a negative Y-axis forward camera (Editor). -// Analytically this shold involve a preRotation of -90 degrees around the x-axis. -// For Y-Up scenes, our Open 3D Engine Tools inserts an additional 180 rotation around the Y-axis when orienting .cgf files. We need to -// 'undo' for FBX anim curves. This does not apply to cameras which do not use .cgf files -static const FbxVector4 s_PRE_ROTATION_FOR_YUP_SCENES (-90.0f, .0f, .0f); -static const FbxVector4 s_POST_ROTATION_FOR_YUP_OBJECTS(-90.0f, 180.0f, .0f); -static const FbxVector4 s_POST_ROTATION_FOR_ZFORWARD_CAMERAS(-90.0f, .0f, .0f); - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace { - std::string GetFilePath(const std::string& filename) - { - int pos = filename.find_last_of("/\\"); - if (pos > 0) - { - return filename.substr(0, pos + 1); - } - - return filename; - } - - - std::string GetFileName(const std::string& fullFilename) - { - int pos = fullFilename.find_last_of("/\\"); - if (pos > 0) - { - return fullFilename.substr(pos + 1); - } - - return fullFilename; - } -} // namespace - - -#ifdef DEBUG -/////////////////////////////////////////////////////////////////////// -// debugging function to print all the keys in an Fbx Curve -void DebugPrintCurveKeys(FbxAnimCurve* pCurve, const QString& name) -{ - if (pCurve) - { - ILog* log = GetIEditor()->GetSystem()->GetILog(); - log->Log("\n%s", name); - for (int keyID = 0; keyID < pCurve->KeyGetCount(); ++keyID) - { - FbxAnimCurveKey key = pCurve->KeyGet(keyID); - - log->Log("%.2g:%g, ", key.GetTime().GetSecondDouble(), key.GetValue()); - } - } -} -#endif - -// CFBXExporter -CFBXExporter::CFBXExporter() - : m_pFBXManager(0) - , m_pFBXScene(0) -{ - m_settings.bCopyTextures = true; - m_settings.bEmbedded = false; - m_settings.bAsciiFormat = false; - m_settings.bConvertAxesForMaxMaya = false; -} - - -const char* CFBXExporter::GetExtension() const -{ - return "fbx"; -} - - -const char* CFBXExporter::GetShortDescription() const -{ - return "FBX format"; -} - - -bool CFBXExporter::ExportToFile(const char* filename, const Export::IData* pData) -{ - if (!m_pFBXManager) - { - m_pFBXManager = FbxManager::Create(); - } - - bool bAnimationExport = false; - - for (int objectID = 0; objectID < pData->GetObjectCount(); ++objectID) - { - Export::Object* pObject = pData->GetObject(objectID); - - if (pObject->GetEntityAnimationDataCount() > 0) - { - bAnimationExport = true; - break; - } - } - - // do nothing if the user cancels - if (!OpenFBXSettingsDlg(m_settings)) - { - return false; - } - - m_path = GetFilePath(filename); - std::string name = GetFileName(filename); - - // create an IOSettings object - FbxIOSettings* pSettings = FbxIOSettings::Create(m_pFBXManager, IOSROOT); - m_pFBXManager->SetIOSettings(pSettings); - - // Create a scene object - FbxScene* pFBXScene = FbxScene::Create(m_pFBXManager, "Test"); - pFBXScene->GetGlobalSettings().SetAxisSystem(FbxAxisSystem::Max); - pFBXScene->GetGlobalSettings().SetOriginalUpAxis(FbxAxisSystem::Max); - - // Create document info - FbxDocumentInfo* pDocInfo = FbxDocumentInfo::Create(m_pFBXManager, "DocInfo"); - pDocInfo->mTitle = name.c_str(); - pDocInfo->mSubject = "Exported geometry from editor application."; - pDocInfo->mAuthor = "Editor FBX exporter."; - pDocInfo->mRevision = "rev. 1.0"; - pDocInfo->mKeywords = "Editor FBX export"; - pDocInfo->mComment = ""; - pFBXScene->SetDocumentInfo(pDocInfo); - - // Create nodes from objects and add them to the scene - FbxNode* pRootNode = pFBXScene->GetRootNode(); - - FbxAnimStack* pAnimStack = FbxAnimStack::Create(pFBXScene, "AnimStack"); - FbxAnimLayer* pAnimBaseLayer = FbxAnimLayer::Create(pFBXScene, "AnimBaseLayer"); - pAnimStack->AddMember(pAnimBaseLayer); - - int numObjects = pData->GetObjectCount(); - - m_nodes.resize(0); - m_nodes.reserve(numObjects); - - for (int i = 0; i < numObjects; ++i) - { - Export::Object* pObj = pData->GetObject(i); - FbxNode* newNode = NULL; - - if (!bAnimationExport) - { - newNode = CreateFBXNode(pObj); - } - else - { - newNode = CreateFBXAnimNode(pFBXScene, pAnimBaseLayer, pObj); - } - - m_nodes.push_back(newNode); - } - - // solve hierarchy - for (int i = 0; i < m_nodes.size() && i < numObjects; ++i) - { - const Export::Object* pObj = pData->GetObject(i); - FbxNode* pNode = m_nodes[i]; - FbxNode* pParentNode = 0; - if (pObj->nParent >= 0 && pObj->nParent < m_nodes.size()) - { - pParentNode = m_nodes[pObj->nParent]; - } - if (pParentNode) - { - pParentNode->AddChild(pNode); - } - else - { - pRootNode->AddChild(pNode); - } - } - - int nFileFormat = -1; - - if (m_settings.bAsciiFormat) - { - if (nFileFormat < 0 || nFileFormat >= m_pFBXManager->GetIOPluginRegistry()->GetWriterFormatCount()) - { - nFileFormat = m_pFBXManager->GetIOPluginRegistry()->GetNativeWriterFormat(); - int lFormatIndex, lFormatCount = m_pFBXManager->GetIOPluginRegistry()->GetWriterFormatCount(); - for (lFormatIndex = 0; lFormatIndex < lFormatCount; lFormatIndex++) - { - if (m_pFBXManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex)) - { - FbxString lDesc = m_pFBXManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex); - const char* lASCII = "ascii"; - if (lDesc.Find(lASCII) >= 0) - { - nFileFormat = lFormatIndex; - break; - } - } - } - } - } - - pSettings->SetBoolProp(EXP_FBX_EMBEDDED, m_settings.bEmbedded); - - if (m_settings.bConvertAxesForMaxMaya) - { - // convert the scene from our Z-Up world to Maya's Y-Up World. This is stored in the FBX scene and both Max & Maya will - // import accordingly - FbxAxisSystem::MayaYUp.ConvertScene(pFBXScene); - - // process all camera nodes in the scene to make them look down their negative Z-axis - convertCamerasForMaxMaya(pFBXScene->GetRootNode()); - } - - //Save a scene - bool bRet = false; - FbxExporter* pFBXExporter = FbxExporter::Create(m_pFBXManager, name.c_str()); - - // For backward compatilibity choose a widely compatible FBX version that's been out for a while: - if (pFBXExporter) - { - pFBXExporter->SetFileExportVersion(FBX_2014_00_COMPATIBLE); - - if (pFBXExporter->Initialize(filename, nFileFormat, pSettings)) - { - bRet = pFBXExporter->Export(pFBXScene); - } - pFBXExporter->Destroy(); - } - - pFBXScene->Destroy(); - - m_materials.clear(); - m_meshMaterialIndices.clear(); - - m_pFBXManager->Destroy(); - m_pFBXManager = 0; - - if (bRet) - { - GetIEditor()->GetSystem()->GetILog()->Log("\nFBX Exporter: Exported successfully to %s.", name.c_str()); - } - else - { - GetIEditor()->GetSystem()->GetILog()->LogError("\nFBX Exporter: Failed."); - } - - return bRet; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// This method finds all cameras (via recursion) in the node tree rooted at pNode and bakes the necessary -// transforms into any cameras it finds to take care of the conversion from Maya Z-forward to our negative-y forward cameras -void CFBXExporter::convertCamerasForMaxMaya(FbxNode* pNode) const -{ - if (pNode) - { - // recurse to children to convert all cameras in the level - for (int i = 0; i < pNode->GetChildCount(); i++) - { - convertCamerasForMaxMaya(pNode->GetChild(i)); - } - - // process this node if it's a camera - convertCameraForMaxMaya(pNode); - } -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Maya cameras look down the negative z-axis. Ours look down the positive-y. This method bakes the necessary transforms -// into the local transforms of the given pNode if it's a camera to take care of the conversion -void CFBXExporter::convertCameraForMaxMaya(FbxNode* pNode) const -{ - // Maya puts in an extra 90 x-rotation in the "Rotate Axis" channel. Adding an extra post-rotation fixes this, - // determined experimentally - static const FbxVector4 s_EXTRA_EXPORT_POST_ROTATION_FOR_MAX_MAYA(.0f, -90.0f, .0f); - - if (pNode && pNode->GetNodeAttribute() && pNode->GetNodeAttribute()->GetAttributeType() == FbxNodeAttribute::eCamera) - { - // bake in s_PRE/POST_ROTATION_FOR_MAYA into anim curves - pNode->SetPivotState(FbxNode::eSourcePivot, FbxNode::ePivotActive); - pNode->SetPivotState(FbxNode::eDestinationPivot, FbxNode::ePivotActive); - - pNode->SetPreRotation(FbxNode::eSourcePivot, s_PRE_ROTATION_FOR_YUP_SCENES); - pNode->SetPostRotation(FbxNode::eSourcePivot, s_POST_ROTATION_FOR_ZFORWARD_CAMERAS); - - pNode->ResetPivotSetAndConvertAnimation(s_CONVERSION_BAKING_SAMPLE_RATE, true); // bake postRotation in for all animStacks - - // Maya puts in an extra 90 x-rotation in the "Rotate Axis" channel. Adding an extra post-rotation after the baking of transforms - // fixes this - i.e. baked transformes change the camera's local rotation channels themselves, post-bake post-transforms get - // stuffed into Maya's 'Rotate Axis' channels - pNode->SetPostRotation(FbxNode::eSourcePivot, s_EXTRA_EXPORT_POST_ROTATION_FOR_MAX_MAYA); - } -} - -FbxMesh* CFBXExporter::CreateFBXMesh(const Export::Object* pObj) -{ - if (!m_pFBXManager) - { - return 0; - } - - int numVertices = pObj->GetVertexCount(); - const Export::Vector3D* pVerts = pObj->GetVertexBuffer(); - - int numMeshes = pObj->GetMeshCount(); - - int numAllFaces = 0; - for (int j = 0; j < numMeshes; ++j) - { - const Export::Mesh* pMesh = pObj->GetMesh(j); - int numFaces = pMesh->GetFaceCount(); - numAllFaces += numFaces; - } - - if (numVertices == 0 || numAllFaces == 0) - { - return 0; - } - - FbxMesh* pFBXMesh = FbxMesh::Create(m_pFBXManager, pObj->name); - - pFBXMesh->InitControlPoints(numVertices); - FbxVector4* pControlPoints = pFBXMesh->GetControlPoints(); - - for (int i = 0; i < numVertices; ++i) - { - const Export::Vector3D& vertex = pVerts[i]; - pControlPoints[i] = FbxVector4(vertex.x, vertex.y, vertex.z); - } - - /* - // We want to have one normal for each vertex (or control point), - // so we set the mapping mode to eBY_CONTROL_POINT. - FbxGeometryElementNormal* lElementNormal= pFBXMesh->CreateElementNormal(); - - //FbxVector4 lNormalZPos(0, 0, 1); - - lElementNormal->SetMappingMode(FbxGeometryElement::eBY_CONTROL_POINT); - - // Set the normal values for every control point. - lElementNormal->SetReferenceMode(FbxGeometryElement::eDIRECT); - - lElementNormal->GetDirectArray().Add(lNormalZPos); - */ - - - int numTexCoords = pObj->GetTexCoordCount(); - const Export::UV* pTextCoords = pObj->GetTexCoordBuffer(); - if (numTexCoords) - { - // Create UV for Diffuse channel. - FbxGeometryElementUV* pFBXDiffuseUV = pFBXMesh->CreateElementUV("DiffuseUV"); - FBX_ASSERT(pFBXDiffuseUV != NULL); - - pFBXDiffuseUV->SetMappingMode(FbxGeometryElement::eByPolygonVertex); - pFBXDiffuseUV->SetReferenceMode(FbxGeometryElement::eIndexToDirect); - - for (int i = 0; i < numTexCoords; ++i) - { - const Export::UV& textCoord = pTextCoords[i]; - pFBXDiffuseUV->GetDirectArray().Add(FbxVector2(textCoord.u, textCoord.v)); - } - - //Now we have set the UVs as eINDEX_TO_DIRECT reference and in eBY_POLYGON_VERTEX mapping mode - //we must update the size of the index array. - pFBXDiffuseUV->GetIndexArray().SetCount(numTexCoords); - } - - pFBXMesh->ReservePolygonCount(numAllFaces); - pFBXMesh->ReservePolygonVertexCount(numAllFaces * 3); - - // Set material mapping. - FbxGeometryElementMaterial* pMaterialElement = pFBXMesh->CreateElementMaterial(); - pMaterialElement->SetMappingMode(FbxGeometryElement::eByPolygon); - pMaterialElement->SetReferenceMode(FbxGeometryElement::eIndexToDirect); - - for (int j = 0; j < numMeshes; ++j) - { - const Export::Mesh* pMesh = pObj->GetMesh(j); - - // Write all faces, convert the indices to one based indices - int numFaces = pMesh->GetFaceCount(); - - int polygonCount = pFBXMesh->GetPolygonCount(); - pMaterialElement->GetIndexArray().SetCount(polygonCount + numFaces); - int materialIndex = m_meshMaterialIndices[pMesh]; - - const Export::Face* pFaces = pMesh->GetFaceBuffer(); - for (int i = 0; i < numFaces; ++i) - { - const Export::Face& face = pFaces[i]; - pFBXMesh->BeginPolygon(-1, -1, -1, false); - - pFBXMesh->AddPolygon(face.idx[0], face.idx[0]); - pFBXMesh->AddPolygon(face.idx[1], face.idx[1]); - pFBXMesh->AddPolygon(face.idx[2], face.idx[2]); - - //pFBXDiffuseUV->GetIndexArray().SetAt(face.idx[0], face.idx[0]); - - pFBXMesh->EndPolygon(); - //pPolygonGroupElement->GetIndexArray().Add(j); - - pMaterialElement->GetIndexArray().SetAt(polygonCount + i, materialIndex); - } - } - - return pFBXMesh; -} - - -FbxFileTexture* CFBXExporter::CreateFBXTexture(const char* pTypeName, const char* pName) -{ - std::string filename = pName; - - if (m_settings.bCopyTextures) - { - // check if file exists - QFileInfo fi(pName); - if (!fi.exists() || fi.isDir()) - { - GetIEditor()->GetSystem()->GetILog()->LogError("\nFBX Exporter: Texture %s is not on the disk.", pName); - } - else - { - filename = m_path; - filename += GetFileName(pName); - if (QFile::copy(pName, filename.c_str())) - { - GetIEditor()->GetSystem()->GetILog()->Log("\nFBX Exporter: Texture %s was copied.", pName); - } - filename = GetFileName(pName); // It works for Maya, but not good for MAX - } - } - - FbxFileTexture* pFBXTexture = FbxFileTexture::Create(m_pFBXManager, pTypeName); - pFBXTexture->SetFileName(filename.c_str()); - pFBXTexture->SetTextureUse(FbxTexture::eStandard); - pFBXTexture->SetMappingType(FbxTexture::eUV); - pFBXTexture->SetMaterialUse(FbxFileTexture::eModelMaterial); - pFBXTexture->SetSwapUV(false); - pFBXTexture->SetTranslation(0.0, 0.0); - pFBXTexture->SetScale(1.0, 1.0); - pFBXTexture->SetRotation(0.0, 0.0); - - return pFBXTexture; -} - - -FbxSurfaceMaterial* CFBXExporter::CreateFBXMaterial(const std::string& name, const Export::Mesh* pMesh) -{ - auto it = m_materials.find(name); - if (it != m_materials.end()) - { - return it->second; - } - - FbxSurfacePhong* pMaterial = FbxSurfacePhong::Create(m_pFBXManager, name.c_str()); - - pMaterial->Diffuse.Set(FbxDouble3(pMesh->material.diffuse.r, pMesh->material.diffuse.g, pMesh->material.diffuse.b)); - pMaterial->DiffuseFactor.Set(1.0); - pMaterial->Specular.Set(FbxDouble3(pMesh->material.specular.r, pMesh->material.specular.g, pMesh->material.specular.b)); - pMaterial->SpecularFactor.Set(1.0); - - // Opacity - pMaterial->TransparentColor.Set(FbxDouble3(1.0f, 1.0f, 1.0f)); // need explicitly setup - pMaterial->TransparencyFactor.Set(1.0f - pMesh->material.opacity); - - // Glossiness - // CRC TODO: Why was this commented out? - //pMaterial->Shininess.Set(pow(2, pMesh->material.shininess * 10)); - - if (pMesh->material.mapDiffuse[0] != '\0') - { - FbxFileTexture* pFBXTexture = CreateFBXTexture("Diffuse", pMesh->material.mapDiffuse); - pMaterial->Diffuse.ConnectSrcObject(pFBXTexture); - } - - if (pMesh->material.mapSpecular[0] != '\0') - { - FbxFileTexture* pFBXTexture = CreateFBXTexture("Specular", pMesh->material.mapSpecular); - pMaterial->Specular.ConnectSrcObject(pFBXTexture); - } - - if (pMesh->material.mapOpacity[0] != '\0') - { - FbxFileTexture* pFBXTexture = CreateFBXTexture("Opacity", pMesh->material.mapOpacity); - pMaterial->TransparentColor.ConnectSrcObject(pFBXTexture); - } - // CRC TODO: Why was this commented out? - /* - if (pMesh->material.mapBump[0] != '\0') - { - FbxFileTexture* pFBXTexture = CreateFBXTexture("Bump", pMesh->material.mapBump); - pMaterial->Bump.ConnectSrcObject(pFBXTexture); - } - */ - - if (pMesh->material.mapDisplacement[0] != '\0') - { - FbxFileTexture* pFBXTexture = CreateFBXTexture("Displacement", pMesh->material.mapDisplacement); - pMaterial->DisplacementColor.ConnectSrcObject(pFBXTexture); - } - - m_materials[name] = pMaterial; - - return pMaterial; -} - - -FbxNode* CFBXExporter::CreateFBXAnimNode(FbxScene* pScene, FbxAnimLayer* pAnimBaseLayer, const Export::Object* pObj) -{ - FbxNode* pAnimNode = FbxNode::Create(pScene, pObj->name); - pAnimNode->LclTranslation.GetCurveNode(pAnimBaseLayer, true); - pAnimNode->LclRotation.GetCurveNode(pAnimBaseLayer, true); - pAnimNode->LclScaling.GetCurveNode(pAnimBaseLayer, true); - - FbxCamera* pCamera = FbxCamera::Create(pScene, pObj->name); - - if (pObj->entityType == Export::eCamera) - { - pCamera->SetApertureMode(FbxCamera::eHorizontal); - pCamera->SetFormat(FbxCamera::eCustomFormat); - pCamera->SetAspect(FbxCamera::eFixedRatio, 1.777778f, 1.0); - - pAnimNode->SetNodeAttribute(pCamera); - - if (pObj->cameraTargetNodeName[0]) - { - for (int i = 0; i < m_nodes.size(); ++i) - { - FbxNode* pCameraTargetNode = m_nodes[i]; - const char* nodeName = pCameraTargetNode->GetName(); - if (strcmp(nodeName, pObj->cameraTargetNodeName) == 0) - { - FbxMarker* pMarker = FbxMarker::Create(pScene, ""); - pCameraTargetNode->SetNodeAttribute(pMarker); - pAnimNode->SetTarget(pCameraTargetNode); - } - } - } - } - - if (pObj->GetEntityAnimationDataCount() > 0) - { - int animDataCount = pObj->GetEntityAnimationDataCount(); - - for (int animDataIndex = 0; animDataIndex < animDataCount; ++animDataIndex) - { - const Export::EntityAnimData* pAnimData = pObj->GetEntityAnimationData(animDataIndex); - - FbxTime time = 0; - time.SetSecondDouble(pAnimData->keyTime); - - FbxAnimCurve* pCurve = NULL; - - switch (pAnimData->dataType) - { - case Export::AnimParamType::PositionX: - pCurve = pAnimNode->LclTranslation.GetCurve(pAnimBaseLayer, "X", true); - break; - case Export::AnimParamType::PositionY: - pCurve = pAnimNode->LclTranslation.GetCurve(pAnimBaseLayer, "Y", true); - break; - case Export::AnimParamType::PositionZ: - pCurve = pAnimNode->LclTranslation.GetCurve(pAnimBaseLayer, "Z", true); - break; - case Export::AnimParamType::RotationX: - pCurve = pAnimNode->LclRotation.GetCurve(pAnimBaseLayer, "X", true); - break; - case Export::AnimParamType::RotationY: - pCurve = pAnimNode->LclRotation.GetCurve(pAnimBaseLayer, "Y", true); - break; - case Export::AnimParamType::RotationZ: - pCurve = pAnimNode->LclRotation.GetCurve(pAnimBaseLayer, "Z", true); - break; - case Export::AnimParamType::FOV: - { - pCurve = pCamera->FieldOfView.GetCurve(pAnimBaseLayer, "FieldOfView", true); - } - break; - - default: - break; - } - - if (pCurve) - { - int keyIndex = 0; - - pCurve->KeyModifyBegin(); - keyIndex = pCurve->KeyInsert(time); - pCurve->KeySet(keyIndex, time, pAnimData->keyValue, FbxAnimCurveDef::eInterpolationCubic, FbxAnimCurveDef::eTangentBreak, pAnimData->rightTangent, pAnimData->leftTangent, FbxAnimCurveDef::eWeightedAll, pAnimData->rightTangentWeight, pAnimData->leftTangentWeight); - - pCurve->KeySetLeftDerivative(keyIndex, pAnimData->leftTangent); - pCurve->KeySetRightDerivative(keyIndex, pAnimData->rightTangent); - - pCurve->KeySetLeftTangentWeight(keyIndex, pAnimData->leftTangentWeight); - pCurve->KeySetRightTangentWeight(keyIndex, pAnimData->rightTangentWeight); - - FbxAnimCurveTangentInfo keyLeftInfo; - keyLeftInfo.mAuto = 0; - keyLeftInfo.mDerivative = pAnimData->leftTangent; - keyLeftInfo.mWeight = pAnimData->leftTangentWeight; - keyLeftInfo.mWeighted = true; - keyLeftInfo.mVelocity = 0.0f; - keyLeftInfo.mHasVelocity = false; - - FbxAnimCurveTangentInfo keyRightInfo; - keyRightInfo.mAuto = 0; - keyRightInfo.mDerivative = pAnimData->rightTangent; - keyRightInfo.mWeight = pAnimData->rightTangentWeight; - keyRightInfo.mWeighted = true; - keyRightInfo.mVelocity = 0.0f; - keyRightInfo.mHasVelocity = false; - - pCurve->KeySetLeftDerivativeInfo(keyIndex, keyLeftInfo); - pCurve->KeySetRightDerivativeInfo(keyIndex, keyRightInfo); - - pCurve->KeyModifyEnd(); - } - } - } - - return pAnimNode; -} - -FbxNode* CFBXExporter::CreateFBXNode(const Export::Object* pObj) -{ - if (!m_pFBXManager) - { - return 0; - } - - // create a FbxNode - FbxNode* pNode = FbxNode::Create(m_pFBXManager, pObj->name); - pNode->LclTranslation.Set(FbxVector4(pObj->pos.x, pObj->pos.y, pObj->pos.z)); - - // Rotation: Create Euler angels from quaternion throughout a matrix - FbxAMatrix rotMat; - rotMat.SetQ(FbxQuaternion(pObj->rot.v.x, pObj->rot.v.y, pObj->rot.v.z, pObj->rot.w)); - pNode->LclRotation.Set(rotMat.GetR()); - - pNode->LclScaling.Set(FbxVector4(pObj->scale.x, pObj->scale.y, pObj->scale.z)); - - - // collect materials - int materialIndex = 0; - if (pObj->GetMeshCount() != 0 && pObj->materialName[0] != '\0') - { - for (int i = 0; i < pObj->GetMeshCount(); ++i) - { - const Export::Mesh* pMesh = pObj->GetMesh(i); - - if (pMesh->material.name[0] == '\0') - { - continue; - } - - // find if material was created for this object - int findIndex = -1; - for (int j = 0; j < i; ++j) - { - const Export::Mesh* pTestMesh = pObj->GetMesh(j); - if (!strcmp(pTestMesh->material.name, pMesh->material.name)) - { - findIndex = m_meshMaterialIndices[pTestMesh]; - break; - } - } - - if (findIndex != -1) - { - m_meshMaterialIndices[pMesh] = findIndex; - continue; - } - - std::string materialName = pObj->materialName; - if (strcmp(pObj->materialName, pMesh->material.name)) - { - materialName += ':'; - materialName += pMesh->material.name; - } - - FbxSurfaceMaterial* pFBXMaterial = CreateFBXMaterial(materialName, pMesh); - if (pFBXMaterial) - { - pNode->AddMaterial(pFBXMaterial); - m_meshMaterialIndices[pMesh] = materialIndex++; - } - } - } - - - FbxMesh* pFBXMesh = CreateFBXMesh(pObj); - if (pFBXMesh) - { - pNode->SetNodeAttribute(pFBXMesh); - pNode->SetShadingMode(FbxNode::eTextureShading); - } - - return pNode; -} - -void CFBXExporter::Release() -{ - delete this; -} - -inline f32 Maya2SandboxFOVDeg(const f32 fov, const f32 ratio) { return RAD2DEG(2.0f * atanf(tan(DEG2RAD(fov) / 2.0f) / ratio)); }; - -void CFBXExporter::FillAnimationData(Export::Object* pObject, FbxNode* pNode, [[maybe_unused]] FbxAnimLayer* pAnimLayer, FbxAnimCurve* pCurve, Export::AnimParamType paramType) -{ - if (pCurve) - { - for (int keyID = 0; keyID < pCurve->KeyGetCount(); ++keyID) - { - Export::EntityAnimData entityData; - - FbxAnimCurveKey key = pCurve->KeyGet(keyID); - entityData.keyValue = key.GetValue(); - FbxTime time = key.GetTime(); - entityData.keyTime = aznumeric_cast(time.GetSecondDouble()); - - entityData.leftTangent = pCurve->KeyGetLeftDerivative(keyID); - entityData.rightTangent = pCurve->KeyGetRightDerivative(keyID); - entityData.leftTangentWeight = pCurve->KeyGetLeftTangentWeight(keyID); - entityData.rightTangentWeight = pCurve->KeyGetRightTangentWeight(keyID); - - if (paramType == Export::AnimParamType::FocalLength && pNode && pNode->GetCamera()) - { - // special handling for Focal Length - we convert it to FoV for use in-engine (including switching the paramType) - // We handle this because Maya 2015 doesn't save Angle of View or Field of View animation in FBX - it only uses FocalLength. - entityData.dataType = Export::AnimParamType::FOV; - // Open 3D Engine field of view is the vertical angle - pNode->GetCamera()->SetApertureMode(FbxCamera::eVertical); - entityData.keyValue = aznumeric_cast(pNode->GetCamera()->ComputeFieldOfView(entityData.keyValue)); - } - else - { - entityData.dataType = paramType; - } - - // If the Exporter is Sandbox or Maya, convert fov, positions - QString exporterName = m_pFBXScene->GetDocumentInfo()->Original_ApplicationName.Get().Buffer(); - - if (!exporterName.toLower().contains("3ds")) - { - if (paramType == Export::AnimParamType::PositionX || paramType == Export::AnimParamType::PositionY || paramType == Export::AnimParamType::PositionZ) - { - entityData.rightTangent /= 100.0f; - entityData.leftTangent /= 100.0f; - entityData.keyValue /= 100.0f; - } - else if (paramType == Export::AnimParamType::FOV) // Maya 2015 uses FocalLength instead of FoV - assuming this is for legacy Sandbox or Maya? - { - const float kAspectRatio = 1.777778f; - entityData.keyValue = Maya2SandboxFOVDeg(entityData.keyValue, kAspectRatio); - } - } - - pObject->SetEntityAnimationData(entityData); - } - } -} - - -bool CFBXExporter::ImportFromFile(const char* filename, Export::IData* pData) -{ - FbxManager* pFBXManager = FbxManager::Create(); - - FbxScene* pFBXScene = FbxScene::Create(pFBXManager, "Test"); - m_pFBXScene = pFBXScene; - pFBXScene->GetGlobalSettings().SetAxisSystem(FbxAxisSystem::Max); - pFBXScene->GetGlobalSettings().SetOriginalUpAxis(FbxAxisSystem::Max); - - FbxImporter* pImporter = FbxImporter::Create(pFBXManager, ""); - - FbxIOSettings* pSettings = FbxIOSettings::Create(pFBXManager, IOSROOT); - - pFBXManager->SetIOSettings(pSettings); - pSettings->SetBoolProp(IMP_FBX_ANIMATION, true); - - const bool lImportStatus = pImporter->Initialize(filename, -1, pFBXManager->GetIOSettings()); - if (!lImportStatus) - { - return false; - } - - bool bLoadStatus = pImporter->Import(pFBXScene); - - if (!bLoadStatus) - { - return false; - } - - // record the original axis system used in the import file and then convert the file to Open 3D Engine's coord system, - // which matches Max's (Z-Up, negative Y-forward cameras) - int upSign = 1; - FbxAxisSystem importFileAxisSystem = pFBXScene->GetGlobalSettings().GetAxisSystem(); - FbxAxisSystem::EUpVector importSceneUpVector = importFileAxisSystem.GetUpVector(upSign); - FbxAxisSystem::Max.ConvertScene(pFBXScene); - - QString exporterName = pFBXScene->GetDocumentInfo()->Original_ApplicationName.Get().Buffer(); - // const bool fromMaya = (exporterName.contains("maya", Qt::CaseInsensitive)); - // const bool fromMax = (exporterName.contains("max", Qt::CaseInsensitive)); - - FbxNode* pRootNode = pFBXScene->GetRootNode(); - - if (pRootNode) - { - for (int animStackID = 0; animStackID < pFBXScene->GetSrcObjectCount(); ++animStackID) - { - FbxAnimStack* pAnimStack = pFBXScene->GetSrcObject(animStackID); - const int animLayersCount = pAnimStack->GetMemberCount(); - - for (int layerID = 0; layerID < animLayersCount; ++layerID) - { - FbxAnimLayer* pAnimLayer = pAnimStack->GetMember(layerID); - - const int nodeCount = pRootNode->GetChildCount(); - - for (int nodeID = 0; nodeID < nodeCount; ++nodeID) - { - FbxNode* pNode = pRootNode->GetChild(nodeID); - - if (pNode) - { - FbxAnimCurve* pCurve = 0; - Export::Object* pObject = pData->AddObject(pNode->GetName()); - - if (pObject) - { - azstrncpy(pObject->name, sizeof(pObject->name), pNode->GetName(), sizeof(pObject->name) - 1); - pObject->name[sizeof(pObject->name) - 1] = '\0'; - - FbxCamera* pCamera = pNode->GetCamera(); - - // convert animation for Y-Up scenes and for Z-forward Cameras - if (importSceneUpVector == FbxAxisSystem::eYAxis || pCamera) - { - pNode->SetPivotState(FbxNode::eSourcePivot, FbxNode::ePivotActive); - pNode->SetPivotState(FbxNode::eDestinationPivot, FbxNode::ePivotActive); - - if (importSceneUpVector == FbxAxisSystem::eYAxis) - { - // Maps RY to -RZ and RZ to RY - pNode->SetPreRotation(FbxNode::eSourcePivot, s_PRE_ROTATION_FOR_YUP_SCENES); - } - - if (pCamera) - { - // Converts Y-Up, -Z-forward cameras to Open 3D Engine Z-Up, Y-forward cameras - // It is needed regardless of the scene up vector - pNode->SetPostRotation(FbxNode::eSourcePivot, s_POST_ROTATION_FOR_ZFORWARD_CAMERAS); - } - else - { - // Objects from a Y-Up scene (i.e. not cameras). 'undo' the extra transform that the Open 3D Engine Tool - // bakes in to .cgf files from YUp scenes. - pNode->SetPostRotation(FbxNode::eSourcePivot, s_POST_ROTATION_FOR_YUP_OBJECTS); - } - - // bake the pre/post rotations into the anim curves - pNode->ConvertPivotAnimationRecursive(pAnimStack, FbxNode::eSourcePivot, s_CONVERSION_BAKING_SAMPLE_RATE); - } - - if (pCamera) - { - // extract specialized channels for cameras - pCurve = pCamera->FocalLength.GetCurve(pAnimLayer, "FocalLength"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::FocalLength); - pCurve = pCamera->FieldOfView.GetCurve(pAnimLayer, "FieldOfView", true); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::FOV); - } - - pCurve = pNode->LclTranslation.GetCurve(pAnimLayer, "X"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::PositionX); - pCurve = pNode->LclTranslation.GetCurve(pAnimLayer, "Y"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::PositionY); - pCurve = pNode->LclTranslation.GetCurve(pAnimLayer, "Z"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::PositionZ); - pCurve = pNode->LclRotation.GetCurve(pAnimLayer, "X"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::RotationX); - pCurve = pNode->LclRotation.GetCurve(pAnimLayer, "Y"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::RotationY); - pCurve = pNode->LclRotation.GetCurve(pAnimLayer, "Z"); - FillAnimationData(pObject, pNode, pAnimLayer, pCurve, Export::AnimParamType::RotationZ); - } - } - } - } - } - } - - return true; -} diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXExporter.h b/Code/Sandbox/Plugins/FBXPlugin/FBXExporter.h deleted file mode 100644 index 266de76a7d..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXExporter.h +++ /dev/null @@ -1,65 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Export geometry to FBX file format - - -#ifndef CRYINCLUDE_FBXPLUGIN_FBXEXPORTER_H -#define CRYINCLUDE_FBXPLUGIN_FBXEXPORTER_H - -#pragma once -#include -#include "fbxsdk.h" - -struct SFBXSettings -{ - bool bCopyTextures; - bool bEmbedded; - bool bAsciiFormat; - bool bConvertAxesForMaxMaya; -}; - -class CFBXExporter - : public IExporter -{ -public: - CFBXExporter(); - - virtual const char* GetExtension() const; - virtual const char* GetShortDescription() const; - virtual bool ExportToFile(const char* filename, const Export::IData* pData); - virtual bool ImportFromFile(const char* filename, Export::IData* pData); - virtual void Release(); - -private: - // recursively traverse all nodes under pNode and reset prerotations for camera nodes by calling convertCameraForMaxMaya on them - void convertCamerasForMaxMaya(FbxNode* node) const; - // reset prerotations for a specified nodes if it's a camera - void convertCameraForMaxMaya(FbxNode* pNode) const; - - FbxMesh* CreateFBXMesh(const Export::Object* pObj); - FbxFileTexture* CreateFBXTexture(const char* pTypeName, const char* pName); - FbxSurfaceMaterial* CreateFBXMaterial(const std::string& name, const Export::Mesh* pMesh); - FbxNode* CreateFBXNode(const Export::Object* pObj); - FbxNode* CreateFBXAnimNode(FbxScene* pScene, FbxAnimLayer* pCameraAnimBaseLayer, const Export::Object* pObj); - void FillAnimationData(Export::Object* pObject, FbxNode* pNode, FbxAnimLayer* pAnimLayer, FbxAnimCurve* pCurve, Export::AnimParamType paramType); - - FbxManager* m_pFBXManager; - SFBXSettings m_settings; - FbxScene* m_pFBXScene; - std::string m_path; - std::vector m_nodes; - std::map m_materials; - std::map m_meshMaterialIndices; -}; -#endif // CRYINCLUDE_FBXPLUGIN_FBXEXPORTER_H diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.cpp b/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.cpp deleted file mode 100644 index 0d51889b9d..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.cpp +++ /dev/null @@ -1,68 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "FBXPlugin_precompiled.h" -#include "FBXPlugin.h" - -namespace PluginInfo -{ - const char* kName = "FBX Exporter"; - const char* kGUID = "{6CD02F95-362C-4ADF-8BAE-87C6342A8027}"; - const int kVersion = 1; -} - -void CFBXPlugin::Release() -{ - delete this; -} - -void CFBXPlugin::ShowAbout() -{ -} - -const char* CFBXPlugin::GetPluginGUID() -{ - return PluginInfo::kGUID; -} - -DWORD CFBXPlugin::GetPluginVersion() -{ - return PluginInfo::kVersion; -} - -const char* CFBXPlugin::GetPluginName() -{ - return PluginInfo::kName; -} - -bool CFBXPlugin::CanExitNow() -{ - return true; -} - -void CFBXPlugin::Serialize([[maybe_unused]] FILE* hFile, [[maybe_unused]] bool bIsStoring) -{ -} - -void CFBXPlugin::ResetContent() -{ -} - -bool CFBXPlugin::CreateUIElements() -{ - return true; -} - -void CFBXPlugin::OnEditorNotify([[maybe_unused]] EEditorNotifyEvent aEventId) -{ -} diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.h b/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.h deleted file mode 100644 index 30579d6d1d..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.h +++ /dev/null @@ -1,43 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#pragma once -//////////////////////////////////////////////////////////////////////////// -// -// Crytek Engine Source File. -// Copyright (C), Crytek Studios, 2001-2012 -// ------------------------------------------------------------------------- -// Created: 24 June 2011 by Sergiy Shaykin. -// Description: Attachment to the Sandbox plug-in system -// -//////////////////////////////////////////////////////////////////////////// -#ifndef CRYINCLUDE_FBXPLUGIN_FBXPLUGIN_H -#define CRYINCLUDE_FBXPLUGIN_FBXPLUGIN_H -#include - -class CFBXPlugin - : public IPlugin -{ -public: - void Release(); - void ShowAbout(); - const char* GetPluginGUID(); - DWORD GetPluginVersion(); - const char* GetPluginName(); - bool CanExitNow(); - void Serialize(FILE* hFile, bool bIsStoring); - void ResetContent(); - bool CreateUIElements(); - void OnEditorNotify(EEditorNotifyEvent aEventId); -}; -#endif // CRYINCLUDE_FBXPLUGIN_FBXPLUGIN_H diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.rc b/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.rc deleted file mode 100644 index c681b1ea64..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin.rc +++ /dev/null @@ -1,104 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_FBX_EXPORT_SETTINGS DIALOGEX 0, 0, 202, 96 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOOLWINDOW -CAPTION "FBX Export Settings" -FONT 8, "MS Shell Dlg", 400, 0, 0x0 -BEGIN - CONTROL "Copy textures into folder with FBX file",IDC_COPY_TEXTURES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,11,137,10 - CONTROL "Embedded data (Put textures inside FBX file)",IDC_EMBEDDED, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,25,157,10 - COMBOBOX IDC_FILE_FORMAT,71,53,100,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "OK",IDOK,88,75,50,14 - PUSHBUTTON "Cancel",IDCANCEL,140,75,50,14 - LTEXT "File Format:",IDC_STATIC,15,55,39,8 - CONTROL "Convert Cameras for Max/Maya",IDC_CONVERT_CAMERAS_FOR_MAX_MAYA, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,137,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_FBX_EXPORT_SETTINGS, DIALOG - BEGIN - LEFTMARGIN, 6 - RIGHTMARGIN, 190 - TOPMARGIN, 7 - BOTTOMMARGIN, 89 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin_precompiled.cpp b/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin_precompiled.cpp deleted file mode 100644 index cedec4fe05..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin_precompiled.cpp +++ /dev/null @@ -1,15 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "FBXPlugin_precompiled.h" - diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin_precompiled.h b/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin_precompiled.h deleted file mode 100644 index da268110a8..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXPlugin_precompiled.h +++ /dev/null @@ -1,39 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#pragma once - -#include - -#include "resource.h" - -///////////////////////////////////////////////////////////////////////////// -// CRY Stuff //////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -#include - - -///////////////////////////////////////////////////////////////////////////// -// STL -///////////////////////////////////////////////////////////////////////////// -#include -#include -#include - -///////////////////////////////////////////////////////////////////////////// -// CRY Stuff //////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -#include -#include "Util/EditorUtils.h" - -#include "EditorCoreAPI.h" diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.cpp b/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.cpp deleted file mode 100644 index 9766288b5a..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.cpp +++ /dev/null @@ -1,45 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "FBXPlugin_precompiled.h" -#include "FBXSettingsDlg.h" -#include "FBXExporter.h" -#include "resource.h" - -#include - -#include - -#include "ui_FBXSettingsDlg.h" - -bool OpenFBXSettingsDlg(struct SFBXSettings& settings) -{ - Ui::FBXSettingsDialog ui; - QDialog dialog(GetIEditor()->GetEditorMainWindow()); - ui.setupUi(&dialog); - - ui.hCopyTextures->setChecked(settings.bCopyTextures); - ui.hEmbedded->setChecked(settings.bEmbedded); - ui.hFileFormat->setCurrentIndex(settings.bAsciiFormat ? 1 : 0); - ui.hConvertAxesForMaxMaya->setChecked(settings.bConvertAxesForMaxMaya); - - if (dialog.exec() != QDialog::Accepted) - return false; - - settings.bCopyTextures = ui.hCopyTextures->isChecked(); - settings.bEmbedded = ui.hEmbedded->isChecked(); - settings.bAsciiFormat = ui.hFileFormat->currentIndex() == 1; - settings.bConvertAxesForMaxMaya = ui.hConvertAxesForMaxMaya->isChecked(); - - return true; -} diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.h b/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.h deleted file mode 100644 index e9b259234f..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.h +++ /dev/null @@ -1,20 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_FBXPLUGIN_FBXSETTINGSDLG_H -#define CRYINCLUDE_FBXPLUGIN_FBXSETTINGSDLG_H - -#pragma once - -bool OpenFBXSettingsDlg(struct SFBXSettings& settings); -#endif // CRYINCLUDE_FBXPLUGIN_FBXSETTINGSDLG_H diff --git a/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.ui b/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.ui deleted file mode 100644 index 8f2367255a..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/FBXSettingsDlg.ui +++ /dev/null @@ -1,109 +0,0 @@ - - - FBXSettingsDialog - - - - 0 - 0 - 313 - 149 - - - - FBX Export Settings - - - - - - Copy textures into folder with FBX file - - - - - - - Embedded data (Put textures inside FBX file) - - - - - - - Convert Cameras for Max/Maya - - - - - - - File Format: - - - hFileFormat - - - - - - - - Bin - - - - - Ascii - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - FBXSettingsDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - FBXSettingsDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Linux/platform_linux.cmake b/Code/Sandbox/Plugins/FBXPlugin/Platform/Linux/platform_linux.cmake deleted file mode 100644 index ed7bdab4b2..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Linux/platform_linux.cmake +++ /dev/null @@ -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. -# - -set(PAL_TRAIT_BUILD_FBX_PLUGIN_SUPPORTED FALSE) diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Linux/platform_linux_files.cmake b/Code/Sandbox/Plugins/FBXPlugin/Platform/Linux/platform_linux_files.cmake deleted file mode 100644 index 4d5680a30d..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Linux/platform_linux_files.cmake +++ /dev/null @@ -1,10 +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. -# diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Mac/platform_mac.cmake b/Code/Sandbox/Plugins/FBXPlugin/Platform/Mac/platform_mac.cmake deleted file mode 100644 index fc4f6ca1b3..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Mac/platform_mac.cmake +++ /dev/null @@ -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. -# - -set(PAL_TRAIT_BUILD_FBX_PLUGIN_SUPPORTED TRUE) diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Mac/platform_mac_files.cmake b/Code/Sandbox/Plugins/FBXPlugin/Platform/Mac/platform_mac_files.cmake deleted file mode 100644 index 4d5680a30d..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Mac/platform_mac_files.cmake +++ /dev/null @@ -1,10 +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. -# diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/platform_windows.cmake b/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/platform_windows.cmake deleted file mode 100644 index fc4f6ca1b3..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/platform_windows.cmake +++ /dev/null @@ -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. -# - -set(PAL_TRAIT_BUILD_FBX_PLUGIN_SUPPORTED TRUE) diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/platform_windows_files.cmake b/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/platform_windows_files.cmake deleted file mode 100644 index 7e654edcbe..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/platform_windows_files.cmake +++ /dev/null @@ -1,14 +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 - DllMain_Windows.cpp -) diff --git a/Code/Sandbox/Plugins/FBXPlugin/fbxplugin_files.cmake b/Code/Sandbox/Plugins/FBXPlugin/fbxplugin_files.cmake deleted file mode 100644 index b3cacea11c..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/fbxplugin_files.cmake +++ /dev/null @@ -1,25 +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 - FBXExporter.cpp - FBXExporter.h - FBXPlugin.cpp - FBXPlugin.h - FBXPlugin.rc - FBXSettingsDlg.cpp - FBXSettingsDlg.h - FBXSettingsDlg.ui - main.cpp - resource.h - FBXPlugin_precompiled.cpp - FBXPlugin_precompiled.h -) diff --git a/Code/Sandbox/Plugins/FBXPlugin/main.cpp b/Code/Sandbox/Plugins/FBXPlugin/main.cpp deleted file mode 100644 index 1949350135..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/main.cpp +++ /dev/null @@ -1,41 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Export geometry to FBX file format - -#include "FBXPlugin_precompiled.h" - -#include "FBXPlugin.h" -#include "FBXExporter.h" - - - -PLUGIN_API IPlugin* CreatePluginInstance(PLUGIN_INIT_PARAM* pInitParam) -{ - if (pInitParam->pluginVersion != SANDBOX_PLUGIN_SYSTEM_VERSION) - { - pInitParam->outErrorCode = IPlugin::eError_VersionMismatch; - return 0; - } - - ModuleInitISystem(GetIEditor()->GetSystem(), "FBX Exporter Plugin"); - - IExportManager* pExportManager = GetIEditor()->GetExportManager(); - if (pExportManager) - { - pExportManager->RegisterExporter(new CFBXExporter()); - } - - GetIEditor()->GetSystem()->GetILog()->Log("FBX plugin: CreatePluginInstance"); - return new CFBXPlugin; -} diff --git a/Code/Sandbox/Plugins/FBXPlugin/resource.h b/Code/Sandbox/Plugins/FBXPlugin/resource.h deleted file mode 100644 index 0784105d96..0000000000 --- a/Code/Sandbox/Plugins/FBXPlugin/resource.h +++ /dev/null @@ -1,29 +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. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#define IDD_FBX_EXPORT_SETTINGS 103 -#define IDC_COPY_TEXTURES 1003 -#define IDC_EMBEDDED 1004 -#define IDC_FILE_FORMAT 1005 -#define IDC_CONVERT_CAMERAS_FOR_MAX_MAYA 1006 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1007 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.cpp b/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.cpp index c2aac4e943..73bc075deb 100644 --- a/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.cpp +++ b/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.cpp @@ -20,13 +20,18 @@ namespace AssetBundler { const char* DateTimeFormat = "hh:mm:ss MMM dd, yyyy"; + const char* ReadOnlyFileErrorMessage = "File (%s) is Read-Only. Please check your version control and try again."; AssetBundlerAbstractFileTableModel::AssetBundlerAbstractFileTableModel(QObject* parent) : QAbstractTableModel(parent) { } - void AssetBundlerAbstractFileTableModel::Reload(const char* fileExtension, const QSet& watchedFolders, const QSet& watchedFiles, const AZStd::unordered_map& pathToProjectNameMap) + void AssetBundlerAbstractFileTableModel::Reload( + const char* fileExtension, + const QSet& watchedFolders, + const QSet& watchedFiles, + const AZStd::unordered_map& pathToProjectNameMap) { AZStd::vector keysToRemove = m_fileListKeys; @@ -49,7 +54,9 @@ namespace AssetBundler // If a project name is already specified, then the associated file is a default file LoadFile(absolutePath, projectName, !projectName.empty()); - keysToRemove.erase(AZStd::remove(keysToRemove.begin(), keysToRemove.end(), AssetBundler::GenerateKeyFromAbsolutePath(absolutePath)), keysToRemove.end()); + keysToRemove.erase( + AZStd::remove(keysToRemove.begin(), keysToRemove.end(), AssetBundler::GenerateKeyFromAbsolutePath(absolutePath)), + keysToRemove.end()); } } @@ -63,7 +70,9 @@ namespace AssetBundler // If a project name is already specified, then the associated file is a default file LoadFile(absolutePath, projectName, !projectName.empty()); - keysToRemove.erase(AZStd::remove(keysToRemove.begin(), keysToRemove.end(), AssetBundler::GenerateKeyFromAbsolutePath(absolutePath)), keysToRemove.end()); + keysToRemove.erase( + AZStd::remove(keysToRemove.begin(), keysToRemove.end(), AssetBundler::GenerateKeyFromAbsolutePath(absolutePath)), + keysToRemove.end()); } } @@ -74,7 +83,9 @@ namespace AssetBundler } } - void AssetBundlerAbstractFileTableModel::ReloadFiles(const AZStd::vector& absoluteFilePathList, AZStd::unordered_map pathToProjectNameMap) + void AssetBundlerAbstractFileTableModel::ReloadFiles( + const AZStd::vector& absoluteFilePathList, + AZStd::unordered_map pathToProjectNameMap) { for (const AZStd::string& absoluteFilePath : absoluteFilePathList) { diff --git a/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.h b/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.h index cfe3e3f241..6c7ae81254 100644 --- a/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.h +++ b/Code/Tools/AssetBundler/source/models/AssetBundlerAbstractFileTableModel.h @@ -30,6 +30,7 @@ namespace AssetBundler { extern const char* DateTimeFormat; + extern const char* ReadOnlyFileErrorMessage; //! Provides an abstract model that can be subclassed to create table models used to store information about files found on-disk. class AssetBundlerAbstractFileTableModel @@ -47,9 +48,15 @@ namespace AssetBundler ////////////////////////////////////////////////////////////////////////// // Pure virtual functions - virtual AZStd::vector CreateNewFiles(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& platforms, const QString& project = QString()) = 0; + virtual AZStd::vector CreateNewFiles( + const AZStd::string& absoluteFilePath, + const AzFramework::PlatformFlags& platforms, + const QString& project = QString()) = 0; virtual bool DeleteFile(const QModelIndex& index) = 0; - virtual void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) = 0; + virtual void LoadFile( + const AZStd::string& absoluteFilePath, + const AZStd::string& projectName = "", + bool isDefaultFile = false) = 0; virtual bool WriteToDisk(const AZStd::string& key) = 0; //! Returns the absolute path of the file at the given index on success, returns an empty string on failure. @@ -60,9 +67,15 @@ namespace AssetBundler ////////////////////////////////////////////////////////////////////////// //! Reload all the data based on the watched folders and files - virtual void Reload(const char* fileExtension, const QSet& watchedFolders, const QSet& watchedFiles = QSet(), const AZStd::unordered_map& pathToProjectNameMap = AZStd::unordered_map()); + virtual void Reload( + const char* fileExtension, + const QSet& watchedFolders, + const QSet& watchedFiles = QSet(), + const AZStd::unordered_map& pathToProjectNameMap = AZStd::unordered_map()); - virtual void ReloadFiles(const AZStd::vector& absoluteFilePathList, AZStd::unordered_map pathToProjectNameMap = AZStd::unordered_map()); + virtual void ReloadFiles( + const AZStd::vector& absoluteFilePathList, + AZStd::unordered_map pathToProjectNameMap = AZStd::unordered_map()); bool Save(const QModelIndex& selectedIndex); diff --git a/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.cpp b/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.cpp index e4bb7b6ca2..a2502c73a5 100644 --- a/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.cpp +++ b/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.cpp @@ -87,12 +87,15 @@ namespace AssetBundler { if (AZ::IO::FileIOBase::GetInstance()->IsReadOnly(absolutePath)) { + AZ_Error(AssetBundler::AppWindowName, false, ReadOnlyFileErrorMessage, absolutePath); return false; } auto deleteResult = AZ::IO::FileIOBase::GetInstance()->Remove(absolutePath); if (!deleteResult) { + AZ_Error(AssetBundler::AppWindowName, false, + "Unable to delete (%s). Result code: %u", absolutePath, deleteResult.GetResultCode()); return false; } } @@ -104,7 +107,10 @@ namespace AssetBundler return true; } - void AssetListFileTableModel::LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& /*projectName*/, bool /*isDefaultFile*/) + void AssetListFileTableModel::LoadFile( + const AZStd::string& absoluteFilePath, + const AZStd::string& /*projectName*/, + bool /*isDefaultFile*/) { AZStd::string fullFileName; AzFramework::StringFunc::Path::GetFullFileName(absoluteFilePath.c_str(), fullFileName); diff --git a/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.h b/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.h index 61f1455130..699122a1ea 100644 --- a/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.h +++ b/Code/Tools/AssetBundler/source/models/AssetListFileTableModel.h @@ -56,7 +56,10 @@ namespace AssetBundler ////////////////////////////////////////////////////////////////////////// // AssetBundlerAbstractFileTableModel overrides - AZStd::vector CreateNewFiles(const AZStd::string& /*absoluteFilePath*/, const AzFramework::PlatformFlags& /*platforms*/, const QString& /*project*/) override { return {}; } + AZStd::vector CreateNewFiles( + const AZStd::string& /*absoluteFilePath*/, + const AzFramework::PlatformFlags& /*platforms*/, + const QString& /*project*/) override { return {}; } bool DeleteFile(const QModelIndex& index) override; void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) override; bool WriteToDisk(const AZStd::string& key) override; diff --git a/Code/Tools/AssetBundler/source/models/AssetListTableModel.h b/Code/Tools/AssetBundler/source/models/AssetListTableModel.h index 94500f520f..f05fa0572b 100644 --- a/Code/Tools/AssetBundler/source/models/AssetListTableModel.h +++ b/Code/Tools/AssetBundler/source/models/AssetListTableModel.h @@ -23,7 +23,10 @@ namespace AssetBundler : public QAbstractTableModel { public: - explicit AssetListTableModel(QObject* parent = nullptr, const AZStd::string& absolutePath = AZStd::string(), const AZStd::string& platform = ""); + explicit AssetListTableModel( + QObject* parent = nullptr, + const AZStd::string& absolutePath = AZStd::string(), + const AZStd::string& platform = ""); virtual ~AssetListTableModel() {} AZStd::shared_ptr GetSeedListManager() { return m_seedListManager; } diff --git a/Code/Tools/AssetBundler/source/models/BundleFileListModel.cpp b/Code/Tools/AssetBundler/source/models/BundleFileListModel.cpp index d7c0e93279..a2bb6ef91f 100644 --- a/Code/Tools/AssetBundler/source/models/BundleFileListModel.cpp +++ b/Code/Tools/AssetBundler/source/models/BundleFileListModel.cpp @@ -73,14 +73,15 @@ namespace AssetBundler { if (AZ::IO::FileIOBase::GetInstance()->IsReadOnly(absolutePath)) { - AZ_Error(AssetBundler::AppWindowName, false, "File (%s) is Read-Only. Please check your version control and try again.", absolutePath); + AZ_Error(AssetBundler::AppWindowName, false, ReadOnlyFileErrorMessage, absolutePath); return false; } auto deleteResult = AZ::IO::FileIOBase::GetInstance()->Remove(absolutePath); if (!deleteResult) { - AZ_Error(AssetBundler::AppWindowName, false, "Unable to delete: %s", absolutePath); + AZ_Error(AssetBundler::AppWindowName, false, + "Unable to delete (%s). Result code: %u", absolutePath, deleteResult.GetResultCode()); return false; } } @@ -175,7 +176,10 @@ namespace AssetBundler return Column::ColumnFileCreationTime; } - void BundleFileListModel::LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& /*projectName*/, bool /*isDefaultFile*/) + void BundleFileListModel::LoadFile( + const AZStd::string& absoluteFilePath, + const AZStd::string& /*projectName*/, + bool /*isDefaultFile*/) { AZStd::string key = AssetBundler::GenerateKeyFromAbsolutePath(absoluteFilePath); diff --git a/Code/Tools/AssetBundler/source/models/BundleFileListModel.h b/Code/Tools/AssetBundler/source/models/BundleFileListModel.h index 13e5838c57..320c2b2d59 100644 --- a/Code/Tools/AssetBundler/source/models/BundleFileListModel.h +++ b/Code/Tools/AssetBundler/source/models/BundleFileListModel.h @@ -43,7 +43,10 @@ namespace AssetBundler explicit BundleFileListModel(); virtual ~BundleFileListModel() {} - AZStd::vector CreateNewFiles(const AZStd::string& /*absoluteFilePath*/, const AzFramework::PlatformFlags& /*platforms*/, const QString& /*project*/) override { return {}; } + AZStd::vector CreateNewFiles( + const AZStd::string& /*absoluteFilePath*/, + const AzFramework::PlatformFlags& /*platforms*/, + const QString& /*project*/) override { return {}; } bool DeleteFile(const QModelIndex& index) override; void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) override; bool WriteToDisk(const AZStd::string& /*key*/) override { return true; } diff --git a/Code/Tools/AssetBundler/source/models/RulesFileTableModel.cpp b/Code/Tools/AssetBundler/source/models/RulesFileTableModel.cpp index c7ae384d6e..b452dee6bf 100644 --- a/Code/Tools/AssetBundler/source/models/RulesFileTableModel.cpp +++ b/Code/Tools/AssetBundler/source/models/RulesFileTableModel.cpp @@ -67,7 +67,10 @@ namespace AssetBundler { } - AZStd::vector RulesFileTableModel::CreateNewFiles(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& /*platforms*/, const QString& /*project*/) + AZStd::vector RulesFileTableModel::CreateNewFiles( + const AZStd::string& absoluteFilePath, + const AzFramework::PlatformFlags& /*platforms*/, + const QString& /*project*/) { if (absoluteFilePath.empty()) { @@ -116,14 +119,16 @@ namespace AssetBundler // Remove file from disk if (AZ::IO::FileIOBase::GetInstance()->IsReadOnly(rulesFileInfo->m_absolutePath.c_str())) { - AZ_Error(AssetBundler::AppWindowName, false, "File (%s) is Read-Only. Please check your version control and try again.", rulesFileInfo->m_absolutePath.c_str()); + AZ_Error(AssetBundler::AppWindowName, false, ReadOnlyFileErrorMessage, rulesFileInfo->m_absolutePath.c_str()); return false; } auto deleteResult = AZ::IO::FileIOBase::GetInstance()->Remove(rulesFileInfo->m_absolutePath.c_str()); if (!deleteResult) { - AZ_Error(AssetBundler::AppWindowName, false, "Unable to delete: %s", rulesFileInfo->m_absolutePath.c_str()); + AZ_Error(AssetBundler::AppWindowName, false, + "Unable to delete (%s). Result code: %u", rulesFileInfo->m_absolutePath.c_str(), + deleteResult.GetResultCode()); return false; } @@ -134,7 +139,10 @@ namespace AssetBundler return true; } - void RulesFileTableModel::LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& /*projectName*/, bool /*isDefaultFile*/) + void RulesFileTableModel::LoadFile( + const AZStd::string& absoluteFilePath, + const AZStd::string& /*projectName*/, + bool /*isDefaultFile*/) { // Get the file name without the extension for display purposes AZStd::string fileName(absoluteFilePath); @@ -145,7 +153,8 @@ namespace AssetBundler auto fileInfoIt = m_rulesFileInfoMap.find(key); if (fileInfoIt != m_rulesFileInfoMap.end() && fileInfoIt->second->m_hasUnsavedChanges) { - AZ_Warning(AssetBundler::AppWindowName, false, "Rules File %s has unsaved changes and couldn't be reloaded", absoluteFilePath.c_str()); + AZ_Warning(AssetBundler::AppWindowName, false, + "Rules File %s has unsaved changes and couldn't be reloaded", absoluteFilePath.c_str()); return; } diff --git a/Code/Tools/AssetBundler/source/models/RulesFileTableModel.h b/Code/Tools/AssetBundler/source/models/RulesFileTableModel.h index a9931a9819..7808fc2479 100644 --- a/Code/Tools/AssetBundler/source/models/RulesFileTableModel.h +++ b/Code/Tools/AssetBundler/source/models/RulesFileTableModel.h @@ -48,7 +48,10 @@ namespace AssetBundler RulesFileTableModel(); virtual ~RulesFileTableModel() {} - AZStd::vector CreateNewFiles(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& platforms = AzFramework::PlatformFlags::Platform_NONE, const QString& project = QString()) override; + AZStd::vector CreateNewFiles( + const AZStd::string& absoluteFilePath, + const AzFramework::PlatformFlags& platforms = AzFramework::PlatformFlags::Platform_NONE, + const QString& project = QString()) override; bool DeleteFile(const QModelIndex& index) override; diff --git a/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.cpp b/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.cpp index 1e7ec36bac..36622c809d 100644 --- a/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.cpp +++ b/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.cpp @@ -91,12 +91,19 @@ namespace AssetBundler m_seedTabWidget = nullptr; } - void SeedListFileTableModel::AddDefaultSeedsToInMemoryList(const AZStd::vector& defaultSeeds, const char* projectName, const AzFramework::PlatformFlags& platforms) + void SeedListFileTableModel::AddDefaultSeedsToInMemoryList( + const AZStd::vector& defaultSeeds, + const char* projectName, + const AzFramework::PlatformFlags& platforms) { - m_inMemoryDefaultSeedList.reset(new SeedListFileInfo(m_inMemoryDefaultSeedListKey, tr("DefaultSeeds"), QString(projectName), false, true, defaultSeeds, platforms)); + m_inMemoryDefaultSeedList.reset( + new SeedListFileInfo(m_inMemoryDefaultSeedListKey, tr("DefaultSeeds"), QString(projectName), false, true, defaultSeeds, platforms)); } - AZStd::vector SeedListFileTableModel::CreateNewFiles(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& /*platforms*/, const QString& project) + AZStd::vector SeedListFileTableModel::CreateNewFiles( + const AZStd::string& absoluteFilePath, + const AzFramework::PlatformFlags& /*platforms*/, + const QString& project) { if (absoluteFilePath.empty()) { @@ -111,7 +118,8 @@ namespace AssetBundler // Create a Seed List File and save it to disk AZStd::string key = AssetBundler::GenerateKeyFromAbsolutePath(absoluteFilePath); - AZStd::shared_ptr newSeedListFile = AZStd::make_shared(absoluteFilePath, QString(fileName.c_str()), project, false); + AZStd::shared_ptr newSeedListFile = + AZStd::make_shared(absoluteFilePath, QString(fileName.c_str()), project, false); newSeedListFile->m_seedListModel->SetHasUnsavedChanges(true); bool saveResult = newSeedListFile->SaveSeedFile(); if (!saveResult) @@ -151,14 +159,15 @@ namespace AssetBundler { if (AZ::IO::FileIOBase::GetInstance()->IsReadOnly(absolutePath)) { - AZ_Error(AssetBundler::AppWindowName, false, "File (%s) is Read-Only. Please check your version control and try again.", absolutePath); + AZ_Error(AssetBundler::AppWindowName, false, ReadOnlyFileErrorMessage, absolutePath); return false; } auto deleteResult = AZ::IO::FileIOBase::GetInstance()->Remove(absolutePath); if (!deleteResult) { - AZ_Error(AssetBundler::AppWindowName, false, "Unable to delete: %s", absolutePath); + AZ_Error(AssetBundler::AppWindowName, false, + "Unable to delete (%s). Result code: %u", absolutePath, deleteResult.GetResultCode()); return false; } } @@ -170,7 +179,11 @@ namespace AssetBundler return true; } - void SeedListFileTableModel::Reload(const char* fileExtension, const QSet& watchedFolders, const QSet& watchedFiles, const AZStd::unordered_map& pathToProjectNameMap) + void SeedListFileTableModel::Reload( + const char* fileExtension, + const QSet& watchedFolders, + const QSet& watchedFiles, + const AZStd::unordered_map& pathToProjectNameMap) { // Load in the Seed List files from disk AssetBundlerAbstractFileTableModel::Reload(fileExtension, watchedFolders, watchedFiles, pathToProjectNameMap); @@ -191,7 +204,8 @@ namespace AssetBundler auto fileInfoIt = m_seedListFileInfoMap.find(key); if (fileInfoIt != m_seedListFileInfoMap.end() && fileInfoIt->second->HasUnsavedChanges()) { - AZ_Warning(AssetBundler::AppWindowName, false, "Seed List File %s has unsaved changes and couldn't be reloaded", absoluteFilePath.c_str()); + AZ_Warning(AssetBundler::AppWindowName, false, + "Seed List File %s has unsaved changes and couldn't be reloaded", absoluteFilePath.c_str()); return; } @@ -208,7 +222,8 @@ namespace AssetBundler projectNameOnDisplay = outcome.TakeValue(); } - m_seedListFileInfoMap[key].reset(new SeedListFileInfo(absoluteFilePath, QString(fileName.c_str()), QString(projectNameOnDisplay.c_str()), true, isDefaultFile)); + m_seedListFileInfoMap[key].reset( + new SeedListFileInfo(absoluteFilePath, QString(fileName.c_str()), QString(projectNameOnDisplay.c_str()), true, isDefaultFile)); AddFileKey(key); } @@ -241,7 +256,9 @@ namespace AssetBundler emit dataChanged(firstIndex, lastIndex, { Qt::CheckStateRole }); } - AZStd::vector SeedListFileTableModel::GenerateAssetLists(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& platforms) + AZStd::vector SeedListFileTableModel::GenerateAssetLists( + const AZStd::string& absoluteFilePath, + const AzFramework::PlatformFlags& platforms) { if (!m_checkedSeedListFiles.size()) { @@ -280,7 +297,8 @@ namespace AssetBundler AZStd::vector createdFiles; for (const auto& platformIndex : AzFramework::PlatformHelper::GetPlatformIndicesInterpreted(platforms)) { - AZStd::string platformSpecificCachePath = AzToolsFramework::PlatformAddressedAssetCatalog::GetCatalogRegistryPathForPlatform(platformIndex); + AZStd::string platformSpecificCachePath = + AzToolsFramework::PlatformAddressedAssetCatalog::GetCatalogRegistryPathForPlatform(platformIndex); AzFramework::StringFunc::Path::StripFullName(platformSpecificCachePath); FilePath platformSpecificPath(absoluteFilePath, AZStd::string(AzFramework::PlatformHelper::GetPlatformName(platformIndex))); @@ -304,7 +322,10 @@ namespace AssetBundler return seedFileInfoOutcome.GetValue()->m_seedListModel; } - bool SeedListFileTableModel::SetSeedPlatforms(const QModelIndex& seedFileIndex, const QModelIndex& seedIndex, const AzFramework::PlatformFlags& platforms) + bool SeedListFileTableModel::SetSeedPlatforms( + const QModelIndex& seedFileIndex, + const QModelIndex& seedIndex, + const AzFramework::PlatformFlags& platforms) { AZStd::string key = GetFileKey(seedFileIndex); if (key.empty()) @@ -334,7 +355,10 @@ namespace AssetBundler return true; } - bool SeedListFileTableModel::AddSeed(const QModelIndex& seedFileIndex, const AZStd::string& seedRelativePath, const AzFramework::PlatformFlags& platforms) + bool SeedListFileTableModel::AddSeed( + const QModelIndex& seedFileIndex, + const AZStd::string& seedRelativePath, + const AzFramework::PlatformFlags& platforms) { AZStd::string key = GetFileKey(seedFileIndex); if (key.empty()) diff --git a/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.h b/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.h index 3bd8fbd600..9adac6a64b 100644 --- a/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.h +++ b/Code/Tools/AssetBundler/source/models/SeedListFileTableModel.h @@ -71,15 +71,28 @@ namespace AssetBundler explicit SeedListFileTableModel(SeedTabWidget* parentSeedTabWidget); virtual ~SeedListFileTableModel(); - void AddDefaultSeedsToInMemoryList(const AZStd::vector& defaultSeeds, const char* projectName, const AzFramework::PlatformFlags& platforms); + void AddDefaultSeedsToInMemoryList( + const AZStd::vector& defaultSeeds, + const char* projectName, + const AzFramework::PlatformFlags& platforms); - AZStd::vector CreateNewFiles(const AZStd::string& absoluteFilePath, const AzFramework::PlatformFlags& platforms, const QString& project) override; + AZStd::vector CreateNewFiles( + const AZStd::string& absoluteFilePath, + const AzFramework::PlatformFlags& platforms, + const QString& project) override; bool DeleteFile(const QModelIndex& index) override; - void Reload(const char* fileExtension, const QSet& watchedFolders, const QSet& watchedFiles = QSet(), const AZStd::unordered_map& pathToProjectNameMap = AZStd::unordered_map()) override; + void Reload( + const char* fileExtension, + const QSet& watchedFolders, + const QSet& watchedFiles = QSet(), + const AZStd::unordered_map& pathToProjectNameMap = AZStd::unordered_map()) override; - void LoadFile(const AZStd::string& absoluteFilePath, const AZStd::string& projectName = "", bool isDefaultFile = false) override; + void LoadFile( + const AZStd::string& absoluteFilePath, + const AZStd::string& projectName = "", + bool isDefaultFile = false) override; void SelectDefaultSeedLists(bool setSelected); diff --git a/Code/Tools/AssetBundler/source/models/SeedListTableModel.cpp b/Code/Tools/AssetBundler/source/models/SeedListTableModel.cpp index fc04686436..8b721d961c 100644 --- a/Code/Tools/AssetBundler/source/models/SeedListTableModel.cpp +++ b/Code/Tools/AssetBundler/source/models/SeedListTableModel.cpp @@ -38,7 +38,11 @@ namespace AssetBundler ////////////////////////////////////////////////////////////////////////////////////////////////// // SeedListTableModel ////////////////////////////////////////////////////////////////////////////////////////////////// - SeedListTableModel::SeedListTableModel(QObject* parent, const AZStd::string& absolutePath, const AZStd::vector& defaultSeeds, const AzFramework::PlatformFlags& platforms) + SeedListTableModel::SeedListTableModel( + QObject* parent, + const AZStd::string& absolutePath, + const AZStd::vector& defaultSeeds, + const AzFramework::PlatformFlags& platforms) : QAbstractTableModel(parent) { m_seedListManager.reset(new AzToolsFramework::AssetSeedManager()); @@ -66,7 +70,10 @@ namespace AssetBundler QString platformList; for (const auto& seed : m_seedListManager->GetAssetSeedList()) { - assetInfo = AzToolsFramework::AssetSeedManager::GetAssetInfoById(seed.m_assetId, AzFramework::PlatformHelper::GetPlatformIndicesInterpreted(seed.m_platformFlags)[0], absolutePath); + assetInfo = AzToolsFramework::AssetSeedManager::GetAssetInfoById( + seed.m_assetId, + AzFramework::PlatformHelper::GetPlatformIndicesInterpreted(seed.m_platformFlags)[0], + absolutePath); platformList = QString(m_seedListManager->GetReadablePlatformList(seed).c_str()); m_additionalSeedInfoMap[seed.m_assetId].reset(new AdditionalSeedInfo(assetInfo.m_relativePath.c_str(), platformList)); @@ -126,7 +133,8 @@ namespace AssetBundler AZ_Error(AssetBundler::AppWindowName, false, "Unable to find additional Seed info"); return false; } - additionalSeedInfo->second->m_platformList = QString(AzFramework::PlatformHelper::GetCommaSeparatedPlatformList(platforms).c_str()); + additionalSeedInfo->second->m_platformList = + QString(AzFramework::PlatformHelper::GetCommaSeparatedPlatformList(platforms).c_str()); SetHasUnsavedChanges(true); @@ -140,7 +148,8 @@ namespace AssetBundler bool SeedListTableModel::AddSeed(const AZStd::string& seedRelativePath, const AzFramework::PlatformFlags& platforms) { - AZStd::pair addSeedsResult = m_seedListManager->AddSeedAssetForValidPlatforms(seedRelativePath, platforms); + AZStd::pair addSeedsResult = + m_seedListManager->AddSeedAssetForValidPlatforms(seedRelativePath, platforms); if (!addSeedsResult.first.IsValid() || addSeedsResult.second == AzFramework::PlatformFlags::Platform_NONE) { diff --git a/Code/Tools/AssetBundler/source/models/SeedListTableModel.h b/Code/Tools/AssetBundler/source/models/SeedListTableModel.h index b8cbe95201..37d52717a7 100644 --- a/Code/Tools/AssetBundler/source/models/SeedListTableModel.h +++ b/Code/Tools/AssetBundler/source/models/SeedListTableModel.h @@ -36,7 +36,11 @@ namespace AssetBundler : public QAbstractTableModel { public: - explicit SeedListTableModel(QObject* parent = nullptr, const AZStd::string& absolutePath = AZStd::string(), const AZStd::vector& defaultSeeds = AZStd::vector(), const AzFramework::PlatformFlags& platforms = AzFramework::PlatformFlags::Platform_NONE); + explicit SeedListTableModel( + QObject* parent = nullptr, + const AZStd::string& absolutePath = AZStd::string(), + const AZStd::vector& defaultSeeds = AZStd::vector(), + const AzFramework::PlatformFlags& platforms = AzFramework::PlatformFlags::Platform_NONE); virtual ~SeedListTableModel() {} AZStd::shared_ptr GetSeedListManager() { return m_seedListManager; } diff --git a/Code/Tools/AssetBundler/source/ui/AddSeedDialog.cpp b/Code/Tools/AssetBundler/source/ui/AddSeedDialog.cpp index be156efde2..214fe7e850 100644 --- a/Code/Tools/AssetBundler/source/ui/AddSeedDialog.cpp +++ b/Code/Tools/AssetBundler/source/ui/AddSeedDialog.cpp @@ -22,7 +22,10 @@ const char QtRelativePathPrefix[] = "../"; namespace AssetBundler { - AddSeedDialog::AddSeedDialog(QWidget* parent, const AzFramework::PlatformFlags& enabledPlatforms, const AZStd::string& platformSpecificCachePath) + AddSeedDialog::AddSeedDialog( + QWidget* parent, + const AzFramework::PlatformFlags& enabledPlatforms, + const AZStd::string& platformSpecificCachePath) : QDialog(parent) , m_platformSpecificCachePath(platformSpecificCachePath.c_str()) { @@ -35,7 +38,10 @@ namespace AssetBundler // Set up Platform selection m_ui->platformSelectionWidget->Init(enabledPlatforms); - connect(m_ui->platformSelectionWidget, &PlatformSelectionWidget::PlatformsSelected, this, &AddSeedDialog::OnPlatformSelectionChanged); + connect(m_ui->platformSelectionWidget, + &PlatformSelectionWidget::PlatformsSelected, + this, + &AddSeedDialog::OnPlatformSelectionChanged); // Set up Cancel and Create New File buttons m_ui->addSeedButton->setEnabled(false); diff --git a/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h b/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h index fed6b031d1..7699f0a820 100644 --- a/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h +++ b/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h @@ -34,7 +34,10 @@ namespace AssetBundler Q_OBJECT public: - explicit AddSeedDialog(QWidget* parent, const AzFramework::PlatformFlags& enabledPlatforms, const AZStd::string& platformSpecificCachePath); + explicit AddSeedDialog( + QWidget* parent, + const AzFramework::PlatformFlags& enabledPlatforms, + const AZStd::string& platformSpecificCachePath); virtual ~AddSeedDialog() {} AZStd::string GetFileName(); diff --git a/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp index 9dcfd34c35..2d2f40e038 100644 --- a/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp @@ -73,7 +73,10 @@ namespace AssetBundler SetupContextMenu(); Reload(); - connect(GetFileTableView()->header(), &QHeaderView::sortIndicatorChanged, m_fileTableFilterModel.get(), &AssetBundlerFileTableFilterModel::sort); + connect(GetFileTableView()->header(), + &QHeaderView::sortIndicatorChanged, + m_fileTableFilterModel.get(), + &AssetBundlerFileTableFilterModel::sort); GetFileTableView()->header()->setSortIndicatorShown(true); // Setting this in descending order will ensure the most recent files are at the top GetFileTableView()->header()->setSortIndicator(GetFileTableModel()->GetTimeStampColumnIndex(), Qt::DescendingOrder); @@ -163,9 +166,11 @@ namespace AssetBundler return; } - QString messageBoxText = QString(tr("Are you sure you would like to delete %1? \n\nThis will permanently delete the file.")).arg(QString(selectedFileAbsolutePath.c_str())); + QString messageBoxText = + QString(tr("Are you sure you would like to delete %1? \n\nThis will permanently delete the file.")).arg(QString(selectedFileAbsolutePath.c_str())); - QMessageBox::StandardButton confirmDeleteFileResult = QMessageBox::question(this, QString(tr("Delete %1")).arg(GetFileTypeDisplayName()), messageBoxText); + QMessageBox::StandardButton confirmDeleteFileResult = + QMessageBox::question(this, QString(tr("Delete %1")).arg(GetFileTypeDisplayName()), messageBoxText); if (confirmDeleteFileResult != QMessageBox::StandardButton::Yes) { // User canceled out of the confirmation dialog @@ -206,7 +211,8 @@ namespace AssetBundler defaultFolderPath = m_guiApplicationManager->GetBundlesFolder(); break; default: - AZ_Warning(AssetBundler::AppWindowName, false, "No default folder is defined for AssetBundlingFileType ( %i ).", static_cast(fileType)); + AZ_Warning(AssetBundler::AppWindowName, false, + "No default folder is defined for AssetBundlingFileType ( %i ).", static_cast(fileType)); break; } @@ -224,7 +230,8 @@ namespace AssetBundler void AssetBundlerTabWidget::AddScanPathToAssetBundlerSettings(AssetBundlingFileType fileType, const QString& filePath) { - AZStd::string assetBundlerSettingsFileAbsolutePath = GetAssetBundlerUserSettingsFile(m_guiApplicationManager->GetCurrentProjectFolder().c_str()); + AZStd::string assetBundlerSettingsFileAbsolutePath = + GetAssetBundlerUserSettingsFile(m_guiApplicationManager->GetCurrentProjectFolder().c_str()); QJsonObject assetBundlerSettings = AssetBundler::ReadJson(assetBundlerSettingsFileAbsolutePath); QJsonObject scanPathsSettings = assetBundlerSettings[ScanPathsKey].toObject(); QJsonArray scanPaths = scanPathsSettings[AssetBundlingFileTypes[fileType]].toArray(); @@ -256,7 +263,8 @@ namespace AssetBundler void AssetBundlerTabWidget::RemoveScanPathFromAssetBundlerSettings(AssetBundlingFileType fileType, const QString& filePath) { - AZStd::string assetBundlerSettingsFileAbsolutePath = GetAssetBundlerUserSettingsFile(m_guiApplicationManager->GetCurrentProjectFolder().c_str()); + AZStd::string assetBundlerSettingsFileAbsolutePath = + GetAssetBundlerUserSettingsFile(m_guiApplicationManager->GetCurrentProjectFolder().c_str()); QJsonObject assetBundlerSettings = AssetBundler::ReadJson(assetBundlerSettingsFileAbsolutePath); QJsonObject scanPathsSettings = assetBundlerSettings[ScanPathsKey].toObject(); QJsonArray scanPaths = scanPathsSettings[AssetBundlingFileTypes[fileType]].toArray(); @@ -305,7 +313,10 @@ namespace AssetBundler void AssetBundlerTabWidget::SetupContextMenu() { GetFileTableView()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(GetFileTableView(), &QTreeView::customContextMenuRequested, this, &AssetBundlerTabWidget::OnFileTableContextMenuRequested); + connect(GetFileTableView(), + &QTreeView::customContextMenuRequested, + this, + &AssetBundlerTabWidget::OnFileTableContextMenuRequested); } void AssetBundlerTabWidget::ReadAssetBundlerSettings(const AZStd::string& filePath, AssetBundlingFileType fileType) diff --git a/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.h b/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.h index edef5c0437..17eb171d6d 100644 --- a/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.h +++ b/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.h @@ -78,7 +78,9 @@ namespace AssetBundler virtual void ApplyConfig() = 0; - virtual void FileSelectionChanged(const QItemSelection& /*selected*/ = QItemSelection(), const QItemSelection& /*deselected*/ = QItemSelection()) = 0; + virtual void FileSelectionChanged( + const QItemSelection& /*selected*/ = QItemSelection(), + const QItemSelection& /*deselected*/ = QItemSelection()) = 0; static void InitAssetBundlerSettings(const char* currentProjectFolderPath); diff --git a/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.cpp index 339dc080fa..2f0351e39e 100644 --- a/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.cpp @@ -44,14 +44,22 @@ namespace AssetBundler m_ui->mainVerticalLayout->setContentsMargins(10, 10, 10, 10); // File view of all Asset List Files - m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel(this, m_fileTableModel->GetFileNameColumnIndex(), m_fileTableModel->GetTimeStampColumnIndex())); + m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel( + this, + m_fileTableModel->GetFileNameColumnIndex(), + m_fileTableModel->GetTimeStampColumnIndex())); m_fileTableFilterModel->setSourceModel(m_fileTableModel.data()); m_ui->assetListsTable->setModel(m_fileTableFilterModel.data()); - connect(m_ui->fileFilteredSearchWidget, &AzQtComponents::FilteredSearchWidget::TextFilterChanged, - m_fileTableFilterModel.data(), static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); + connect(m_ui->fileFilteredSearchWidget, + &AzQtComponents::FilteredSearchWidget::TextFilterChanged, + m_fileTableFilterModel.data(), + static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); - connect(m_ui->assetListsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &AssetListTabWidget::FileSelectionChanged); + connect(m_ui->assetListsTable->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &AssetListTabWidget::FileSelectionChanged); m_ui->fileTableHeaderLayout->setContentsMargins(0, 0, 0, 0); m_ui->fileTableVerticalLayout->setContentsMargins(0, 0, 0, 0); @@ -70,8 +78,10 @@ namespace AssetBundler m_assetListContentsFilterModel->setSourceModel(m_assetListContentsModel.data()); m_ui->assetListContentsTable->setModel(m_assetListContentsFilterModel.data()); - connect(m_ui->assetListContentsFilteredSearchWidget, &AzQtComponents::FilteredSearchWidget::TextFilterChanged, - m_assetListContentsFilterModel.data(), static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); + connect(m_ui->assetListContentsFilteredSearchWidget, + &AzQtComponents::FilteredSearchWidget::TextFilterChanged, + m_assetListContentsFilterModel.data(), + static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); m_ui->fileContentsHeaderLayout->setContentsMargins(0, 0, 0, 0); @@ -121,13 +131,21 @@ namespace AssetBundler m_ui->fileTableFrame->setFixedWidth(config.fileTableWidth); - m_ui->assetListsTable->header()->resizeSection(AssetListFileTableModel::Column::ColumnFileName, config.assetListFileNameColumnWidth); - m_ui->assetListsTable->header()->resizeSection(AssetListFileTableModel::Column::ColumnPlatform, config.assetListPlatformColumnWidth); + m_ui->assetListsTable->header()->resizeSection( + AssetListFileTableModel::Column::ColumnFileName, + config.assetListFileNameColumnWidth); + m_ui->assetListsTable->header()->resizeSection( + AssetListFileTableModel::Column::ColumnPlatform, + config.assetListPlatformColumnWidth); m_ui->assetListContentsFilteredSearchWidget->setFixedWidth(config.fileTableWidth); - m_ui->assetListContentsTable->header()->resizeSection(AssetListTableModel::Column::ColumnAssetName, config.productAssetNameColumnWidth); - m_ui->assetListContentsTable->header()->resizeSection(AssetListTableModel::Column::ColumnRelativePath, config.productAssetRelativePathColumnWidth); + m_ui->assetListContentsTable->header()->resizeSection( + AssetListTableModel::Column::ColumnAssetName, + config.productAssetNameColumnWidth); + m_ui->assetListContentsTable->header()->resizeSection( + AssetListTableModel::Column::ColumnRelativePath, + config.productAssetRelativePathColumnWidth); } diff --git a/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.h b/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.h index 890f45a0c9..294c32ed38 100644 --- a/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.h +++ b/Code/Tools/AssetBundler/source/ui/AssetListTabWidget.h @@ -65,7 +65,9 @@ namespace AssetBundler AssetBundlerAbstractFileTableModel* GetFileTableModel() override; void SetActiveProjectLabel(const QString& labelText) override; void ApplyConfig() override; - void FileSelectionChanged(const QItemSelection& /*selected*/ = QItemSelection(), const QItemSelection& /*deselected*/ = QItemSelection()) override; + void FileSelectionChanged( + const QItemSelection& /*selected*/ = QItemSelection(), + const QItemSelection& /*deselected*/ = QItemSelection()) override; ////////////////////////////////////////////////////////////////////////// private: diff --git a/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.cpp index b670fd0ebd..53f0acc0fe 100644 --- a/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.cpp @@ -34,14 +34,22 @@ namespace AssetBundler m_ui->mainVerticalLayout->setContentsMargins(MarginSize, MarginSize, MarginSize, MarginSize); m_fileTableModel.reset(new BundleFileListModel); - m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel(this, m_fileTableModel->GetFileNameColumnIndex(), m_fileTableModel->GetTimeStampColumnIndex())); + m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel( + this, + m_fileTableModel->GetFileNameColumnIndex(), + m_fileTableModel->GetTimeStampColumnIndex())); m_fileTableFilterModel->setSourceModel(m_fileTableModel.data()); m_ui->fileTableView->setModel(m_fileTableFilterModel.data()); - connect(m_ui->fileFilteredSearchWidget, &AzQtComponents::FilteredSearchWidget::TextFilterChanged, - m_fileTableFilterModel.data(), static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); + connect(m_ui->fileFilteredSearchWidget, + &AzQtComponents::FilteredSearchWidget::TextFilterChanged, + m_fileTableFilterModel.data(), + static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); - connect(m_ui->fileTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &BundleListTabWidget::FileSelectionChanged); + connect(m_ui->fileTableView->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &BundleListTabWidget::FileSelectionChanged); m_ui->fileTableView->setIndentation(0); diff --git a/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.h b/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.h index c05e1078fa..83439539c8 100644 --- a/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.h +++ b/Code/Tools/AssetBundler/source/ui/BundleListTabWidget.h @@ -53,7 +53,9 @@ namespace AssetBundler AssetBundlerAbstractFileTableModel* GetFileTableModel() override; void SetActiveProjectLabel(const QString& labelText) override; void ApplyConfig() override; - void FileSelectionChanged(const QItemSelection& /*selected*/ = QItemSelection(), const QItemSelection& /*deselected*/ = QItemSelection()) override; + void FileSelectionChanged( + const QItemSelection& /*selected*/ = QItemSelection(), + const QItemSelection& /*deselected*/ = QItemSelection()) override; private: void ClearDisplayedBundleValues(); diff --git a/Code/Tools/AssetBundler/source/ui/ComparisonDataWidget.cpp b/Code/Tools/AssetBundler/source/ui/ComparisonDataWidget.cpp index b5c2d78030..81055676fb 100644 --- a/Code/Tools/AssetBundler/source/ui/ComparisonDataWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/ComparisonDataWidget.cpp @@ -42,7 +42,8 @@ namespace AssetBundler if (!IsComparisonDataIndexValid()) { - AZ_Error("AssetBundler", false, "ComparisonData index ( %u ) is out of bounds. ComparisonData cannot be displayed.", m_comparisonDataIndex); + AZ_Error("AssetBundler", false, + "ComparisonData index ( %u ) is out of bounds. ComparisonData cannot be displayed.", m_comparisonDataIndex); return; } @@ -64,14 +65,26 @@ namespace AssetBundler connect(m_ui->nameLineEdit, &QLineEdit::textEdited, this, &ComparisonDataWidget::OnNameLineEditChanged); m_ui->comparisonTypeComboBox->installEventFilter(mouseWheelEventFilter); - connect(m_ui->comparisonTypeComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ComparisonDataWidget::OnComparisonTypeComboBoxChanged); + connect(m_ui->comparisonTypeComboBox, + QOverload::of(&QComboBox::currentIndexChanged), + this, + &ComparisonDataWidget::OnComparisonTypeComboBoxChanged); m_ui->firstInputComboBox->installEventFilter(mouseWheelEventFilter); - connect(m_ui->firstInputComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ComparisonDataWidget::OnFirstInputComboBoxChanged); - connect(m_ui->firstInputBrowseButton, &QPushButton::pressed, this, &ComparisonDataWidget::OnFirstInputBrowseButtonPressed); + connect(m_ui->firstInputComboBox, + QOverload::of(&QComboBox::currentIndexChanged), + this, + &ComparisonDataWidget::OnFirstInputComboBoxChanged); + connect(m_ui->firstInputBrowseButton, + &QPushButton::pressed, + this, + &ComparisonDataWidget::OnFirstInputBrowseButtonPressed); m_ui->secondInputComboBox->installEventFilter(mouseWheelEventFilter); - connect(m_ui->secondInputComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ComparisonDataWidget::OnSecondInputComboBoxChanged); + connect(m_ui->secondInputComboBox, + QOverload::of(&QComboBox::currentIndexChanged), + this, + &ComparisonDataWidget::OnSecondInputComboBoxChanged); connect(m_ui->secondInputBrowseButton, &QPushButton::pressed, this, &ComparisonDataWidget::OnSecondInputBrowseButtonPressed); connect(m_ui->filePatternLineEdit, &QLineEdit::textEdited, this, &ComparisonDataWidget::OnFilePatternLineEditChanged); @@ -187,7 +200,8 @@ namespace AssetBundler m_ui->filePatternLineEdit->setText(comparisonData.m_filePattern.c_str()); } - void ComparisonDataWidget::InitComparisonTypeComboBox(const AzToolsFramework::AssetFileInfoListComparison::ComparisonData& comparisonData) + void ComparisonDataWidget::InitComparisonTypeComboBox( + const AzToolsFramework::AssetFileInfoListComparison::ComparisonData& comparisonData) { using namespace AzToolsFramework; @@ -225,7 +239,8 @@ namespace AssetBundler initialSelectionIndex = ComparisonTypeIndex::Complement; break; default: - AZ_Warning("AssetBundler", false, "ComparisonType ( %u ) is not supported in the Asset Bundler", comparisonData.m_comparisonType); + AZ_Warning("AssetBundler", false, + "ComparisonType ( %u ) is not supported in the Asset Bundler", comparisonData.m_comparisonType); } } diff --git a/Code/Tools/AssetBundler/source/ui/EditSeedDialog.cpp b/Code/Tools/AssetBundler/source/ui/EditSeedDialog.cpp index a42e0cd0f0..db243f6bc2 100644 --- a/Code/Tools/AssetBundler/source/ui/EditSeedDialog.cpp +++ b/Code/Tools/AssetBundler/source/ui/EditSeedDialog.cpp @@ -32,7 +32,10 @@ namespace AssetBundler m_ui->platformSelectionWidget->Init(enabledPlatforms); m_ui->platformSelectionWidget->SetSelectedPlatforms(selectedPlatforms, partiallySelectedPlatforms); - connect(m_ui->platformSelectionWidget, &PlatformSelectionWidget::PlatformsSelected, this, &EditSeedDialog::OnPlatformSelectionChanged); + connect(m_ui->platformSelectionWidget, + &PlatformSelectionWidget::PlatformsSelected, + this, + &EditSeedDialog::OnPlatformSelectionChanged); // Set up confirm and cancel buttons connect(m_ui->applyChangesButton, &QPushButton::clicked, this, &QDialog::accept); @@ -49,7 +52,9 @@ namespace AssetBundler return m_ui->platformSelectionWidget->GetPartiallySelectedPlatforms(); } - void EditSeedDialog::OnPlatformSelectionChanged(const AzFramework::PlatformFlags& selectedPlatforms, const AzFramework::PlatformFlags& partiallySelectedPlatforms) + void EditSeedDialog::OnPlatformSelectionChanged( + const AzFramework::PlatformFlags& selectedPlatforms, + const AzFramework::PlatformFlags& partiallySelectedPlatforms) { // Disable the "Apply Changes" button if no platforms are selected bool areAnyPlatformsSelected = selectedPlatforms != AzFramework::PlatformFlags::Platform_NONE || diff --git a/Code/Tools/AssetBundler/source/ui/EditSeedDialog.h b/Code/Tools/AssetBundler/source/ui/EditSeedDialog.h index 751c1eae3d..189212ddbd 100644 --- a/Code/Tools/AssetBundler/source/ui/EditSeedDialog.h +++ b/Code/Tools/AssetBundler/source/ui/EditSeedDialog.h @@ -44,7 +44,9 @@ namespace AssetBundler AzFramework::PlatformFlags GetPartiallySelectedPlatformFlags(); private: - void OnPlatformSelectionChanged(const AzFramework::PlatformFlags& selectedPlatforms, const AzFramework::PlatformFlags& partiallySelectedPlatforms); + void OnPlatformSelectionChanged( + const AzFramework::PlatformFlags& selectedPlatforms, + const AzFramework::PlatformFlags& partiallySelectedPlatforms); QSharedPointer m_ui; }; diff --git a/Code/Tools/AssetBundler/source/ui/GenerateBundlesModal.cpp b/Code/Tools/AssetBundler/source/ui/GenerateBundlesModal.cpp index 3724bc8753..326251af88 100644 --- a/Code/Tools/AssetBundler/source/ui/GenerateBundlesModal.cpp +++ b/Code/Tools/AssetBundler/source/ui/GenerateBundlesModal.cpp @@ -52,26 +52,41 @@ namespace AssetBundler // Bundle Output m_ui->outputBundlePathLineEdit->setReadOnly(true); - connect(m_ui->outputBundlePathBrowseButton, &QPushButton::clicked, this, &GenerateBundlesModal::OnOutputBundleLocationBrowseButtonPressed); + connect(m_ui->outputBundlePathBrowseButton, + &QPushButton::clicked, + this, + &GenerateBundlesModal::OnOutputBundleLocationBrowseButtonPressed); // Bundle Settings files m_ui->bundleSettingsFileLineEdit->setReadOnly(true); m_ui->bundleSettingsFileLineEdit->setText(tr(CustomBundleSettingsText)); - connect(m_ui->bundleSettingsFileBrowseButton, &QPushButton::clicked, this, &GenerateBundlesModal::OnBundleSettingsBrowseButtonPressed); - connect(m_ui->bundleSettingsFileSaveButton, &QPushButton::clicked, this, &GenerateBundlesModal::OnBundleSettingsSaveButtonPressed); + connect(m_ui->bundleSettingsFileBrowseButton, + &QPushButton::clicked, + this, + &GenerateBundlesModal::OnBundleSettingsBrowseButtonPressed); + connect(m_ui->bundleSettingsFileSaveButton, + &QPushButton::clicked, + this, + &GenerateBundlesModal::OnBundleSettingsSaveButtonPressed); // Max Bundle Size m_ui->maxBundleSizeSpinBox->setRange(1, AzToolsFramework::MaxBundleSizeInMB); m_ui->maxBundleSizeSpinBox->setValue(AzToolsFramework::MaxBundleSizeInMB); m_ui->maxBundleSizeSpinBox->setButtonSymbols(QAbstractSpinBox::ButtonSymbols::NoButtons); m_ui->maxBundleSizeSpinBox->setSuffix(" MB"); - connect(m_ui->maxBundleSizeSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &GenerateBundlesModal::OnMaxBundleSizeChanged); + connect(m_ui->maxBundleSizeSpinBox, + QOverload::of(&QSpinBox::valueChanged), + this, + &GenerateBundlesModal::OnMaxBundleSizeChanged); // Bundle Version m_ui->bundleVersionSpinBox->setRange(1, AzFramework::AssetBundleManifest::CurrentBundleVersion); m_ui->bundleVersionSpinBox->setValue(AzFramework::AssetBundleManifest::CurrentBundleVersion); m_ui->bundleVersionSpinBox->setButtonSymbols(QAbstractSpinBox::ButtonSymbols::NoButtons); - connect(m_ui->bundleVersionSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &GenerateBundlesModal::OnBundleVersionChanged); + connect(m_ui->bundleVersionSpinBox, + QOverload::of(&QSpinBox::valueChanged), + this, + &GenerateBundlesModal::OnBundleVersionChanged); // Cancel and Generate Bundles buttons m_ui->generateBundlesButton->setEnabled(false); @@ -197,9 +212,11 @@ namespace AssetBundler if (AZ::IO::FileIOBase::GetInstance()->Exists(bundleSettingsAbsolutePath.c_str())) { - QString messageBoxText = QString(tr("Bundle Settings ( %1 ) already exists on-disk. Saving the current settings will override the existing settings. \n\nDo you wish to continue?")).arg(bundleSettingsAbsolutePath.c_str()); + QString messageBoxText = QString(tr( + "Bundle Settings ( %1 ) already exists on-disk. Saving the current settings will override the existing settings. \n\nDo you wish to continue?")).arg(bundleSettingsAbsolutePath.c_str()); - QMessageBox::StandardButton confirmDeleteFileResult = QMessageBox::question(this, QString(tr("Replace Existing Settings")), messageBoxText); + QMessageBox::StandardButton confirmDeleteFileResult = + QMessageBox::question(this, QString(tr("Replace Existing Settings")), messageBoxText); if (confirmDeleteFileResult != QMessageBox::StandardButton::Yes) { // User canceled out of the operation @@ -237,9 +254,11 @@ namespace AssetBundler if (AZ::IO::FileIOBase::GetInstance()->Exists(m_bundleSettings.m_bundleFilePath.c_str())) { - QString messageBoxText = QString(tr("Asset Bundle ( %1 ) already exists on-disk. Generating a new Bundle will override the existing Bundle. \n\nDo you wish to permanently delete the existing Bundle?")).arg(m_bundleSettings.m_bundleFilePath.c_str()); + QString messageBoxText = QString(tr( + "Asset Bundle ( %1 ) already exists on-disk. Generating a new Bundle will override the existing Bundle. \n\nDo you wish to permanently delete the existing Bundle?")).arg(m_bundleSettings.m_bundleFilePath.c_str()); - QMessageBox::StandardButton confirmDeleteFileResult = QMessageBox::question(this, QString(tr("Replace Existing Bundle")), messageBoxText); + QMessageBox::StandardButton confirmDeleteFileResult = + QMessageBox::question(this, QString(tr("Replace Existing Bundle")), messageBoxText); if (confirmDeleteFileResult != QMessageBox::StandardButton::Yes) { // User canceled out of the operation @@ -259,10 +278,14 @@ namespace AssetBundler if (result) { - m_assetListTabWidget->AddScanPathToAssetBundlerSettings(AssetBundlingFileType::BundleFileType, m_bundleSettings.m_bundleFilePath); + m_assetListTabWidget->AddScanPathToAssetBundlerSettings( + AssetBundlingFileType::BundleFileType, + m_bundleSettings.m_bundleFilePath); // The watched files list was updated after the files were created, so we need to force-reload them - m_assetListTabWidget->GetGUIApplicationManager()->UpdateFiles(AssetBundlingFileType::BundleFileType, { m_bundleSettings.m_bundleFilePath }); + m_assetListTabWidget->GetGUIApplicationManager()->UpdateFiles( + AssetBundlingFileType::BundleFileType, + { m_bundleSettings.m_bundleFilePath }); } AZStd::vector generatedFilePaths = { m_bundleSettings.m_bundleFilePath }; diff --git a/Code/Tools/AssetBundler/source/ui/MainWindow.cpp b/Code/Tools/AssetBundler/source/ui/MainWindow.cpp index c0e30c01f2..53b1c07943 100644 --- a/Code/Tools/AssetBundler/source/ui/MainWindow.cpp +++ b/Code/Tools/AssetBundler/source/ui/MainWindow.cpp @@ -63,7 +63,10 @@ namespace AssetBundler // Set up Tabs AssetBundlerTabWidget::InitAssetBundlerSettings(m_guiApplicationManager->GetCurrentProjectFolder().c_str()); - m_seedListTab.reset(new SeedTabWidget(this, m_guiApplicationManager, QString(m_guiApplicationManager->GetAssetBundlingFolder().c_str()))); + m_seedListTab.reset(new SeedTabWidget( + this, + m_guiApplicationManager, + QString(m_guiApplicationManager->GetAssetBundlingFolder().c_str()))); m_ui->tabWidget->addTab(m_seedListTab.data(), m_seedListTab->GetTabTitle()); m_assetListTab.reset(new AssetListTabWidget(this, m_guiApplicationManager)); diff --git a/Code/Tools/AssetBundler/source/ui/NewFileDialog.cpp b/Code/Tools/AssetBundler/source/ui/NewFileDialog.cpp index 170da4a659..00a63d193b 100644 --- a/Code/Tools/AssetBundler/source/ui/NewFileDialog.cpp +++ b/Code/Tools/AssetBundler/source/ui/NewFileDialog.cpp @@ -51,7 +51,8 @@ namespace AssetBundler m_newFileDialog.setNameFilter(fileNameFilter); m_newFileDialog.setViewMode(QFileDialog::Detail); m_newFileDialog.setDirectory(m_startingPath); - // We are not creating a new file when Qt thinks we are, so we need to block signals or else the file watcher will be triggered too soon + // We are not creating a new file when Qt thinks we are, so we need to block signals or else the file watcher will be + // triggered too soon m_newFileDialog.blockSignals(true); // Set up Platform selection @@ -61,7 +62,10 @@ namespace AssetBundler disabledPatformMessageOverride = tr("This platform is not valid for all input Asset Lists."); } m_ui->platformSelectionWidget->Init(enabledPlatforms, disabledPatformMessageOverride); - connect(m_ui->platformSelectionWidget, &PlatformSelectionWidget::PlatformsSelected, this, &NewFileDialog::OnPlatformSelectionChanged); + connect(m_ui->platformSelectionWidget, + &PlatformSelectionWidget::PlatformsSelected, + this, + &NewFileDialog::OnPlatformSelectionChanged); // Set up Cancel and Create New File buttons m_ui->createFileButton->setEnabled(false); @@ -112,7 +116,8 @@ namespace AssetBundler { // Check to see if any of the selected platform-specific files already exist on-disk QString overwriteExistingFilesList; - AZStd::fixed_vector selectedPlatformNames = AzFramework::PlatformHelper::GetPlatforms(GetPlatformFlags()); + AZStd::fixed_vector selectedPlatformNames = + AzFramework::PlatformHelper::GetPlatforms(GetPlatformFlags()); for (const AZStd::string& platformName : selectedPlatformNames) { FilePath platformSpecificFilePath(GetAbsoluteFilePath(), platformName); @@ -126,9 +131,11 @@ namespace AssetBundler // Ask the user if they are sure they want to overwrite existing files if (!overwriteExistingFilesList.isEmpty()) { - QString messageBoxText = QString(tr("The following files already exist on-disk. Generating new files will overwrite the existing ones.\n\n%1\n\nDo you wish to permanently delete the existing files?")).arg(overwriteExistingFilesList); + QString messageBoxText = QString(tr( + "The following files already exist on-disk. Generating new files will overwrite the existing ones.\n\n%1\n\nDo you wish to permanently delete the existing files?")).arg(overwriteExistingFilesList); - QMessageBox::StandardButton confirmDeleteFileResult = QMessageBox::question(this, QString(tr("Replace Existing Files")), messageBoxText); + QMessageBox::StandardButton confirmDeleteFileResult = + QMessageBox::question(this, QString(tr("Replace Existing Files")), messageBoxText); if (confirmDeleteFileResult != QMessageBox::StandardButton::Yes) { // User canceled out of the operation @@ -139,7 +146,11 @@ namespace AssetBundler emit QDialog::accept(); } - AZStd::string NewFileDialog::OSNewFileDialog(QWidget* parent, const char* fileExtension, const char* fileTypeDisplayName, const AZStd::string& startingDirectory) + AZStd::string NewFileDialog::OSNewFileDialog( + QWidget* parent, + const char* fileExtension, + const char* fileTypeDisplayName, + const AZStd::string& startingDirectory) { QFileDialog filePathDialog(parent); filePathDialog.setFileMode(QFileDialog::AnyFile); @@ -160,13 +171,17 @@ namespace AssetBundler AZStd::string absoluteFilePath(filePathDialog.selectedFiles()[0].toUtf8().data()); if (!AzFramework::StringFunc::Path::HasExtension(absoluteFilePath.c_str())) { - absoluteFilePath = AZStd::string::format("%s%c%s", absoluteFilePath.c_str(), AZ_FILESYSTEM_EXTENSION_SEPARATOR, fileExtension); + absoluteFilePath = + AZStd::string::format("%s%c%s", absoluteFilePath.c_str(), AZ_FILESYSTEM_EXTENSION_SEPARATOR, fileExtension); } return absoluteFilePath; } - int NewFileDialog::FileGenerationResultMessageBox(QWidget* parent, const AZStd::vector& generatedFiles, bool generatedWithErrors) + int NewFileDialog::FileGenerationResultMessageBox( + QWidget* parent, + const AZStd::vector& generatedFiles, + bool generatedWithErrors) { QMessageBox messageBox(parent); messageBox.setStandardButtons(QMessageBox::Ok); diff --git a/Code/Tools/AssetBundler/source/ui/NewFileDialog.h b/Code/Tools/AssetBundler/source/ui/NewFileDialog.h index 5974d3da6a..37cb81a3d3 100644 --- a/Code/Tools/AssetBundler/source/ui/NewFileDialog.h +++ b/Code/Tools/AssetBundler/source/ui/NewFileDialog.h @@ -51,9 +51,16 @@ namespace AssetBundler //! A standard OS-specific New File Dialog, but blocks all Qt signals from the dialog and does NOT create a new file. //! Use in place of the static QFileDialog functions to avoid unexpected file watcher updates. //! Returns the absolute path of the file the user either selected or attempted to create, or an empty string if the user canceled out of the dialog. - static AZStd::string OSNewFileDialog(QWidget* parent, const char* fileExtension, const char* fileTypeDisplayName, const AZStd::string& startingDirectory); + static AZStd::string OSNewFileDialog( + QWidget* parent, + const char* fileExtension, + const char* fileTypeDisplayName, + const AZStd::string& startingDirectory); - static int FileGenerationResultMessageBox(QWidget* parent, const AZStd::vector& generatedFiles, bool generatedWithErrors); + static int FileGenerationResultMessageBox( + QWidget* parent, + const AZStd::vector& generatedFiles, + bool generatedWithErrors); private: void OnBrowseButtonPressed(); diff --git a/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.cpp b/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.cpp index 80b4590c3c..ae203077fe 100644 --- a/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.cpp @@ -66,7 +66,9 @@ namespace AssetBundler } } - void PlatformSelectionWidget::SetSelectedPlatforms(const AzFramework::PlatformFlags& selectedPlatforms, const AzFramework::PlatformFlags& partiallySelectedPlatforms) + void PlatformSelectionWidget::SetSelectedPlatforms( + const AzFramework::PlatformFlags& selectedPlatforms, + const AzFramework::PlatformFlags& partiallySelectedPlatforms) { m_selectedPlatforms = AzFramework::PlatformFlags::Platform_NONE; m_partiallySelectedPlatforms = AzFramework::PlatformFlags::Platform_NONE; diff --git a/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.h b/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.h index 223044478f..10e47d0385 100644 --- a/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.h +++ b/Code/Tools/AssetBundler/source/ui/PlatformSelectionWidget.h @@ -39,7 +39,9 @@ namespace AssetBundler void Init(const AzFramework::PlatformFlags& enabledPlatforms, const QString& disabledPatformMessageOverride = ""); - void SetSelectedPlatforms(const AzFramework::PlatformFlags& selectedPlatforms, const AzFramework::PlatformFlags& partiallySelectedPlatforms); + void SetSelectedPlatforms( + const AzFramework::PlatformFlags& selectedPlatforms, + const AzFramework::PlatformFlags& partiallySelectedPlatforms); AzFramework::PlatformFlags GetSelectedPlatforms(); AzFramework::PlatformFlags GetPartiallySelectedPlatforms(); diff --git a/Code/Tools/AssetBundler/source/ui/RulesTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/RulesTabWidget.cpp index 56447f4a57..81eb5f3b61 100644 --- a/Code/Tools/AssetBundler/source/ui/RulesTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/RulesTabWidget.cpp @@ -45,14 +45,22 @@ namespace AssetBundler m_ui->fileTableView->setModel(m_fileTableModel.data()); // Table View of all Rules files - m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel(this, m_fileTableModel->GetFileNameColumnIndex(), m_fileTableModel->GetTimeStampColumnIndex())); + m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel( + this, + m_fileTableModel->GetFileNameColumnIndex(), + m_fileTableModel->GetTimeStampColumnIndex())); m_fileTableFilterModel->setSourceModel(m_fileTableModel.data()); m_ui->fileTableView->setModel(m_fileTableFilterModel.data()); - connect(m_ui->fileFilteredSearchWidget, &AzQtComponents::FilteredSearchWidget::TextFilterChanged, - m_fileTableFilterModel.data(), static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); + connect(m_ui->fileFilteredSearchWidget, + &AzQtComponents::FilteredSearchWidget::TextFilterChanged, + m_fileTableFilterModel.data(), + static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); - connect(m_ui->fileTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RulesTabWidget::FileSelectionChanged); + connect(m_ui->fileTableView->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &RulesTabWidget::FileSelectionChanged); m_ui->fileTableView->setIndentation(0); @@ -76,7 +84,10 @@ namespace AssetBundler void RulesTabWidget::Reload() { - m_fileTableModel->Reload(AzToolsFramework::AssetFileInfoListComparison::GetComparisonRulesFileExtension(), m_watchedFolders, m_watchedFiles); + m_fileTableModel->Reload( + AzToolsFramework::AssetFileInfoListComparison::GetComparisonRulesFileExtension(), + m_watchedFolders, + m_watchedFiles); FileSelectionChanged(); } @@ -223,7 +234,8 @@ namespace AssetBundler AZStd::vector outputFilePaths; bool hasFileGenerationErrors = false; - AZStd::fixed_vector selectedPlatformNames = AzFramework::PlatformHelper::GetPlatforms(runRuleDialog.GetPlatformFlags()); + AZStd::fixed_vector selectedPlatformNames = + AzFramework::PlatformHelper::GetPlatforms(runRuleDialog.GetPlatformFlags()); for (const AZStd::string& platformName : selectedPlatformNames) { // We do not want to modify the original Rules file, as we do not save Asset List file paths to disk @@ -238,7 +250,8 @@ namespace AssetBundler { if (comparisonStep.m_cachedFirstInputPath.empty()) { - AZ_Error("AssetBundler", false, "Unable to run Rule: Comparison Step #%u has no specified first input.", comparisonStepIndex); + AZ_Error("AssetBundler", false, + "Unable to run Rule: Comparison Step #%u has no specified first input.", comparisonStepIndex); return; } @@ -251,7 +264,8 @@ namespace AssetBundler { if (comparisonStep.m_cachedSecondInputPath.empty()) { - AZ_Error("AssetBundler", false, "Unable to run Rule: Comparison Step #%u has no specified second input.", comparisonStepIndex); + AZ_Error("AssetBundler", false, + "Unable to run Rule: Comparison Step #%u has no specified second input.", comparisonStepIndex); return; } @@ -313,17 +327,28 @@ namespace AssetBundler } } - void RulesTabWidget::CreateComparisonDataCard(AZStd::shared_ptr comparisonList, size_t comparisonDataIndex) + void RulesTabWidget::CreateComparisonDataCard( + AZStd::shared_ptr comparisonList, + size_t comparisonDataIndex) { - ComparisonDataCard* comparisonDataCard = new ComparisonDataCard(comparisonList, comparisonDataIndex, m_guiApplicationManager->GetAssetListsFolder()); + ComparisonDataCard* comparisonDataCard = new ComparisonDataCard( + comparisonList, + comparisonDataIndex, + m_guiApplicationManager->GetAssetListsFolder()); comparisonDataCard->setTitle(tr("Step %1").arg(static_cast(comparisonDataIndex) + 1)); m_ui->comparisonDataListLayout->addWidget(comparisonDataCard); m_comparisonDataCardList.push_back(comparisonDataCard); ComparisonDataWidget* comparisonDataWidget = comparisonDataCard->GetComparisonDataWidget(); - connect(comparisonDataCard, &ComparisonDataCard::comparisonDataCardContextMenuRequested, this, &RulesTabWidget::OnComparisonDataCardContextMenuRequested); + connect(comparisonDataCard, + &ComparisonDataCard::comparisonDataCardContextMenuRequested, + this, + &RulesTabWidget::OnComparisonDataCardContextMenuRequested); connect(comparisonDataWidget, &ComparisonDataWidget::comparisonDataChanged, this, &RulesTabWidget::MarkFileChanged); - connect(comparisonDataWidget, &ComparisonDataWidget::comparisonDataTokenNameChanged, this, &RulesTabWidget::OnAnyTokenNameChanged); + connect(comparisonDataWidget, + &ComparisonDataWidget::comparisonDataTokenNameChanged, + this, + &RulesTabWidget::OnAnyTokenNameChanged); comparisonDataCard->show(); } diff --git a/Code/Tools/AssetBundler/source/ui/RulesTabWidget.h b/Code/Tools/AssetBundler/source/ui/RulesTabWidget.h index 7dedce3efe..a48bd47617 100644 --- a/Code/Tools/AssetBundler/source/ui/RulesTabWidget.h +++ b/Code/Tools/AssetBundler/source/ui/RulesTabWidget.h @@ -81,7 +81,9 @@ namespace AssetBundler void ApplyConfig() override; - void FileSelectionChanged(const QItemSelection& /*selected*/ = QItemSelection(), const QItemSelection& /*deselected*/ = QItemSelection()) override; + void FileSelectionChanged( + const QItemSelection& /*selected*/ = QItemSelection(), + const QItemSelection& /*deselected*/ = QItemSelection()) override; private: void OnNewFileButtonPressed(); @@ -94,7 +96,9 @@ namespace AssetBundler void PopulateComparisonDataCardList(); - void CreateComparisonDataCard(AZStd::shared_ptr comparisonList, size_t comparisonDataIndex); + void CreateComparisonDataCard( + AZStd::shared_ptr comparisonList, + size_t comparisonDataIndex); void RemoveAllComparisonDataCards(); diff --git a/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp index 60b4104c5a..26e700a170 100644 --- a/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp @@ -56,14 +56,22 @@ namespace AssetBundler AZ::Debug::TraceMessageBus::Handler::BusConnect(); // File view of all Seed List Files - m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel(this, m_fileTableModel->GetFileNameColumnIndex(), m_fileTableModel->GetTimeStampColumnIndex())); + m_fileTableFilterModel.reset(new AssetBundlerFileTableFilterModel( + this, + m_fileTableModel->GetFileNameColumnIndex(), + m_fileTableModel->GetTimeStampColumnIndex())); m_fileTableFilterModel->setSourceModel(m_fileTableModel.data()); m_ui->fileTableView->setModel(m_fileTableFilterModel.data()); - connect(m_ui->fileFilteredSearchWidget, &AzQtComponents::FilteredSearchWidget::TextFilterChanged, - m_fileTableFilterModel.data(), static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); + connect(m_ui->fileFilteredSearchWidget, + &AzQtComponents::FilteredSearchWidget::TextFilterChanged, + m_fileTableFilterModel.data(), + static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); - connect(m_ui->fileTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &SeedTabWidget::FileSelectionChanged); + connect(m_ui->fileTableView->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &SeedTabWidget::FileSelectionChanged); m_ui->fileTableView->setIndentation(CheckBoxTableIndentationSize); @@ -82,11 +90,16 @@ namespace AssetBundler m_seedListContentsFilterModel->setSourceModel(m_seedListContentsModel.data()); m_ui->seedFileContentsTable->setModel(m_seedListContentsFilterModel.data()); - connect(m_ui->seedListContentsFilteredSearchWidget, &AzQtComponents::FilteredSearchWidget::TextFilterChanged, - m_seedListContentsFilterModel.data(), static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); + connect(m_ui->seedListContentsFilteredSearchWidget, + &AzQtComponents::FilteredSearchWidget::TextFilterChanged, + m_seedListContentsFilterModel.data(), + static_cast(&AssetBundlerFileTableFilterModel::FilterChanged)); m_ui->seedFileContentsTable->setContextMenuPolicy(Qt::CustomContextMenu); - connect(m_ui->seedFileContentsTable, &QTreeView::customContextMenuRequested, this, &SeedTabWidget::OnSeedListContentsTableContextMenuRequested); + connect(m_ui->seedFileContentsTable, + &QTreeView::customContextMenuRequested, + this, + &SeedTabWidget::OnSeedListContentsTableContextMenuRequested); m_ui->seedFileContentsTable->setIndentation(0); @@ -112,7 +125,11 @@ namespace AssetBundler void SeedTabWidget::Reload() { // Reload all the seed list files - m_fileTableModel->Reload(AzToolsFramework::AssetSeedManager::GetSeedFileExtension(), m_watchedFolders, m_watchedFiles, m_filePathToGemNameMap); + m_fileTableModel->Reload( + AzToolsFramework::AssetSeedManager::GetSeedFileExtension(), + m_watchedFolders, + m_watchedFiles, + m_filePathToGemNameMap); // Update the selected row FileSelectionChanged(); @@ -138,12 +155,18 @@ namespace AssetBundler m_watchedFolders.insert(m_guiApplicationManager->GetSeedListsFolder().c_str()); // Get the list of default Seed List files - m_filePathToGemNameMap = AssetBundler::GetDefaultSeedListFiles(AZStd::string_view{ AZ::Utils::GetEnginePath() }, m_guiApplicationManager->GetCurrentProjectName(), + m_filePathToGemNameMap = AssetBundler::GetDefaultSeedListFiles( + AZStd::string_view{ AZ::Utils::GetEnginePath() }, + m_guiApplicationManager->GetCurrentProjectName(), m_guiApplicationManager->GetGemInfoList(), m_guiApplicationManager->GetEnabledPlatforms()); // Get the list of default Seeds that are not stored in a Seed List file on-disk - AZStd::vector defaultSeeds = GetDefaultSeeds(AZ::Utils::GetProjectPath(), m_guiApplicationManager->GetCurrentProjectName()); - m_fileTableModel->AddDefaultSeedsToInMemoryList(defaultSeeds, m_guiApplicationManager->GetCurrentProjectName().c_str(), m_guiApplicationManager->GetEnabledPlatforms()); + AZStd::vector defaultSeeds = + GetDefaultSeeds(AZ::Utils::GetProjectPath(), m_guiApplicationManager->GetCurrentProjectName()); + m_fileTableModel->AddDefaultSeedsToInMemoryList( + defaultSeeds, + m_guiApplicationManager->GetCurrentProjectName().c_str(), + m_guiApplicationManager->GetEnabledPlatforms()); // Set the new watched filess for the model m_watchedFiles.clear(); @@ -185,7 +208,9 @@ namespace AssetBundler m_ui->fileTableView->header()->resizeSection(SeedListFileTableModel::Column::ColumnCheckBox, config.checkBoxColumnWidth); m_ui->fileTableView->header()->resizeSection(SeedListFileTableModel::Column::ColumnProject, config.projectNameColumnWidth); - m_ui->seedFileContentsTable->header()->resizeSection(SeedListTableModel::Column::ColumnRelativePath, config.seedListContentsNameColumnWidth); + m_ui->seedFileContentsTable->header()->resizeSection( + SeedListTableModel::Column::ColumnRelativePath, + config.seedListContentsNameColumnWidth); } void SeedTabWidget::UncheckSelectDefaultSeedListsCheckBox() @@ -198,15 +223,25 @@ namespace AssetBundler m_ui->generateAssetListsButton->setEnabled(isEnabled); } - bool SeedTabWidget::OnPreError(const char* /*window*/, const char* /*fileName*/, int /*line*/, const char* /*func*/, const char* /*message*/) + bool SeedTabWidget::OnPreError( + const char* /*window*/, + const char* /*fileName*/, + int /*line*/, + const char* /*func*/, + const char* /*message*/) { - m_hasWarnings = true; + m_hasWarningsOrErrors = true; return false; } - bool SeedTabWidget::OnPreWarning(const char* /*window*/, const char* /*fileName*/, int /*line*/, const char* /*func*/, const char* /*message*/) + bool SeedTabWidget::OnPreWarning( + const char* /*window*/, + const char* /*fileName*/, + int /*line*/, + const char* /*func*/, + const char* /*message*/) { - m_hasWarnings = true; + m_hasWarningsOrErrors = true; return false; } @@ -275,11 +310,13 @@ namespace AssetBundler return; } - m_hasWarnings = false; - auto createdFiles = m_fileTableModel->GenerateAssetLists(m_generateAssetListsDialog->GetAbsoluteFilePath(), m_generateAssetListsDialog->GetPlatformFlags()); + m_hasWarningsOrErrors = false; + auto createdFiles = m_fileTableModel->GenerateAssetLists( + m_generateAssetListsDialog->GetAbsoluteFilePath(), + m_generateAssetListsDialog->GetPlatformFlags()); // Warnings will not prevent the generation of Asset List files, we must track them separately - NewFileDialog::FileGenerationResultMessageBox(this, createdFiles, m_hasWarnings); + NewFileDialog::FileGenerationResultMessageBox(this, createdFiles, m_hasWarningsOrErrors); if (createdFiles.empty()) { @@ -306,7 +343,8 @@ namespace AssetBundler } // Get the current platforms of the selected Seed so we can display them as already checked - QModelIndex currentSeedIndex = m_seedListContentsFilterModel->mapToSource(m_ui->seedFileContentsTable->selectionModel()->currentIndex()); + QModelIndex currentSeedIndex = + m_seedListContentsFilterModel->mapToSource(m_ui->seedFileContentsTable->selectionModel()->currentIndex()); auto getPlatformOutcome = m_seedListContentsModel->GetSeedPlatforms(currentSeedIndex); if (!getPlatformOutcome.IsSuccess()) { @@ -375,7 +413,8 @@ namespace AssetBundler AzFramework::PlatformFlags checkedPlatforms = m_editSeedDialog->GetPlatformFlags(); AzFramework::PlatformFlags partiallyCheckedPlatforms = m_editSeedDialog->GetPartiallySelectedPlatformFlags(); // If the platform is partially checked, we want to keep its original status when saving the changes - AzFramework::PlatformFlags platformFlags = indexToPlatformFlagsMap[currentSeedIndex] & partiallyCheckedPlatforms | checkedPlatforms; + AzFramework::PlatformFlags platformFlags = + indexToPlatformFlagsMap[currentSeedIndex] & partiallyCheckedPlatforms | checkedPlatforms; m_fileTableModel->SetSeedPlatforms(m_selectedFileTableIndex, currentSeedIndex, platformFlags); } @@ -391,8 +430,10 @@ namespace AssetBundler // Get path to the platform-specific cache folder of one of the enabled platforms AzFramework::PlatformFlags enabledPlatforms = m_guiApplicationManager->GetEnabledPlatforms(); - AZStd::fixed_vector enabledPlatformIndices = AzFramework::PlatformHelper::GetPlatformIndicesInterpreted(enabledPlatforms); - AZStd::string platformSpecificCachePath = AzToolsFramework::PlatformAddressedAssetCatalog::GetCatalogRegistryPathForPlatform(enabledPlatformIndices[0]); + AZStd::fixed_vector enabledPlatformIndices = + AzFramework::PlatformHelper::GetPlatformIndicesInterpreted(enabledPlatforms); + AZStd::string platformSpecificCachePath = + AzToolsFramework::PlatformAddressedAssetCatalog::GetCatalogRegistryPathForPlatform(enabledPlatformIndices[0]); // Create and display the Add Seed Dialog m_addSeedDialog.reset(new AddSeedDialog(this, enabledPlatforms, platformSpecificCachePath)); @@ -416,7 +457,8 @@ namespace AssetBundler } // Set the data in the model - QModelIndex currentSeedIndex = m_seedListContentsFilterModel->mapToSource(m_ui->seedFileContentsTable->selectionModel()->currentIndex()); + QModelIndex currentSeedIndex = + m_seedListContentsFilterModel->mapToSource(m_ui->seedFileContentsTable->selectionModel()->currentIndex()); m_fileTableModel->RemoveSeed(m_selectedFileTableIndex, currentSeedIndex); } diff --git a/Code/Tools/AssetBundler/source/ui/SeedTabWidget.h b/Code/Tools/AssetBundler/source/ui/SeedTabWidget.h index c1383cdd08..784b8edd80 100644 --- a/Code/Tools/AssetBundler/source/ui/SeedTabWidget.h +++ b/Code/Tools/AssetBundler/source/ui/SeedTabWidget.h @@ -82,7 +82,9 @@ namespace AssetBundler void ApplyConfig() override; - void FileSelectionChanged(const QItemSelection& /*selected*/ = QItemSelection(), const QItemSelection& /*deselected*/ = QItemSelection()) override; + void FileSelectionChanged( + const QItemSelection& /*selected*/ = QItemSelection(), + const QItemSelection& /*deselected*/ = QItemSelection()) override; void UncheckSelectDefaultSeedListsCheckBox(); @@ -124,6 +126,6 @@ namespace AssetBundler QSharedPointer m_editSeedDialog; QSharedPointer m_addSeedDialog; - bool m_hasWarnings = false; + bool m_hasWarningsOrErrors = false; }; } // namespace AssetBundler diff --git a/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp b/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp index d278b9bd2c..e4dd5edba7 100644 --- a/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp +++ b/Code/Tools/AssetBundler/source/utils/GUIApplicationManager.cpp @@ -83,7 +83,8 @@ namespace AssetBundler ConfigHelpers::read(settings, QStringLiteral("AssetListFileNameColumnWidth"), config.assetListFileNameColumnWidth); ConfigHelpers::read(settings, QStringLiteral("AssetListPlatformColumnWidth"), config.assetListPlatformColumnWidth); ConfigHelpers::read(settings, QStringLiteral("ProductAssetNameColumnWidth"), config.productAssetNameColumnWidth); - ConfigHelpers::read(settings, QStringLiteral("ProductAssetRelativePathColumnWidth"), config.productAssetRelativePathColumnWidth); + ConfigHelpers::read( + settings, QStringLiteral("ProductAssetRelativePathColumnWidth"), config.productAssetRelativePathColumnWidth); } return config; @@ -159,8 +160,7 @@ namespace AssetBundler m_platformCatalogManager = AZStd::make_unique(); // Define some application-level settings - QApplication::setOrganizationName("Amazon"); - QApplication::setOrganizationDomain("amazon.com"); + QApplication::setOrganizationName("O3DE"); QApplication::setApplicationName("Asset Bundler"); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); @@ -194,7 +194,12 @@ namespace AssetBundler engineRoot); AzQtComponents::StyleManager::setStyleSheet(m_mainWindow.data(), QStringLiteral("style:AssetBundler.qss")); - AzQtComponents::ConfigHelpers::loadConfig(&m_fileWatcher, &m_config, QStringLiteral("style:AssetBundlerConfig.ini"), this, std::bind(&GUIApplicationManager::ApplyConfig, this)); + AzQtComponents::ConfigHelpers::loadConfig( + &m_fileWatcher, + &m_config, + QStringLiteral("style:AssetBundlerConfig.ini"), + this, + std::bind(&GUIApplicationManager::ApplyConfig, this)); ApplyConfig(); qApp->setWindowIcon(QIcon("style:AssetBundler-Icon-256x256@x2.ico")); @@ -238,7 +243,12 @@ namespace AssetBundler m_fileWatcher.removePaths(paths.values()); } - bool GUIApplicationManager::OnPreError(const char* /*window*/, const char* /*fileName*/, int /*line*/, const char* /*func*/, const char* message) + bool GUIApplicationManager::OnPreError( + const char* /*window*/, + const char* /*fileName*/, + int /*line*/, + const char* /*func*/, + const char* message) { // We want to display errors during initialization, then let the MainWindow handle errors during runtime if (m_isInitializing) @@ -258,7 +268,12 @@ namespace AssetBundler return false; } - bool GUIApplicationManager::OnPreWarning(const char* /*window*/, const char* /*fileName*/, int /*line*/, const char* /*func*/, const char* /*message*/) + bool GUIApplicationManager::OnPreWarning( + const char* /*window*/, + const char* /*fileName*/, + int /*line*/, + const char* /*func*/, + const char* /*message*/) { // Don't handle warnings, let the MainWindow print them return false; diff --git a/Code/Tools/AssetBundler/source/utils/utils.cpp b/Code/Tools/AssetBundler/source/utils/utils.cpp index 39bc1a7e13..b91dcde9e2 100644 --- a/Code/Tools/AssetBundler/source/utils/utils.cpp +++ b/Code/Tools/AssetBundler/source/utils/utils.cpp @@ -155,8 +155,10 @@ namespace AssetBundler if (fileIO->Exists(platformDirectory.c_str())) { bool recurse = true; - AZ::Outcome, AZStd::string> result = AzFramework::FileFunc::FindFileList(platformDirectory.String(), - AZStd::string::format("*.%s", AzToolsFramework::AssetSeedManager::GetSeedFileExtension()).c_str(), recurse); + AZ::Outcome, AZStd::string> result = AzFramework::FileFunc::FindFileList( + platformDirectory.String(), + AZStd::string::format("*.%s", AzToolsFramework::AssetSeedManager::GetSeedFileExtension()).c_str(), + recurse); if (result.IsSuccess()) { @@ -233,8 +235,11 @@ namespace AssetBundler return platformFlags; } - AZStd::unordered_map GetDefaultSeedListFiles(AZStd::string_view enginePath, AZStd::string_view projectPath, - const AZStd::vector& gemInfoList, AzFramework::PlatformFlags platformFlag) + AZStd::unordered_map GetDefaultSeedListFiles( + AZStd::string_view enginePath, + AZStd::string_view projectPath, + const AZStd::vector& gemInfoList, + AzFramework::PlatformFlags platformFlag) { AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); AZ_Assert(fileIO, "AZ::IO::FileIOBase must be ready for use.\n"); @@ -299,7 +304,9 @@ namespace AssetBundler return relativeProductPath; } - AZStd::unordered_map GetGemSeedListFilePathToGemNameMap(const AZStd::vector& gemInfoList, AzFramework::PlatformFlags platformFlags) + AZStd::unordered_map GetGemSeedListFilePathToGemNameMap( + const AZStd::vector& gemInfoList, + AzFramework::PlatformFlags platformFlags) { AZStd::unordered_map filePathToGemNameMap; for (const AzFramework::GemInfo& gemInfo : gemInfoList) @@ -325,7 +332,11 @@ namespace AssetBundler return filePathToGemNameMap; } - bool IsGemSeedFilePathValid(AZStd::string_view engineRoot, AZStd::string seedAbsoluteFilePath, const AZStd::vector& gemInfoList, AzFramework::PlatformFlags platformFlags) + bool IsGemSeedFilePathValid( + AZStd::string_view engineRoot, + AZStd::string seedAbsoluteFilePath, + const AZStd::vector& gemInfoList, + AzFramework::PlatformFlags platformFlags) { AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); AZ_Assert(fileIO, "AZ::IO::FileIOBase must be ready for use.\n"); @@ -369,7 +380,10 @@ namespace AssetBundler return false; } - AzFramework::PlatformFlags GetEnabledPlatformFlags(AZStd::string_view engineRoot, AZStd::string_view assetRoot, AZStd::string_view projectPath) + AzFramework::PlatformFlags GetEnabledPlatformFlags( + AZStd::string_view engineRoot, + AZStd::string_view assetRoot, + AZStd::string_view projectPath) { auto settingsRegistry = AZ::SettingsRegistry::Get(); if (settingsRegistry == nullptr) @@ -391,7 +405,8 @@ namespace AssetBundler } else { - AZ_Warning(AssetBundler::AppWindowName, false, "Platform Helper is not aware of the platform (%s).\n ", enabledPlatform.c_str()); + AZ_Warning(AssetBundler::AppWindowName, false, + "Platform Helper is not aware of the platform (%s).\n ", enabledPlatform.c_str()); } } @@ -457,31 +472,6 @@ namespace AssetBundler AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder)); } - AZ::Outcome GetPlatformNamesFromCacheFolder(AZStd::vector& platformNames) - { - AZ::Outcome projectCacheRootFolder = GetProjectCacheFolderPath(); - if (!projectCacheRootFolder) - { - return AZ::Failure(projectCacheRootFolder.TakeError()); - } - - const AZStd::string& projectCacheRootPath = projectCacheRootFolder.GetValue().Native(); - QDir projectCacheDir(QString::fromUtf8(projectCacheRootPath.c_str(), aznumeric_cast(projectCacheRootPath.size()))); - auto tempPlatformList = projectCacheDir.entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot); - - if (tempPlatformList.empty()) - { - return AZ::Failure(AZStd::string("Cache is empty. Please run the Open 3D Engine Asset Processor to generate a Cache and build assets.")); - } - - for (const QString& platform : tempPlatformList) - { - platformNames.push_back(AZStd::string(platform.toUtf8().data())); - } - - return AZ::Success(); - } - AZ::Outcome GetAssetCatalogFilePath() { AZ::IO::Path assetCatalogFilePath = GetPlatformSpecificCacheFolderPath(); @@ -501,7 +491,9 @@ namespace AssetBundler AZ::IO::Path platformSpecificCacheFolderPath; if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) { - settingsRegistry->Get(platformSpecificCacheFolderPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder); + settingsRegistry->Get( + platformSpecificCacheFolderPath.Native(), + AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder); } return platformSpecificCacheFolderPath; } @@ -701,7 +693,8 @@ namespace AssetBundler m_errors.swap(AZStd::vector()); } - AZ::Outcome ParseComparisonType(const AZStd::string& comparisonType) + AZ::Outcome ParseComparisonType( + const AZStd::string& comparisonType) { using namespace AzToolsFramework; @@ -729,7 +722,8 @@ namespace AssetBundler } // Failure case - AZStd::string failureMessage = AZStd::string::format("Invalid Comparison Type ( %s ). Valid types are: ", comparisonType.c_str()); + AZStd::string failureMessage = AZStd::string::format( + "Invalid Comparison Type ( %s ). Valid types are: ", comparisonType.c_str()); for (size_t i = 0; i < numTypes - 1; ++i) { failureMessage.append(AZStd::string::format("%s, ", AssetFileInfoListComparison::ComparisonTypeNames[i])); @@ -738,7 +732,8 @@ namespace AssetBundler return AZ::Failure(failureMessage); } - AZ::Outcome ParseFilePatternType(const AZStd::string& filePatternType) + AZ::Outcome ParseFilePatternType( + const AZStd::string& filePatternType) { using namespace AzToolsFramework; @@ -766,7 +761,8 @@ namespace AssetBundler } // Failure case - AZStd::string failureMessage = AZStd::string::format("Invalid File Pattern Type ( %s ). Valid types are: ", filePatternType.c_str()); + AZStd::string failureMessage = AZStd::string::format( + "Invalid File Pattern Type ( %s ). Valid types are: ", filePatternType.c_str()); for (size_t i = 0; i < numTypes - 1; ++i) { failureMessage.append(AZStd::string::format("%s, ", AssetFileInfoListComparison::FilePatternTypeNames[i])); diff --git a/Code/Tools/AssetBundler/source/utils/utils.h b/Code/Tools/AssetBundler/source/utils/utils.h index 454a279878..211096e07c 100644 --- a/Code/Tools/AssetBundler/source/utils/utils.h +++ b/Code/Tools/AssetBundler/source/utils/utils.h @@ -158,17 +158,6 @@ namespace AssetBundler */ AZ::Outcome GetProjectCacheFolderPath(); - /** - * Calculates the list of enabled platforms for the input project by reading the folder names inside the project-specific cache folder. - * If the Asset Processor has not been run yet, or has not been run since the enabled platform list inside AssetProcessorPlatformConfig.setreg - * was changed, the output of this function will be incorrect. - * - * @param projectCacheFolder The directory of a project-specific cache folder: /ProjectPath/Cache - * @param platformNames [out] The list of platforms enabled in the project - * @return void on success, error message on failure - */ - AZ::Outcome GetPlatformNamesFromCacheFolder(AZStd::vector& platformNames); - /** * Computes the absolute path to the Asset Catalog file for a specified project and platform. * With platform set as "pc" and project as "ProjectName", the path will resemble: C:/ProjectPath/Cache/pc/assetcatalog.xml @@ -204,8 +193,11 @@ namespace AssetBundler AzFramework::PlatformFlags GetPlatformsOnDiskForPlatformSpecificFile(const AZStd::string& platformIndependentAbsolutePath); //! Returns a map of of all default Seed List files for the current game project. - AZStd::unordered_map GetDefaultSeedListFiles(AZStd::string_view enginePath, AZStd::string_view projectPath, - const AZStd::vector& gemInfoList, AzFramework::PlatformFlags platformFlags); + AZStd::unordered_map GetDefaultSeedListFiles( + AZStd::string_view enginePath, + AZStd::string_view projectPath, + const AZStd::vector& gemInfoList, + AzFramework::PlatformFlags platformFlags); //! Returns a vector of relative paths to Assets that should be included as default Seeds, but are not already in a Seed List file. AZStd::vector GetDefaultSeeds(AZStd::string_view projectPath, AZStd::string_view projectName); @@ -217,15 +209,24 @@ namespace AssetBundler AZ::IO::Path GetProjectDependenciesAssetPath(AZStd::string_view projectPath, AZStd::string_view projectName); //! Returns the map from gem seed list file path to gem name - AZStd::unordered_map GetGemSeedListFilePathToGemNameMap(const AZStd::vector& gemInfoList, AzFramework::PlatformFlags platformFlags); + AZStd::unordered_map GetGemSeedListFilePathToGemNameMap( + const AZStd::vector& gemInfoList, + AzFramework::PlatformFlags platformFlags); //! Given an absolute gem seed file path determines whether the file is valid for the current game project. //! This method is for validating gem seed list files only. - bool IsGemSeedFilePathValid(AZStd::string_view enginePath, AZStd::string seedAbsoluteFilePath, const AZStd::vector& gemInfoList, AzFramework::PlatformFlags platformFlags); + bool IsGemSeedFilePathValid( + AZStd::string_view enginePath, + AZStd::string seedAbsoluteFilePath, + const AZStd::vector& gemInfoList, + AzFramework::PlatformFlags platformFlags); //! Returns platformFlags of all enabled platforms by parsing all the asset processor config files. //! Please note that the game project could be in a different location to the engine therefore we need the assetRoot param. - AzFramework::PlatformFlags GetEnabledPlatformFlags(AZStd::string_view enginePath, AZStd::string_view assetRoot, AZStd::string_view projectPath); + AzFramework::PlatformFlags GetEnabledPlatformFlags( + AZStd::string_view enginePath, + AZStd::string_view assetRoot, + AZStd::string_view projectPath); QJsonObject ReadJson(const AZStd::string& filePath); void SaveJson(const AZStd::string& filePath, const QJsonObject& jsonObject); @@ -239,7 +240,11 @@ namespace AssetBundler { public: AZ_CLASS_ALLOCATOR(FilePath, AZ::SystemAllocator, 0); - explicit FilePath(const AZStd::string& filePath, AZStd::string platformIdentifier = AZStd::string(), bool checkFileCase = false, bool ignoreFileCase = false); + explicit FilePath( + const AZStd::string& filePath, + AZStd::string platformIdentifier = AZStd::string(), + bool checkFileCase = false, + bool ignoreFileCase = false); explicit FilePath(const AZStd::string& filePath, bool checkFileCase, bool ignoreFileCase); FilePath() = default; const AZStd::string& AbsolutePath() const; @@ -279,8 +284,10 @@ namespace AssetBundler bool m_reportingError = false; }; - AZ::Outcome ParseComparisonType(const AZStd::string& comparisonType); - AZ::Outcome ParseFilePatternType(const AZStd::string& filePatternType); + AZ::Outcome ParseComparisonType( + const AZStd::string& comparisonType); + AZ::Outcome ParseFilePatternType( + const AZStd::string& filePatternType); bool LooksLikePath(const AZStd::string& inputString); bool LooksLikeWildcardPattern(const AZStd::string& inputPattern); } diff --git a/Code/Tools/ProjectManager/CMakeLists.txt b/Code/Tools/ProjectManager/CMakeLists.txt index 8315ef831c..e4354bac32 100644 --- a/Code/Tools/ProjectManager/CMakeLists.txt +++ b/Code/Tools/ProjectManager/CMakeLists.txt @@ -27,7 +27,7 @@ ly_add_target( PUBLIC . PRIVATE - source + Source BUILD_DEPENDENCIES PRIVATE @@ -38,4 +38,4 @@ ly_add_target( AZ::AzFramework AZ::AzToolsFramework AZ::AzQtComponents -) +) \ No newline at end of file diff --git a/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.cpp b/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.cpp deleted file mode 100644 index 4a8486f877..0000000000 --- a/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.cpp +++ /dev/null @@ -1,49 +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 -#include - -#include -#include - -#include - -#include - -namespace ProjectManager -{ - ProjectManagerWindow::ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath) - : QMainWindow(parent) - , m_ui(new Ui::ProjectManagerWindowClass()) - { - m_ui->setupUi(this); - - QDir rootDir = QString::fromUtf8(engineRootPath.Native().data(), aznumeric_cast(engineRootPath.Native().size())); - const auto pathOnDisk = rootDir.absoluteFilePath("Code/Tools/ProjectManager/Resources"); - const auto qrcPath = QStringLiteral(":/ProjectManagerWindow"); - AzQtComponents::StyleManager::addSearchPaths("projectmanagerwindow", pathOnDisk, qrcPath, engineRootPath); - - AzQtComponents::StyleManager::setStyleSheet(this, QStringLiteral("projectlauncherwindow:ProjectManagerWindow.qss")); - - - FirstTimeUse* firstTimeUse = new FirstTimeUse(m_ui->centralwidget); - - firstTimeUse->show(); - } - - ProjectManagerWindow::~ProjectManagerWindow() - { - } - - //#include -} // namespace ProjectManager diff --git a/Code/Tools/ProjectManager/Source/EngineSettings.cpp b/Code/Tools/ProjectManager/Source/EngineSettings.cpp new file mode 100644 index 0000000000..bc359637e4 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/EngineSettings.cpp @@ -0,0 +1,35 @@ +/* + * 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 + +#include + +namespace O3DE::ProjectManager +{ + EngineSettings::EngineSettings(ProjectManagerWindow* window) + : ScreenWidget(window) + , m_ui(new Ui::EngineSettingsClass()) + { + m_ui->setupUi(this); + } + + EngineSettings::~EngineSettings() + { + } + + void EngineSettings::ConnectSlotsAndSignals() + { + // Do nothing for now + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/EngineSettings.h b/Code/Tools/ProjectManager/Source/EngineSettings.h new file mode 100644 index 0000000000..f90f760798 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/EngineSettings.h @@ -0,0 +1,39 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include +#endif + +namespace Ui +{ + class EngineSettingsClass; +} + +namespace O3DE::ProjectManager +{ + class EngineSettings + : public ScreenWidget + { + public: + explicit EngineSettings(ProjectManagerWindow* window); + ~EngineSettings(); + + protected: + void ConnectSlotsAndSignals() override; + + private: + QScopedPointer m_ui; + }; + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/EngineSettings.ui b/Code/Tools/ProjectManager/Source/EngineSettings.ui new file mode 100644 index 0000000000..c8fda8bfd7 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/EngineSettings.ui @@ -0,0 +1,82 @@ + + + EngineSettingsClass + + + + 0 + 0 + 839 + 597 + + + + Form + + + + + + O3DE Settings + + + + + + + Engine Version + + + + + + + v1.01 + + + + + + + 3rd Party Software Folder + + + + + + + + + + Restricted Folder + + + + + + + + + + Default Gems Folder + + + + + + + + + + Default Project Templates Folder + + + + + + + + + + + diff --git a/Code/Tools/ProjectManager/Source/FirstTimeUse.cpp b/Code/Tools/ProjectManager/Source/FirstTimeUse.cpp new file mode 100644 index 0000000000..5f5dcd5087 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/FirstTimeUse.cpp @@ -0,0 +1,47 @@ +/* + * 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 + +#include + +namespace O3DE::ProjectManager +{ + FirstTimeUse::FirstTimeUse(ProjectManagerWindow* window) + : ScreenWidget(window) + , m_ui(new Ui::FirstTimeUseClass()) + { + m_ui->setupUi(this); + + ConnectSlotsAndSignals(); + } + + FirstTimeUse::~FirstTimeUse() + { + } + + void FirstTimeUse::ConnectSlotsAndSignals() + { + QObject::connect(m_ui->createProjectButton, &QPushButton::pressed, this, &FirstTimeUse::HandleNewProjectButton); + QObject::connect(m_ui->openProjectButton, &QPushButton::pressed, this, &FirstTimeUse::HandleOpenProjectButton); + } + + void FirstTimeUse::HandleNewProjectButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::NewProjectSettings); + } + void FirstTimeUse::HandleOpenProjectButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::ProjectsHome); + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Qt/FirstTimeUse.h b/Code/Tools/ProjectManager/Source/FirstTimeUse.h similarity index 66% rename from Code/Tools/ProjectManager/Qt/FirstTimeUse.h rename to Code/Tools/ProjectManager/Source/FirstTimeUse.h index 85f344f3fe..708513d493 100644 --- a/Code/Tools/ProjectManager/Qt/FirstTimeUse.h +++ b/Code/Tools/ProjectManager/Source/FirstTimeUse.h @@ -12,7 +12,7 @@ #pragma once #if !defined(Q_MOC_RUN) -#include +#include #endif namespace Ui @@ -20,17 +20,24 @@ namespace Ui class FirstTimeUseClass; } -namespace ProjectManager +namespace O3DE::ProjectManager { - class FirstTimeUse : public QWidget + class FirstTimeUse + : public ScreenWidget { - public: - explicit FirstTimeUse(QWidget* parent); + explicit FirstTimeUse(ProjectManagerWindow* window); ~FirstTimeUse(); + protected: + void ConnectSlotsAndSignals() override; + + protected slots: + void HandleNewProjectButton(); + void HandleOpenProjectButton(); + private: QScopedPointer m_ui; }; -} // namespace ProjectManager +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Qt/FirstTimeUse.ui b/Code/Tools/ProjectManager/Source/FirstTimeUse.ui similarity index 100% rename from Code/Tools/ProjectManager/Qt/FirstTimeUse.ui rename to Code/Tools/ProjectManager/Source/FirstTimeUse.ui diff --git a/Code/Tools/ProjectManager/Source/GemCatalog.cpp b/Code/Tools/ProjectManager/Source/GemCatalog.cpp new file mode 100644 index 0000000000..9d89740816 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog.cpp @@ -0,0 +1,47 @@ +/* + * 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 + +#include + +namespace O3DE::ProjectManager +{ + GemCatalog::GemCatalog(ProjectManagerWindow* window) + : ScreenWidget(window) + , m_ui(new Ui::GemCatalogClass()) + { + m_ui->setupUi(this); + + ConnectSlotsAndSignals(); + } + + GemCatalog::~GemCatalog() + { + } + + void GemCatalog::ConnectSlotsAndSignals() + { + QObject::connect(m_ui->backButton, &QPushButton::pressed, this, &GemCatalog::HandleBackButton); + QObject::connect(m_ui->confirmButton, &QPushButton::pressed, this, &GemCatalog::HandleConfirmButton); + } + + void GemCatalog::HandleBackButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::NewProjectSettings); + } + void GemCatalog::HandleConfirmButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::ProjectsHome); + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog.h b/Code/Tools/ProjectManager/Source/GemCatalog.h new file mode 100644 index 0000000000..e45d865e58 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog.h @@ -0,0 +1,44 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include +#endif + +namespace Ui +{ + class GemCatalogClass; +} + +namespace O3DE::ProjectManager +{ + class GemCatalog + : public ScreenWidget + { + + public: + explicit GemCatalog(ProjectManagerWindow* window); + ~GemCatalog(); + + protected: + void ConnectSlotsAndSignals() override; + + protected slots: + void HandleBackButton(); + void HandleConfirmButton(); + + private: + QScopedPointer m_ui; + }; + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog.ui b/Code/Tools/ProjectManager/Source/GemCatalog.ui new file mode 100644 index 0000000000..acc2ea80a1 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog.ui @@ -0,0 +1,231 @@ + + + GemCatalogClass + + + + 0 + 0 + 806 + 566 + + + + Form + + + + + + + + Gem Catalog + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cart + + + + + + + Hamburger Menu + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + TextLabel + + + + + + + RadioButton + + + + + + + RadioButton + + + + + + + RadioButton + + + + + + + Qt::Horizontal + + + + + + + TextLabel + + + + + + + CheckBox + + + + + + + CheckBox + + + + + + + CheckBox + + + + + + + + + + 0 + 0 + + + + + + + + + + TextLabel + + + + + + + + 0 + 0 + + + + + Atom + + + + + Audio + + + + + Camera + + + + + PhysX + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Back + + + + + + + Create Project + + + + + + + + + + diff --git a/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/DllMain_Windows.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.cpp similarity index 60% rename from Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/DllMain_Windows.cpp rename to Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.cpp index 7c180714d4..b11c7a7a2c 100644 --- a/Code/Sandbox/Plugins/FBXPlugin/Platform/Windows/DllMain_Windows.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.cpp @@ -10,17 +10,16 @@ * */ -#include +#include "GemInfo.h" -HINSTANCE g_hInstance = NULL; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, ULONG fdwReason, [[maybe_unused]] LPVOID lpvReserved) +namespace O3DE::ProjectManager { - if (fdwReason == DLL_PROCESS_ATTACH) + GemInfo::GemInfo(const QString& name, const QString& creator, const QString& summary, Platforms platforms, bool isAdded) + : m_name(name) + , m_creator(creator) + , m_summary(summary) + , m_platforms(platforms) + , m_isAdded(isAdded) { - g_hInstance = hinstDLL; - //DisableThreadLibraryCalls(hInstance); } - - return(TRUE); -} +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h new file mode 100644 index 0000000000..e5aa9c41f7 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h @@ -0,0 +1,55 @@ +/* +* 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 + +#if !defined(Q_MOC_RUN) +#include +#include +#include +#include +#endif + +namespace O3DE::ProjectManager +{ + class GemInfo + { + public: + enum Platform + { + Android = 0x0, + iOS = 0x1, + Linux = 0x2, + macOS = 0x3, + Windows = 0x4 + }; + Q_DECLARE_FLAGS(Platforms, Platform) + + GemInfo(const QString& name, const QString& creator, const QString& summary, Platforms platforms, bool isAdded); + + QString m_name; + QString m_displayName; + AZ::Uuid m_uuid; + QString m_creator; + bool m_isAdded = false; //! Is the gem currently added and enabled in the project? + QString m_summary; + Platforms m_platforms; + QStringList m_features; + QString m_version; + QString m_lastUpdatedDate; + QString m_documentationUrl; + QVector m_dependingGemUuids; + QVector m_conflictingGemUuids; + }; +} // namespace O3DE::ProjectManager + +Q_DECLARE_OPERATORS_FOR_FLAGS(O3DE::ProjectManager::GemInfo::Platforms) diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettings.cpp b/Code/Tools/ProjectManager/Source/NewProjectSettings.cpp new file mode 100644 index 0000000000..2ebe54e682 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/NewProjectSettings.cpp @@ -0,0 +1,47 @@ +/* + * 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 + +#include + +namespace O3DE::ProjectManager +{ + NewProjectSettings::NewProjectSettings(ProjectManagerWindow* window) + : ScreenWidget(window) + , m_ui(new Ui::NewProjectSettingsClass()) + { + m_ui->setupUi(this); + + ConnectSlotsAndSignals(); + } + + NewProjectSettings::~NewProjectSettings() + { + } + + void NewProjectSettings::ConnectSlotsAndSignals() + { + QObject::connect(m_ui->backButton, &QPushButton::pressed, this, &NewProjectSettings::HandleBackButton); + QObject::connect(m_ui->nextButton, &QPushButton::pressed, this, &NewProjectSettings::HandleNextButton); + } + + void NewProjectSettings::HandleBackButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::FirstTimeUse); + } + void NewProjectSettings::HandleNextButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::GemCatalog); + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettings.h b/Code/Tools/ProjectManager/Source/NewProjectSettings.h new file mode 100644 index 0000000000..f5fa91a9b9 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/NewProjectSettings.h @@ -0,0 +1,43 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include +#endif + +namespace Ui +{ + class NewProjectSettingsClass; +} + +namespace O3DE::ProjectManager +{ + class NewProjectSettings + : public ScreenWidget + { + public: + explicit NewProjectSettings(ProjectManagerWindow* window); + ~NewProjectSettings(); + + protected: + void ConnectSlotsAndSignals() override; + + protected slots: + void HandleBackButton(); + void HandleNextButton(); + + private: + QScopedPointer m_ui; + }; + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettings.ui b/Code/Tools/ProjectManager/Source/NewProjectSettings.ui new file mode 100644 index 0000000000..98db10338e --- /dev/null +++ b/Code/Tools/ProjectManager/Source/NewProjectSettings.ui @@ -0,0 +1,97 @@ + + + NewProjectSettingsClass + + + + 0 + 0 + 880 + 546 + + + + Form + + + + + + Project Name + + + + + + + + + + Project Path + + + + + + + + + + Project Template + + + + + + + + + Standard (Recommened) + + + + + + + Empty + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Back + + + + + + + Next + + + + + + + + + + diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerWindow.cpp b/Code/Tools/ProjectManager/Source/ProjectManagerWindow.cpp new file mode 100644 index 0000000000..12980fc836 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectManagerWindow.cpp @@ -0,0 +1,106 @@ +/* + * 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 +#include + +#include +#include + +#include + +#include + +namespace O3DE::ProjectManager +{ + ProjectManagerWindow::ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath) + : QMainWindow(parent) + , m_ui(new Ui::ProjectManagerWindowClass()) + { + m_ui->setupUi(this); + + ConnectSlotsAndSignals(); + + QDir rootDir = QString::fromUtf8(engineRootPath.Native().data(), aznumeric_cast(engineRootPath.Native().size())); + const auto pathOnDisk = rootDir.absoluteFilePath("Code/Tools/ProjectManager/Resources"); + const auto qrcPath = QStringLiteral(":/ProjectManagerWindow"); + AzQtComponents::StyleManager::addSearchPaths("projectmanagerwindow", pathOnDisk, qrcPath, engineRootPath); + + AzQtComponents::StyleManager::setStyleSheet(this, QStringLiteral("projectlauncherwindow:ProjectManagerWindow.qss")); + + BuildScreens(); + + ChangeToScreen(ProjectManagerScreen::FirstTimeUse); + } + + ProjectManagerWindow::~ProjectManagerWindow() + { + } + + void ProjectManagerWindow::BuildScreens() + { + // Basically just iterate over the ProjectManagerScreen enum creating each screen + // Could add some fancy to do this but there are few screens right now + + ResetScreen(ProjectManagerScreen::FirstTimeUse); + ResetScreen(ProjectManagerScreen::NewProjectSettings); + ResetScreen(ProjectManagerScreen::GemCatalog); + ResetScreen(ProjectManagerScreen::ProjectsHome); + ResetScreen(ProjectManagerScreen::ProjectSettings); + ResetScreen(ProjectManagerScreen::EngineSettings); + } + + QStackedWidget* ProjectManagerWindow::GetScreenStack() + { + return m_ui->stackedScreens; + } + + void ProjectManagerWindow::ChangeToScreen(ProjectManagerScreen screen) + { + int index = aznumeric_cast(screen); + m_ui->stackedScreens->setCurrentIndex(index); + } + + void ProjectManagerWindow::ResetScreen(ProjectManagerScreen screen) + { + int index = aznumeric_cast(screen); + + // Fine the old screen if it exists and get rid of it so we can start fresh + QWidget* oldScreen = m_ui->stackedScreens->widget(index); + + if (oldScreen) + { + m_ui->stackedScreens->removeWidget(oldScreen); + oldScreen->deleteLater(); + } + + // Add new screen + QWidget* newScreen = BuildScreen(this, screen); + m_ui->stackedScreens->insertWidget(index, newScreen); + } + + void ProjectManagerWindow::ConnectSlotsAndSignals() + { + QObject::connect(m_ui->projectsMenu, &QMenu::aboutToShow, this, &ProjectManagerWindow::HandleProjectsMenu); + QObject::connect(m_ui->engineMenu, &QMenu::aboutToShow, this, &ProjectManagerWindow::HandleEngineMenu); + } + + void ProjectManagerWindow::HandleProjectsMenu() + { + ChangeToScreen(ProjectManagerScreen::ProjectsHome); + } + void ProjectManagerWindow::HandleEngineMenu() + { + ChangeToScreen(ProjectManagerScreen::EngineSettings); + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.h b/Code/Tools/ProjectManager/Source/ProjectManagerWindow.h similarity index 63% rename from Code/Tools/ProjectManager/Qt/ProjectManagerWindow.h rename to Code/Tools/ProjectManager/Source/ProjectManagerWindow.h index a62e823a92..9e5761fbd2 100644 --- a/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.h +++ b/Code/Tools/ProjectManager/Source/ProjectManagerWindow.h @@ -12,7 +12,10 @@ #pragma once #if !defined(Q_MOC_RUN) +#include + #include +#include #include #endif @@ -22,17 +25,33 @@ namespace Ui class ProjectManagerWindowClass; } -namespace ProjectManager +namespace O3DE::ProjectManager { - class ProjectManagerWindow : public QMainWindow + class ProjectManagerWindow + : public QMainWindow { + Q_OBJECT public: explicit ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath); ~ProjectManagerWindow(); + void BuildScreens(); + QStackedWidget* GetScreenStack(); + + public slots: + void ChangeToScreen(ProjectManagerScreen screen); + void ResetScreen(ProjectManagerScreen screen); + + protected: + void ConnectSlotsAndSignals(); + + protected slots: + void HandleProjectsMenu(); + void HandleEngineMenu(); + private: QScopedPointer m_ui; }; -} // namespace ProjectManager +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.ui b/Code/Tools/ProjectManager/Source/ProjectManagerWindow.ui similarity index 74% rename from Code/Tools/ProjectManager/Qt/ProjectManagerWindow.ui rename to Code/Tools/ProjectManager/Source/ProjectManagerWindow.ui index 60ec2dd674..704e74e38e 100644 --- a/Code/Tools/ProjectManager/Qt/ProjectManagerWindow.ui +++ b/Code/Tools/ProjectManager/Source/ProjectManagerWindow.ui @@ -13,8 +13,12 @@ O3DE Project Manager - - + + + + + + @@ -30,7 +34,7 @@ 16 - + Icon @@ -39,19 +43,19 @@ :/Resources/o3de_editor.ico:/Resources/o3de_editor.ico - + Projects - + Engine - - - + + + diff --git a/Code/Tools/ProjectManager/Source/ProjectSettings.cpp b/Code/Tools/ProjectManager/Source/ProjectSettings.cpp new file mode 100644 index 0000000000..bc653f9c5b --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectSettings.cpp @@ -0,0 +1,42 @@ +/* + * 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 + +#include + +namespace O3DE::ProjectManager +{ + ProjectSettings::ProjectSettings(ProjectManagerWindow* window) + : ScreenWidget(window) + , m_ui(new Ui::ProjectSettingsClass()) + { + m_ui->setupUi(this); + + ConnectSlotsAndSignals(); + } + + ProjectSettings::~ProjectSettings() + { + } + + void ProjectSettings::ConnectSlotsAndSignals() + { + QObject::connect(m_ui->gemsButton, &QPushButton::pressed, this, &ProjectSettings::HandleGemsButton); + } + + void ProjectSettings::HandleGemsButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::GemCatalog); + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectSettings.h b/Code/Tools/ProjectManager/Source/ProjectSettings.h new file mode 100644 index 0000000000..e7781d3a2a --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectSettings.h @@ -0,0 +1,42 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include +#endif + +namespace Ui +{ + class ProjectSettingsClass; +} + +namespace O3DE::ProjectManager +{ + class ProjectSettings + : public ScreenWidget + { + public: + explicit ProjectSettings(ProjectManagerWindow* window); + ~ProjectSettings(); + + protected: + void ConnectSlotsAndSignals() override; + + protected slots: + void HandleGemsButton(); + + private: + QScopedPointer m_ui; + }; + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectSettings.ui b/Code/Tools/ProjectManager/Source/ProjectSettings.ui new file mode 100644 index 0000000000..934238a257 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectSettings.ui @@ -0,0 +1,113 @@ + + + ProjectSettingsClass + + + + 0 + 0 + 782 + 579 + + + + Form + + + + + + + + Project Settings + + + + + + + Gems + + + + + + + Qt::Horizontal + + + + 761 + 20 + + + + + + + + + + + + + + Project Name + + + + + + + + + + Project Location + + + + + + + + + + Project Image Location + + + + + + + + + + Project Background Image Location + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/Code/Tools/ProjectManager/Source/ProjectsHome.cpp b/Code/Tools/ProjectManager/Source/ProjectsHome.cpp new file mode 100644 index 0000000000..1a451f3d10 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectsHome.cpp @@ -0,0 +1,52 @@ +/* + * 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 + +#include + +namespace O3DE::ProjectManager +{ + ProjectsHome::ProjectsHome(ProjectManagerWindow* window) + : ScreenWidget(window) + , m_ui(new Ui::ProjectsHomeClass()) + { + m_ui->setupUi(this); + + ConnectSlotsAndSignals(); + } + + ProjectsHome::~ProjectsHome() + { + } + + void ProjectsHome::ConnectSlotsAndSignals() + { + QObject::connect(m_ui->newProjectButton, &QPushButton::pressed, this, &ProjectsHome::HandleNewProjectButton); + QObject::connect(m_ui->addProjectButton, &QPushButton::pressed, this, &ProjectsHome::HandleAddProjectButton); + QObject::connect(m_ui->editProjectButton, &QPushButton::pressed, this, &ProjectsHome::HandleEditProjectButton); + } + + void ProjectsHome::HandleNewProjectButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::NewProjectSettings); + } + void ProjectsHome::HandleAddProjectButton() + { + //Do nothing for now + } + void ProjectsHome::HandleEditProjectButton() + { + m_projectManagerWindow->ChangeToScreen(ProjectManagerScreen::ProjectSettings); + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectsHome.h b/Code/Tools/ProjectManager/Source/ProjectsHome.h new file mode 100644 index 0000000000..4cc2918a38 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectsHome.h @@ -0,0 +1,45 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include +#endif + +namespace Ui +{ + class ProjectsHomeClass; +} + +namespace O3DE::ProjectManager +{ + class ProjectsHome + : public ScreenWidget + { + + public: + explicit ProjectsHome(ProjectManagerWindow* window); + ~ProjectsHome(); + + protected: + void ConnectSlotsAndSignals() override; + + protected slots: + void HandleNewProjectButton(); + void HandleAddProjectButton(); + void HandleEditProjectButton(); + + private: + QScopedPointer m_ui; + }; + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectsHome.ui b/Code/Tools/ProjectManager/Source/ProjectsHome.ui new file mode 100644 index 0000000000..ea3e34d84b --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ProjectsHome.ui @@ -0,0 +1,137 @@ + + + ProjectsHomeClass + + + + 0 + 0 + 826 + 585 + + + + Form + + + + + + My Projects + + + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + + + + + :/Resources/Add.svg:/Resources/Add.svg + + + + + + + + 0 + 0 + + + + + + + + :/Resources/Select_Folder.svg:/Resources/Select_Folder.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + Edit Project + + + + + + + Open a Project + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/Code/Tools/ProjectManager/Qt/FirstTimeUse.cpp b/Code/Tools/ProjectManager/Source/ScreenDefs.h similarity index 60% rename from Code/Tools/ProjectManager/Qt/FirstTimeUse.cpp rename to Code/Tools/ProjectManager/Source/ScreenDefs.h index 640849740e..f02b1de1b8 100644 --- a/Code/Tools/ProjectManager/Qt/FirstTimeUse.cpp +++ b/Code/Tools/ProjectManager/Source/ScreenDefs.h @@ -9,23 +9,17 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ +#pragma once -#include - -#include - -namespace ProjectManager +namespace O3DE::ProjectManager { - FirstTimeUse::FirstTimeUse(QWidget* parent) - : QWidget(parent) - , m_ui(new Ui::FirstTimeUseClass()) + enum class ProjectManagerScreen { - m_ui->setupUi(this); - } - - FirstTimeUse::~FirstTimeUse() - { - } - - //#include -} // namespace ProjectManager + FirstTimeUse, + NewProjectSettings, + GemCatalog, + ProjectsHome, + ProjectSettings, + EngineSettings + }; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ScreenFactory.cpp b/Code/Tools/ProjectManager/Source/ScreenFactory.cpp new file mode 100644 index 0000000000..b07816e69e --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ScreenFactory.cpp @@ -0,0 +1,43 @@ +/* + * 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 + +#include +#include +#include +#include +#include +#include + +namespace O3DE::ProjectManager +{ + QWidget* BuildScreen(ProjectManagerWindow* window, ProjectManagerScreen screen) + { + switch(screen) + { + case (ProjectManagerScreen::FirstTimeUse): + return new FirstTimeUse(window); + case (ProjectManagerScreen::NewProjectSettings): + return new NewProjectSettings(window); + case (ProjectManagerScreen::GemCatalog): + return new GemCatalog(window); + case (ProjectManagerScreen::ProjectsHome): + return new ProjectsHome(window); + case (ProjectManagerScreen::ProjectSettings): + return new ProjectSettings(window); + case (ProjectManagerScreen::EngineSettings): + return new EngineSettings(window); + default: + return new QWidget(window->GetScreenStack()); + } + } +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ScreenFactory.h b/Code/Tools/ProjectManager/Source/ScreenFactory.h new file mode 100644 index 0000000000..ea68534a08 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ScreenFactory.h @@ -0,0 +1,24 @@ +/* + * 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 + +#include + +#include + + +namespace O3DE::ProjectManager +{ + QWidget* BuildScreen(ProjectManagerWindow* window, ProjectManagerScreen screen); +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ScreenWidget.h b/Code/Tools/ProjectManager/Source/ScreenWidget.h new file mode 100644 index 0000000000..b4c4fd190c --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ScreenWidget.h @@ -0,0 +1,38 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include + +#include +#endif + +namespace O3DE::ProjectManager +{ + class ScreenWidget + : public QWidget + { + public: + explicit ScreenWidget(ProjectManagerWindow* window) + : QWidget(window->GetScreenStack()) + , m_projectManagerWindow(window) + { + } + + protected: + virtual void ConnectSlotsAndSignals() = 0; + + ProjectManagerWindow* m_projectManagerWindow; + }; + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/source/main.cpp b/Code/Tools/ProjectManager/Source/main.cpp similarity index 94% rename from Code/Tools/ProjectManager/source/main.cpp rename to Code/Tools/ProjectManager/Source/main.cpp index ecfae3b28e..149da79491 100644 --- a/Code/Tools/ProjectManager/source/main.cpp +++ b/Code/Tools/ProjectManager/Source/main.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) AzQtComponents::StyleManager styleManager(&app); styleManager.initialize(&app, engineRootPath); - ProjectManager::ProjectManagerWindow window(nullptr, engineRootPath); + O3DE::ProjectManager::ProjectManagerWindow window(nullptr, engineRootPath); window.show(); return app.exec(); diff --git a/Code/Tools/ProjectManager/project_manager_files.cmake b/Code/Tools/ProjectManager/project_manager_files.cmake index 4d36550e56..a97ff692b7 100644 --- a/Code/Tools/ProjectManager/project_manager_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_files.cmake @@ -11,11 +11,32 @@ set(FILES project_manager.qrc - source/main.cpp - Qt/FirstTimeUse.h - Qt/FirstTimeUse.cpp - Qt/FirstTimeUse.ui - Qt/ProjectManagerWindow.h - Qt/ProjectManagerWindow.cpp - Qt/ProjectManagerWindow.ui + Source/main.cpp + Source/ScreenDefs.h + Source/ScreenFactory.h + Source/ScreenFactory.cpp + Source/ScreenWidget.h + Source/FirstTimeUse.h + Source/FirstTimeUse.cpp + Source/FirstTimeUse.ui + Source/ProjectManagerWindow.h + Source/ProjectManagerWindow.cpp + Source/ProjectManagerWindow.ui + Source/NewProjectSettings.h + Source/NewProjectSettings.cpp + Source/NewProjectSettings.ui + Source/GemCatalog.h + Source/GemCatalog.cpp + Source/GemCatalog.ui + Source/ProjectsHome.h + Source/ProjectsHome.cpp + Source/ProjectsHome.ui + Source/ProjectSettings.h + Source/ProjectSettings.cpp + Source/ProjectSettings.ui + Source/EngineSettings.h + Source/EngineSettings.cpp + Source/EngineSettings.ui + Source/GemCatalog/GemInfo.h + Source/GemCatalog/GemInfo.cpp ) diff --git a/Code/Tools/SceneAPI/CMakeLists.txt b/Code/Tools/SceneAPI/CMakeLists.txt index 0dfcbaf9cd..70bfe9e837 100644 --- a/Code/Tools/SceneAPI/CMakeLists.txt +++ b/Code/Tools/SceneAPI/CMakeLists.txt @@ -10,7 +10,7 @@ # add_subdirectory(FbxSceneBuilder) -add_subdirectory(FbxSDKWrapper) add_subdirectory(SceneCore) add_subdirectory(SceneData) add_subdirectory(SceneUI) +add_subdirectory(SDKWrapper) diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveNodeWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveNodeWrapper.cpp deleted file mode 100644 index 78d7c713e0..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveNodeWrapper.cpp +++ /dev/null @@ -1,47 +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 -#include "FbxAnimCurveNodeWrapper.h" -#include "FbxAnimCurveWrapper.h" -#include "fbxsdk.h" - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxAnimCurveNodeWrapper::FbxAnimCurveNodeWrapper(FbxAnimCurveNode* fbxAnimCurveNode) - : m_fbxAnimCurveNode(fbxAnimCurveNode) - { - } - - const char* FbxAnimCurveNodeWrapper::GetName() const - { - return m_fbxAnimCurveNode->GetName(); - } - - int FbxAnimCurveNodeWrapper::GetChannelCount() const - { - return m_fbxAnimCurveNode->GetChannelsCount(); - } - - int FbxAnimCurveNodeWrapper::GetCurveCount(int channelID) const - { - return m_fbxAnimCurveNode->GetCurveCount(channelID); - } - - AZStd::shared_ptr FbxAnimCurveNodeWrapper::GetCurveWrapper(int channelID, int index) const - { - return AZStd::make_shared(static_cast(m_fbxAnimCurveNode->GetCurve(channelID, index))); - } - } -} diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveNodeWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveNodeWrapper.h deleted file mode 100644 index a1213de32b..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveNodeWrapper.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -/* -* 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 "fbxsdk.h" -#include "FbxTimeWrapper.h" -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxAnimCurveWrapper; - - class FbxAnimCurveNodeWrapper - { - public: - FbxAnimCurveNodeWrapper(FbxAnimCurveNode* fbxAnimCurveNode); - ~FbxAnimCurveNodeWrapper() = default; - const char* GetName() const; - int GetChannelCount() const; - int GetCurveCount(int channelID) const; - - AZStd::shared_ptr GetCurveWrapper(int channelID, int index) const; - - protected: - FbxAnimCurveNode* m_fbxAnimCurveNode; - }; - } -} diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveWrapper.cpp deleted file mode 100644 index e1e32278d9..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveWrapper.cpp +++ /dev/null @@ -1,34 +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 - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxAnimCurveWrapper::FbxAnimCurveWrapper(FbxAnimCurve* fbxAnimCurve) - : m_fbxAnimCurve(fbxAnimCurve) - { - } - - const char* FbxAnimCurveWrapper::GetName() const - { - return m_fbxAnimCurve->GetName(); - } - - float FbxAnimCurveWrapper::Evaluate(FbxTimeWrapper& time) const - { - return m_fbxAnimCurve->Evaluate(time.m_fbxTime); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveWrapper.h deleted file mode 100644 index f8793f53cd..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimCurveWrapper.h +++ /dev/null @@ -1,34 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxAnimCurveWrapper - { - public: - FbxAnimCurveWrapper(FbxAnimCurve* fbxAnimCurve); - ~FbxAnimCurveWrapper() = default; - const char* GetName() const; - float Evaluate(FbxTimeWrapper& time) const; - - protected: - FbxAnimCurve* m_fbxAnimCurve; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimLayerWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimLayerWrapper.cpp deleted file mode 100644 index a99fe05303..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimLayerWrapper.cpp +++ /dev/null @@ -1,49 +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 -#include -#include -#include - -#include "fbxsdk.h" - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxAnimLayerWrapper::FbxAnimLayerWrapper(FbxAnimLayer* fbxAnimLayer) - : m_fbxAnimLayer(fbxAnimLayer) - { - } - - const char* FbxAnimLayerWrapper::GetName() const - { - return m_fbxAnimLayer->GetName(); - } - - u32 FbxAnimLayerWrapper::GetCurveNodeCount() const - { - return static_cast(m_fbxAnimLayer->GetMemberCount()); - } - - FbxAnimLayer* FbxAnimLayerWrapper::GetFbxLayer() const - { - return m_fbxAnimLayer; - } - - AZStd::shared_ptr FbxAnimLayerWrapper::GetCurveNodeWrapper(u32 index) const - { - return AZStd::make_shared(static_cast(m_fbxAnimLayer->GetMember(aznumeric_cast(index)))); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimLayerWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimLayerWrapper.h deleted file mode 100644 index ace0f7eee0..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimLayerWrapper.h +++ /dev/null @@ -1,39 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxAnimCurveNodeWrapper; - - class FbxAnimLayerWrapper - { - friend class FbxNodeWrapper; - public: - FbxAnimLayerWrapper(FbxAnimLayer* fbxAnimLayer); - ~FbxAnimLayerWrapper() = default; - const char* GetName() const; - u32 GetCurveNodeCount() const ; - FbxAnimLayer* GetFbxLayer() const; - AZStd::shared_ptr GetCurveNodeWrapper(u32 index) const; - - protected: - FbxAnimLayer* m_fbxAnimLayer; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimStackWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimStackWrapper.cpp deleted file mode 100644 index 943bff2bc0..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimStackWrapper.cpp +++ /dev/null @@ -1,55 +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 -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxAnimStackWrapper::FbxAnimStackWrapper(FbxAnimStack* fbxAnimStack) - : m_fbxAnimStack(fbxAnimStack) - { - AZ_Assert(fbxAnimStack, "Invalid FbxAnimStack input to initialize FbxAnimStackWrapper"); - } - - FbxAnimStackWrapper::~FbxAnimStackWrapper() - { - m_fbxAnimStack = nullptr; - } - - const char* FbxAnimStackWrapper::GetName() const - { - return m_fbxAnimStack->GetName(); - } - - int FbxAnimStackWrapper::GetAnimationLayerCount() const - { - return m_fbxAnimStack->GetMemberCount(); - } - - const AZStd::shared_ptr FbxAnimStackWrapper::GetAnimationLayerAt(int index) const - { - AZ_Assert(index < GetAnimationLayerCount(), "Invalid animation layer index %d for layer count %d", index, GetAnimationLayerCount()); - return AZStd::make_shared(m_fbxAnimStack->GetMember(index)); - } - - FbxTimeSpanWrapper FbxAnimStackWrapper::GetLocalTimeSpan() const - { - return FbxTimeSpanWrapper(m_fbxAnimStack->GetLocalTimeSpan()); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimStackWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimStackWrapper.h deleted file mode 100644 index 97e1f86324..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAnimStackWrapper.h +++ /dev/null @@ -1,42 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - using FbxSDKLongLong = FbxLongLong; - class FbxAnimLayerWrapper; - class FbxTimeSpanWrapper; - - class FbxAnimStackWrapper - { - public: - FbxAnimStackWrapper(FbxAnimStack* fbxAnimStack); - virtual ~FbxAnimStackWrapper(); - - virtual const char* GetName() const; - virtual int GetAnimationLayerCount() const; - virtual const AZStd::shared_ptr GetAnimationLayerAt(int index) const; - virtual FbxTimeSpanWrapper GetLocalTimeSpan() const; - - protected: - FbxAnimStackWrapper() = default; - FbxAnimStack* m_fbxAnimStack; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAxisSystemWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAxisSystemWrapper.cpp deleted file mode 100644 index b957b1105c..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAxisSystemWrapper.cpp +++ /dev/null @@ -1,75 +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 -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxAxisSystemWrapper::FbxAxisSystemWrapper(const FbxAxisSystem& fbxAxisSystem) - : m_fbxAxisSystem(fbxAxisSystem) - { - } - - FbxAxisSystemWrapper::UpVector FbxAxisSystemWrapper::GetUpVector(int& sign) const - { - switch (m_fbxAxisSystem.GetUpVector(sign)) - { - case FbxAxisSystem::eXAxis: - return X; - case FbxAxisSystem::eYAxis: - return Y; - case FbxAxisSystem::eZAxis: - return Z; - default: - AZ_TraceContext("Unknown value", m_fbxAxisSystem.GetUpVector(sign)); - AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unrecognized axis up vector type"); - return Unknown; - } - } - - SceneAPI::DataTypes::MatrixType FbxAxisSystemWrapper::CalculateConversionTransform(UpVector targetUpAxis) - { - FbxAxisSystem targetSystem; - switch (targetUpAxis) - { - case Y: - // Maya YUp coordinate system (UpVector = +Y, FrontVector = +Z, CoordSystem = +X (RightHanded)) - targetSystem = FbxAxisSystem::MayaYUp; - break; - case Z: - // CryTek ZUp coordinate system (UpVector = +Z, FrontVector = +Y, CoordSystem = -X (RightHanded)) - targetSystem = FbxAxisSystem(FbxAxisSystem::eZAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eRightHanded); - break; - case X: - // Default XUp coordinate system (UpVector = +X, FrontVector = +Z, CoordSystem = -Y (RightHanded)) - targetSystem = FbxAxisSystem(FbxAxisSystem::eXAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eRightHanded); - break; - default: - AZ_TraceContext("Unknown value", targetUpAxis); - AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unrecognized axis conversion target axis type"); - return SceneAPI::DataTypes::MatrixType::CreateIdentity(); - } - FbxAMatrix targetMatrix; - targetSystem.GetMatrix(targetMatrix); - FbxAMatrix currentMatrix; - m_fbxAxisSystem.GetMatrix(currentMatrix); - FbxAMatrix adjustMatrix = targetMatrix * currentMatrix.Inverse(); - return FbxTypeConverter::ToTransform(adjustMatrix); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAxisSystemWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAxisSystemWrapper.h deleted file mode 100644 index d8dba5068a..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxAxisSystemWrapper.h +++ /dev/null @@ -1,44 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxAxisSystemWrapper - { - public: - enum UpVector - { - X, - Y, - Z, - Unknown - }; - - FbxAxisSystemWrapper() = default; - FbxAxisSystemWrapper(const FbxAxisSystem& fbxAxisSystem); - virtual ~FbxAxisSystemWrapper() = default; - - virtual UpVector GetUpVector(int& sign) const; - virtual SceneAPI::DataTypes::MatrixType CalculateConversionTransform(UpVector targetUpAxis); - - protected: - FbxAxisSystem m_fbxAxisSystem; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeChannelWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeChannelWrapper.cpp deleted file mode 100644 index 92cf655dbd..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeChannelWrapper.cpp +++ /dev/null @@ -1,100 +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 -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxBlendShapeChannelWrapper::FbxBlendShapeChannelWrapper(FbxBlendShapeChannel* fbxBlendShapeChannel) - : m_fbxBlendShapeChannel(fbxBlendShapeChannel) - { - AZ_Assert(fbxBlendShapeChannel, "Invalid FbxSkin input to initialize FbxBlendShapeChannelWrapper"); - } - - FbxBlendShapeChannelWrapper::~FbxBlendShapeChannelWrapper() - { - m_fbxBlendShapeChannel = nullptr; - } - - const char* FbxBlendShapeChannelWrapper::GetName() const - { - return m_fbxBlendShapeChannel->GetName(); - } - - //The engine currently only supports one target shape. If there are more than one, - //code will ultimately end up just using the max index returned by this function. - int FbxBlendShapeChannelWrapper::GetTargetShapeCount() const - { - return m_fbxBlendShapeChannel->GetTargetShapeCount(); - } - - //While not strictly true that the target shapes are meshes, for the purposes of the engine's - //current runtime they must be meshes. - AZStd::shared_ptr FbxBlendShapeChannelWrapper::GetTargetShape(int index) const - { - //we need to create a duplicate FbxMesh from the base mesh and the target data - //FbxMeshWrapper needs an FbxMesh to point to so we are generating one - //by cloning the mesh data and then replacing with the morph data. - FbxShape* fbxShape = m_fbxBlendShapeChannel->GetTargetShape(index); - if (!fbxShape) - { - return nullptr; - } - - FbxGeometry* fbxGeom = fbxShape->GetBaseGeometry(); - if (fbxGeom && fbxGeom->GetAttributeType() == FbxNodeAttribute::EType::eMesh) - { - FbxMesh* fbxMesh = static_cast(fbxGeom); - FbxMesh* fbxBlendMesh = FbxMesh::Create(m_fbxBlendShapeChannel->GetScene(),""); - fbxBlendMesh->Copy(*fbxMesh); - //TODO: test that mesh is managed by the sdk - const int count = fbxBlendMesh->GetControlPointsCount(); - //set control points from blend shape - for (int i = 0; i < count; i++) - { - fbxBlendMesh->SetControlPointAt(fbxShape->GetControlPointAt(i), i); - } - - //source data - FbxLayerElementArrayTemplate* normalsTemplate; - if (fbxShape->GetNormals(&normalsTemplate)) - { - int normalCount = normalsTemplate->GetCount(); - - //destination data - FbxLayer* normalLayer = fbxBlendMesh->GetLayer(0, FbxLayerElement::eNormal); - if (normalLayer) - { - FbxLayerElementNormal* normals = normalLayer->GetNormals(); - if (normals) - { - //set normal data from blend shape - for (int j = 0; j < normalCount; j++) - { - FbxVector4 normal = normalsTemplate->GetAt(j); - normals->GetDirectArray().SetAt(j, normal); - } - } - } - } - return AZStd::make_shared(fbxBlendMesh); - } - return nullptr; - } - } -} diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeChannelWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeChannelWrapper.h deleted file mode 100644 index a8f2fffdcc..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeChannelWrapper.h +++ /dev/null @@ -1,43 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxNodeWrapper; - class FbxMeshWrapper; - - class FbxBlendShapeChannelWrapper - { - public: - FbxBlendShapeChannelWrapper(FbxBlendShapeChannel* fbxBlendShapeChannel); - virtual ~FbxBlendShapeChannelWrapper(); - - virtual const char* GetName() const; - virtual int GetTargetShapeCount() const; - - //While not strictly true that the target shapes are meshes, for the purposes of the engine's - //current runtime they must be meshes. - virtual AZStd::shared_ptr GetTargetShape(int index) const; - - protected: - FbxBlendShapeChannelWrapper() = default; - FbxBlendShapeChannel* m_fbxBlendShapeChannel; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeWrapper.cpp deleted file mode 100644 index ab75613ab5..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeWrapper.cpp +++ /dev/null @@ -1,74 +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 -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxBlendShapeWrapper::FbxBlendShapeWrapper(FbxBlendShape* fbxBlendShape) - : m_fbxBlendShape(fbxBlendShape) - { - AZ_Assert(fbxBlendShape, "Invalid FbxBlendShape input to initialize FbxBlendShapeWrapper"); - } - - FbxBlendShapeWrapper::~FbxBlendShapeWrapper() - { - m_fbxBlendShape = nullptr; - } - - const char* FbxBlendShapeWrapper::GetName() const - { - return m_fbxBlendShape->GetName(); - } - - //Technically Fbx returns a FbxGeometry off this interface, but we only support meshes in the engine runtime. - AZStd::shared_ptr FbxBlendShapeWrapper::GetGeometry() const - { - FbxGeometry* fbxGeom = m_fbxBlendShape->GetGeometry(); - - if (fbxGeom && fbxGeom->GetAttributeType() == FbxNodeAttribute::EType::eMesh ) - { - return AZStd::make_shared(static_cast(fbxGeom)); - } - else - { - return nullptr; - } - } - - int FbxBlendShapeWrapper::GetBlendShapeChannelCount() const - { - return m_fbxBlendShape->GetBlendShapeChannelCount(); - } - - AZStd::shared_ptr FbxBlendShapeWrapper::GetBlendShapeChannel(int index) const - { - FbxBlendShapeChannel* fbxBlendShapeChannel = m_fbxBlendShape->GetBlendShapeChannel(index); - if (fbxBlendShapeChannel) - { - return AZStd::make_shared(fbxBlendShapeChannel); - } - else - { - return nullptr; - } - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeWrapper.h deleted file mode 100644 index d049f5cec8..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxBlendShapeWrapper.h +++ /dev/null @@ -1,43 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxBlendShapeChannelWrapper; - class FbxNodeWrapper; - class FbxMeshWrapper; - - class FbxBlendShapeWrapper - { - public: - FbxBlendShapeWrapper(FbxBlendShape* fbxBlendShape); - virtual ~FbxBlendShapeWrapper(); - - virtual const char* GetName() const; - //Technically Fbx returns a FbxGeometry off this interface, but we only support meshes in the engine runtime. - virtual AZStd::shared_ptr GetGeometry() const; - virtual int GetBlendShapeChannelCount() const; - virtual AZStd::shared_ptr GetBlendShapeChannel(int index) const; - - protected: - FbxBlendShapeWrapper() = default; - FbxBlendShape* m_fbxBlendShape; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxLayerElementUtilities.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxLayerElementUtilities.h deleted file mode 100644 index a4eed3f947..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxLayerElementUtilities.h +++ /dev/null @@ -1,31 +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 - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxLayerElementUtilities - { - public: - template - static void GetGeometryElement(ValueType& value, const ElementArrayType* elementArray, - int polygonIndex, int polygonVertexIndex, int controlPointIndex); - }; - } // namespace FbxSDKWrapper -} // namespace AZ - -#include "FbxLayerElementUtilities.inl" diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxLayerElementUtilities.inl b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxLayerElementUtilities.inl deleted file mode 100644 index eb1d9ef925..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxLayerElementUtilities.inl +++ /dev/null @@ -1,74 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - template - void FbxLayerElementUtilities::GetGeometryElement( ValueType& value, const ElementArrayType* elementArray, - int polygonIndex, int polygonVertexIndex, int controlPointIndex) - { - if (!elementArray) - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Invalid ElementArrayType input"); - return; - } - - int fbxElementIndex; - switch (elementArray->GetMappingMode()) - { - case FbxGeometryElement::eByControlPoint: - // One mapping coordinate for each surface control point/vertex. - fbxElementIndex = controlPointIndex; - break; - case FbxGeometryElement::eByPolygonVertex: - // One mapping coordinate for each vertex, for every polygon of which it is a part. - // This means that a vertex will have as many mapping coordinates as polygons of which it is a part. - fbxElementIndex = polygonVertexIndex; - break; - case FbxGeometryElement::eByPolygon: - // One mapping coordinate for the whole polygon. - fbxElementIndex = polygonIndex; - break; - default: - AZ_TraceContext("Unknown value", elementArray->GetMappingMode()); - AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Invalid ElementArrayType mapping mode"); - return; - } - - if (elementArray->GetReferenceMode() == FbxGeometryElement::eIndexToDirect) - { - // Convert index from "index of value's index" to "index of value". - const FbxLayerElementArrayTemplate& indices = elementArray->GetIndexArray(); - AZ_Assert(fbxElementIndex < indices.GetCount(), "Invalid element index %d", fbxElementIndex); - if (fbxElementIndex >= indices.GetCount()) - { - return; - } - fbxElementIndex = indices.GetAt(fbxElementIndex); - } - - const FbxLayerElementArrayTemplate& elements = elementArray->GetDirectArray(); - AZ_Assert(fbxElementIndex < elements.GetCount(), "Invalid element index %d", fbxElementIndex); - if (fbxElementIndex >= elements.GetCount()) - { - return; - } - value = elements.GetAt(fbxElementIndex); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMaterialWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMaterialWrapper.cpp deleted file mode 100644 index 37c23bc2cb..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMaterialWrapper.cpp +++ /dev/null @@ -1,185 +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 -#include -#include -#include -#include -#include -#include - -namespace -{ - const char* s_physicalisedAttributeName = "physicalize"; - const char* s_proxyNoDraw = "ProxyNoDraw"; -} - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxMaterialWrapper::FbxMaterialWrapper(FbxSurfaceMaterial* fbxMaterial) - : SDKMaterial::MaterialWrapper(fbxMaterial) - { - AZ_Assert(fbxMaterial, "Invalid FbxSurfaceMaterial input to initialize FbxMaterialWrapper"); - } - - AZStd::string FbxMaterialWrapper::GetName() const - { - return m_fbxMaterial->GetInitialName(); - } - - AZ::Vector3 FbxMaterialWrapper::GetDiffuseColor() const - { - if (m_fbxMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId)) - { - FbxSurfaceLambert* lambertMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = lambertMat->Diffuse.Get(); - const float power = static_cast(lambertMat->DiffuseFactor.Get()); - return power * AZ::Vector3(static_cast(fbxValue[0]), static_cast(fbxValue[1]), static_cast(fbxValue[2])); - } - else if (m_fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) - { - FbxSurfacePhong* phongMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = phongMat->Diffuse.Get(); - const float power = static_cast(phongMat->DiffuseFactor.Get()); - return power * AZ::Vector3(static_cast(fbxValue[0]), static_cast(fbxValue[1]), static_cast(fbxValue[2])); - } - - return AZ::Vector3::CreateOne(); - } - - AZ::Vector3 FbxMaterialWrapper::GetSpecularColor() const - { - if (m_fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) - { - FbxSurfacePhong* phongMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = phongMat->Specular.Get(); - const float power = static_cast(phongMat->SpecularFactor.Get()); - return power * AZ::Vector3(static_cast(fbxValue[0]), static_cast(fbxValue[1]), static_cast(fbxValue[2])); - } - - return AZ::Vector3::CreateZero(); - } - - AZ::Vector3 FbxMaterialWrapper::GetEmissiveColor() const - { - if (m_fbxMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId)) - { - FbxSurfaceLambert* lambertMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = lambertMat->Emissive.Get(); - const float power = static_cast(lambertMat->EmissiveFactor.Get()); - return power * AZ::Vector3(static_cast(fbxValue[0]), static_cast(fbxValue[1]), static_cast(fbxValue[2])); - } - else if (m_fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) - { - FbxSurfacePhong* phongMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = phongMat->Emissive.Get(); - const float power = static_cast(phongMat->EmissiveFactor.Get()); - return power * AZ::Vector3(static_cast(fbxValue[0]), static_cast(fbxValue[1]), static_cast(fbxValue[2])); - } - - return AZ::Vector3::CreateZero(); - } - - float FbxMaterialWrapper::GetShininess() const - { - if (m_fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) - { - FbxSurfacePhong* phongMat = static_cast(m_fbxMaterial); - return static_cast(phongMat->Shininess.Get()); - } - - return 10.f; - } - - AZ::u64 FbxMaterialWrapper::GetUniqueId() const - { - return m_fbxMaterial->GetUniqueID(); - } - - float FbxMaterialWrapper::GetOpacity() const - { - // FBX materials are erroneously reporting a TransparencyFactor of 1.0 (fully transparent) - // even for values that are 0.0 in Maya. It is instead storing it in the components - // for TransparentColor, so extract from there instead. - - if (m_fbxMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId)) - { - FbxSurfaceLambert* lambertMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = lambertMat->TransparentColor.Get(); - return 1.f - AZ::GetMin(AZ::GetMin(static_cast(fbxValue[0]), static_cast(fbxValue[1])), static_cast(fbxValue[2])); - } - else if (m_fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) - { - FbxSurfacePhong* phongMat = static_cast(m_fbxMaterial); - const FbxDouble3 fbxValue = phongMat->TransparentColor.Get(); - return 1.f - AZ::GetMin(AZ::GetMin(static_cast(fbxValue[0]), static_cast(fbxValue[1])), static_cast(fbxValue[2])); - } - - return 1.f; - } - - AZStd::string FbxMaterialWrapper::GetTextureFileName(const char* textureType) const - { - FbxFileTexture* fileTexture = nullptr; - FbxProperty property = m_fbxMaterial->FindProperty(textureType); - FbxDataType propertyType = property.GetPropertyDataType(); - - /// Engine currently doesn't support multiple textures. Right now we only use first texture of first layer. - int layeredTextureCount = property.GetSrcObjectCount(); - if (layeredTextureCount > 0) - { - FbxLayeredTexture* layeredTexture = FbxCast(property.GetSrcObject(0)); - int textureCount = layeredTexture->GetSrcObjectCount(); - if (textureCount > 0) - { - fileTexture = FbxCast(layeredTexture->GetSrcObject(0)); - } - } - else - { - int textureCount = property.GetSrcObjectCount(); - if (textureCount > 0) - { - fileTexture = FbxCast(property.GetSrcObject(0)); - } - } - - return fileTexture ? fileTexture->GetFileName() : AZStd::string(); - } - - AZStd::string FbxMaterialWrapper::GetTextureFileName(const AZStd::string& textureType) const - { - return GetTextureFileName(textureType.c_str()); - } - - AZStd::string FbxMaterialWrapper::GetTextureFileName(MaterialMapType textureType) const - { - switch (textureType) - { - case MaterialMapType::Diffuse: - return GetTextureFileName(FbxSurfaceMaterial::sDiffuse); - case MaterialMapType::Specular: - return GetTextureFileName(FbxSurfaceMaterial::sSpecular); - case MaterialMapType::Bump: - return GetTextureFileName(FbxSurfaceMaterial::sBump); - case MaterialMapType::Normal: - return GetTextureFileName(FbxSurfaceMaterial::sNormalMap); - default: - AZ_TraceContext("Unknown value", aznumeric_cast(textureType)); - AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unrecognized MaterialMapType retrieved"); - return AZStd::string(); - } - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMaterialWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMaterialWrapper.h deleted file mode 100644 index 0f195b939d..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMaterialWrapper.h +++ /dev/null @@ -1,44 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxMaterialWrapper : public SDKMaterial::MaterialWrapper - { - public: - AZ_RTTI(FbxMaterialWrapper, "{227582F6-93BC-4E44-823E-FB1D631443A7}", SDKMaterial::MaterialWrapper); - - FbxMaterialWrapper(FbxSurfaceMaterial* fbxMaterial); - ~FbxMaterialWrapper() override = default; - - AZStd::string GetName() const override; - virtual AZStd::string GetTextureFileName(const char* textureType) const; - virtual AZStd::string GetTextureFileName(const AZStd::string& textureType) const; - AZStd::string GetTextureFileName(MaterialMapType textureType) const override; - - AZ::Vector3 GetDiffuseColor() const override; - AZ::Vector3 GetSpecularColor() const override; - AZ::Vector3 GetEmissiveColor() const override; - float GetOpacity() const override; - float GetShininess() const override; - AZ::u64 GetUniqueId() const override; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMeshWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMeshWrapper.cpp deleted file mode 100644 index b6778153c2..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMeshWrapper.cpp +++ /dev/null @@ -1,154 +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 -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxMeshWrapper::FbxMeshWrapper(FbxMesh* fbxMesh) - : m_fbxMesh(fbxMesh) - { - AZ_Assert(fbxMesh, "Invalid FbxMesh input to initialize FbxMeshWrapper"); - } - - FbxMeshWrapper::~FbxMeshWrapper() - { - m_fbxMesh = nullptr; - } - - const char* FbxMeshWrapper::GetName() const - { - return m_fbxMesh->GetName(); - } - - int FbxMeshWrapper::GetDeformerCount() const - { - return m_fbxMesh->GetDeformerCount(); - } - - int FbxMeshWrapper::GetDeformerCount(int type) const - { - return m_fbxMesh->GetDeformerCount(static_cast(type)); - } - - int FbxMeshWrapper::GetControlPointsCount() const - { - return m_fbxMesh->GetControlPointsCount(); - } - - AZStd::vector FbxMeshWrapper::GetControlPoints() const - { - FbxVector4* controlPoints = m_fbxMesh->GetControlPoints(); - AZStd::vector azControlPoints; - azControlPoints.reserve(aznumeric_caster(GetControlPointsCount())); - for (int i = 0; i < GetControlPointsCount(); ++i) - { - azControlPoints.push_back(FbxTypeConverter::ToVector3(controlPoints[i])); - } - return azControlPoints; - } - - AZStd::shared_ptr FbxMeshWrapper::GetSkin(int index) const - { - FbxSkin* skin = static_cast(m_fbxMesh->GetDeformer(index, FbxDeformer::eSkin)); - return skin ? AZStd::make_shared(skin) : nullptr; - } - - AZStd::shared_ptr FbxMeshWrapper::GetBlendShape(int index) const - { - FbxBlendShape* blendShape = static_cast(m_fbxMesh->GetDeformer(index, FbxDeformer::eBlendShape)); - return blendShape ? AZStd::make_shared(blendShape) : nullptr; - } - - int FbxMeshWrapper::GetPolygonCount() const - { - return m_fbxMesh->GetPolygonCount(); - } - - int FbxMeshWrapper::GetPolygonSize(int polygonIndex) const - { - return m_fbxMesh->GetPolygonSize(polygonIndex); - } - - int* FbxMeshWrapper::GetPolygonVertices() const - { - return m_fbxMesh->GetPolygonVertices(); - } - - int FbxMeshWrapper::GetPolygonVertexIndex(int polygonIndex) const - { - return m_fbxMesh->GetPolygonVertexIndex(polygonIndex); - } - - bool FbxMeshWrapper::GetMaterialIndices(FbxLayerElementArrayTemplate** lockableArray) const - { - return m_fbxMesh->GetMaterialIndices(lockableArray); - } - - FbxUVWrapper FbxMeshWrapper::GetElementUV(int index) - { - return FbxUVWrapper(m_fbxMesh->GetElementUV(index)); - } - - FbxVertexTangentWrapper FbxMeshWrapper::GetElementTangent(int index) - { - return FbxVertexTangentWrapper(m_fbxMesh->GetElementTangent(index)); - } - - FbxVertexBitangentWrapper FbxMeshWrapper::GetElementBitangent(int index) - { - return FbxVertexBitangentWrapper(m_fbxMesh->GetElementBinormal(index)); - } - - int FbxMeshWrapper::GetElementUVCount() const - { - return m_fbxMesh->GetElementUVCount(); - } - - int FbxMeshWrapper::GetElementTangentCount() const - { - return m_fbxMesh->GetElementTangentCount(); - } - - int FbxMeshWrapper::GetElementBitangentCount() const - { - return m_fbxMesh->GetElementBinormalCount(); - } - - FbxVertexColorWrapper FbxMeshWrapper::GetElementVertexColor(int index) - { - return FbxVertexColorWrapper(m_fbxMesh->GetElementVertexColor(index)); - } - - int FbxMeshWrapper::GetElementVertexColorCount() const - { - return m_fbxMesh->GetElementVertexColorCount(); - } - - bool FbxMeshWrapper::GetPolygonVertexNormal(int polyIndex, int vertexIndex, Vector3& normal) const - { - FbxVector4 fbxNormal; - bool hasVertexNormal = m_fbxMesh->GetPolygonVertexNormal(polyIndex, vertexIndex, fbxNormal); - normal = FbxTypeConverter::ToVector3(fbxNormal); - return hasVertexNormal; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMeshWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMeshWrapper.h deleted file mode 100644 index 80912d1a1b..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxMeshWrapper.h +++ /dev/null @@ -1,89 +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 -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxSkinWrapper; - class FbxBlendShapeWrapper; - class FbxVertexTangentWrapper; - class FbxVertexBitangentWrapper; - - class FbxMeshWrapper - { - public: - FbxMeshWrapper(FbxMesh* fbxMesh); - virtual ~FbxMeshWrapper(); - - virtual const char* GetName() const; - - virtual int GetDeformerCount() const; - virtual int GetDeformerCount(int type) const; - virtual AZStd::shared_ptr GetSkin(int index) const; - virtual AZStd::shared_ptr GetBlendShape(int index) const; - virtual bool GetMaterialIndices(FbxLayerElementArrayTemplate** lockableArray) const; - - // Vertex positions access - // Get the control points number - virtual int GetControlPointsCount() const; - - // Get the array of control points - virtual AZStd::vector GetControlPoints() const; - - // Polygon data accesses - // Get the polygon count of this mesh - virtual int GetPolygonCount() const; - - // Get the number of polygon vertices in a polygon - virtual int GetPolygonSize(int polygonIndex) const; - - // Get the array of polygon vertices (i.e: indices to the control points) - virtual int* GetPolygonVertices() const; - - // Gets the start index into the array returned by GetPolygonVertices() for the given polygon - virtual int GetPolygonVertexIndex(int polygonIndex) const; - - // Vertex colors and UV textures accesses - // Returns this geometry's UV element - virtual FbxUVWrapper GetElementUV(int index = 0); - - virtual int GetElementUVCount() const; - - virtual int GetElementTangentCount() const; - virtual int GetElementBitangentCount() const; - virtual FbxVertexTangentWrapper GetElementTangent(int index = 0); - virtual FbxVertexBitangentWrapper GetElementBitangent(int index = 0); - - // Returns this geometry's vertex color element - virtual FbxVertexColorWrapper GetElementVertexColor(int index = 0); - - virtual int GetElementVertexColorCount() const; - - // Get the normal associated with the specified polygon vertex - virtual bool GetPolygonVertexNormal(int polyIndex, int vertexIndex, Vector3& normal) const; - - protected: - FbxMeshWrapper() = default; - FbxMesh* m_fbxMesh; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxNodeWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxNodeWrapper.cpp deleted file mode 100644 index 92621c2ce4..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxNodeWrapper.cpp +++ /dev/null @@ -1,220 +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 -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxNodeWrapper::FbxNodeWrapper(FbxNode* fbxNode) - : NodeWrapper(fbxNode) - { - AZ_Assert(fbxNode, "Invalid FbxNode to initialize FbxNodeWrapper"); - } - - FbxNodeWrapper::~FbxNodeWrapper() - { - } - - - int FbxNodeWrapper::GetMaterialCount() const - { - return m_fbxNode->GetMaterialCount(); - } - - const char* FbxNodeWrapper::GetMaterialName(int index) const - { - if (index < GetMaterialCount()) - { - return m_fbxNode->GetMaterial(index)->GetName(); - } - AZ_Assert(index < GetMaterialCount(), "Invalid material index %d", index); - return nullptr; - } - - const std::shared_ptr FbxNodeWrapper::GetMesh() const - { - FbxMesh* mesh = m_fbxNode->GetMesh(); - return mesh ? std::shared_ptr(new FbxMeshWrapper(mesh)) : nullptr; - } - - const std::shared_ptr FbxNodeWrapper::FindProperty(const char* name) const - { - FbxProperty propertyName = m_fbxNode->FindProperty(name); - return std::shared_ptr(new FbxPropertyWrapper(&propertyName)); - } - - bool FbxNodeWrapper::IsBone() const - { - return (m_fbxNode->GetSkeleton() != nullptr); - } - - bool FbxNodeWrapper::IsMesh() const - { - return (m_fbxNode->GetMesh() != nullptr); - } - - const char* FbxNodeWrapper::GetName() const - { - return m_fbxNode->GetName(); - } - - AZ::u64 FbxNodeWrapper::GetUniqueId() const - { - return m_fbxNode->GetUniqueID(); - } - - SceneAPI::DataTypes::MatrixType FbxNodeWrapper::EvaluateGlobalTransform() - { - return FbxTypeConverter::ToTransform(m_fbxNode->EvaluateGlobalTransform()); - } - - Vector3 FbxNodeWrapper::EvaluateLocalTranslation() - { - return FbxTypeConverter::ToVector3(m_fbxNode->EvaluateLocalTranslation()); - } - - Vector3 FbxNodeWrapper::EvaluateLocalTranslation(FbxTimeWrapper& time) - { - return FbxTypeConverter::ToVector3(m_fbxNode->EvaluateLocalTranslation(time.m_fbxTime)); - } - - SceneAPI::DataTypes::MatrixType FbxNodeWrapper::EvaluateLocalTransform() - { - return FbxTypeConverter::ToTransform(m_fbxNode->EvaluateLocalTransform()); - } - - SceneAPI::DataTypes::MatrixType FbxNodeWrapper::EvaluateLocalTransform(FbxTimeWrapper& time) - { - return FbxTypeConverter::ToTransform(m_fbxNode->EvaluateLocalTransform(time.m_fbxTime)); - } - - Vector3 FbxNodeWrapper::EvaluateLocalRotation() - { - return FbxTypeConverter::ToVector3(m_fbxNode->EvaluateLocalTransform().GetR()); - } - - Vector3 FbxNodeWrapper::EvaluateLocalRotation(FbxTimeWrapper& time) - { - return FbxTypeConverter::ToVector3(m_fbxNode->EvaluateLocalTransform(time.m_fbxTime).GetR()); - } - - Vector3 FbxNodeWrapper::GetGeometricTranslation() const - { - return FbxTypeConverter::ToVector3(m_fbxNode->GetGeometricTranslation(FbxNode::eSourcePivot)); - } - - Vector3 FbxNodeWrapper::GetGeometricScaling() const - { - return FbxTypeConverter::ToVector3(m_fbxNode->GetGeometricScaling(FbxNode::eSourcePivot)); - } - - Vector3 FbxNodeWrapper::GetGeometricRotation() const - { - return FbxTypeConverter::ToVector3(m_fbxNode->GetGeometricRotation(FbxNode::eSourcePivot)); - } - - SceneAPI::DataTypes::MatrixType FbxNodeWrapper::GetGeometricTransform() const - { - FbxAMatrix geoTransform(m_fbxNode->GetGeometricTranslation(FbxNode::eSourcePivot), - m_fbxNode->GetGeometricRotation(FbxNode::eSourcePivot), m_fbxNode->GetGeometricScaling(FbxNode::eSourcePivot)); - return FbxTypeConverter::ToTransform(geoTransform); - } - - const AZStd::shared_ptr FbxNodeWrapper::GetLocalTranslationCurve(const AZStd::shared_ptr& layer, - CurveNodeComponent component) const - { - if (!layer) - { - return nullptr; - } - const char* componentString = nullptr; - switch (component) - { - case Component_X: - componentString = FBXSDK_CURVENODE_COMPONENT_X; - break; - case Component_Y: - componentString = FBXSDK_CURVENODE_COMPONENT_Y; - break; - case Component_Z: - componentString = FBXSDK_CURVENODE_COMPONENT_Z; - break; - default: - break; - } - // If there is available animation curve data of specified component/channel for translation, create and return a wrapped version of it. - return m_fbxNode->LclTranslation.GetCurve(layer->m_fbxAnimLayer, componentString) ? - AZStd::make_shared(m_fbxNode->LclTranslation.GetCurve(layer->m_fbxAnimLayer, componentString)) : nullptr; - } - - const AZStd::shared_ptr FbxNodeWrapper::GetLocalRotationCurve(const AZStd::shared_ptr& layer, - CurveNodeComponent component) const - { - if (!layer) - { - return nullptr; - } - const char* componentString = nullptr; - switch (component) - { - case Component_X: - componentString = FBXSDK_CURVENODE_COMPONENT_X; - break; - case Component_Y: - componentString = FBXSDK_CURVENODE_COMPONENT_Y; - break; - case Component_Z: - componentString = FBXSDK_CURVENODE_COMPONENT_Z; - break; - default: - break; - } - // If there is available animation curve data of specified component/channel for rotation, create and return a wrapped version of it. - return m_fbxNode->LclRotation.GetCurve(layer->m_fbxAnimLayer, componentString) ? - AZStd::make_shared(m_fbxNode->LclRotation.GetCurve(layer->m_fbxAnimLayer, componentString)) : nullptr; - } - - bool FbxNodeWrapper::IsAnimated() const - { - return FbxAnimUtilities::IsAnimated(m_fbxNode); - } - - int FbxNodeWrapper::GetChildCount() const - { - return m_fbxNode->GetChildCount(); - } - - const std::shared_ptr FbxNodeWrapper::GetChild(int childIndex) const - { - FbxNode* child = m_fbxNode->GetChild(childIndex); - AZ_Assert(child, "Cannot get child FbxNode at index %d", childIndex); - return child ? std::shared_ptr(new FbxNodeWrapper(child)) : nullptr; - } - - const std::shared_ptr FbxNodeWrapper::GetMaterial(int index) const - { - if (index < GetMaterialCount()) - { - return std::shared_ptr(new FbxMaterialWrapper(m_fbxNode->GetMaterial(index))); - } - AZ_Assert(index < GetMaterialCount(), "Invalid material index %d", index); - return nullptr; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxNodeWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxNodeWrapper.h deleted file mode 100644 index fceebc96d4..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxNodeWrapper.h +++ /dev/null @@ -1,69 +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 -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxMaterialWrapper; - class FbxAnimLayerWrapper; - class FbxAnimCurveWrapper; - - class FbxNodeWrapper : public SDKNode::NodeWrapper - { - public: - AZ_RTTI(FbxNodeWrapper, "{5F1C09D1-791C-41CA-94DB-D7DD2810C859}", SDKNode::NodeWrapper); - FbxNodeWrapper(FbxNode* fbxNode); - ~FbxNodeWrapper() override; - - int GetMaterialCount() const override; - virtual const char* GetMaterialName(int index) const; - virtual const std::shared_ptr GetMaterial(int index) const; - virtual const std::shared_ptr GetMesh() const; - virtual const std::shared_ptr FindProperty(const char* name) const; - virtual bool IsBone() const; - virtual bool IsMesh() const; - const char* GetName() const override; - AZ::u64 GetUniqueId() const override; - - virtual SceneAPI::DataTypes::MatrixType EvaluateGlobalTransform(); - virtual Vector3 EvaluateLocalTranslation(); - virtual Vector3 EvaluateLocalTranslation(FbxTimeWrapper& time); - virtual SceneAPI::DataTypes::MatrixType EvaluateLocalTransform(); - virtual SceneAPI::DataTypes::MatrixType EvaluateLocalTransform(FbxTimeWrapper& time); - virtual Vector3 EvaluateLocalRotation(); - virtual Vector3 EvaluateLocalRotation(FbxTimeWrapper& time); - virtual Vector3 GetGeometricTranslation() const; - virtual Vector3 GetGeometricScaling() const; - virtual Vector3 GetGeometricRotation() const; - virtual SceneAPI::DataTypes::MatrixType GetGeometricTransform() const; - virtual const AZStd::shared_ptr GetLocalTranslationCurve(const AZStd::shared_ptr& layer, CurveNodeComponent component) const; - virtual const AZStd::shared_ptr GetLocalRotationCurve(const AZStd::shared_ptr& layer, CurveNodeComponent component) const; - - int GetChildCount() const override; - const std::shared_ptr GetChild(int childIndex) const override; - - virtual bool IsAnimated() const; - - protected: - FbxNodeWrapper() = default; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxPropertyWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxPropertyWrapper.cpp deleted file mode 100644 index 3e2e149a8c..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxPropertyWrapper.cpp +++ /dev/null @@ -1,57 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxPropertyWrapper::FbxPropertyWrapper(FbxProperty* fbxProperty) - : m_fbxProperty(fbxProperty) - { - AZ_Assert(fbxProperty, "Invalid FbxProperty to initialize FbxPropertyWrapper"); - } - - FbxPropertyWrapper::~FbxPropertyWrapper() - { - m_fbxProperty = nullptr; - } - - bool FbxPropertyWrapper::IsValid() const - { - return m_fbxProperty->IsValid(); - } - - Vector3 FbxPropertyWrapper::GetFbxVector3() const - { - return FbxTypeConverter::ToVector3(m_fbxProperty->Get()); - } - - int FbxPropertyWrapper::GetFbxInt() const - { - return aznumeric_caster(m_fbxProperty->Get()); - } - - AZStd::string FbxPropertyWrapper::GetFbxString() const - { - return AZStd::string(m_fbxProperty->Get().Buffer()); - } - - const char* FbxPropertyWrapper::GetEnumValue(int index) const - { - return m_fbxProperty->GetEnumValue(index); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxPropertyWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxPropertyWrapper.h deleted file mode 100644 index ffa174b0a9..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxPropertyWrapper.h +++ /dev/null @@ -1,39 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxPropertyWrapper - { - public: - FbxPropertyWrapper(FbxProperty* fbxProperty); - virtual ~FbxPropertyWrapper(); - - virtual bool IsValid() const; - virtual Vector3 GetFbxVector3() const; - virtual int GetFbxInt() const; - virtual AZStd::string GetFbxString() const; - virtual const char* GetEnumValue(int index) const; - - protected: - FbxProperty* m_fbxProperty; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSceneWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSceneWrapper.cpp deleted file mode 100644 index 0a1b8b50d8..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSceneWrapper.cpp +++ /dev/null @@ -1,200 +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 -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxSceneWrapper::FbxSceneWrapper() - : SceneWrapperBase() - , m_fbxManager(nullptr) - , m_fbxImporter(nullptr) - , m_fbxIOSettings(nullptr) - { - } - - FbxSceneWrapper::FbxSceneWrapper(FbxScene* fbxScene) - : SceneWrapperBase(fbxScene) - , m_fbxManager(nullptr) - , m_fbxImporter(nullptr) - , m_fbxIOSettings(nullptr) - { - AZ_Assert(fbxScene, "FbxSceneWrapper should have a valid scene to initialize."); - } - - FbxSceneWrapper::~FbxSceneWrapper() - { - if (m_fbxScene) - { - m_fbxScene->Destroy(); - m_fbxScene = nullptr; - } - - if (m_fbxImporter) - { - m_fbxImporter->Destroy(); - m_fbxImporter = nullptr; - } - - if (m_fbxIOSettings) - { - m_fbxIOSettings->Destroy(); - m_fbxIOSettings = nullptr; - } - - if (m_fbxManager) - { - m_fbxManager->Destroy(); - m_fbxManager = nullptr; - } - } - - AZStd::shared_ptr FbxSceneWrapper::GetAxisSystem() const - { - return AZStd::make_shared(m_fbxScene->GetGlobalSettings().GetAxisSystem()); - } - - AZStd::shared_ptr FbxSceneWrapper::GetSystemUnit() const - { - return AZStd::make_shared(m_fbxScene->GetGlobalSettings().GetSystemUnit()); - } - - FbxTimeWrapper FbxSceneWrapper::GetTimeLineDefaultDuration() const - { - FbxTimeSpan timeSpan; - m_fbxScene->GetGlobalSettings().GetTimelineDefaultTimeSpan(timeSpan); - return FbxTimeWrapper(timeSpan.GetDuration()); - } - - const char* FbxSceneWrapper::GetLastSavedApplicationName() const - { - if (m_fbxScene->GetDocumentInfo()) - { - return m_fbxScene->GetDocumentInfo()->LastSaved_ApplicationName.Get().Buffer(); - } - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Cannot get valid document info from FbxScene"); - return nullptr; - } - - const char* FbxSceneWrapper::GetLastSavedApplicationVersion() const - { - if (m_fbxScene->GetDocumentInfo()) - { - return m_fbxScene->GetDocumentInfo()->LastSaved_ApplicationVersion.Get().Buffer(); - } - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Cannot get valid document info from FbxScene"); - return nullptr; - } - - const std::shared_ptr FbxSceneWrapper::GetRootNode() const - { - return std::shared_ptr(new FbxNodeWrapper(m_fbxScene->GetRootNode())); - } - - std::shared_ptr FbxSceneWrapper::GetRootNode() - { - return std::shared_ptr(new FbxNodeWrapper(m_fbxScene->GetRootNode())); - } - - int FbxSceneWrapper::GetAnimationStackCount() const - { - return m_fbxScene->GetSrcObjectCount(); - } - - const std::shared_ptr FbxSceneWrapper::GetAnimationStackAt(int index) const - { - return std::shared_ptr(new FbxAnimStackWrapper(FbxCast(m_fbxScene->GetSrcObject(index)))); - } - - bool FbxSceneWrapper::LoadSceneFromFile(const char* fileName) - { - AZ_TracePrintf(SceneAPI::Utilities::LogWindow, "FbxSceneWrapper::LoadSceneFromFile %s", fileName); - AZ_TraceContext("Filename", fileName); - - if (!m_fbxManager) - { - m_fbxManager = FbxManager::Create(); - if (!m_fbxManager) - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to create FbxManager"); - return false; - } - } - - if (!m_fbxIOSettings) - { - m_fbxIOSettings = FbxIOSettings::Create(m_fbxManager, IOSROOT); - if (!m_fbxIOSettings) - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to create FbxIOSettings"); - return false; - } - } - - m_fbxManager->SetIOSettings(m_fbxIOSettings); - - if (!m_fbxImporter) - { - m_fbxImporter = FbxImporter::Create(m_fbxManager, ""); - if (!m_fbxImporter) - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to create FbxImporter with FbxManager"); - return false; - } - } - - if (!m_fbxImporter->Initialize(fileName, -1, m_fbxManager->GetIOSettings())) - { - FbxString error = m_fbxImporter->GetStatus().GetErrorString(); - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to initialize FbxImporter with fbx file. Error returned: %s", error.Buffer()); - return false; - } - - // Create a new FBX scene so it can be populated by the imported file. - m_fbxScene = FbxScene::Create(m_fbxManager, s_defaultSceneName); - - if (!m_fbxScene) - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to create FbxScene"); - return false; - } - - if (!m_fbxImporter->Import(m_fbxScene)) - { - FbxString error = m_fbxImporter->GetStatus().GetErrorString(); - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to import FbxScene. Error returned: %s", error.Buffer()); - return false; - } - - return true; - } - - bool FbxSceneWrapper::LoadSceneFromFile(const AZStd::string& fileName) - { - return LoadSceneFromFile(fileName.c_str()); - } - - void FbxSceneWrapper::Clear() - { - if (m_fbxScene) - { - m_fbxScene->Clear(); - } - } - }//namespace FbxSDKWrapper - -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSceneWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSceneWrapper.h deleted file mode 100644 index f28ee6d7c3..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSceneWrapper.h +++ /dev/null @@ -1,62 +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. -* -*/ - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// -// FBX SDK Wrapper -// provides isolation between AUTODESK FBX SDK and FBX Serializer -// provides necessary APIs for FBX Serializer -// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxSceneWrapper : public SDKScene::SceneWrapperBase - { - public: - AZ_RTTI(FbxSceneWrapper, "{63637E50-BB26-4BE9-AECD-D1168AE2355B}", SDKScene::SceneWrapperBase); - FbxSceneWrapper(); - FbxSceneWrapper(fbxsdk::FbxScene* fbxScene); - ~FbxSceneWrapper(); - - bool LoadSceneFromFile(const char* fileName) override; - bool LoadSceneFromFile(const AZStd::string& fileName) override; - - virtual AZStd::shared_ptr GetSystemUnit() const; - virtual AZStd::shared_ptr GetAxisSystem() const; - virtual FbxTimeWrapper GetTimeLineDefaultDuration() const; - virtual const char* GetLastSavedApplicationName() const; - virtual const char* GetLastSavedApplicationVersion() const; - const std::shared_ptr GetRootNode() const override; - std::shared_ptr GetRootNode() override; - virtual int GetAnimationStackCount() const; - virtual const std::shared_ptr GetAnimationStackAt(int index) const; - void Clear() override; - - protected: - FbxManager* m_fbxManager; - FbxImporter* m_fbxImporter; - FbxIOSettings* m_fbxIOSettings; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSkinWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSkinWrapper.cpp deleted file mode 100644 index 04b90ed6a3..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSkinWrapper.cpp +++ /dev/null @@ -1,86 +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 -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxSkinWrapper::FbxSkinWrapper(FbxSkin* fbxSkin) - : m_fbxSkin(fbxSkin) - { - AZ_Assert(fbxSkin, "Invalid FbxSkin input to initialize FbxSkinWrapper"); - } - - FbxSkinWrapper::~FbxSkinWrapper() - { - m_fbxSkin = nullptr; - } - - const char* FbxSkinWrapper::GetName() const - { - return m_fbxSkin->GetName(); - } - - int FbxSkinWrapper::GetClusterCount() const - { - return m_fbxSkin->GetClusterCount(); - } - - int FbxSkinWrapper::GetClusterControlPointIndicesCount(int index) const - { - if (index < m_fbxSkin->GetClusterCount()) - { - return m_fbxSkin->GetCluster(index)->GetControlPointIndicesCount(); - } - AZ_Assert(index < m_fbxSkin->GetClusterCount(), "Invalid skin cluster index %d", index); - return 0; - } - - int FbxSkinWrapper::GetClusterControlPointIndex(int clusterIndex, int pointIndex) const - { - bool validIndex = clusterIndex < m_fbxSkin->GetClusterCount() && pointIndex < m_fbxSkin->GetCluster(clusterIndex)->GetControlPointIndicesCount(); - if (validIndex) - { - return m_fbxSkin->GetCluster(clusterIndex)->GetControlPointIndices()[pointIndex]; - } - AZ_Assert(validIndex, "Invalid skin cluster control point index at cluster index %d control point index %d", clusterIndex, pointIndex); - return -1; - } - - double FbxSkinWrapper::GetClusterControlPointWeight(int clusterIndex, int pointIndex) const - { - bool validIndex = clusterIndex < m_fbxSkin->GetClusterCount() && pointIndex < m_fbxSkin->GetCluster(clusterIndex)->GetControlPointIndicesCount(); - if (validIndex) - { - return m_fbxSkin->GetCluster(clusterIndex)->GetControlPointWeights()[pointIndex]; - } - AZ_Assert(validIndex, "Invalid skin cluster control point weight at cluster index %d control point index %d", clusterIndex, pointIndex); - return 0.0f; - } - - AZStd::shared_ptr FbxSkinWrapper::GetClusterLink(int index) const - { - if (index < m_fbxSkin->GetClusterCount()) - { - return AZStd::make_shared(m_fbxSkin->GetCluster(index)->GetLink()); - } - AZ_Assert(index < m_fbxSkin->GetClusterCount(), "Invalid skin cluster index %d", index); - return nullptr; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSkinWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSkinWrapper.h deleted file mode 100644 index 1d31248f49..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSkinWrapper.h +++ /dev/null @@ -1,42 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxNodeWrapper; - - class FbxSkinWrapper - { - public: - FbxSkinWrapper(FbxSkin* fbxSkin); - virtual ~FbxSkinWrapper(); - - virtual const char* GetName() const; - virtual int GetClusterCount() const; - virtual int GetClusterControlPointIndicesCount(int index) const; - virtual int GetClusterControlPointIndex(int clusterIndex, int pointIndex) const; - virtual double GetClusterControlPointWeight(int clusterIndex, int pointIndex) const; - virtual AZStd::shared_ptr GetClusterLink(int index) const; - - protected: - FbxSkinWrapper() = default; - FbxSkin* m_fbxSkin; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSystemUnitWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSystemUnitWrapper.cpp deleted file mode 100644 index 2171735c54..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSystemUnitWrapper.cpp +++ /dev/null @@ -1,108 +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 -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxSystemUnitWrapper::FbxSystemUnitWrapper(const FbxSystemUnit& fbxSystemUnit) - : m_fbxSystemUnit(fbxSystemUnit) - { - } - - FbxSystemUnitWrapper::Unit FbxSystemUnitWrapper::GetUnit() const - { - if (m_fbxSystemUnit == FbxSystemUnit::mm) - { - return mm; - } - if (m_fbxSystemUnit == FbxSystemUnit::dm) - { - return dm; - } - if (m_fbxSystemUnit == FbxSystemUnit::cm) - { - return cm; - } - if (m_fbxSystemUnit == FbxSystemUnit::m) - { - return m; - } - if (m_fbxSystemUnit == FbxSystemUnit::km) - { - return km; - } - if (m_fbxSystemUnit == FbxSystemUnit::Inch) - { - return inch; - } - if (m_fbxSystemUnit == FbxSystemUnit::Foot) - { - return foot; - } - if (m_fbxSystemUnit == FbxSystemUnit::Mile) - { - return mile; - } - if (m_fbxSystemUnit == FbxSystemUnit::Yard) - { - return yard; - } - AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unrecognized current unit type"); - return unknown; - } - - float FbxSystemUnitWrapper::GetConversionFactorTo(Unit to) - { - FbxSystemUnit targetUnit; - switch (to) - { - case mm: - targetUnit = FbxSystemUnit::mm; - break; - case dm: - targetUnit = FbxSystemUnit::dm; - break; - case cm: - targetUnit = FbxSystemUnit::cm; - break; - case m: - targetUnit = FbxSystemUnit::m; - break; - case km: - targetUnit = FbxSystemUnit::km; - break; - case inch: - targetUnit = FbxSystemUnit::Inch; - break; - case foot: - targetUnit = FbxSystemUnit::Foot; - break; - case mile: - targetUnit = FbxSystemUnit::Mile; - break; - case yard: - targetUnit = FbxSystemUnit::Yard; - break; - default: - AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unrecognized unit conversion target type"); - targetUnit = FbxSystemUnit::m; - } - return aznumeric_caster(m_fbxSystemUnit.GetConversionFactorTo(targetUnit)); - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSystemUnitWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSystemUnitWrapper.h deleted file mode 100644 index 8973a68694..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxSystemUnitWrapper.h +++ /dev/null @@ -1,49 +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 - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxSystemUnitWrapper - { - public: - enum Unit - { - mm, - dm, - cm, - m, - km, - inch, - foot, - mile, - yard, - unknown - }; - - FbxSystemUnitWrapper() = default; - FbxSystemUnitWrapper(const FbxSystemUnit& fbxSystemUnit); - virtual ~FbxSystemUnitWrapper() = default; - - virtual Unit GetUnit() const; - virtual float GetConversionFactorTo(Unit to); - - protected: - FbxSystemUnit m_fbxSystemUnit; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeSpanWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeSpanWrapper.cpp deleted file mode 100644 index 9e92a109e2..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeSpanWrapper.cpp +++ /dev/null @@ -1,45 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxTimeSpanWrapper::FbxTimeSpanWrapper(const FbxTimeSpan& fbxTimeSpan) - : m_fbxTimeSpan(fbxTimeSpan) - { - } - - FbxTimeWrapper FbxTimeSpanWrapper::GetStartTime() const - { - return FbxTimeWrapper(m_fbxTimeSpan.GetStart()); - } - - FbxTimeWrapper FbxTimeSpanWrapper::GetStopTime() const - { - return FbxTimeWrapper(m_fbxTimeSpan.GetStop()); - } - - double FbxTimeSpanWrapper::GetFrameRate() const - { - return FbxTimeWrapper(m_fbxTimeSpan.GetStart()).GetFrameRate(); - } - - int64_t FbxTimeSpanWrapper::GetNumFrames() const - { - return GetStopTime().GetFrameCount() - GetStartTime().GetFrameCount() + 1; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeSpanWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeSpanWrapper.h deleted file mode 100644 index 4dfdcc2da5..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeSpanWrapper.h +++ /dev/null @@ -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. -* -*/ - -#pragma once - -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxTimeSpanWrapper - { - public: - FbxTimeSpanWrapper(const FbxTimeSpan& fbxTimeSpan); - virtual ~FbxTimeSpanWrapper() = default; - - virtual FbxTimeWrapper GetStartTime() const; - virtual FbxTimeWrapper GetStopTime() const; - virtual double GetFrameRate() const; - int64_t GetNumFrames() const; - - protected: - FbxTimeSpan m_fbxTimeSpan; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeWrapper.cpp deleted file mode 100644 index 3b6c555fe1..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeWrapper.cpp +++ /dev/null @@ -1,76 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxTimeWrapper::FbxTimeWrapper() : m_fbxTime(FBXSDK_TIME_INFINITE) - { - } - - FbxTimeWrapper::FbxTimeWrapper(const FbxTime& fbxTime) : m_fbxTime(fbxTime) - { - } - - FbxTimeWrapper::~FbxTimeWrapper() - { - } - - void FbxTimeWrapper::SetFrame(int64_t frames, TimeMode timeMode) - { - m_fbxTime.SetFrame(static_cast(frames), GetFbxTimeMode(timeMode)); - } - - void FbxTimeWrapper::SetTime(double time) - { - m_fbxTime.SetSecondDouble(time); - } - - double FbxTimeWrapper::GetFrameRate() const - { - return m_fbxTime.GetFrameRate(m_fbxTime.GetGlobalTimeMode()); - } - - int64_t FbxTimeWrapper::GetFrameCount() const - { - return static_cast(m_fbxTime.GetFrameCount()); - } - - double FbxTimeWrapper::GetTime() const - { - return m_fbxTime.GetSecondDouble(); - } - - FbxTime::EMode FbxTimeWrapper::GetFbxTimeMode(TimeMode timeMode) const - { - switch (timeMode) - { - case frames60: - return FbxTime::eFrames60; - case frames30: - return FbxTime::eFrames30; - case frames24: - return FbxTime::eFrames24; - case defaultMode: - return FbxTime::eDefaultMode; - default: - AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unsupported frame rate"); - return FbxTime::eDefaultMode; - } - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeWrapper.h deleted file mode 100644 index 6f00670025..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTimeWrapper.h +++ /dev/null @@ -1,52 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxTimeWrapper - { - friend class FbxNodeWrapper; - friend class FbxAnimCurveWrapper; - public: - enum TimeMode - { - defaultMode, - frames60, - frames30, - frames24, - eModesCount - }; - - FbxTimeWrapper(); - FbxTimeWrapper(const FbxTime& fbxTime); - virtual ~FbxTimeWrapper(); - - virtual void SetFrame(int64_t frames, TimeMode timeMode = defaultMode); - virtual void SetTime(double time); - virtual double GetFrameRate() const; - virtual int64_t GetFrameCount() const; - virtual double GetTime() const; - - protected: - FbxTime::EMode GetFbxTimeMode(TimeMode timeMode) const; - - FbxTime m_fbxTime; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTypeConverter.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTypeConverter.cpp deleted file mode 100644 index 7bf1d719df..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTypeConverter.cpp +++ /dev/null @@ -1,64 +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 - -namespace AZ -{ - namespace FbxSDKWrapper - { - Vector2 FbxTypeConverter::ToVector2(const FbxVector2& vector) - { - return Vector2(static_cast(vector[0]), - static_cast(vector[1])); - } - - Vector3 FbxTypeConverter::ToVector3(const FbxVector4& vector) - { - // Note: FbxVector4[x] is of type FbxDouble and aznumeric_caster does not accept it as cast from type. - return Vector3(static_cast(vector[0]), - static_cast(vector[1]), - static_cast(vector[2])); - } - - SceneAPI::DataTypes::MatrixType FbxTypeConverter::ToTransform(const FbxAMatrix& matrix) - { - SceneAPI::DataTypes::MatrixType transform; - for (int row = 0; row < 3; ++row) - { - FbxVector4 line = matrix.GetColumn(row); - for (int column = 0; column < 4; ++column) - { - // Note: FbxVector4[x] is of type FbxDouble and aznumeric_caster does not accept it as cast from type. - transform.SetElement(row, column, static_cast(line[column])); - } - } - return transform; - } - - SceneAPI::DataTypes::MatrixType FbxTypeConverter::ToTransform(const FbxMatrix& matrix) - { - // This implementation ignores the last row, effectively assuming it to be (0,0,0,1) - SceneAPI::DataTypes::MatrixType transform; - for (int row = 0; row < 3; ++row) - { - FbxVector4 line = matrix.GetColumn(row); - for (int column = 0; column < 4; ++column) - { - // Note: FbxVector4[x] is of type FbxDouble and aznumeric_caster does not accept it as cast from type. - transform.SetElement(row, column, static_cast(line[column])); - } - } - return transform; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTypeConverter.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTypeConverter.h deleted file mode 100644 index b670bc3770..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxTypeConverter.h +++ /dev/null @@ -1,32 +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 -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxTypeConverter - { - public: - static Vector2 ToVector2(const FbxVector2& vector); - static Vector3 ToVector3(const FbxVector4& vector); - static SceneAPI::DataTypes::MatrixType ToTransform(const FbxAMatrix& matrix); - static SceneAPI::DataTypes::MatrixType ToTransform(const FbxMatrix& matrix); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxUVWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxUVWrapper.cpp deleted file mode 100644 index 8c7538b54e..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxUVWrapper.cpp +++ /dev/null @@ -1,53 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxUVWrapper::FbxUVWrapper(FbxGeometryElementUV* fbxUV) - : m_fbxUV(fbxUV) - { - AZ_Assert(fbxUV, "Invalid FbxGeometryElementUV to initialize FbxUVWrapper") - } - - FbxUVWrapper::~FbxUVWrapper() - { - m_fbxUV = nullptr; - } - - const char* FbxUVWrapper::GetName() const - { - if (m_fbxUV) - { - return m_fbxUV->GetName(); - } - return nullptr; - } - - Vector2 FbxUVWrapper::GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const - { - FbxVector2 uv; - FbxLayerElementUtilities::GetGeometryElement(uv, m_fbxUV, polygonIndex, polygonVertexIndex, controlPointIndex); - return FbxTypeConverter::ToVector2(uv); - } - - bool FbxUVWrapper::IsValid() const - { - return m_fbxUV != nullptr; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxUVWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxUVWrapper.h deleted file mode 100644 index 23bd77f4df..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxUVWrapper.h +++ /dev/null @@ -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. -* -*/ - -#pragma once - -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxUVWrapper - { - public: - FbxUVWrapper(FbxGeometryElementUV* fbxUV); - ~FbxUVWrapper(); - - Vector2 GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const; - const char* GetName() const; - bool IsValid() const; - - protected: - FbxGeometryElementUV* m_fbxUV; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexBitangentWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexBitangentWrapper.cpp deleted file mode 100644 index eeb3eb8f8e..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexBitangentWrapper.cpp +++ /dev/null @@ -1,58 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxVertexBitangentWrapper::FbxVertexBitangentWrapper(FbxGeometryElementBinormal* fbxBitangent) - : m_fbxBitangent(fbxBitangent) - { - AZ_Assert(fbxBitangent, "Invalid FbxGeometryElementBinormal to initialize FbxVertexBitangentWrapper") - } - - - FbxVertexBitangentWrapper::~FbxVertexBitangentWrapper() - { - m_fbxBitangent = nullptr; - } - - - const char* FbxVertexBitangentWrapper::GetName() const - { - if (m_fbxBitangent) - { - return m_fbxBitangent->GetName(); - } - return ""; - } - - - Vector3 FbxVertexBitangentWrapper::GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const - { - FbxVector4 bitangent; - FbxLayerElementUtilities::GetGeometryElement(bitangent, m_fbxBitangent, polygonIndex, polygonVertexIndex, controlPointIndex); - return FbxTypeConverter::ToVector3(bitangent); - } - - - bool FbxVertexBitangentWrapper::IsValid() const - { - return m_fbxBitangent != nullptr; - } - - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexBitangentWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexBitangentWrapper.h deleted file mode 100644 index 51a9e3c1d4..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexBitangentWrapper.h +++ /dev/null @@ -1,39 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - - class FbxVertexBitangentWrapper - { - public: - FbxVertexBitangentWrapper(FbxGeometryElementBinormal* fbxBitangent); - ~FbxVertexBitangentWrapper(); - - Vector3 GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const; - const char* GetName() const; - bool IsValid() const; - - protected: - FbxGeometryElementBinormal* m_fbxBitangent; - }; - - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexColorWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexColorWrapper.cpp deleted file mode 100644 index 9a3aaf1328..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexColorWrapper.cpp +++ /dev/null @@ -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 -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - FbxColorWrapper::FbxColorWrapper(FbxColor& fbxColor) - : m_fbxColor(fbxColor) - { - } - - float FbxColorWrapper::GetR() const - { - return aznumeric_caster(m_fbxColor.mRed); - } - - float FbxColorWrapper::GetG() const - { - return aznumeric_caster(m_fbxColor.mGreen); - } - - float FbxColorWrapper::GetB() const - { - return aznumeric_caster(m_fbxColor.mBlue); - } - - float FbxColorWrapper::GetAlpha() const - { - return aznumeric_caster(m_fbxColor.mAlpha); - } - - FbxVertexColorWrapper::FbxVertexColorWrapper(FbxGeometryElementVertexColor* fbxVertexColor) - : m_fbxVertexColor(fbxVertexColor) - { - AZ_Assert(m_fbxVertexColor, "Invalid FbxGeometryElementVertexColor to initialie FbxVertexColorWrapper"); - } - - FbxVertexColorWrapper::~FbxVertexColorWrapper() - { - m_fbxVertexColor = nullptr; - } - - const char* FbxVertexColorWrapper::GetName() const - { - if (m_fbxVertexColor) - { - return m_fbxVertexColor->GetName(); - } - return nullptr; - } - - FbxColorWrapper FbxVertexColorWrapper::GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const - { - FbxColor color; - FbxLayerElementUtilities::GetGeometryElement(color, m_fbxVertexColor, polygonIndex, polygonVertexIndex, controlPointIndex); - return FbxColorWrapper(color); - } - - bool FbxVertexColorWrapper::IsValid() const - { - return m_fbxVertexColor != nullptr; - } - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexColorWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexColorWrapper.h deleted file mode 100644 index af1c414acb..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexColorWrapper.h +++ /dev/null @@ -1,49 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxColorWrapper - { - public: - FbxColorWrapper(FbxColor& fbxColor); - float GetR() const; - float GetG() const; - float GetB() const; - float GetAlpha() const; - - protected: - FbxColor m_fbxColor; - }; - - class FbxVertexColorWrapper - { - public: - FbxVertexColorWrapper(FbxGeometryElementVertexColor* fbxVertexColor); - ~FbxVertexColorWrapper(); - - FbxColorWrapper GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const; - const char* GetName() const; - bool IsValid() const; - - protected: - FbxGeometryElementVertexColor* m_fbxVertexColor; - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexTangentWrapper.cpp b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexTangentWrapper.cpp deleted file mode 100644 index bdf2ebd44b..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexTangentWrapper.cpp +++ /dev/null @@ -1,59 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - - FbxVertexTangentWrapper::FbxVertexTangentWrapper(FbxGeometryElementTangent* fbxTangent) - : m_fbxTangent(fbxTangent) - { - AZ_Assert(fbxTangent, "Invalid FbxGeometryElementTangent to initialize FbxVertexTangentWrapper") - } - - - FbxVertexTangentWrapper::~FbxVertexTangentWrapper() - { - m_fbxTangent = nullptr; - } - - - const char* FbxVertexTangentWrapper::GetName() const - { - if (m_fbxTangent) - { - return m_fbxTangent->GetName(); - } - return ""; - } - - - Vector3 FbxVertexTangentWrapper::GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const - { - FbxVector4 tangent; - FbxLayerElementUtilities::GetGeometryElement(tangent, m_fbxTangent, polygonIndex, polygonVertexIndex, controlPointIndex); - return FbxTypeConverter::ToVector3(tangent); - } - - - bool FbxVertexTangentWrapper::IsValid() const - { - return m_fbxTangent != nullptr; - } - - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexTangentWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexTangentWrapper.h deleted file mode 100644 index 24cfebd3d5..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/FbxVertexTangentWrapper.h +++ /dev/null @@ -1,39 +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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - - class FbxVertexTangentWrapper - { - public: - FbxVertexTangentWrapper(FbxGeometryElementTangent* fbxTangent); - ~FbxVertexTangentWrapper(); - - Vector3 GetElementAt(int polygonIndex, int polygonVertexIndex, int controlPointIndex) const; - const char* GetName() const; - bool IsValid() const; - - protected: - FbxGeometryElementTangent* m_fbxTangent; - }; - - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxAnimStackWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxAnimStackWrapper.h deleted file mode 100644 index 122ab05ecb..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxAnimStackWrapper.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxAnimStackWrapper - : public FbxAnimStackWrapper - { - public: - MOCK_CONST_METHOD0(GetMemberCount, - int()); - MOCK_CONST_METHOD1(GetAnimationLayerAt, - FbxAnimLayer * (int index)); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxAxisSystemWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxAxisSystemWrapper.h deleted file mode 100644 index 7cd022ce50..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxAxisSystemWrapper.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxAxisSystemWrapper - : public FbxAxisSystemWrapper - { - public: - MOCK_CONST_METHOD1(GetUpVector, - UpVector(int)); - MOCK_METHOD1(CalculateConversionTransform, - Transform(UpVector)); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxMaterialWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxMaterialWrapper.h deleted file mode 100644 index ac19831be7..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxMaterialWrapper.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxMaterialWrapper - : public FbxMaterialWrapper - { - public: - MOCK_CONST_METHOD0(GetName, - std::string()); - MOCK_CONST_METHOD1(GetTextureFileName, - std::string(const char* textureType)); - MOCK_CONST_METHOD1(GetTextureFileName, - std::string(const std::string& textureType)); - MOCK_CONST_METHOD1(GetTextureFileName, - std::string(MaterialMapType textureType)); - MOCK_CONST_METHOD0(IsNoDraw, - bool()); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxMeshWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxMeshWrapper.h deleted file mode 100644 index c498d56426..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxMeshWrapper.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxMeshWrapper - : public FbxMeshWrapper - { - public: - MOCK_CONST_METHOD0(GetDeformerCount, - int()); - MOCK_CONST_METHOD1(GetSkin, - AZStd::shared_ptr(int index)); - MOCK_CONST_METHOD1(GetMaterialIndices, - bool(FbxLayerElementArrayTemplate**)); - MOCK_CONST_METHOD0(GetControlPointsCount, - int()); - MOCK_CONST_METHOD0(GetControlPoints, - AZStd::vector()); - MOCK_CONST_METHOD0(GetPolygonCount, - int()); - MOCK_CONST_METHOD1(GetPolygonSize, - int(int)); - MOCK_CONST_METHOD1(GetPolygonVertics, - int(int index)); - MOCK_CONST_METHOD1(GetPolygonVertexIndex, - int(int)); - MOCK_CONST_METHOD1(GetElementUV, - FbxUVWrapper(int)); - MOCK_CONST_METHOD0(GetElementUVCount, - int()); - MOCK_CONST_METHOD1(GetElementVertexColor, - FbxVertexColorWrapper(int)); - MOCK_CONST_METHOD0(GetElementVertexColorCount, - int()); - MOCK_CONST_METHOD3(GetPolygonVertexNormal, - bool(int, int, Vector3&)); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxNodeWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxNodeWrapper.h deleted file mode 100644 index aa02d633b0..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxNodeWrapper.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -/* -* 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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxNodeWrapper - : public FbxNodeWrapper - { - public: - MOCK_CONST_METHOD0(GetMaterialCount, - int()); - MOCK_CONST_METHOD1(GetMaterialName, - const char*(int index)); - MOCK_CONST_METHOD1(GetMaterial, - const std::shared_ptr(int index)); - MOCK_CONST_METHOD0(GetMesh, - const std::shared_ptr()); - MOCK_CONST_METHOD1(FindProperty, - const std::shared_ptr(const char* name)); - MOCK_CONST_METHOD0(IsBone, - bool()); - MOCK_CONST_METHOD0(GetName, - const char*()); - MOCK_METHOD0(EvaluateGlobalTransform, - Transform()); - MOCK_METHOD0(EvaluateLocalTranslation, - Vector3()); - MOCK_METHOD1(EvaluateLocalTranslation, - Vector3(FbxTimeWrapper& time)); - MOCK_METHOD0(EvaluateLocalTransform, - Transform()); - MOCK_METHOD1(EvaluateLocalTransform, - Transform(FbxTimeWrapper& time)); - MOCK_CONST_METHOD0(GetGeometricTranslation, - Vector3()); - MOCK_CONST_METHOD0(GetGeometricScaling, - Vector3()); - MOCK_CONST_METHOD0(GetGeometricRotation, - Vector3()); - MOCK_CONST_METHOD0(GetGeometricTransform, - Transform()); - MOCK_CONST_METHOD0(GetChildCount, - int()); - MOCK_CONST_METHOD1(GetChild, - const std::shared_ptr(int childIndex)); - MOCK_CONST_METHOD0(IsAnimated, - bool()); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxPropertyWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxPropertyWrapper.h deleted file mode 100644 index f49521f136..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxPropertyWrapper.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxPropertyWrapper - : public FbxPropertyWrapper - { - public: - MockFbxPropertyWrapper() - : FbxPropertyWrapper(new FbxProperty()) - { - } - MOCK_CONST_METHOD0(IsValid, - bool()); - MOCK_CONST_METHOD0(GetFbxVector4, - Vector4()); - MOCK_CONST_METHOD0(GetFbxInt, - FbxInt()); - MOCK_CONST_METHOD0(GetFbxString, - AZStd::string()); - MOCK_CONST_METHOD1(GetEnumValue, - const char*(int index)); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSceneWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSceneWrapper.h deleted file mode 100644 index 8f3d1903ac..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSceneWrapper.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -/* -* 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 -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxSceneWrapper - : public FbxSceneWrapper - { - public: - virtual ~MockFbxSceneWrapper() = default; - - MOCK_METHOD1(LoadSceneFromFile, - bool(const char* fileName)); - MOCK_METHOD1(LoadSceneFromFile, - bool(const std::string& fileName)); - MOCK_CONST_METHOD0(GetSystemUnit, - AZStd::shared_ptr()); - MOCK_CONST_METHOD0(GetAxisSystem, - AZStd::shared_ptr()); - MOCK_CONST_METHOD0(GetTimeLineDefaultDuration, - FbxTimeWrapper()); - MOCK_CONST_METHOD0(GetLastSavedApplicationName, - const char*()); - MOCK_CONST_METHOD0(GetLastSavedApplicationVersion, - const char*()); - MOCK_CONST_METHOD0(GetRootNode, - const std::shared_ptr()); - MOCK_METHOD0(GetRootNode, - std::shared_ptr()); - MOCK_CONST_METHOD0(GetAnimationStackCount, - int()); - MOCK_CONST_METHOD1(GetAnimationStackAt, - const std::shared_ptr(int index)); - MOCK_METHOD0(Clear, - void()); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSkinWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSkinWrapper.h deleted file mode 100644 index dd17a12146..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSkinWrapper.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxSkinWrapper - : public FbxSkinWrapper - { - public: - MOCK_CONST_METHOD0(GetName, - const char*()); - MOCK_CONST_METHOD0(GetClusterCount, - int()); - MOCK_CONST_METHOD1(GetClusterControlPointIndicesCount, - int(int index)); - MOCK_CONST_METHOD2(GetClusterControlPointIndices, - int(int clusterIndex, int pointIndex)); - MOCK_CONST_METHOD2(GetClusterControlPointWeights, - double(int clusterIndex, int pointIndex)); - MOCK_CONST_METHOD1(GetClusterLink, - AZStd::shared_ptr(int index)); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSystemUnitWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSystemUnitWrapper.h deleted file mode 100644 index 822a700edd..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxSystemUnitWrapper.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxSystemUnitWrapper - : public FbxSystemUnitWrapper - { - public: - MOCK_CONST_METHOD0(GetUnit, - Unit()); - MOCK_METHOD1(GetConversionFactorTo, - float(Unit)); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxTimeWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxTimeWrapper.h deleted file mode 100644 index 6ab6194261..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxTimeWrapper.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxTimeWrapper - : public FbxTimeWrapper - { - public: - MOCK_METHOD2(SetFrame, - void(int64_t, TimeMode)); - MOCK_CONST_METHOD0(GetFrameRate, - double()); - MOCK_CONST_METHOD0(GetFrameCount, - int64_t()); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxUVWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxUVWrapper.h deleted file mode 100644 index 73fb2af587..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxUVWrapper.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxUVWrapper - : public FbxUVWrapper - { - public: - MOCK_CONST_METHOD3(GetElementAt, - Vector2(int, int, int)); - MOCK_CONST_METHOD0(GetName, - const char*()); - MOCK_CONST_METHOD0(IsValid, - bool()); - }; - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxVertexColorWrapper.h b/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxVertexColorWrapper.h deleted file mode 100644 index a2291807f6..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/Mocks/MockFbxVertexColorWrapper.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -/* -* 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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class MockFbxVertexColorWrapper - : public FbxVertexColorWrapper - { - public: - MOCK_CONST_METHOD3(GetElementAt, - FbxColorWrapper(int, int, int)); - MOCK_CONST_METHOD0(GetName, - const char*()); - MOCK_CONST_METHOD0(IsValid, - bool()); - }; - - } // namespace FbxSDKWrapper -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/fbxsdkwrapper_files.cmake b/Code/Tools/SceneAPI/FbxSDKWrapper/fbxsdkwrapper_files.cmake deleted file mode 100644 index a3bb994725..0000000000 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/fbxsdkwrapper_files.cmake +++ /dev/null @@ -1,69 +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 - FbxSceneWrapper.cpp - FbxAnimStackWrapper.cpp - FbxAnimLayerWrapper.cpp - FbxAnimCurveNodeWrapper.cpp - FbxAnimCurveWrapper.cpp - FbxNodeWrapper.cpp - FbxMeshWrapper.cpp - FbxSkinWrapper.cpp - FbxPropertyWrapper.cpp - FbxMaterialWrapper.cpp - FbxTimeWrapper.cpp - FbxTimeSpanWrapper.cpp - FbxTypeConverter.cpp - FbxAxisSystemWrapper.cpp - FbxSystemUnitWrapper.cpp - FbxVertexColorWrapper.cpp - FbxVertexTangentWrapper.cpp - FbxVertexBitangentWrapper.cpp - FbxUVWrapper.cpp - FbxBlendShapeWrapper.cpp - FbxBlendShapeChannelWrapper.cpp - FbxLayerElementUtilities.inl - FbxSceneWrapper.h - FbxAnimStackWrapper.h - FbxAnimLayerWrapper.h - FbxAnimCurveNodeWrapper.h - FbxAnimCurveWrapper.h - FbxNodeWrapper.h - FbxMeshWrapper.h - FbxSkinWrapper.h - FbxPropertyWrapper.h - FbxMaterialWrapper.h - FbxTimeWrapper.h - FbxTimeSpanWrapper.h - FbxTypeConverter.h - FbxAxisSystemWrapper.h - FbxSystemUnitWrapper.h - FbxVertexColorWrapper.h - FbxVertexTangentWrapper.h - FbxVertexBitangentWrapper.h - FbxUVWrapper.h - FbxBlendShapeWrapper.h - FbxBlendShapeChannelWrapper.h - FbxLayerElementUtilities.h - Mocks/MockFbxAnimStackWrapper.h - Mocks/MockFbxAxisSystemWrapper.h - Mocks/MockFbxMaterialWrapper.h - Mocks/MockFbxMeshWrapper.h - Mocks/MockFbxNodeWrapper.h - Mocks/MockFbxPropertyWrapper.h - Mocks/MockFbxSceneWrapper.h - Mocks/MockFbxSkinWrapper.h - Mocks/MockFbxSystemUnitWrapper.h - Mocks/MockFbxTimeWrapper.h - Mocks/MockFbxUVWrapper.h - Mocks/MockFbxVertexColorWrapper.h -) diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/CMakeLists.txt b/Code/Tools/SceneAPI/FbxSceneBuilder/CMakeLists.txt index fdd6f8b755..144191b286 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/CMakeLists.txt +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/CMakeLists.txt @@ -31,9 +31,9 @@ ly_add_target( AZ::AzFramework PUBLIC AZ::AzToolsFramework - AZ::FbxSDKWrapper AZ::SceneCore AZ::SceneData + AZ::SDKWrapper ) ly_add_target( diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp index d567f1f9c5..3dc14814de 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp @@ -31,18 +31,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include namespace AZ { @@ -78,18 +66,6 @@ namespace AZ g_componentDescriptors.push_back(FbxSceneBuilder::FbxImporter::CreateDescriptor()); // Node and attribute importers - g_componentDescriptors.push_back(FbxAnimationImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxBlendShapeImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxBoneImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxColorStreamImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxMaterialImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxMeshImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxSkinImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxSkinWeightsImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxTransformImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxUvMapImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxTangentStreamImporter::CreateDescriptor()); - g_componentDescriptors.push_back(FbxBitangentStreamImporter::CreateDescriptor()); g_componentDescriptors.push_back(AssImpBitangentStreamImporter::CreateDescriptor()); g_componentDescriptors.push_back(AssImpColorStreamImporter::CreateDescriptor()); g_componentDescriptors.push_back(AssImpMaterialImporter::CreateDescriptor()); diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp index 650eb4c935..c7f7b4ad79 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.cpp @@ -20,13 +20,10 @@ #include #include #include -#include #include #include -#include +#include #include -#include -#include #include #include #include @@ -55,16 +52,7 @@ namespace AZ FbxImporter::FbxImporter() : m_sceneSystem(new FbxSceneSystem()) { - - if (m_useAssetImporterSDK) - { - m_sceneWrapper = AZStd::make_unique(); - } - else - { - m_sceneWrapper = AZStd::make_unique(); - } - + m_sceneWrapper = AZStd::make_unique(); BindToCall(&FbxImporter::ImportProcessing); } @@ -89,15 +77,13 @@ namespace AZ typedef AZStd::function ConvertFunc; ConvertFunc convertFunc; m_sceneSystem->Set(m_sceneWrapper.get()); - if (azrtti_istypeof(m_sceneWrapper.get())) + if (!azrtti_istypeof(m_sceneWrapper.get())) { - convertFunc = AZStd::bind(&FbxImporter::ConvertFbxSceneContext, this, AZStd::placeholders::_1); - } - else - { - convertFunc = AZStd::bind(&FbxImporter::ConvertFbxScene, this, AZStd::placeholders::_1); + return Events::ProcessingResult::Failure; } + convertFunc = AZStd::bind(&FbxImporter::ConvertFbxScene, this, AZStd::placeholders::_1); + if (convertFunc(context.GetScene())) { return Events::ProcessingResult::Success; @@ -108,175 +94,6 @@ namespace AZ } } - bool FbxImporter::ConvertFbxSceneContext(Containers::Scene& scene) const - { - std::shared_ptr fbxRoot = m_sceneWrapper->GetRootNode(); - if (!fbxRoot) - { - return false; - } - FbxSDKWrapper::FbxSceneWrapper* fbxSceneWrapper = azrtti_cast (m_sceneWrapper.get()); - int sign = 0; - FbxSDKWrapper::FbxAxisSystemWrapper::UpVector upVector = fbxSceneWrapper->GetAxisSystem()->GetUpVector(sign); - AZ_Assert(sign != 0, "sign failed to populate which is a failure in GetUpVector"); - - if (upVector == FbxSDKWrapper::FbxAxisSystemWrapper::UpVector::Z) - { - if (sign > 0) - { - scene.SetOriginalSceneOrientation(Containers::Scene::SceneOrientation::ZUp); - } - else - { - scene.SetOriginalSceneOrientation(Containers::Scene::SceneOrientation::NegZUp); - AZ_Assert(false, "Negative Z Up scene orientation is not a currently supported orientation."); - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Negative Z Up scene orientation is not a currently supported orientation."); - } - } - else if (upVector == FbxSDKWrapper::FbxAxisSystemWrapper::UpVector::Y) - { - if (sign > 0) - { - scene.SetOriginalSceneOrientation(Containers::Scene::SceneOrientation::YUp); - } - else - { - scene.SetOriginalSceneOrientation(Containers::Scene::SceneOrientation::NegYUp); - AZ_Assert(false, "Negative Y Up scene orientation is not a currently supported orientation."); - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Negative Y Up scene orientation is not a currently supported orientation."); - } - } - else if (upVector == FbxSDKWrapper::FbxAxisSystemWrapper::UpVector::X) - { - if (sign > 0) - { - scene.SetOriginalSceneOrientation(Containers::Scene::SceneOrientation::XUp); - AZ_Assert(false, "Positive X Up scene orientation is not a currently supported orientation."); - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Positive X Up scene orientation is not a currently supported orientation."); - } - else - { - scene.SetOriginalSceneOrientation(Containers::Scene::SceneOrientation::NegXUp); - AZ_Assert(false, "Negative X Up scene orientation is not a currently supported orientation."); - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Negative X Up scene orientation is not a currently supported orientation."); - } - } - - AZStd::queue nodes; - nodes.emplace(AZStd::move(fbxRoot), scene.GetGraph().GetRoot()); - - RenamedNodesMap nodeNameMap; - - while (!nodes.empty()) - { - FbxSceneBuilder::QueueNode& node = nodes.front(); - - AZ_Assert(node.m_node, "Empty fbx node queued"); - - if (!nodeNameMap.RegisterNode(node.m_node, scene.GetGraph(), node.m_parent)) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Failed to register fbx node in name table."); - continue; - } - AZStd::string nodeName = nodeNameMap.GetNodeName(node.m_node); - AZ_TraceContext("SceneAPI Node Name", nodeName); - - Containers::SceneGraph::NodeIndex newNode = scene.GetGraph().AddChild(node.m_parent, nodeName.c_str()); - AZ_Assert(newNode.IsValid(), "Failed to add node to scene graph"); - if (!newNode.IsValid()) - { - continue; - } - FbxNodeEncounteredContext sourceNodeEncountered(scene, newNode, *fbxSceneWrapper, *m_sceneSystem, nodeNameMap, *azrtti_cast(node.m_node.get())); - Events::ProcessingResultCombiner nodeResult; - nodeResult += Events::Process(sourceNodeEncountered); - - // If no importer created data, we still create an empty node that may eventually contain a transform - if (sourceNodeEncountered.m_createdData.empty()) - { - AZ_Assert(nodeResult.GetResult() != Events::ProcessingResult::Success, - "Importers returned success but no data was created"); - AZStd::shared_ptr nullData(nullptr); - sourceNodeEncountered.m_createdData.emplace_back(nullData); - nodeResult += Events::ProcessingResult::Success; - } - - // Create single node since only one piece of graph data was created - if (sourceNodeEncountered.m_createdData.size() == 1) - { - AZ_Assert(nodeResult.GetResult() != Events::ProcessingResult::Ignored, - "An importer created data, but did not return success"); - if (nodeResult.GetResult() == Events::ProcessingResult::Failure) - { - AZ_TracePrintf(Utilities::ErrorWindow, "One or more importers failed to create data."); - } - - SceneDataPopulatedContext dataProcessed(sourceNodeEncountered, - sourceNodeEncountered.m_createdData[0], nodeName.c_str()); - Events::ProcessingResult result = AddDataNodeWithContexts(dataProcessed); - if (result != Events::ProcessingResult::Failure) - { - newNode = dataProcessed.m_currentGraphPosition; - } - } - // Create an empty parent node and place all data under it. The remaining - // tree will be built off of this as the logical parent - else - { - AZ_Assert(nodeResult.GetResult() != Events::ProcessingResult::Ignored, - "%i importers created data, but did not return success", - sourceNodeEncountered.m_createdData.size()); - if (nodeResult.GetResult() == Events::ProcessingResult::Failure) - { - AZ_TracePrintf(Utilities::ErrorWindow, "One or more importers failed to create data."); - } - - size_t offset = nodeName.length(); - for (size_t i = 0; i < sourceNodeEncountered.m_createdData.size(); ++i) - { - nodeName += '_'; - nodeName += AZStd::to_string(aznumeric_cast(i + 1)); - - Containers::SceneGraph::NodeIndex subNode = - scene.GetGraph().AddChild(newNode, nodeName.c_str()); - AZ_Assert(subNode.IsValid(), "Failed to create new scene sub node"); - SceneDataPopulatedContext dataProcessed(sourceNodeEncountered, - sourceNodeEncountered.m_createdData[i], nodeName); - dataProcessed.m_currentGraphPosition = subNode; - AddDataNodeWithContexts(dataProcessed); - - // Remove the temporary extension again. - nodeName.erase(offset, nodeName.length() - offset); - } - } - - AZ_Assert(nodeResult.GetResult() == Events::ProcessingResult::Success, - "No importers successfully added processed scene data."); - AZ_Assert(newNode != node.m_parent, - "Failed to update current graph position during data processing."); - - int childCount = node.m_node->GetChildCount(); - for (int i = 0; i < childCount; ++i) - { - std::shared_ptr child = std::make_shared(node.m_node->GetChild(i)->GetFbxNode()); - if (child) - { - nodes.emplace(AZStd::move(child), newNode); - } - } - - nodes.pop(); - } - - Events::ProcessingResult result = Events::Process(scene, *fbxSceneWrapper, *m_sceneSystem, nodeNameMap); - if (result == Events::ProcessingResult::Failure) - { - return false; - } - - return true; - } - bool FbxImporter::ConvertFbxScene(Containers::Scene& scene) const { std::shared_ptr fbxRoot = m_sceneWrapper->GetRootNode(); diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h index 5bf9ab84c9..5e35bcddc3 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImporter.h @@ -45,13 +45,11 @@ namespace AZ Events::ProcessingResult ImportProcessing(Events::ImportEventContext& context); protected: - bool ConvertFbxSceneContext(Containers::Scene& scene) const; bool ConvertFbxScene(Containers::Scene& scene) const; void SanitizeNodeName(AZStd::string& nodeName) const; AZStd::unique_ptr m_sceneWrapper; AZStd::shared_ptr m_sceneSystem; - bool m_useAssetImporterSDK = true; }; } // namespace FbxSceneBuilder } // namespace SceneAPI diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxSceneSystem.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxSceneSystem.cpp index af79ab86d3..31abaf0311 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxSceneSystem.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxSceneSystem.cpp @@ -11,8 +11,8 @@ */ #include -#include #include +#include #include #include #include @@ -33,103 +33,86 @@ namespace AZ void FbxSceneSystem::Set(const SDKScene::SceneWrapperBase* fbxScene) { // Get unit conversion factor to meter. - if (azrtti_istypeof(fbxScene)) + if (!azrtti_istypeof(fbxScene)) { - const FbxSDKWrapper::FbxSceneWrapper* fbxSDKScene = azrtti_cast (fbxScene); - m_unitSizeInMeters = fbxSDKScene->GetSystemUnit()->GetConversionFactorTo(FbxSDKWrapper::FbxSystemUnitWrapper::m); - const FbxGlobalSettings& globalSettings = fbxSDKScene->GetFbxScene()->GetGlobalSettings(); - m_originalUnitSizeInMeters = static_cast(globalSettings.GetOriginalSystemUnit().GetConversionFactorTo(FbxSystemUnit::m)); - - int sign = 0; - FbxSDKWrapper::FbxAxisSystemWrapper::UpVector upVector = fbxSDKScene->GetAxisSystem()->GetUpVector(sign); - - if (upVector != FbxSDKWrapper::FbxAxisSystemWrapper::Z && upVector != FbxSDKWrapper::FbxAxisSystemWrapper::Unknown) - { - m_adjustTransform.reset(new DataTypes::MatrixType(fbxSDKScene->GetAxisSystem()->CalculateConversionTransform(FbxSDKWrapper::FbxAxisSystemWrapper::Z))); - m_adjustTransformInverse.reset(new DataTypes::MatrixType(m_adjustTransform->GetInverseFull())); - } + return; } - else if (azrtti_istypeof(fbxScene)) + + const AssImpSDKWrapper::AssImpSceneWrapper* assImpScene = azrtti_cast(fbxScene); + + // If either meta data piece is not available, the default of 1 will be used. + assImpScene->GetAssImpScene()->mMetaData->Get("UnitScaleFactor", m_unitSizeInMeters); + assImpScene->GetAssImpScene()->mMetaData->Get("OriginalUnitScaleFactor", m_originalUnitSizeInMeters); + + /* Conversion factor for converting from centimeters to meters */ + m_unitSizeInMeters = m_unitSizeInMeters * .01f; + + AZStd::pair upAxisAndSign = assImpScene->GetUpVectorAndSign(); + + if (upAxisAndSign.second <= 0) { - const AssImpSDKWrapper::AssImpSceneWrapper* assImpScene = azrtti_cast(fbxScene); + AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Negative scene orientation is not a currently supported orientation."); + return; + } - // If either meta data piece is not available, the default of 1 will be used. - assImpScene->GetAssImpScene()->mMetaData->Get("UnitScaleFactor", m_unitSizeInMeters); - assImpScene->GetAssImpScene()->mMetaData->Get("OriginalUnitScaleFactor", m_originalUnitSizeInMeters); + AZStd::pair frontAxisAndSign = assImpScene->GetFrontVectorAndSign(); - /* Conversion factor for converting from centimeters to meters */ - m_unitSizeInMeters = m_unitSizeInMeters *.01f; + if (upAxisAndSign.first != AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::Z && + upAxisAndSign.first != AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::Unknown) + { + AZ::Matrix4x4 currentCoordMatrix = AZ::Matrix4x4::CreateIdentity(); + //(UpVector = +Z, FrontVector = +Y, CoordSystem = -X(RightHanded)) + AZ::Matrix4x4 targetCoordMatrix = AZ::Matrix4x4::CreateFromColumns( + AZ::Vector4(-1, 0, 0, 0), + AZ::Vector4(0, 0, 1, 0), + AZ::Vector4(0, 1, 0, 0), + AZ::Vector4(0, 0, 0, 1)); - AZStd::pair upAxisAndSign = assImpScene->GetUpVectorAndSign(); - - if (upAxisAndSign.second <= 0) + switch (upAxisAndSign.first) { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Negative scene orientation is not a currently supported orientation."); - return; - } - - AZStd::pair frontAxisAndSign = assImpScene->GetFrontVectorAndSign(); - - - if (upAxisAndSign.first != AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::Z && - upAxisAndSign.first != AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::Unknown) - { - AZ::Matrix4x4 currentCoordMatrix = AZ::Matrix4x4::CreateIdentity(); - //(UpVector = +Z, FrontVector = +Y, CoordSystem = -X(RightHanded)) - AZ::Matrix4x4 targetCoordMatrix = AZ::Matrix4x4::CreateFromColumns( - AZ::Vector4(-1, 0, 0, 0), - AZ::Vector4(0, 0, 1, 0), - AZ::Vector4(0, 1, 0, 0), - AZ::Vector4(0, 0, 0, 1)); - - switch (upAxisAndSign.first) + case AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::X: { + if (frontAxisAndSign.second == 1) { - case AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::X: + currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( + AZ::Vector4(0, -1, 0, 0), + AZ::Vector4(1, 0, 0, 0), + AZ::Vector4(0, 0, 1, 0), + AZ::Vector4(0, 0, 0, 1)); + } + else { - if (frontAxisAndSign.second == 1) - { - currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( - AZ::Vector4(0, -1, 0, 0), - AZ::Vector4(1, 0, 0, 0), - AZ::Vector4(0, 0, 1, 0), - AZ::Vector4(0, 0, 0, 1)); - } - else - { - currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( - AZ::Vector4(0, 1, 0, 0), - AZ::Vector4(1, 0, 0, 0), - AZ::Vector4(0, 0, -1, 0), - AZ::Vector4(0, 0, 0, 1)); - } + currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( + AZ::Vector4(0, 1, 0, 0), + AZ::Vector4(1, 0, 0, 0), + AZ::Vector4(0, 0, -1, 0), + AZ::Vector4(0, 0, 0, 1)); } - break; - case AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::Y: - { - if (frontAxisAndSign.second == 1) - { - currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( - AZ::Vector4(1, 0, 0, 0), - AZ::Vector4(0, 1, 0, 0), - AZ::Vector4(0, 0, 1, 0), - AZ::Vector4(0, 0, 0, 1)); - } - else - { - currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( - AZ::Vector4(-1, 0, 0, 0), - AZ::Vector4(0, 1, 0, 0), - AZ::Vector4(0, 0, -1, 0), - AZ::Vector4(0, 0, 0, 1)); - } - } - break; - } - AZ::Matrix4x4 inverse = currentCoordMatrix.GetInverseTransform(); - AZ::Matrix4x4 adjustmatrix = targetCoordMatrix * currentCoordMatrix.GetInverseTransform(); - m_adjustTransform.reset(new DataTypes::MatrixType(AssImpSDKWrapper::AssImpTypeConverter::ToTransform(adjustmatrix))); - m_adjustTransformInverse.reset(new DataTypes::MatrixType(m_adjustTransform->GetInverseFull())); } + break; + case AssImpSDKWrapper::AssImpSceneWrapper::AxisVector::Y: { + if (frontAxisAndSign.second == 1) + { + currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( + AZ::Vector4(1, 0, 0, 0), + AZ::Vector4(0, 1, 0, 0), + AZ::Vector4(0, 0, 1, 0), + AZ::Vector4(0, 0, 0, 1)); + } + else + { + currentCoordMatrix = AZ::Matrix4x4::CreateFromColumns( + AZ::Vector4(-1, 0, 0, 0), + AZ::Vector4(0, 1, 0, 0), + AZ::Vector4(0, 0, -1, 0), + AZ::Vector4(0, 0, 0, 1)); + } + } + break; + } + AZ::Matrix4x4 inverse = currentCoordMatrix.GetInverseTransform(); + AZ::Matrix4x4 adjustmatrix = targetCoordMatrix * currentCoordMatrix.GetInverseTransform(); + m_adjustTransform.reset(new DataTypes::MatrixType(AssImpSDKWrapper::AssImpTypeConverter::ToTransform(adjustmatrix))); + m_adjustTransformInverse.reset(new DataTypes::MatrixType(m_adjustTransform->GetInverseFull())); } } diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/ImportContexts/FbxImportContexts.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/ImportContexts/FbxImportContexts.cpp deleted file mode 100644 index bbb1ac12ea..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/ImportContexts/FbxImportContexts.cpp +++ /dev/null @@ -1,115 +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 -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxImportContext::FbxImportContext(const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, FbxSDKWrapper::FbxNodeWrapper& sourceNode) - : m_sourceScene(sourceScene) - , m_sourceSceneSystem(sourceSceneSystem) - , m_sourceNode(sourceNode) - { - } - - FbxNodeEncounteredContext::FbxNodeEncounteredContext(Containers::Scene& scene, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode) - : FbxImportContext(sourceScene, sourceSceneSystem, sourceNode) - , NodeEncounteredContext(scene, currentGraphPosition, nodeNameMap) - { - } - - FbxNodeEncounteredContext::FbxNodeEncounteredContext( - Events::ImportEventContext& parent, Containers::SceneGraph::NodeIndex currentGraphPosition, - const FbxSDKWrapper::FbxSceneWrapper& sourceScene, const FbxSceneSystem& sourceSceneSystem, - RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode) - : FbxImportContext(sourceScene, sourceSceneSystem, sourceNode) - , NodeEncounteredContext(parent.GetScene(), currentGraphPosition, nodeNameMap) - { - } - - SceneDataPopulatedContext::SceneDataPopulatedContext(FbxNodeEncounteredContext& parent, - const AZStd::shared_ptr& graphData, const AZStd::string& dataName) - : FbxImportContext(parent.m_sourceScene, parent.m_sourceSceneSystem, parent.m_sourceNode) - , SceneDataPopulatedContextBase(parent, graphData, dataName) - { - } - - SceneDataPopulatedContext::SceneDataPopulatedContext(Containers::Scene& scene, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode, - const AZStd::shared_ptr& nodeData, const AZStd::string& dataName) - : FbxImportContext(sourceScene, sourceSceneSystem, sourceNode) - , SceneDataPopulatedContextBase(scene, currentGraphPosition, nodeNameMap, nodeData, dataName) - { - } - - SceneNodeAppendedContext::SceneNodeAppendedContext(SceneDataPopulatedContext& parent, - Containers::SceneGraph::NodeIndex newIndex) - : FbxImportContext(parent.m_sourceScene, parent.m_sourceSceneSystem, parent.m_sourceNode) - , SceneNodeAppendedContextBase(parent.m_scene, newIndex, parent.m_nodeNameMap) - { - } - - SceneNodeAppendedContext::SceneNodeAppendedContext(Containers::Scene& scene, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode) - : FbxImportContext(sourceScene, sourceSceneSystem, sourceNode) - , SceneNodeAppendedContextBase(scene, currentGraphPosition, nodeNameMap) - { - } - - SceneAttributeDataPopulatedContext::SceneAttributeDataPopulatedContext(SceneNodeAppendedContext& parent, - const AZStd::shared_ptr& nodeData, - const Containers::SceneGraph::NodeIndex attributeNodeIndex, const AZStd::string& dataName) - : FbxImportContext(parent.m_sourceScene, parent.m_sourceSceneSystem, parent.m_sourceNode) - , SceneAttributeDataPopulatedContextBase(parent, nodeData, attributeNodeIndex, dataName) - { - } - - SceneAttributeNodeAppendedContext::SceneAttributeNodeAppendedContext( - SceneAttributeDataPopulatedContext& parent, Containers::SceneGraph::NodeIndex newIndex) - : FbxImportContext(parent.m_sourceScene, parent.m_sourceSceneSystem, parent.m_sourceNode) - , SceneAttributeNodeAppendedContextBase(parent, newIndex) - { - } - - SceneNodeAddedAttributesContext::SceneNodeAddedAttributesContext(SceneNodeAppendedContext& parent) - : FbxImportContext(parent.m_sourceScene, parent.m_sourceSceneSystem, parent.m_sourceNode) - , SceneNodeAddedAttributesContextBase(parent) - { - } - - SceneNodeFinalizeContext::SceneNodeFinalizeContext(SceneNodeAddedAttributesContext& parent) - : FbxImportContext(parent.m_sourceScene, parent.m_sourceSceneSystem, parent.m_sourceNode) - , SceneNodeFinalizeContextBase(parent) - { - } - - FinalizeSceneContext::FinalizeSceneContext(Containers::Scene& scene, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap) - : FinalizeSceneContextBase(scene, nodeNameMap) - , m_sourceScene(sourceScene) - , m_sourceSceneSystem(sourceSceneSystem) - { - } - } // namespace SceneAPI - } // namespace FbxSceneBuilder -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/ImportContexts/FbxImportContexts.h b/Code/Tools/SceneAPI/FbxSceneBuilder/ImportContexts/FbxImportContexts.h deleted file mode 100644 index a3bc3e0b45..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/ImportContexts/FbxImportContexts.h +++ /dev/null @@ -1,184 +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 -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxSceneWrapper; - class FbxNodeWrapper; - } - - namespace SceneAPI - { - class FbxSceneSystem; - - namespace FbxSceneBuilder - { - class RenamedNodesMap; - - // FbxImportContext - // Base structure containing common data needed for all import contexts - // Member Variables: - // m_sourceScene - Basic scene data extracted from the FBX Scene. Used to - // transform data. - // m_sourceNode - FBX node being used for data processing. - struct FbxImportContext - { - AZ_RTTI(FbxImportContext, "{C8D665D5-E871-41AD-90E7-C84CF6842BCF}"); - - FbxImportContext(const FbxSDKWrapper::FbxSceneWrapper& sourceScene, const FbxSceneSystem& sourceSceneSystem, - FbxSDKWrapper::FbxNodeWrapper& sourceNode); - - const FbxSDKWrapper::FbxSceneWrapper& m_sourceScene; - const FbxSceneSystem& m_sourceSceneSystem; // Needed for unit and axis conversion - FbxSDKWrapper::FbxNodeWrapper& m_sourceNode; - }; - - // FbxNodeEncounteredContext - // Context pushed to indicate that a new FBX Node has been found and any - // importers that have means to process the contained data should do so - // Member Variables: - // m_createdData - out container that importers must add their created data - // to. - struct FbxNodeEncounteredContext - : public FbxImportContext - , public NodeEncounteredContext - { - AZ_RTTI(FbxNodeEncounteredContext, "{BE21E324-6745-41FD-A79C-A6CA7AB15A7A}", FbxImportContext, NodeEncounteredContext); - - FbxNodeEncounteredContext(Containers::Scene& scene, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode); - - FbxNodeEncounteredContext(Events::ImportEventContext& parent, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode); - }; - - // SceneDataPopulatedContext - // Context pushed to indicate that a piece of scene data has been fully - // processed and any importers that wish to place it within the scene graph - // may now do so. This may be triggered by processing a FbxNodeEncounteredContext - // (for base data, e.g. bones, meshes) or from a SceneNodeAppendedContext - // (for attribute data, e.g. UV Maps, materials) - // Member Variables: - // m_graphData - the piece of data that should be inserted in the graph - // m_dataName - the name that should be used as the basis for the scene node - // name - // m_isAttribute - Indicates whether the graph data is an attribute - struct SceneDataPopulatedContext - : public FbxImportContext - , public SceneDataPopulatedContextBase - { - AZ_RTTI(SceneDataPopulatedContext, "{DF17306C-FE28-4BEB-9CF0-88CF0472B8A8}", FbxImportContext, SceneDataPopulatedContextBase); - - SceneDataPopulatedContext(FbxNodeEncounteredContext& parent, - const AZStd::shared_ptr& nodeData, - const AZStd::string& dataName); - - SceneDataPopulatedContext(Containers::Scene& scene, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode, - const AZStd::shared_ptr& nodeData, const AZStd::string& dataName); - }; - - // SceneNodeAppendedContext - // Context pushed to indicate that data has been added to the scene graph. - // Generally created due to the insertion of a node during SceneDataPopulatedContext - // processing. - struct SceneNodeAppendedContext - : public FbxImportContext - , public SceneNodeAppendedContextBase - { - AZ_RTTI(SceneNodeAppendedContext, "{72C1C37A-C6ED-4CB7-B929-DA03AA44131C}", FbxImportContext, SceneNodeAppendedContextBase); - - SceneNodeAppendedContext(SceneDataPopulatedContext& parent, Containers::SceneGraph::NodeIndex newIndex); - SceneNodeAppendedContext(Containers::Scene& scene, - Containers::SceneGraph::NodeIndex currentGraphPosition, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap, FbxSDKWrapper::FbxNodeWrapper& sourceNode); - }; - - // SceneAttributeDataPopulatedContext - // Context pushed to indicate that attribute data has been found and processed - struct SceneAttributeDataPopulatedContext - : public FbxImportContext - , public SceneAttributeDataPopulatedContextBase - { - AZ_RTTI(SceneAttributeDataPopulatedContext, "{93E67C26-5A40-4385-8189-947A626E3CDA}", FbxImportContext, SceneAttributeDataPopulatedContextBase); - - SceneAttributeDataPopulatedContext(SceneNodeAppendedContext& parent, - const AZStd::shared_ptr& nodeData, - const Containers::SceneGraph::NodeIndex attributeNodeIndex, const AZStd::string& dataName); - }; - - // SceneAttributeNodeAppendedContext - // Context pushed to indicate that an attribute node has been added to the scene graph - struct SceneAttributeNodeAppendedContext - : public FbxImportContext - , public SceneAttributeNodeAppendedContextBase - { - AZ_RTTI(SceneAttributeNodeAppendedContext, "{C0DD4F39-5C61-4CA0-96C5-9EA3AC40D98B}", FbxImportContext, SceneAttributeNodeAppendedContextBase); - - SceneAttributeNodeAppendedContext(SceneAttributeDataPopulatedContext& parent, - Containers::SceneGraph::NodeIndex newIndex); - }; - - // SceneNodeAddedAttributesContext - // Context pushed to indicate that all attribute processors have completed their - // work for a specific data node. - struct SceneNodeAddedAttributesContext - : public FbxImportContext - , public SceneNodeAddedAttributesContextBase - { - AZ_RTTI(SceneNodeAddedAttributesContext, "{1601900C-5109-4D37-83F1-22317A4D7C78}", FbxImportContext, SceneNodeAddedAttributesContextBase); - - SceneNodeAddedAttributesContext(SceneNodeAppendedContext& parent); - }; - - // SceneNodeFinalizeContext - // Context pushed last after all other contexts for a scene node to allow any - // post-processing needed for an importer. - struct SceneNodeFinalizeContext - : public FbxImportContext - , public SceneNodeFinalizeContextBase - { - AZ_RTTI(SceneNodeFinalizeContext, "{D1D9839A-EA48-425D-BB7A-A9AEA65B8B7A}", FbxImportContext, SceneNodeFinalizeContextBase); - - SceneNodeFinalizeContext(SceneNodeAddedAttributesContext& parent); - }; - - // FinalizeSceneContext - // Context pushed after the scene has been fully created. This can be used to finalize pending work - // such as resolving named links. - struct FinalizeSceneContext - : public FinalizeSceneContextBase - { - AZ_RTTI(FinalizeSceneContext, "{C8D665D5-E871-41AD-90E7-C84CF6842BCF}", FinalizeSceneContextBase); - - FinalizeSceneContext(Containers::Scene& scene, const FbxSDKWrapper::FbxSceneWrapper& sourceScene, - const FbxSceneSystem& sourceSceneSystem, RenamedNodesMap& nodeNameMap); - - const FbxSDKWrapper::FbxSceneWrapper& m_sourceScene; - const FbxSceneSystem& m_sourceSceneSystem; // Needed for unit and axis conversion - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ - diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp index e456f2dbab..dd92e6bb8b 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.cpp @@ -22,11 +22,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.h index 3c06153d04..e27264c171 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.h +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpAnimationImporter.h @@ -12,8 +12,6 @@ #pragma once -#include -#include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBitangentStreamImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBitangentStreamImporter.cpp index b5bcab31e6..c2b1f20035 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBitangentStreamImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBitangentStreamImporter.cpp @@ -14,13 +14,14 @@ #include #include #include -#include +#include #include #include #include #include #include #include +#include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBlendShapeImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBlendShapeImporter.cpp index 404a5857c1..c0399329d3 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBlendShapeImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBlendShapeImporter.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBoneImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBoneImporter.cpp index 0dd525c058..4467d6933b 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBoneImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpBoneImporter.cpp @@ -17,8 +17,7 @@ #include #include #include -#include -#include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpColorStreamImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpColorStreamImporter.cpp index 55c14fd5d7..7ebdb55363 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpColorStreamImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpColorStreamImporter.cpp @@ -14,13 +14,14 @@ #include #include #include -#include +#include #include #include #include #include #include #include +#include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpMaterialImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpMaterialImporter.cpp index a63c2406f4..e314804ea1 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpMaterialImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpMaterialImporter.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpSkinWeightsImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpSkinWeightsImporter.cpp index bcfbaa9624..abcbf10b4a 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpSkinWeightsImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpSkinWeightsImporter.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTangentStreamImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTangentStreamImporter.cpp index 88177a04a0..992a6a6ab1 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTangentStreamImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTangentStreamImporter.cpp @@ -14,13 +14,14 @@ #include #include #include -#include +#include #include #include #include #include #include #include +#include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp index 90030a3058..84c0e3e18c 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp index 65e7c00d74..f5f47b233d 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp @@ -16,12 +16,13 @@ #include #include #include -#include +#include #include #include #include #include #include +#include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxAnimationImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxAnimationImporter.cpp deleted file mode 100644 index 8122b68e3d..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxAnimationImporter.cpp +++ /dev/null @@ -1,215 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - const char* FbxAnimationImporter::s_animationNodeName = "animation"; - const FbxSDKWrapper::FbxTimeWrapper::TimeMode FbxAnimationImporter::s_defaultTimeMode = - FbxSDKWrapper::FbxTimeWrapper::frames30; - - FbxAnimationImporter::FbxAnimationImporter() - { - BindToCall(&FbxAnimationImporter::ImportAnimation); - } - - void FbxAnimationImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxAnimationImporter::ImportAnimation(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Animation"); - - // Add check for animation layers at the scene level. - - if (context.m_sourceScene.GetAnimationStackCount() <= 0) - { - return Events::ProcessingResult::Ignored; - } - - if (context.m_sourceNode.IsMesh()) - { - return ImportBlendShapeAnimation(context); - } - - if (!context.m_sourceNode.IsBone()) - { - return Events::ProcessingResult::Ignored; - } - - AZStd::string nodeName = s_animationNodeName; - RenamedNodesMap::SanitizeNodeName(nodeName, context.m_scene.GetGraph(), context.m_currentGraphPosition); - AZ_TraceContext("Animation node name", nodeName); - - auto animStackWrapper = context.m_sourceScene.GetAnimationStackAt(0); - const FbxSDKWrapper::FbxTimeWrapper startTime = animStackWrapper->GetLocalTimeSpan().GetStartTime(); - const double frameRate = startTime.GetFrameRate(); - - if (frameRate == 0.0) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Scene has a 0 framerate. Animation cannot be processed without timing information."); - return Events::ProcessingResult::Failure; - } - - const int64_t startFrame = startTime.GetFrameCount(); - const int64_t numFrames = animStackWrapper->GetLocalTimeSpan().GetNumFrames(); - - AZStd::shared_ptr createdAnimationData = - AZStd::make_shared(); - createdAnimationData->ReserveKeyFrames(numFrames); - createdAnimationData->SetTimeStepBetweenFrames(1.0 / frameRate); - - { - FbxSDKWrapper::FbxTimeWrapper currTime = startTime; - for (int64_t currFrame = startFrame; currFrame < startFrame + numFrames; currFrame++) - { - currTime.SetFrame(currFrame); - - SceneAPI::DataTypes::MatrixType animTransform = context.m_sourceNode.EvaluateLocalTransform(currTime); - context.m_sourceSceneSystem.SwapTransformForUpAxis(animTransform); - context.m_sourceSceneSystem.ConvertBoneUnit(animTransform); - - createdAnimationData->AddKeyFrame(animTransform); - } - - AZ_Assert(createdAnimationData->GetKeyFrameCount() == numFrames, "The imported animation data created does not have the same number of keyframes as the FBX data."); - } - - Containers::SceneGraph::NodeIndex addNode = context.m_scene.GetGraph().AddChild( - context.m_currentGraphPosition, nodeName.c_str(), AZStd::move(createdAnimationData)); - context.m_scene.GetGraph().MakeEndPoint(addNode); - - return Events::ProcessingResult::Success; - } - - Events::ProcessingResult FbxAnimationImporter::ImportBlendShapeAnimation(SceneNodeAppendedContext& context) - { - FbxNode * node = context.m_sourceNode.GetFbxNode(); - FbxMesh * pMesh = node->GetMesh(); - if (!pMesh) - { - return Events::ProcessingResult::Ignored; - } - - int deformerCount = pMesh->GetDeformerCount(FbxDeformer::eBlendShape); - int blendShapeIndex = -1; - AZStd::string nodeName; - AZStd::string animNodeName; - for (int deformerIndex = 0; deformerIndex < deformerCount; ++deformerIndex) - { - //we are assuming 1 anim stack (single animation clip export) - const FbxBlendShape* pDeformer = (FbxBlendShape*)pMesh->GetDeformer(deformerIndex, FbxDeformer::eBlendShape); - if (!pDeformer) - { - continue; - } - blendShapeIndex++; - int blendShapeChannelCount = pDeformer->GetBlendShapeChannelCount(); - auto animStackWrapper = context.m_sourceScene.GetAnimationStackAt(0); - - const FbxSDKWrapper::FbxTimeWrapper startTime = animStackWrapper->GetLocalTimeSpan().GetStartTime(); - const double frameRate = startTime.GetFrameRate(); - - if (frameRate == 0.0) - { - AZ_TracePrintf("Animation_Warning", "Scene has a 0 framerate. Animation cannot be processed without timing information."); - return Events::ProcessingResult::Failure; - } - - const int64_t startFrame = startTime.GetFrameCount(); - const int64_t numFrames = animStackWrapper->GetLocalTimeSpan().GetNumFrames(); - - const int layerCount = animStackWrapper->GetAnimationLayerCount(); - - for (int blendShapeChannelIdx = 0; blendShapeChannelIdx < blendShapeChannelCount; ++blendShapeChannelIdx) - { - const FbxBlendShapeChannel* pChannel = pDeformer->GetBlendShapeChannel(blendShapeChannelIdx); - if (!pChannel) - { - continue; - } - - for (int layerIndex = 0; layerIndex < layerCount; layerIndex++) - { - FbxAnimLayer* animationLayer = animStackWrapper->GetAnimationLayerAt(layerIndex)->GetFbxLayer(); - FbxAnimCurve* animCurve = pMesh->GetShapeChannel(blendShapeIndex, blendShapeChannelIdx, animationLayer); - if (!animCurve) - { - continue; - } - AZStd::shared_ptr animCurveWrapper = AZStd::make_shared(animCurve); - - AZStd::shared_ptr createdAnimationData = - AZStd::make_shared(); - - createdAnimationData->ReserveKeyFrames(numFrames); - createdAnimationData->SetTimeStepBetweenFrames(1.0 / frameRate); - - { - FbxSDKWrapper::FbxTimeWrapper currTime = startTime; - for (int64_t currFrame = startFrame; currFrame < startFrame + numFrames; currFrame++) - { - currTime.SetFrame(currFrame); - - //weight values from FBX are range 0 - 100 - float sampleValue = animCurveWrapper->Evaluate(currTime) / 100.0f; - createdAnimationData->AddKeyFrame(sampleValue); - } - AZ_Assert(createdAnimationData->GetKeyFrameCount() == numFrames, "Imported animation blend data does not contain the same number of keyframes as the source FBX data.") - } - - nodeName = pChannel->GetName(); - const size_t dotIndex = nodeName.find_last_of('.'); - nodeName = nodeName.substr(dotIndex + 1); - createdAnimationData->SetBlendShapeName(nodeName.c_str()); - animNodeName = AZStd::string::format("%s_%s", s_animationNodeName, nodeName.c_str()); - Containers::SceneGraph::NodeIndex addNode = context.m_scene.GetGraph().AddChild( - context.m_currentGraphPosition, animNodeName.c_str(), AZStd::move(createdAnimationData)); - context.m_scene.GetGraph().MakeEndPoint(addNode); - } - } - } - return Events::ProcessingResult::Success; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxAnimationImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxAnimationImporter.h deleted file mode 100644 index 2abb7f1170..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxAnimationImporter.h +++ /dev/null @@ -1,46 +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 -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxAnimationImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxAnimationImporter, "{26ABDA62-9DB7-4B4D-961D-44B5F5F56808}", SceneCore::LoadingComponent); - - FbxAnimationImporter(); - ~FbxAnimationImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportAnimation(SceneNodeAppendedContext& context); - Events::ProcessingResult ImportBlendShapeAnimation(SceneNodeAppendedContext& context); - - protected: - static const char* s_animationNodeName; - static const FbxSDKWrapper::FbxTimeWrapper::TimeMode s_defaultTimeMode; - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBitangentStreamImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBitangentStreamImporter.cpp deleted file mode 100644 index f94dc9cf2f..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBitangentStreamImporter.cpp +++ /dev/null @@ -1,160 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxBitangentStreamImporter::FbxBitangentStreamImporter() - { - BindToCall(&FbxBitangentStreamImporter::ImportBitangents); - } - - - void FbxBitangentStreamImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - - Events::ProcessingResult FbxBitangentStreamImporter::ImportBitangents(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Bitangents"); - std::shared_ptr fbxMesh = context.m_sourceNode.GetMesh(); - if (!fbxMesh) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedStreamResults; - const int numBitangentSets = context.m_sourceNode.GetMesh()->GetElementBitangentCount(); - for (int elementIndex = 0; elementIndex < numBitangentSets; ++elementIndex) - { - AZ_TraceContext("Bitangent set index", elementIndex); - - FbxSDKWrapper::FbxVertexBitangentWrapper fbxVertexBitangents = fbxMesh->GetElementBitangent(elementIndex); - if (!fbxVertexBitangents.IsValid()) - { - AZ_TracePrintf(Utilities::WarningWindow, "Invalid bitangent set found, ignoring"); - continue; - } - - const AZStd::string originalNodeName = AZStd::string::format("BitangentSet_Fbx_%d", elementIndex); - const AZStd::string nodeName = AZ::SceneAPI::DataTypes::Utilities::CreateUniqueName(originalNodeName, context.m_scene.GetManifest()); - AZ_TraceContext("Bitangent Set Name", nodeName); - if (originalNodeName != nodeName) - { - AZ_TracePrintf(Utilities::WarningWindow, "Bitangent set '%s' has been renamed to '%s' because the name was already in use.", originalNodeName.c_str(), nodeName.c_str()); - } - - AZStd::shared_ptr parentData = context.m_scene.GetGraph().GetNodeContent(context.m_currentGraphPosition); - AZ_Assert(parentData && parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid()), "Tried to construct bitangent set attribute for invalid or non-mesh parent data"); - if (!parentData || !parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid())) - { - combinedStreamResults += Events::ProcessingResult::Failure; - continue; - } - - const SceneData::GraphData::MeshData* const parentMeshData = azrtti_cast(parentData.get()); - const size_t vertexCount = parentMeshData->GetVertexCount(); - AZStd::shared_ptr bitangentStream = BuildVertexBitangentData(fbxVertexBitangents, vertexCount, fbxMesh); - - AZ_Assert(bitangentStream, "Failed to allocate bitangent data for scene graph."); - if (!bitangentStream) - { - combinedStreamResults += Events::ProcessingResult::Failure; - continue; - } - - bitangentStream->SetBitangentSetIndex(elementIndex); - bitangentStream->SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace::FromFbx); - - Containers::SceneGraph::NodeIndex newIndex = context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, nodeName.c_str()); - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if (!newIndex.IsValid()) - { - combinedStreamResults += Events::ProcessingResult::Failure; - continue; - } - - Events::ProcessingResult streamResults; - SceneAttributeDataPopulatedContext dataPopulated(context, bitangentStream, newIndex, nodeName); - streamResults = Events::Process(dataPopulated); - if (streamResults != Events::ProcessingResult::Failure) - { - streamResults = AddAttributeDataNodeWithContexts(dataPopulated); - } - - combinedStreamResults += streamResults; - } - - return combinedStreamResults.GetResult(); - } - - - AZStd::shared_ptr FbxBitangentStreamImporter::BuildVertexBitangentData(const FbxSDKWrapper::FbxVertexBitangentWrapper& bitangents, size_t vertexCount, const std::shared_ptr& fbxMesh) - { - AZStd::shared_ptr bitangentData = AZStd::make_shared(); - bitangentData->ReserveContainerSpace(vertexCount); - - const int fbxPolygonCount = fbxMesh->GetPolygonCount(); - const int* const fbxPolygonVertices = fbxMesh->GetPolygonVertices(); - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - const int fbxPolygonVertexCount = fbxMesh->GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount <= 2) - { - continue; - } - - const int fbxVertexStartIndex = fbxMesh->GetPolygonVertexIndex(fbxPolygonIndex); - for (int index = 0; index < fbxPolygonVertexCount; ++index) - { - const int fbxPolygonVertexIndex = fbxVertexStartIndex + index; - const int fbxControlPointIndex = fbxPolygonVertices[fbxPolygonVertexIndex]; - - const Vector3 bitangent = bitangents.GetElementAt(fbxPolygonIndex, fbxPolygonVertexIndex, fbxControlPointIndex); - bitangentData->AppendBitangent(bitangent); - } - } - - if (bitangentData->GetCount() != vertexCount) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Vertex count (%i) doesn't match the number of entries for the bitangent stream %s (%i)", vertexCount, bitangents.GetName(), bitangentData->GetCount()); - return nullptr; - } - - return bitangentData; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBitangentStreamImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBitangentStreamImporter.h deleted file mode 100644 index 4fd6820ebf..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBitangentStreamImporter.h +++ /dev/null @@ -1,58 +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 -#include -#include - -namespace AZ -{ - namespace SceneData - { - namespace GraphData - { - class MeshVertexBitangentData; - } - } - - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - class FbxVertexBitangentWrapper; - } - - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxBitangentStreamImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxBitangentStreamImporter, "{B68F90E6-9F9D-448F-A874-CABA9F67E5FD}", SceneCore::LoadingComponent); - - FbxBitangentStreamImporter(); - ~FbxBitangentStreamImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportBitangents(SceneNodeAppendedContext& context); - - protected: - AZStd::shared_ptr BuildVertexBitangentData(const FbxSDKWrapper::FbxVertexBitangentWrapper& bitangents, - size_t vertexCount, const std::shared_ptr& fbxMesh); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBlendShapeImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBlendShapeImporter.cpp deleted file mode 100644 index cc20d76d87..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBlendShapeImporter.cpp +++ /dev/null @@ -1,128 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxBlendShapeImporter::FbxBlendShapeImporter() - { - BindToCall(&FbxBlendShapeImporter::ImportBlendShapes); - } - - void FbxBlendShapeImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxBlendShapeImporter::ImportBlendShapes(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Blend Shapes"); - - if (!IsSkinnedMesh(context.m_sourceNode)) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedBlendShapeResult; - - const std::shared_ptr sourceMesh = context.m_sourceNode.GetMesh(); - int blendShapeDeformerCount = sourceMesh->GetDeformerCount(FbxDeformer::eBlendShape); - for (int deformerIndex = 0; deformerIndex < blendShapeDeformerCount; ++deformerIndex) - { - AZ_TraceContext("Deformer Index", deformerIndex); - AZStd::shared_ptr fbxBlendShape = sourceMesh->GetBlendShape(deformerIndex); - - if (!fbxBlendShape) - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Unable to extract BlendShape Deformer at index %d", deformerIndex); - return Events::ProcessingResult::Failure; - } - int blendShapeChannelCount = fbxBlendShape->GetBlendShapeChannelCount(); - for (int channelIndex = 0; channelIndex < blendShapeChannelCount; ++channelIndex) - { - //extract the mesh and build a blendshape data object. - AZStd::shared_ptr blendShapeChannel = fbxBlendShape->GetBlendShapeChannel(channelIndex); - - int shapeCount = blendShapeChannel->GetTargetShapeCount(); - - //We do not support percentage blends at this time. Take only the final shape. - AZStd::shared_ptr mesh = blendShapeChannel->GetTargetShape(shapeCount - 1); - - if (mesh) - { - //Maya is creating node names of the form cone_skin_blendShapeNode.cone_squash during export. - //We need the name after the period for our naming purposes. - AZStd::string nodeName(blendShapeChannel->GetName()); - size_t dotIndex = nodeName.rfind('.'); - if (dotIndex != AZStd::string::npos) - { - nodeName.erase(0, dotIndex + 1); - } - RenamedNodesMap::SanitizeNodeName(nodeName, context.m_scene.GetGraph(), context.m_currentGraphPosition, "BlendShape"); - AZ_TraceContext("Blend shape name", nodeName); - - AZStd::shared_ptr blendShapeData = - AZStd::make_shared(); - - BuildSceneBlendShapeFromFbxBlendShape(blendShapeData, mesh, context.m_sourceSceneSystem); - - Containers::SceneGraph::NodeIndex newIndex = - context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, nodeName.c_str()); - - Events::ProcessingResult blendShapeResult; - SceneAttributeDataPopulatedContext dataPopulated(context, blendShapeData, newIndex, nodeName); - blendShapeResult = Events::Process(dataPopulated); - - if (blendShapeResult != Events::ProcessingResult::Failure) - { - blendShapeResult = AddAttributeDataNodeWithContexts(dataPopulated); - } - combinedBlendShapeResult += blendShapeResult; - } - else - { - AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Unable to extract blendshape mesh for node '%s' from BlendShapeChannel %d", sourceMesh->GetName(), channelIndex); - combinedBlendShapeResult += Events::ProcessingResult::Failure; - } - } - } - - return combinedBlendShapeResult.GetResult(); - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBlendShapeImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBlendShapeImporter.h deleted file mode 100644 index b56a622383..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBlendShapeImporter.h +++ /dev/null @@ -1,39 +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 -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxBlendShapeImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxBlendShapeImporter, "{3E733F1B-B4A1-4F6F-B2EE-A1C501830E91}", SceneCore::LoadingComponent); - - FbxBlendShapeImporter(); - ~FbxBlendShapeImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportBlendShapes(SceneNodeAppendedContext& context); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBoneImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBoneImporter.cpp deleted file mode 100644 index 728a4c7828..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBoneImporter.cpp +++ /dev/null @@ -1,84 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxBoneImporter::FbxBoneImporter() - { - BindToCall(&FbxBoneImporter::ImportBone); - } - - void FbxBoneImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxBoneImporter::ImportBone(FbxNodeEncounteredContext& context) - { - AZ_TraceContext("Importer", "Bone"); - - if (!context.m_sourceNode.IsBone()) - { - return Events::ProcessingResult::Ignored; - } - - AZStd::shared_ptr boneGraphData; - - // If the current scene node (our eventual parent) contains bone data, we are not a root bone - AZStd::shared_ptr createdBoneData; - - if (NodeHasAncestorOfType(context.m_scene.GetGraph(), context.m_currentGraphPosition, - DataTypes::IBoneData::TYPEINFO_Uuid())) - { - createdBoneData = AZStd::make_shared(); - } - else - { - createdBoneData = AZStd::make_shared(); - } - - SceneAPI::DataTypes::MatrixType globalTransform = context.m_sourceNode.EvaluateGlobalTransform(); - - context.m_sourceSceneSystem.SwapTransformForUpAxis(globalTransform); - - context.m_sourceSceneSystem.ConvertBoneUnit(globalTransform); - - createdBoneData->SetWorldTransform(globalTransform); - - context.m_createdData.push_back(AZStd::move(createdBoneData)); - - return Events::ProcessingResult::Success; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBoneImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBoneImporter.h deleted file mode 100644 index 29ac288149..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxBoneImporter.h +++ /dev/null @@ -1,39 +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 -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxBoneImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxBoneImporter, "{3575F356-BC2F-45F6-B57C-9C590ED54995}", SceneCore::LoadingComponent); - - FbxBoneImporter(); - ~FbxBoneImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportBone(FbxNodeEncounteredContext& context); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxColorStreamImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxColorStreamImporter.cpp deleted file mode 100644 index 78c2933d0b..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxColorStreamImporter.cpp +++ /dev/null @@ -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. -* -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxColorStreamImporter::FbxColorStreamImporter() - { - BindToCall(&FbxColorStreamImporter::ImportColorStreams); - } - - void FbxColorStreamImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxColorStreamImporter::ImportColorStreams(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Color Stream"); - std::shared_ptr fbxMesh = - context.m_sourceNode.GetMesh(); - if (!fbxMesh) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedVertexColorResults; - - for (int i = 0; i < context.m_sourceNode.GetMesh()->GetElementVertexColorCount(); ++i) - { - AZ_TraceContext("Vertex color index", i); - - FbxSDKWrapper::FbxVertexColorWrapper fbxVertexColors = - fbxMesh->GetElementVertexColor(i); - - if (!fbxVertexColors.IsValid()) - { - AZ_TracePrintf(Utilities::WarningWindow, "Invalid vertex color channel found, ignoring"); - continue; - } - - AZStd::string nodeName = fbxVertexColors.GetName(); - RenamedNodesMap::SanitizeNodeName(nodeName, context.m_scene.GetGraph(), context.m_currentGraphPosition, "ColorStream"); - AZ_TraceContext("Color Stream Name", nodeName); - - AZStd::shared_ptr parentData = - context.m_scene.GetGraph().GetNodeContent(context.m_currentGraphPosition); - AZ_Assert(parentData && parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid()), - "Tried to construct color stream attribute for invalid or non-mesh parent data"); - if (!parentData || !parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid())) - { - combinedVertexColorResults += Events::ProcessingResult::Failure; - continue; - } - - SceneData::GraphData::MeshData* parentMeshData = - azrtti_cast(parentData.get()); - size_t vertexCount = parentMeshData->GetVertexCount(); - AZStd::shared_ptr vertexColors = - BuildVertexColorData(fbxVertexColors, vertexCount, fbxMesh); - AZ_Assert(vertexColors, "Failed to allocate vertex color data for scene graph."); - if (!vertexColors) - { - combinedVertexColorResults += Events::ProcessingResult::Failure; - continue; - } - - Containers::SceneGraph::NodeIndex newIndex = - context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, nodeName.c_str()); - - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if (!newIndex.IsValid()) - { - combinedVertexColorResults += Events::ProcessingResult::Failure; - continue; - } - - Events::ProcessingResult vertexColorResult; - SceneAttributeDataPopulatedContext dataPopulated(context, vertexColors, newIndex, nodeName); - vertexColorResult = AddAttributeDataNodeWithContexts(dataPopulated); - - combinedVertexColorResults += vertexColorResult; - } - - return combinedVertexColorResults.GetResult(); - } - - AZStd::shared_ptr FbxColorStreamImporter::BuildVertexColorData(const FbxSDKWrapper::FbxVertexColorWrapper& fbxVertexColors, size_t vertexCount, const std::shared_ptr& fbxMesh) - { - AZ_Assert(fbxVertexColors.IsValid(), "BuildVertexColorData was called for invalid color stream data."); - if (!fbxVertexColors.IsValid()) - { - return nullptr; - } - - AZStd::shared_ptr colorData = AZStd::make_shared(); - colorData->ReserveContainerSpace(vertexCount); - colorData->SetCustomName(fbxVertexColors.GetName()); - - const int fbxPolygonCount = fbxMesh->GetPolygonCount(); - const int* const fbxPolygonVertices = fbxMesh->GetPolygonVertices(); - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - const int fbxPolygonVertexCount = fbxMesh->GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount < 3) - { - continue; - } - - const int fbxVertexStartIndex = fbxMesh->GetPolygonVertexIndex(fbxPolygonIndex); - - for (int polygonVertexIndex = 0; polygonVertexIndex < fbxPolygonVertexCount; ++polygonVertexIndex) - { - const int fbxPolygonVertexIndex = fbxVertexStartIndex + polygonVertexIndex; - const int fbxControlPointIndex = fbxPolygonVertices[fbxPolygonVertexIndex]; - - FbxSDKWrapper::FbxColorWrapper color = fbxVertexColors.GetElementAt(fbxPolygonIndex, fbxPolygonVertexIndex, fbxControlPointIndex); - - colorData->AppendColor({color.GetR(), color.GetG(), color.GetB(), color.GetAlpha()}); - } - } - - if (colorData->GetCount() != vertexCount) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Vertex count (%i) doesn't match the number of entries for the vertex color stream %s (%i)", - vertexCount, fbxVertexColors.GetName(), colorData->GetCount()); - return nullptr; - } - - return colorData; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxColorStreamImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxColorStreamImporter.h deleted file mode 100644 index bf614cf0d3..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxColorStreamImporter.h +++ /dev/null @@ -1,57 +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 -#include -#include - -namespace AZ -{ - namespace SceneData - { - namespace GraphData - { - class MeshVertexColorData; - } - } - - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - class FbxVertexColorWrapper; - } - - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxColorStreamImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxColorStreamImporter, "{96A25361-04FC-43EC-A443-C81E2E28F3BB}", SceneCore::LoadingComponent); - - FbxColorStreamImporter(); - ~FbxColorStreamImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportColorStreams(SceneNodeAppendedContext& context); - - protected: - AZStd::shared_ptr BuildVertexColorData(const FbxSDKWrapper::FbxVertexColorWrapper& fbxVertexColors, size_t vertexCount, const std::shared_ptr& fbxMesh); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMaterialImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMaterialImporter.cpp deleted file mode 100644 index 199f476ec0..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMaterialImporter.cpp +++ /dev/null @@ -1,159 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxMaterialImporter::FbxMaterialImporter() - { - BindToCall(&FbxMaterialImporter::ImportMaterials); - } - - void FbxMaterialImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxMaterialImporter::ImportMaterials(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Material"); - - if (!context.m_sourceNode.GetMesh()) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedMaterialImportResults; - - for (int materialIndex = 0; materialIndex < context.m_sourceNode.GetMaterialCount(); ++materialIndex) - { - AZ_TraceContext("Material Index", materialIndex); - - const std::shared_ptr fbxMaterial = - context.m_sourceNode.GetMaterial(materialIndex); - - if (!fbxMaterial) - { - AZ_TracePrintf(Utilities::WarningWindow, "Invalid material data found, ignoring."); - continue; - } - - AZStd::string materialName = fbxMaterial->GetName().c_str(); - RenamedNodesMap::SanitizeNodeName(materialName, context.m_scene.GetGraph(), context.m_currentGraphPosition, "Material"); - AZ_TraceContext("Material Name", materialName); - - AZStd::shared_ptr materialData = - BuildMaterial(context.m_sourceNode, materialIndex); - - AZ_Assert(materialData, "Failed to allocate scene material data."); - if (!materialData) - { - combinedMaterialImportResults += Events::ProcessingResult::Failure; - continue; - } - - Events::ProcessingResult materialResult; - Containers::SceneGraph::NodeIndex newIndex = - context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, materialName.c_str()); - - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if(!newIndex.IsValid()) - { - combinedMaterialImportResults += Events::ProcessingResult::Failure; - continue; - } - - SceneAttributeDataPopulatedContext dataPopulated(context, materialData, newIndex, materialName); - materialResult = Events::Process(dataPopulated); - - if (materialResult != Events::ProcessingResult::Failure) - { - materialResult = AddAttributeDataNodeWithContexts(dataPopulated); - } - - combinedMaterialImportResults += materialResult; - } - - return combinedMaterialImportResults.GetResult(); - } - - AZStd::shared_ptr FbxMaterialImporter::BuildMaterial(FbxSDKWrapper::FbxNodeWrapper& node, int materialIndex) const - { - AZ_Assert(materialIndex < node.GetMaterialCount(), "Invalid material index (%i)", materialIndex); - const std::shared_ptr fbxMaterial = node.GetMaterial(materialIndex); - if (!fbxMaterial) - { - return nullptr; - } - - AZStd::shared_ptr material = AZStd::make_shared(); - - material->SetMaterialName(fbxMaterial->GetName()); - material->SetTexture(DataTypes::IMaterialData::TextureMapType::Diffuse, - fbxMaterial->GetTextureFileName(FbxSDKWrapper::FbxMaterialWrapper::MaterialMapType::Diffuse).c_str()); - material->SetTexture(DataTypes::IMaterialData::TextureMapType::Specular, - fbxMaterial->GetTextureFileName(FbxSDKWrapper::FbxMaterialWrapper::MaterialMapType::Specular).c_str()); - material->SetTexture(DataTypes::IMaterialData::TextureMapType::Bump, - fbxMaterial->GetTextureFileName(FbxSDKWrapper::FbxMaterialWrapper::MaterialMapType::Bump).c_str()); - material->SetTexture(DataTypes::IMaterialData::TextureMapType::Normal, - fbxMaterial->GetTextureFileName(FbxSDKWrapper::FbxMaterialWrapper::MaterialMapType::Normal).c_str()); - material->SetDiffuseColor(fbxMaterial->GetDiffuseColor()); - material->SetSpecularColor(fbxMaterial->GetSpecularColor()); - material->SetEmissiveColor(fbxMaterial->GetEmissiveColor()); - material->SetShininess(fbxMaterial->GetShininess()); - - float opacity = fbxMaterial->GetOpacity(); - if (opacity == 0.0f) - { - opacity = 1.0f; - AZ_TracePrintf(Utilities::WarningWindow, "Opacity has been changed from 0 to full. Some DCC tools ignore the opacity and " - "write 0 to indicate opacity is not used. This causes meshes to turn invisible, which is often not the intention so " - "the opacity has been set to full automatically. If the intention was for a fully transparent mesh, please update " - "the opacity in Open 3D Engine's material editor."); - } - material->SetOpacity(opacity); - - // Due to the fact that fbxMaterial->GetUniqueId() will return a different ID - // each time when the fbx is reprocessed, we need a more stable ID. - // The current best candidate is probably the name of the material. - // But this will also force the user to update the material component for overrides - // if the fbx material name is changed outside from apps like dcc tools. - // (Ideally, only changing the material properties in the dcc tool will force the user to update the material component) - // - // Using 32-bit CRC as it is mathematically stable and enough within the same fbx. - uint64_t id = uint32_t(AZ::Crc32(fbxMaterial->GetName())); - material->SetUniqueId(id); - return material; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMaterialImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMaterialImporter.h deleted file mode 100644 index a6b7bbd5ee..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMaterialImporter.h +++ /dev/null @@ -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. -* -*/ - -#pragma once - -#include -#include -#include - -namespace AZ -{ - namespace SceneData - { - namespace GraphData - { - class MaterialData; - } - } - - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxMaterialImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxMaterialImporter, "{E1DF4182-793D-4188-B833-1236D33CCEB4}", SceneCore::LoadingComponent); - - FbxMaterialImporter(); - ~FbxMaterialImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportMaterials(SceneNodeAppendedContext& context); - - protected: - AZStd::shared_ptr BuildMaterial(FbxSDKWrapper::FbxNodeWrapper& node, int materialIndex) const; - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMeshImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMeshImporter.cpp deleted file mode 100644 index 90d4dceb6c..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMeshImporter.cpp +++ /dev/null @@ -1,69 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxMeshImporter::FbxMeshImporter() - { - BindToCall(&FbxMeshImporter::ImportMesh); - } - - void FbxMeshImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxMeshImporter::ImportMesh(FbxNodeEncounteredContext& context) - { - AZ_TraceContext("Importer", "Mesh"); - if (!context.m_sourceNode.GetMesh() || - IsSkinnedMesh(context.m_sourceNode)) - { - return Events::ProcessingResult::Ignored; - } - - AZStd::shared_ptr createdData = - AZStd::make_shared(); - - if (BuildSceneMeshFromFbxMesh(createdData, *context.m_sourceNode.GetMesh(), context.m_sourceSceneSystem)) - { - context.m_createdData.push_back(std::move(createdData)); - return Events::ProcessingResult::Success; - } - else - { - return Events::ProcessingResult::Failure; - } - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMeshImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMeshImporter.h deleted file mode 100644 index 6d205c7bfa..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxMeshImporter.h +++ /dev/null @@ -1,54 +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 -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - } - - namespace SceneData - { - namespace GraphData - { - class MeshData; - } - } - - namespace SceneAPI - { - class FbxSceneSystem; - - namespace FbxSceneBuilder - { - class FbxMeshImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxMeshImporter, "{8D131E77-4D53-486A-B3C6-80ACC27A6D50}", SceneCore::LoadingComponent); - - FbxMeshImporter(); - ~FbxMeshImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportMesh(FbxNodeEncounteredContext& context); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinImporter.cpp deleted file mode 100644 index 7c710fdda0..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinImporter.cpp +++ /dev/null @@ -1,69 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxSkinImporter::FbxSkinImporter() - { - BindToCall(&FbxSkinImporter::ImportSkin); - } - - void FbxSkinImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxSkinImporter::ImportSkin(FbxNodeEncounteredContext& context) - { - if (!context.m_sourceNode.GetMesh() || - !IsSkinnedMesh(context.m_sourceNode)) - { - return Events::ProcessingResult::Ignored; - } - - AZStd::shared_ptr createdData = - AZStd::make_shared(); - - if (BuildSceneMeshFromFbxMesh(createdData, *context.m_sourceNode.GetMesh(), context.m_sourceSceneSystem)) - { - context.m_createdData.push_back(std::move(createdData)); - return Events::ProcessingResult::Success; - } - else - { - return Events::ProcessingResult::Failure; - } - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinImporter.h deleted file mode 100644 index 2ed63a2acd..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinImporter.h +++ /dev/null @@ -1,39 +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 -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxSkinImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxSkinImporter, "{22108E92-7037-442D-94E0-A2E92554A79F}", SceneCore::LoadingComponent); - - FbxSkinImporter(); - ~FbxSkinImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportSkin(FbxNodeEncounteredContext& context); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinWeightsImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinWeightsImporter.cpp deleted file mode 100644 index 3e8b2324d8..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinWeightsImporter.cpp +++ /dev/null @@ -1,177 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - const AZStd::string FbxSkinWeightsImporter::s_skinWeightName = "SkinWeight_"; - - FbxSkinWeightsImporter::FbxSkinWeightsImporter() - { - BindToCall(&FbxSkinWeightsImporter::ImportSkinWeights); - BindToCall(&FbxSkinWeightsImporter::SetupNamedBoneLinks); - } - - void FbxSkinWeightsImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxSkinWeightsImporter::ImportSkinWeights(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Skin Weights"); - - if (!IsSkinnedMesh(context.m_sourceNode)) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedSkinWeightsResult; - - for (int deformerIndex = 0; deformerIndex < context.m_sourceNode.GetMesh()->GetDeformerCount(FbxDeformer::eSkin); ++deformerIndex) - { - AZ_TraceContext("Deformer Index", deformerIndex); - AZStd::shared_ptr fbxSkin = - context.m_sourceNode.GetMesh()->GetSkin(deformerIndex); - if (!fbxSkin) - { - return Events::ProcessingResult::Failure; - } - AZStd::string skinWeightName = s_skinWeightName; - skinWeightName += AZStd::to_string(deformerIndex); - RenamedNodesMap::SanitizeNodeName(skinWeightName, context.m_scene.GetGraph(), context.m_currentGraphPosition); - - AZStd::shared_ptr skinDeformer = - BuildSkinWeightData(context.m_sourceNode.GetMesh(), deformerIndex); - - AZ_Assert(skinDeformer, "Failed to allocate skin weighting data."); - if (!skinDeformer) - { - combinedSkinWeightsResult += Events::ProcessingResult::Failure; - continue; - } - - Containers::SceneGraph::NodeIndex newIndex = - context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, skinWeightName.c_str()); - - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if (!newIndex.IsValid()) - { - combinedSkinWeightsResult += Events::ProcessingResult::Failure; - continue; - } - - Events::ProcessingResult skinWeightsResult; - SceneAttributeDataPopulatedContext dataPopulated(context, skinDeformer, newIndex, skinWeightName); - skinWeightsResult = Events::Process(dataPopulated); - - if (skinWeightsResult != Events::ProcessingResult::Failure) - { - skinWeightsResult = AddAttributeDataNodeWithContexts(dataPopulated); - } - - combinedSkinWeightsResult += skinWeightsResult; - } - - return combinedSkinWeightsResult.GetResult(); - } - - AZStd::shared_ptr FbxSkinWeightsImporter::BuildSkinWeightData( - const std::shared_ptr& fbxMesh, int skinIndex) - { - AZStd::shared_ptr fbxSkin = fbxMesh->GetSkin(skinIndex); - AZ_Assert(fbxSkin, "BuildSkinWeightData was called for index %i which doesn't contain a skin deformer.", - skinIndex); - if (!fbxSkin) - { - return nullptr; - } - - AZStd::shared_ptr skinWeightData = - AZStd::make_shared(); - - // Cache the new object and the link info for now so it can be resolved at a later point when all - // names have been updated. - Pending pending; - pending.m_fbxMesh = fbxMesh; - pending.m_fbxSkin = fbxSkin; - pending.m_skinWeightData = skinWeightData; - m_pendingSkinWeights.push_back(pending); - - return skinWeightData; - } - - Events::ProcessingResult FbxSkinWeightsImporter::SetupNamedBoneLinks(FinalizeSceneContext& context) - { - AZ_TraceContext("Importer", "Skin Weights"); - - for (auto& it : m_pendingSkinWeights) - { - int controlPointCount = it.m_fbxMesh->GetControlPointsCount(); - it.m_skinWeightData->ResizeContainerSpace(controlPointCount); - - int clusterCount = it.m_fbxSkin->GetClusterCount(); - - for (int clusterIndex = 0; clusterIndex < clusterCount; ++clusterIndex) - { - int controlPointCount2 = it.m_fbxSkin->GetClusterControlPointIndicesCount(clusterIndex); - AZStd::shared_ptr fbxLink = it.m_fbxSkin->GetClusterLink(clusterIndex); - - if (!fbxLink) - { - AZ_TracePrintf(Utilities::WarningWindow, "FBX data contains null skin cluster link at index %i", clusterIndex); - continue; - } - - // The name of the bones may be updated as they get processed. Processing of bones may not necessarily happen before - // processing skin weights so to avoid storing names that will be updated later delay setting up the link until - // all processing has completed. - AZStd::string boneName = context.m_nodeNameMap.GetNodeName(fbxLink); - int boneId = it.m_skinWeightData->GetBoneId(boneName); - - for (int pointIndex = 0; pointIndex < controlPointCount2; ++pointIndex) - { - SceneAPI::DataTypes::ISkinWeightData::Link link; - link.boneId = boneId; - link.weight = aznumeric_caster(it.m_fbxSkin->GetClusterControlPointWeight(clusterIndex, pointIndex)); - it.m_skinWeightData->AppendLink(it.m_fbxSkin->GetClusterControlPointIndex(clusterIndex, pointIndex), link); - } - } - } - const auto result = m_pendingSkinWeights.empty() ? Events::ProcessingResult::Ignored : Events::ProcessingResult::Success; - m_pendingSkinWeights.clear(); - return result; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinWeightsImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinWeightsImporter.h deleted file mode 100644 index dfe4ee4ecc..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxSkinWeightsImporter.h +++ /dev/null @@ -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. -* -*/ - -#pragma once - -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - } - - namespace SceneData - { - namespace GraphData - { - class SkinWeightData; - } - } - - namespace SceneAPI - { - namespace Events - { - class PostImportEventContext; - } - - namespace FbxSceneBuilder - { - class FbxSkinWeightsImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxSkinWeightsImporter, "{95FCD291-5E1F-4591-90AD-AB5EA2599C3E}", SceneCore::LoadingComponent); - - FbxSkinWeightsImporter(); - ~FbxSkinWeightsImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportSkinWeights(SceneNodeAppendedContext& context); - Events::ProcessingResult SetupNamedBoneLinks(FinalizeSceneContext& context); - - protected: - struct Pending - { - std::shared_ptr m_fbxMesh; - AZStd::shared_ptr m_fbxSkin; - AZStd::shared_ptr m_skinWeightData; - }; - AZStd::shared_ptr BuildSkinWeightData( - const std::shared_ptr& fbxMesh, int skinIndex); - - //! List of skin weights that still need to be filled in. Setting the data for skin weights is - //! delayed until after the tree has been fully constructed as bones are linked by name, but until - //! the graph has been fully filled in, those names can change which would break the names recorded - //! for the skin. - AZStd::vector m_pendingSkinWeights; - - static const AZStd::string s_skinWeightName; - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTangentStreamImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTangentStreamImporter.cpp deleted file mode 100644 index 3a5257d851..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTangentStreamImporter.cpp +++ /dev/null @@ -1,162 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxTangentStreamImporter::FbxTangentStreamImporter() - { - BindToCall(&FbxTangentStreamImporter::ImportTangents); - } - - - void FbxTangentStreamImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - - Events::ProcessingResult FbxTangentStreamImporter::ImportTangents(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Tangents"); - std::shared_ptr fbxMesh = context.m_sourceNode.GetMesh(); - if (!fbxMesh) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedStreamResults; - const int numTangentSets = context.m_sourceNode.GetMesh()->GetElementTangentCount(); - for (int elementIndex = 0; elementIndex < numTangentSets; ++elementIndex) - { - AZ_TraceContext("Tangent set index", elementIndex); - - FbxSDKWrapper::FbxVertexTangentWrapper fbxVertexTangents = fbxMesh->GetElementTangent(elementIndex); - if (!fbxVertexTangents.IsValid()) - { - AZ_TracePrintf(Utilities::WarningWindow, "Invalid tangent set found, ignoring"); - continue; - } - - const AZStd::string originalNodeName = AZStd::string::format("TangentSet_Fbx_%d", elementIndex); - const AZStd::string nodeName = AZ::SceneAPI::DataTypes::Utilities::CreateUniqueName(originalNodeName, context.m_scene.GetManifest()); - AZ_TraceContext("Tangent Set Name", nodeName); - if (originalNodeName != nodeName) - { - AZ_TracePrintf(Utilities::WarningWindow, "Tangent set '%s' has been renamed to '%s' because the name was already in use.", originalNodeName.c_str(), nodeName.c_str()); - } - - AZStd::shared_ptr parentData = context.m_scene.GetGraph().GetNodeContent(context.m_currentGraphPosition); - AZ_Assert(parentData && parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid()), "Tried to construct tangent set attribute for invalid or non-mesh parent data"); - if (!parentData || !parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid())) - { - combinedStreamResults += Events::ProcessingResult::Failure; - continue; - } - - const SceneData::GraphData::MeshData* const parentMeshData = azrtti_cast(parentData.get()); - const size_t vertexCount = parentMeshData->GetVertexCount(); - AZStd::shared_ptr tangentStream = BuildVertexTangentData(fbxVertexTangents, vertexCount, fbxMesh); - - AZ_Assert(tangentStream, "Failed to allocate tangent data for scene graph."); - if (!tangentStream) - { - combinedStreamResults += Events::ProcessingResult::Failure; - continue; - } - - tangentStream->SetTangentSetIndex(elementIndex); - tangentStream->SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace::FromFbx); - - const Containers::SceneGraph::NodeIndex newIndex = context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, nodeName.c_str()); - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if (!newIndex.IsValid()) - { - combinedStreamResults += Events::ProcessingResult::Failure; - continue; - } - - Events::ProcessingResult streamResults; - SceneAttributeDataPopulatedContext dataPopulated(context, tangentStream, newIndex, nodeName); - streamResults = Events::Process(dataPopulated); - - if (streamResults != Events::ProcessingResult::Failure) - { - streamResults = AddAttributeDataNodeWithContexts(dataPopulated); - } - - combinedStreamResults += streamResults; - } - - return combinedStreamResults.GetResult(); - } - - - AZStd::shared_ptr FbxTangentStreamImporter::BuildVertexTangentData(const FbxSDKWrapper::FbxVertexTangentWrapper& tangents, size_t vertexCount, const std::shared_ptr& fbxMesh) - { - AZStd::shared_ptr tangentData = AZStd::make_shared(); - tangentData->ReserveContainerSpace(vertexCount); - - const int fbxPolygonCount = fbxMesh->GetPolygonCount(); - const int* const fbxPolygonVertices = fbxMesh->GetPolygonVertices(); - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - const int fbxPolygonVertexCount = fbxMesh->GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount <= 2) - { - continue; - } - - const int fbxVertexStartIndex = fbxMesh->GetPolygonVertexIndex(fbxPolygonIndex); - for (int index = 0; index < fbxPolygonVertexCount; ++index) - { - const int fbxPolygonVertexIndex = fbxVertexStartIndex + index; - const int fbxControlPointIndex = fbxPolygonVertices[fbxPolygonVertexIndex]; - - const Vector3 tangent = tangents.GetElementAt(fbxPolygonIndex, fbxPolygonVertexIndex, fbxControlPointIndex); - tangentData->AppendTangent(AZ::Vector4(tangent.GetX(), tangent.GetY(), tangent.GetZ(), 1.0f)); - } - } - - if (tangentData->GetCount() != vertexCount) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Vertex count (%i) doesn't match the number of entries for the tangent stream %s (%i)", vertexCount, tangents.GetName(), tangentData->GetCount()); - return nullptr; - } - - return tangentData; - } - - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTangentStreamImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTangentStreamImporter.h deleted file mode 100644 index 38f561eb04..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTangentStreamImporter.h +++ /dev/null @@ -1,58 +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 -#include -#include - -namespace AZ -{ - namespace SceneData - { - namespace GraphData - { - class MeshVertexTangentData; - } - } - - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - class FbxVertexTangentWrapper; - } - - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxTangentStreamImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxTangentStreamImporter, "{70F3A9F5-5BB1-4FE2-BD63-A60C2DCA4589}", SceneCore::LoadingComponent); - - FbxTangentStreamImporter(); - ~FbxTangentStreamImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportTangents(SceneNodeAppendedContext& context); - - protected: - AZStd::shared_ptr BuildVertexTangentData(const FbxSDKWrapper::FbxVertexTangentWrapper& tangents, - size_t vertexCount, const std::shared_ptr& fbxMesh); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTransformImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTransformImporter.cpp deleted file mode 100644 index b1ccfe8acf..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTransformImporter.cpp +++ /dev/null @@ -1,121 +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 -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - const char* FbxTransformImporter::s_transformNodeName = "transform"; - - FbxTransformImporter::FbxTransformImporter() - { - BindToCall(&FbxTransformImporter::ImportTransform); - } - - void FbxTransformImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxTransformImporter::ImportTransform(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "Transform"); - - DataTypes::MatrixType localTransform; - - if (!GetBindPoseLocalTransform(context.m_sourceScene, context.m_sourceNode, localTransform)) - { - localTransform = context.m_sourceNode.EvaluateLocalTransform(); - DataTypes::MatrixType geoTransform = context.m_sourceNode.GetGeometricTransform(); // transform of the pivot - localTransform *= geoTransform; - } - - if (localTransform == DataTypes::MatrixType::Identity()) - { - return Events::ProcessingResult::Ignored; - } - - - context.m_sourceSceneSystem.SwapTransformForUpAxis(localTransform); - - context.m_sourceSceneSystem.ConvertUnit(localTransform); - - AZStd::shared_ptr transformData = - AZStd::make_shared(localTransform); - AZ_Assert(transformData, "Failed to allocate transform data."); - if (!transformData) - { - return Events::ProcessingResult::Failure; - } - - - // If it is non-endpoint data populated node, add a transform attribute - if (context.m_scene.GetGraph().HasNodeContent(context.m_currentGraphPosition)) - { - if (!context.m_scene.GetGraph().IsNodeEndPoint(context.m_currentGraphPosition)) - { - AZStd::string nodeName = s_transformNodeName; - RenamedNodesMap::SanitizeNodeName(nodeName, context.m_scene.GetGraph(), context.m_currentGraphPosition); - AZ_TraceContext("Transform node name", nodeName); - - Containers::SceneGraph::NodeIndex newIndex = - context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, nodeName.c_str()); - - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if (!newIndex.IsValid()) - { - return Events::ProcessingResult::Failure; - } - - Events::ProcessingResult transformAttributeResult; - SceneAttributeDataPopulatedContext dataPopulated(context, transformData, newIndex, nodeName); - transformAttributeResult = Events::Process(dataPopulated); - - if (transformAttributeResult != Events::ProcessingResult::Failure) - { - transformAttributeResult = AddAttributeDataNodeWithContexts(dataPopulated); - } - - return transformAttributeResult; - } - } - else - { - bool addedData = context.m_scene.GetGraph().SetContent( - context.m_currentGraphPosition, - transformData); - - AZ_Assert(addedData, "Failed to add node data"); - return addedData ? Events::ProcessingResult::Success : Events::ProcessingResult::Failure; - } - - return Events::ProcessingResult::Ignored; - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTransformImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTransformImporter.h deleted file mode 100644 index d9e3b5371b..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxTransformImporter.h +++ /dev/null @@ -1,43 +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 -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxTransformImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxTransformImporter, "{354EAAE2-DF31-4E11-BD8A-619419A3EA17}", SceneCore::LoadingComponent); - - FbxTransformImporter(); - ~FbxTransformImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportTransform(SceneNodeAppendedContext& context); - - protected: - static const char* s_transformNodeName; - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxUvMapImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxUvMapImporter.cpp deleted file mode 100644 index b05c64fcad..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxUvMapImporter.cpp +++ /dev/null @@ -1,164 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - FbxUvMapImporter::FbxUvMapImporter() - { - BindToCall(&FbxUvMapImporter::ImportUvMaps); - } - - void FbxUvMapImporter::Reflect(ReflectContext* context) - { - SerializeContext* serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class()->Version(1); - } - } - - Events::ProcessingResult FbxUvMapImporter::ImportUvMaps(SceneNodeAppendedContext& context) - { - AZ_TraceContext("Importer", "UV Map"); - std::shared_ptr fbxMesh = - context.m_sourceNode.GetMesh(); - if (!fbxMesh) - { - return Events::ProcessingResult::Ignored; - } - - Events::ProcessingResultCombiner combinedUvMapResults; - - for (int uvElementIndex = 0; uvElementIndex < context.m_sourceNode.GetMesh()->GetElementUVCount(); ++uvElementIndex) - { - AZ_TraceContext("UV Map index", uvElementIndex); - - FbxSDKWrapper::FbxUVWrapper fbxVertexUVs = fbxMesh->GetElementUV(uvElementIndex); - - if (!fbxVertexUVs.IsValid()) - { - AZ_TracePrintf(Utilities::WarningWindow, "Invalid UV Map found, ignoring"); - continue; - } - - AZStd::string nodeName = fbxVertexUVs.GetName(); - RenamedNodesMap::SanitizeNodeName(nodeName, context.m_scene.GetGraph(), context.m_currentGraphPosition, "UV"); - AZ_TraceContext("UV Map Name", nodeName); - - AZStd::shared_ptr parentData = - context.m_scene.GetGraph().GetNodeContent(context.m_currentGraphPosition); - AZ_Assert(parentData && parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid()), - "Tried to construct uv stream attribute for invalid or non-mesh parent data"); - if (!parentData || !parentData->RTTI_IsTypeOf(SceneData::GraphData::MeshData::TYPEINFO_Uuid())) - { - combinedUvMapResults += Events::ProcessingResult::Failure; - continue; - } - - const SceneData::GraphData::MeshData* const parentMeshData = - azrtti_cast(parentData.get()); - size_t vertexCount = parentMeshData->GetVertexCount(); - - AZStd::shared_ptr uvMap = BuildVertexUVData(fbxVertexUVs, vertexCount, fbxMesh); - - AZ_Assert(uvMap, "Failed to allocate UV map data for scene graph."); - if (!uvMap) - { - combinedUvMapResults += Events::ProcessingResult::Failure; - continue; - } - - Containers::SceneGraph::NodeIndex newIndex = - context.m_scene.GetGraph().AddChild(context.m_currentGraphPosition, nodeName.c_str()); - - AZ_Assert(newIndex.IsValid(), "Failed to create SceneGraph node for attribute."); - if (!newIndex.IsValid()) - { - combinedUvMapResults += Events::ProcessingResult::Failure; - continue; - } - - Events::ProcessingResult uvMapResults; - SceneAttributeDataPopulatedContext dataPopulated(context, uvMap, newIndex, nodeName); - uvMapResults = Events::Process(dataPopulated); - - if (uvMapResults != Events::ProcessingResult::Failure) - { - uvMapResults = AddAttributeDataNodeWithContexts(dataPopulated); - } - - combinedUvMapResults += uvMapResults; - } - - return combinedUvMapResults.GetResult(); - } - - AZStd::shared_ptr FbxUvMapImporter::BuildVertexUVData(const FbxSDKWrapper::FbxUVWrapper& uvs, - size_t vertexCount, const std::shared_ptr& fbxMesh) - { - AZStd::shared_ptr uvData = AZStd::make_shared(); - uvData->ReserveContainerSpace(vertexCount); - uvData->SetCustomName(uvs.GetName()); - - const int fbxPolygonCount = fbxMesh->GetPolygonCount(); - const int* const fbxPolygonVertices = fbxMesh->GetPolygonVertices(); - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - const int fbxPolygonVertexCount = fbxMesh->GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount <= 2) - { - continue; - } - - const int fbxVertexStartIndex = fbxMesh->GetPolygonVertexIndex(fbxPolygonIndex); - - for (int uvIndex = 0; uvIndex < fbxPolygonVertexCount; ++uvIndex) - { - const int fbxPolygonVertexIndex = fbxVertexStartIndex + uvIndex; - const int fbxControlPointIndex = fbxPolygonVertices[fbxPolygonVertexIndex]; - - Vector2 uv = uvs.GetElementAt(fbxPolygonIndex, fbxPolygonVertexIndex, fbxControlPointIndex); - uv.SetY(1.0f - uv.GetY()); - uvData->AppendUV(uv); - } - } - - if (uvData->GetCount() != vertexCount) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Vertex count (%i) doesn't match the number of entries for the uv set %s (%i)", - vertexCount, uvs.GetName(), uvData->GetCount()); - return nullptr; - } - - return uvData; - - } - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxUvMapImporter.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxUvMapImporter.h deleted file mode 100644 index f64de0034f..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxUvMapImporter.h +++ /dev/null @@ -1,58 +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 -#include -#include - -namespace AZ -{ - namespace SceneData - { - namespace GraphData - { - class MeshVertexUVData; - } - } - - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - class FbxUVWrapper; - } - - namespace SceneAPI - { - namespace FbxSceneBuilder - { - class FbxUvMapImporter - : public SceneCore::LoadingComponent - { - public: - AZ_COMPONENT(FbxUvMapImporter, "{B16CD69D-3C0C-4FE2-B481-1084B1C36242}", SceneCore::LoadingComponent); - - FbxUvMapImporter(); - ~FbxUvMapImporter() override = default; - - static void Reflect(ReflectContext* context); - - Events::ProcessingResult ImportUvMaps(SceneNodeAppendedContext& context); - - protected: - AZStd::shared_ptr BuildVertexUVData(const FbxSDKWrapper::FbxUVWrapper& uvs, - size_t vertexCount, const std::shared_ptr& fbxMesh); - }; - } // namespace FbxSceneBuilder - } // namespace SceneAPI -} // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.cpp similarity index 85% rename from Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.cpp rename to Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.cpp index b50517381d..9b47e3e34a 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.cpp @@ -12,12 +12,8 @@ #include #include -#include #include -#include -#include -#include -#include +#include #include #include #include @@ -50,19 +46,7 @@ namespace AZ dataPopulated.m_scene.GetGraph().SetContent(dataPopulated.m_currentGraphPosition, AZStd::move(dataPopulated.m_graphData)); - if (azrtti_istypeof(dataPopulated)) - { - SceneDataPopulatedContext* dataPopulatedContext = azrtti_cast(&dataPopulated); - SceneNodeAppendedContext nodeAppended(*dataPopulatedContext, dataPopulated.m_currentGraphPosition); - nodeResults += Events::Process(nodeAppended); - - SceneNodeAddedAttributesContext addedAttributes(nodeAppended); - nodeResults += Events::Process(addedAttributes); - - SceneNodeFinalizeContext finalizeNode(addedAttributes); - nodeResults += Events::Process(finalizeNode); - } - else + if (azrtti_istypeof(dataPopulated)) { AssImpSceneDataPopulatedContext* dataPopulatedContext = azrtti_cast(&dataPopulated); AssImpSceneNodeAppendedContext nodeAppended(*dataPopulatedContext, dataPopulated.m_currentGraphPosition); @@ -91,13 +75,7 @@ namespace AZ dataPopulated.m_scene.GetGraph().SetContent(dataPopulated.m_currentGraphPosition, AZStd::move(dataPopulated.m_graphData)); - if (azrtti_istypeof(dataPopulated)) - { - SceneAttributeDataPopulatedContext* dataPopulatedContext = azrtti_cast(&dataPopulated); - SceneAttributeNodeAppendedContext nodeAppended(*dataPopulatedContext, dataPopulated.m_currentGraphPosition); - nodeResults += Events::Process(nodeAppended); - } - else + if (azrtti_istypeof(dataPopulated)) { AssImpSceneAttributeDataPopulatedContext* dataPopulatedContext = azrtti_cast(&dataPopulated); AssImpSceneAttributeNodeAppendedContext nodeAppended(*dataPopulatedContext, dataPopulated.m_currentGraphPosition); @@ -456,48 +434,6 @@ namespace AZ return true; } - - bool GetBindPoseLocalTransform(const FbxSDKWrapper::FbxSceneWrapper& sceneWrapper, - FbxSDKWrapper::FbxNodeWrapper& nodeWrapper, SceneAPI::DataTypes::MatrixType& xf) - { - PoseList poseList; - FbxArray nodeIndices; - - FbxNode* node = nodeWrapper.GetFbxNode(); - - FbxScene* scene = sceneWrapper.GetFbxScene(); - FbxMatrix nodeMatrix; - if (FbxPose::GetBindPoseContaining(scene, node, poseList, nodeIndices)) - { - nodeMatrix = poseList[0]->GetMatrix(nodeIndices[0]); - } - else - { - return false; - } - - // We are after the local transform of the node while fbx bind pose provides the global transform. - // To get the local transform, we multiply with the inverse of the parent's global transform. - FbxNode* parentNode = node->GetParent(); - FbxMatrix parentMatrix; - if (parentNode) - { - poseList.Clear(); - nodeIndices.Clear(); - if (FbxPose::GetBindPoseContaining(scene, parentNode, poseList, nodeIndices)) - { - parentMatrix = poseList[0]->GetMatrix(nodeIndices[0]); - } - else - { - parentMatrix = parentNode->EvaluateGlobalTransform(); - } - } - FbxMatrix nodeLocalMatrix = parentMatrix.Inverse() * nodeMatrix; - xf = FbxSDKWrapper::FbxTypeConverter::ToTransform(nodeLocalMatrix); - return true; - } - } // namespace FbxSceneBuilder } // namespace SceneAPI } // namespace AZ diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.h similarity index 74% rename from Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.h rename to Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.h index 7f16422fdb..d3577d54af 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.h +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.h @@ -12,7 +12,9 @@ #pragma once -#include +#include +#include +#include #include #include @@ -20,12 +22,6 @@ namespace AZ { struct Uuid; - namespace FbxSDKWrapper - { - class FbxNodeWrapper; - class FbxSceneWrapper; - } - namespace SceneAPI { namespace FbxSceneBuilder @@ -42,7 +38,6 @@ namespace AZ const AZ::Uuid& uuid); inline bool NodeHasAncestorOfType(const CoreSceneGraph& graph, CoreGraphNodeIndex nodeIndex, const AZ::Uuid& uuid); - inline bool IsSkinnedMesh(const FbxSDKWrapper::FbxNodeWrapper& sourceNode); CoreProcessingResult AddDataNodeWithContexts(SceneDataPopulatedContextBase& dataContext); CoreProcessingResult AddAttributeDataNodeWithContexts(SceneAttributeDataPopulatedContextBase& dataContext); bool AreSceneGraphsEqual(const CoreSceneGraph& lhsGraph, const CoreSceneGraph& rhsGraph); @@ -51,12 +46,8 @@ namespace AZ bool IsGraphDataEqual(const AZStd::shared_ptr& lhs, const AZStd::shared_ptr& rhs); - // If the scene contains bindpose information for the node, returns true and sets "xf" to the local transform - // of the node in bindpose. Returns false if bindpose info is not available for the node. - bool GetBindPoseLocalTransform(const FbxSDKWrapper::FbxSceneWrapper& sceneWrapper, - FbxSDKWrapper::FbxNodeWrapper& nodeWrapper, DataTypes::MatrixType& xf); } // namespace FbxSceneBuilder } // namespace SceneAPI } // namespace AZ -#include +#include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.inl b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.inl similarity index 81% rename from Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.inl rename to Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.inl index 3fd0e02f08..f56982a06c 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/FbxImporterUtilities.inl +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/ImporterUtilities.inl @@ -10,10 +10,7 @@ * */ -#include -#include -#include -#include +#include #include #include @@ -57,12 +54,6 @@ namespace AZ return false; } - bool IsSkinnedMesh(const FbxSDKWrapper::FbxNodeWrapper& sourceNode) - { - const std::shared_ptr fbxMesh = sourceNode.GetMesh(); - return (fbxMesh && (fbxMesh->GetDeformerCount(FbxDeformer::eSkin) > 0 || fbxMesh->GetDeformerCount(FbxDeformer::eBlendShape) > 0)); - } - bool AreScenesEqual(const CoreScene& lhs, const CoreScene& rhs) { if (lhs.GetGraph().GetNodeCount() != rhs.GetGraph().GetNodeCount()) diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/FbxMeshImporterUtilities.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/FbxMeshImporterUtilities.cpp deleted file mode 100644 index 5dddaff4d8..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/FbxMeshImporterUtilities.cpp +++ /dev/null @@ -1,312 +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 -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace SceneAPI - { - namespace FbxSceneBuilder - { - bool BuildSceneMeshFromFbxMesh(const AZStd::shared_ptr& mesh, - const FbxSDKWrapper::FbxMeshWrapper& sourceMesh, const FbxSceneSystem& sceneSystem) - { - // Save unit sizes of the mesh - mesh->SetUnitSizeInMeters(sceneSystem.GetUnitSizeInMeters()); - mesh->SetOriginalUnitSizeInMeters(sceneSystem.GetOriginalUnitSizeInMeters()); - - // Get mesh subset count by scanning material IDs in meshes. - // For negative material ids we will add an additional - // subset at the end, see "++maxMaterialIndex". - - // These defines material index range for all polygons in the mesh - // Each polygon has a material index - int minMeshMaterialIndex = INT_MAX; - int maxMeshMaterialIndex = INT_MIN; - - FbxLayerElementArrayTemplate* fbxMaterialIndices; - sourceMesh.GetMaterialIndices(&fbxMaterialIndices); // per polygon - - int fbxPolygonCount = sourceMesh.GetPolygonCount(); - - AZ_Error("FbxSceneBuilder", fbxPolygonCount, - "Source mesh %s polygon count is 0. Zero count meshes are not supported, either remove this mesh or add polygons to it.", - sourceMesh.GetName()); - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - // if the polygon has less than 3 vertices, it's not a valid polygon and is skipped - const int fbxPolygonVertexCount = sourceMesh.GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount <= 2) - { - continue; - } - - // Get the material index of each polygon - const int meshMaterialIndex = fbxMaterialIndices ? (*fbxMaterialIndices)[fbxPolygonIndex] : -1; - minMeshMaterialIndex = AZ::GetMin(minMeshMaterialIndex, meshMaterialIndex); - maxMeshMaterialIndex = AZ::GetMax(maxMeshMaterialIndex, meshMaterialIndex); - } - - if (minMeshMaterialIndex > maxMeshMaterialIndex) - { - return false; - } - - if (maxMeshMaterialIndex < 0) - { - minMeshMaterialIndex = maxMeshMaterialIndex = 0; - } - else if (minMeshMaterialIndex < 0) - { - minMeshMaterialIndex = 0; - ++maxMeshMaterialIndex; - } - - // Fill geometry - - // Control points contain positions of vertices - AZStd::vector fbxControlPoints = sourceMesh.GetControlPoints(); - const int* const fbxPolygonVertices = sourceMesh.GetPolygonVertices(); - - fbxMaterialIndices = nullptr; - sourceMesh.GetMaterialIndices(&fbxMaterialIndices); // per polygon - - // Iterate through each polygon in the mesh and convert data - fbxPolygonCount = sourceMesh.GetPolygonCount(); - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - const int fbxPolygonVertexCount = sourceMesh.GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount <= 2) - { - continue; - } - - AZ_TraceContext("Polygon Index", fbxPolygonIndex); - - // Ensure the validity of the material index for the polygon - int fbxMaterialIndex = fbxMaterialIndices ? (*fbxMaterialIndices)[fbxPolygonIndex] : -1; - if (fbxMaterialIndex < minMeshMaterialIndex || fbxMaterialIndex > maxMeshMaterialIndex) - { - fbxMaterialIndex = maxMeshMaterialIndex; - } - - const int fbxVertexStartIndex = sourceMesh.GetPolygonVertexIndex(fbxPolygonIndex); - - // Triangulate polygon as a fan and remember resulting vertices and faces - - int firstMeshVertexIndex = -1; - int previousMeshVertexIndex = -1; - - AZ::SceneAPI::DataTypes::IMeshData::Face meshFace; - int verticesInMeshFace = 0; - - // Iterate through each vertex in the polygon - for (int vertexIndex = 0; vertexIndex < fbxPolygonVertexCount; ++vertexIndex) - { - const int meshVertexIndex = aznumeric_caster(mesh->GetVertexCount()); - - const int fbxPolygonVertexIndex = fbxVertexStartIndex + vertexIndex; - const int fbxControlPointIndex = fbxPolygonVertices[fbxPolygonVertexIndex]; - - Vector3 meshPosition = fbxControlPoints[fbxControlPointIndex]; - - Vector3 meshVertexNormal; - sourceMesh.GetPolygonVertexNormal(fbxPolygonIndex, vertexIndex, meshVertexNormal); - - sceneSystem.SwapVec3ForUpAxis(meshPosition); - sceneSystem.ConvertUnit(meshPosition); - // Add position - mesh->AddPosition(meshPosition); - - // Add normal - sceneSystem.SwapVec3ForUpAxis(meshVertexNormal); - meshVertexNormal.NormalizeSafe(); - mesh->AddNormal(meshVertexNormal); - - mesh->SetVertexIndexToControlPointIndexMap(meshVertexIndex, fbxControlPointIndex); - - // Add face - { - if (vertexIndex == 0) - { - firstMeshVertexIndex = meshVertexIndex; - } - - int meshVertices[3]; - int meshVertexCount = 0; - - meshVertices[meshVertexCount++] = meshVertexIndex; - - // If we already have generated one triangle before, make a new triangle at a time as we encounter a new vertex. - // The new triangle is composed with the first vertex of the polygon, the last vertex, and the current vertex. - if (vertexIndex >= 3) - { - meshVertices[meshVertexCount++] = firstMeshVertexIndex; - meshVertices[meshVertexCount++] = previousMeshVertexIndex; - } - - for (int faceVertexIndex = 0; faceVertexIndex < meshVertexCount; ++faceVertexIndex) - { - meshFace.vertexIndex[verticesInMeshFace++] = meshVertices[faceVertexIndex]; - if (verticesInMeshFace == 3) - { - verticesInMeshFace = 0; - mesh->AddFace(meshFace, fbxMaterialIndex); - } - } - } - - previousMeshVertexIndex = meshVertexIndex; - } - - // Report problem if there are vertices that left for forming a polygon - if (verticesInMeshFace != 0) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Internal error in mesh filler"); - return false; - } - } - - // Report problem if no vertex or face converted to MeshData - if (mesh->GetVertexCount() <= 0 || mesh->GetFaceCount() <= 0) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Missing geometry data in mesh node"); - return false; - } - - return true; - } - - // Currently doesn't maintain a list of unique control points. - // Normals are associated with each triangle vertex from the face. - bool BuildSceneBlendShapeFromFbxBlendShape(const AZStd::shared_ptr& blendShape, - const AZStd::shared_ptr& sourceMesh, const FbxSceneSystem& sceneSystem) - { - // Control points contain positions of vertices - const AZStd::vector& fbxControlPoints = sourceMesh->GetControlPoints(); - const int* const fbxPolygonVertices = sourceMesh->GetPolygonVertices(); - - // Iterate through each polygon in the mesh and convert data - const int fbxPolygonCount = sourceMesh->GetPolygonCount(); - - for (int fbxPolygonIndex = 0; fbxPolygonIndex < fbxPolygonCount; ++fbxPolygonIndex) - { - const int fbxPolygonVertexCount = sourceMesh->GetPolygonSize(fbxPolygonIndex); - if (fbxPolygonVertexCount <= 2) - { - continue; - } - - AZ_TraceContext("Polygon Index", fbxPolygonIndex); - - const int fbxVertexStartIndex = sourceMesh->GetPolygonVertexIndex(fbxPolygonIndex); - - // Triangulate polygon as a fan and remember resulting vertices and faces - - int firstMeshVertexIndex = -1; - int previousMeshVertexIndex = -1; - - DataTypes::IBlendShapeData::Face face; - int verticesInMeshFace = 0; - - // Iterate through each vertex in the polygon - for (int vertexIndex = 0; vertexIndex < fbxPolygonVertexCount; ++vertexIndex) - { - const int meshVertexIndex = aznumeric_caster(blendShape->GetVertexCount()); - - const int fbxPolygonVertexIndex = fbxVertexStartIndex + vertexIndex; - const int fbxControlPointIndex = fbxPolygonVertices[fbxPolygonVertexIndex]; - - // This data allows for mapping vertex data to original Control Point index. - blendShape->SetVertexIndexToControlPointIndexMap(meshVertexIndex, fbxControlPointIndex); - - Vector3 meshVertexPosition = fbxControlPoints[fbxControlPointIndex]; - Vector3 meshVertexNormal; - sourceMesh->GetPolygonVertexNormal(fbxPolygonIndex, vertexIndex, meshVertexNormal); - - // position - sceneSystem.SwapVec3ForUpAxis(meshVertexPosition); - sceneSystem.ConvertUnit(meshVertexPosition); - - // normal - sceneSystem.SwapVec3ForUpAxis(meshVertexNormal); - meshVertexNormal.Normalize(); - - blendShape->AddPosition(meshVertexPosition); - blendShape->AddNormal(meshVertexNormal); - - // Add face - { - if (vertexIndex == 0) - { - firstMeshVertexIndex = meshVertexIndex; - } - - int meshVertices[3]; - int meshNormals[3]; - - int meshVertexCount = 0; - - meshVertices[meshVertexCount] = meshVertexIndex; - meshNormals[meshVertexCount++] = meshVertexIndex; - - // If we already have generated one triangle before, make a new triangle at a time as we encounter a new vertex. - // The new triangle is composed with the first vertex of the polygon, the last vertex, and the current vertex. - if (vertexIndex >= 3) - { - meshVertices[meshVertexCount++] = firstMeshVertexIndex; - meshVertices[meshVertexCount++] = previousMeshVertexIndex; - } - - for (int faceVertexIndex = 0; faceVertexIndex < meshVertexCount; ++faceVertexIndex) - { - face.vertexIndex[verticesInMeshFace++] = meshVertices[faceVertexIndex]; - - if (verticesInMeshFace == 3) - { - verticesInMeshFace = 0; - blendShape->AddFace(face); - break; - } - } - } - - previousMeshVertexIndex = meshVertexIndex; - } - - // Report problem if there are vertices that left for forming a polygon - if (verticesInMeshFace != 0) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Internal error in mesh filler. Vertices were left without forming polygon"); - return false; - } - } - - // Report problem if no vertex or face converted to MeshData - if (blendShape->GetVertexCount() <= 0 || blendShape->GetFaceCount() <= 0) - { - AZ_TracePrintf(Utilities::ErrorWindow, "Missing geometry data in blendshape node"); - return false; - } - - return true; - } - } - } -} diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/FbxMeshImporterUtilities.h b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/FbxMeshImporterUtilities.h deleted file mode 100644 index efb85e5275..0000000000 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/FbxMeshImporterUtilities.h +++ /dev/null @@ -1,42 +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 - -namespace AZ -{ - namespace FbxSDKWrapper - { - class FbxMeshWrapper; - } - - namespace SceneData - { - namespace GraphData - { - class MeshData; - class BlendShapeData; - } - } - - namespace SceneAPI - { - class FbxSceneSystem; - namespace FbxSceneBuilder - { - bool BuildSceneMeshFromFbxMesh(const AZStd::shared_ptr& mesh, - const FbxSDKWrapper::FbxMeshWrapper& sourceMesh, const FbxSceneSystem& sceneSystem); - bool BuildSceneBlendShapeFromFbxBlendShape(const AZStd::shared_ptr& blendShape, - const AZStd::shared_ptr& sourceMesh, const FbxSceneSystem& sceneSystem); - } - } -} diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/RenamedNodesMap.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/RenamedNodesMap.cpp index 3c0414734f..abc095d583 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/RenamedNodesMap.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/Utilities/RenamedNodesMap.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Tests/Importers/FbxImporterUtilitiesTests.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Tests/Importers/FbxImporterUtilitiesTests.cpp index 7ac64b3eda..66db966cac 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Tests/Importers/FbxImporterUtilitiesTests.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Tests/Importers/FbxImporterUtilitiesTests.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/fbxscenebuilder_files.cmake b/Code/Tools/SceneAPI/FbxSceneBuilder/fbxscenebuilder_files.cmake index 93976a1709..92e02f3c6d 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/fbxscenebuilder_files.cmake +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/fbxscenebuilder_files.cmake @@ -19,39 +19,8 @@ set(FILES FbxSceneSystem.cpp ImportContexts/ImportContexts.h ImportContexts/ImportContexts.cpp - ImportContexts/FbxImportContexts.h - ImportContexts/FbxImportContexts.cpp ImportContexts/AssImpImportContexts.h ImportContexts/AssImpImportContexts.cpp - Importers/FbxAnimationImporter.h - Importers/FbxAnimationImporter.cpp - Importers/FbxBoneImporter.h - Importers/FbxBoneImporter.cpp - Importers/FbxBlendShapeImporter.h - Importers/FbxBlendShapeImporter.cpp - Importers/FbxColorStreamImporter.h - Importers/FbxColorStreamImporter.cpp - Importers/FbxTangentStreamImporter.h - Importers/FbxTangentStreamImporter.cpp - Importers/FbxBitangentStreamImporter.h - Importers/FbxBitangentStreamImporter.cpp - Importers/FbxImporterUtilities.h - Importers/FbxImporterUtilities.inl - Importers/FbxImporterUtilities.cpp - Importers/FbxMaterialImporter.h - Importers/FbxMaterialImporter.cpp - Importers/FbxMeshImporter.h - Importers/FbxMeshImporter.cpp - Importers/FbxSkinImporter.h - Importers/FbxSkinImporter.cpp - Importers/FbxSkinWeightsImporter.h - Importers/FbxSkinWeightsImporter.cpp - Importers/FbxTransformImporter.h - Importers/FbxTransformImporter.cpp - Importers/FbxUvMapImporter.h - Importers/FbxUvMapImporter.cpp - Importers/Utilities/FbxMeshImporterUtilities.h - Importers/Utilities/FbxMeshImporterUtilities.cpp Importers/Utilities/AssImpMeshImporterUtilities.h Importers/Utilities/AssImpMeshImporterUtilities.cpp Importers/Utilities/RenamedNodesMap.h @@ -84,4 +53,7 @@ set(FILES Importers/AssImpUvMapImporter.cpp Importers/AssImpAnimationImporter.h Importers/AssImpAnimationImporter.cpp + Importers/ImporterUtilities.h + Importers/ImporterUtilities.cpp + Importers/ImporterUtilities.inl ) diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt b/Code/Tools/SceneAPI/SDKWrapper/CMakeLists.txt similarity index 84% rename from Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt rename to Code/Tools/SceneAPI/SDKWrapper/CMakeLists.txt index ddbabe604d..b1664ca7e5 100644 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt +++ b/Code/Tools/SceneAPI/SDKWrapper/CMakeLists.txt @@ -16,21 +16,18 @@ endif() set(sdkwrapper_dir ${CMAKE_CURRENT_LIST_DIR}/../SDKWrapper) ly_add_target( - NAME FbxSDKWrapper STATIC + NAME SDKWrapper STATIC NAMESPACE AZ FILES_CMAKE - fbxsdkwrapper_files.cmake - ${sdkwrapper_dir}/sdkwrapper_files.cmake + sdkwrapper_files.cmake INCLUDE_DIRECTORIES PUBLIC . ../.. - ${sdkwrapper_dir} BUILD_DEPENDENCIES PRIVATE AZ::AzCore AZ::AzToolsFramework PUBLIC - 3rdParty::FbxSdk 3rdParty::assimplib ) diff --git a/Gems/AWSCore/Code/Include/Private/Configuration/AWSCoreConfiguration.h b/Gems/AWSCore/Code/Include/Private/Configuration/AWSCoreConfiguration.h index f3d474f053..bd30af3ce7 100644 --- a/Gems/AWSCore/Code/Include/Private/Configuration/AWSCoreConfiguration.h +++ b/Gems/AWSCore/Code/Include/Private/Configuration/AWSCoreConfiguration.h @@ -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; diff --git a/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingConstants.h b/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingConstants.h index 2ca203bb96..55360f1c76 100644 --- a/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingConstants.h +++ b/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingConstants.h @@ -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", diff --git a/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingManager.h b/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingManager.h index 9200a9c4ff..6d22c55d2c 100644 --- a/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingManager.h +++ b/Gems/AWSCore/Code/Include/Private/ResourceMapping/AWSResourceMappingManager.h @@ -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 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; diff --git a/Gems/AWSCore/Code/Source/Configuration/AWSCoreConfiguration.cpp b/Gems/AWSCore/Code/Source/Configuration/AWSCoreConfiguration.cpp index 0445ea830e..3c0f48c058 100644 --- a/Gems/AWSCore/Code/Source/Configuration/AWSCoreConfiguration.cpp +++ b/Gems/AWSCore/Code/Source/Configuration/AWSCoreConfiguration.cpp @@ -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 diff --git a/Gems/AWSCore/Code/Source/Credential/AWSDefaultCredentialHandler.cpp b/Gems/AWSCore/Code/Source/Credential/AWSDefaultCredentialHandler.cpp index ba7a8c72dd..bb195e487a 100644 --- a/Gems/AWSCore/Code/Source/Credential/AWSDefaultCredentialHandler.cpp +++ b/Gems/AWSCore/Code/Source/Credential/AWSDefaultCredentialHandler.cpp @@ -84,7 +84,7 @@ namespace AWSCore { AZ_Warning("AWSDefaultCredentialHandler", false, "Failed to get profile name, use default profile name instead"); SetProfileCredentialsProvider(Aws::MakeShared( - AWSDEFAULTCREDENTIALHANDLER_ALLOC_TAG, AWSCoreConfiguration::AWSCORE_DEFAULT_PROFILE_NAME)); + AWSDEFAULTCREDENTIALHANDLER_ALLOC_TAG, AWSCoreConfiguration::AWSCoreDefaultProfileName)); } else { diff --git a/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp b/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp index c87a7f99ba..efdba0e9e0 100644 --- a/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp +++ b/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp @@ -12,12 +12,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -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 writer(error); + validator.GetError().Accept(writer); + AZ_Warning(AWSResourceMappingManagerName, false, ResourceMappingFileInvalidContentErrorMessage, error.GetString()); + return false; } return true; diff --git a/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingUtils.cpp b/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingUtils.cpp index 74be3bf914..7d17a86909 100644 --- a/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingUtils.cpp +++ b/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingUtils.cpp @@ -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()); } } diff --git a/Gems/AWSCore/Code/Tests/Configuration/AWSCoreConfigurationTest.cpp b/Gems/AWSCore/Code/Tests/Configuration/AWSCoreConfigurationTest.cpp index dab405dee4..b3c2b8d2ca 100644 --- a/Gems/AWSCore/Code/Tests/Configuration/AWSCoreConfigurationTest.cpp +++ b/Gems/AWSCore/Code/Tests/Configuration/AWSCoreConfigurationTest.cpp @@ -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); } diff --git a/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp b/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp index 73a28f97cb..3adebc9a24 100644 --- a/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp +++ b/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp @@ -98,7 +98,7 @@ public: "AWSResourceMappingManager", AZ::Uuid::CreateRandom().ToString(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); } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Previewer/ImagePreviewer.ui b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Previewer/ImagePreviewer.ui index bdb94bd489..a276adeb78 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Previewer/ImagePreviewer.ui +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Previewer/ImagePreviewer.ui @@ -127,11 +127,6 @@ - - QWidget -
Controls/PreviewModelCtrl.h
- 1 -
AzToolsFramework::AspectRatioAwarePixmapWidget QWidget diff --git a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli similarity index 96% rename from Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli rename to Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli index 0aeb43bcf2..a7bb6cd3b1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrg.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli @@ -10,11 +10,9 @@ * */ -#ifndef AZ_COLLECTING_PARTIAL_SRGS -#error Do not include this file directly. Include the main .srgi file instead. -#endif +#include -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[]; -} - - +} \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrgAll.azsli b/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrgAll.azsli deleted file mode 100644 index b1b2bea750..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/RayTracingSceneSrgAll.azsli +++ /dev/null @@ -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 -#endif diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader index a781a598ba..804b534277 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing.azshader differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant index e9f841047e..b3bee56bfd 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_dx12_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant index e399dbcef0..d9b2f17848 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_null_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant index 1580aa2477..cf39160d3f 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracing_vulkan_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader index bfed840feb..c4a83a26dc 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit.azshader differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant index ee2031bf1a..fb5b740f04 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_dx12_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant index 3b37084adf..b7bdabeb4e 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_null_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant index e2f5a8cb50..1eeeffa8be 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingclosesthit_vulkan_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg index 930d34171e..c9fa0f4e1c 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingcommon_raytracingglobalsrg.azsrg @@ -9904,4 +9904,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader index 84e773d9db..4f0cea1bfe 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss.azshader differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant index b288bb7647..839efa7278 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_dx12_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant index 0f2473b606..5f08825487 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_null_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant index bfd979e588..a5b0e842ef 100644 Binary files a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant and b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/diffuseprobegridraytracingmiss_vulkan_0.azshadervariant differ diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake index f14fb4f4a0..84ef494216 100644 --- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake +++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake @@ -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 diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Decals/DecalFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Decals/DecalFeatureProcessorInterface.h index 214feb2040..a7aebf5aa4 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Decals/DecalFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Decals/DecalFeatureProcessorInterface.h @@ -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; diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp index 7abc6698fa..55fa633e5d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.cpp @@ -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()); diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h index 9c4acf6322..3b99715d5a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalFeatureProcessor.h @@ -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; diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp index 9d1ea4e680..4000df646d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.cpp @@ -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()); diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.h index 7ab073c7f9..825e461fc2 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/DecalTextureArrayFeatureProcessor.h @@ -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; diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index 0c24c2953d..c4e9306dc9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -67,7 +67,7 @@ namespace AZ // load the RayTracingSceneSrg asset Data::Asset rayTracingSceneSrgAsset = - RPI::AssetUtils::LoadAssetByProductPath("shaderlib/raytracingscenesrg_raytracingscenesrg.azsrg", RPI::AssetUtils::TraceLevel::Error); + RPI::AssetUtils::LoadAssetByProductPath("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); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp index 4cae8af48e..7fc75f67fe 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp @@ -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(context)) { - behaviorContext->Class() + behaviorContext->Class("ShaderCollectionItem") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation) ->Attribute(AZ::Script::Attributes::Category, "Shader") ->Attribute(AZ::Script::Attributes::Module, "shader") diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorGroupHeaderWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorGroupHeaderWidget.h index d1beed1a65..bba299187b 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorGroupHeaderWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorGroupHeaderWidget.h @@ -15,6 +15,7 @@ #if !defined(Q_MOC_RUN) #include #include +#include #include #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: diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h index 5f16894a0c..81b512faf2 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h @@ -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; diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h index 9f8df2da71..b0932b3b04 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h @@ -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 m_ui; + AZStd::vector m_headers; + AZStd::vector m_groups; }; } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h index 5dbbf04f1b..8e64c1467e 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h @@ -94,9 +94,10 @@ namespace AtomToolsFramework bool ShowGrid() override; bool AngleSnappingEnabled() override; float AngleStep() override; - QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override; - AZStd::optional ViewportScreenToWorld(const QPoint& screenPosition, float depth) override; - AZStd::optional ViewportScreenToWorldRay(const QPoint& screenPosition) override; + AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition) override; + AZStd::optional ViewportScreenToWorld(const AzFramework::ScreenPoint& screenPosition, float depth) override; + AZStd::optional ViewportScreenToWorldRay( + const AzFramework::ScreenPoint& screenPosition) override; // AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Handler ... void BeginCursorCapture() override; diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorGroupHeaderWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorGroupHeaderWidget.cpp index 2928d745c1..41cc1e4a50 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorGroupHeaderWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorGroupHeaderWidget.cpp @@ -14,10 +14,10 @@ #include #include -#include -#include #include +#include #include +#include #include 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 diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp index 31a291c845..ec5f9893bd 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp @@ -10,12 +10,13 @@ * */ +#include #include #include #include -#include #include +#include #include #include @@ -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 diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index 483b4bc55b..5f3c553601 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.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 RenderViewportWidget::ViewportScreenToWorld(const QPoint& screenPosition, float depth) + AZStd::optional 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 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}; } diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp index d36307e4ec..40684640d6 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp +++ b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp @@ -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 dynamicDraw = m_atomFont->GetOrCreateDynamicDrawForScene(renderScene); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp index 22a7e1c6c0..3c748e352e 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp @@ -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); } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.h index dc6b6e70ea..14204c43dc 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -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 diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index deab9d2715..70627fd2f1 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -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) diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp b/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp index 8011a87ed2..7f3735dacf 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp @@ -26,9 +26,9 @@ #include #include -#include #include #include +#include #include diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp index e472ad57db..040d635bbd 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp @@ -33,8 +33,8 @@ #include #include -#include #include +#include namespace Audio { diff --git a/Gems/CMakeLists.txt b/Gems/CMakeLists.txt index 3b630cfd2f..8a9a140008 100644 --- a/Gems/CMakeLists.txt +++ b/Gems/CMakeLists.txt @@ -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) diff --git a/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp b/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp index 0759e1bbe9..b9b512da36 100644 --- a/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp @@ -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; diff --git a/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp b/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp index 88b0df6e73..c825ab8834 100644 --- a/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp +++ b/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp @@ -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; } diff --git a/Gems/GameEffectSystem/Assets/GameEffectsSystem_Dependencies.xml b/Gems/GameEffectSystem/Assets/GameEffectsSystem_Dependencies.xml deleted file mode 100644 index 0e958e3c7d..0000000000 --- a/Gems/GameEffectSystem/Assets/GameEffectsSystem_Dependencies.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Gems/GameEffectSystem/Assets/seedList.seed b/Gems/GameEffectSystem/Assets/seedList.seed deleted file mode 100644 index b011adc47b..0000000000 --- a/Gems/GameEffectSystem/Assets/seedList.seed +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Gems/GameEffectSystem/CMakeLists.txt b/Gems/GameEffectSystem/CMakeLists.txt deleted file mode 100644 index 20a680bce9..0000000000 --- a/Gems/GameEffectSystem/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/Gems/GameEffectSystem/Code/CMakeLists.txt b/Gems/GameEffectSystem/Code/CMakeLists.txt deleted file mode 100644 index f5735b5107..0000000000 --- a/Gems/GameEffectSystem/Code/CMakeLists.txt +++ /dev/null @@ -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 -) diff --git a/Gems/GameEffectSystem/Code/gameeffectsystem_files.cmake b/Gems/GameEffectSystem/Code/gameeffectsystem_files.cmake deleted file mode 100644 index a8f66da7e0..0000000000 --- a/Gems/GameEffectSystem/Code/gameeffectsystem_files.cmake +++ /dev/null @@ -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 -) diff --git a/Gems/GameEffectSystem/Code/gameeffectsystem_shared_files.cmake b/Gems/GameEffectSystem/Code/gameeffectsystem_shared_files.cmake deleted file mode 100644 index 565deee4c2..0000000000 --- a/Gems/GameEffectSystem/Code/gameeffectsystem_shared_files.cmake +++ /dev/null @@ -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 -) - diff --git a/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffects/GameEffectBase.h b/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffects/GameEffectBase.h deleted file mode 100644 index 464c0bcdf0..0000000000 --- a/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffects/GameEffectBase.h +++ /dev/null @@ -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 -#include -#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 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 CGameEffect::LoadMaterial(const char* pMaterialName) -{ - _smart_ptr pMaterial = NULL; - I3DEngine* p3DEngine = gEnv->p3DEngine; - if (pMaterialName && p3DEngine) - { - IMaterialManager* pMaterialManager = p3DEngine->GetMaterialManager(); - if (pMaterialManager) - { - pMaterial = pMaterialManager->LoadMaterial(pMaterialName); - } - } - return pMaterial; -} //------------------------------------------------------------------------------------------------ - - -#endif//_GAMEEFFECTBASE_H_ diff --git a/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffects/IGameEffect.h b/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffects/IGameEffect.h deleted file mode 100644 index b2f9aed17f..0000000000 --- a/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffects/IGameEffect.h +++ /dev/null @@ -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 - -//================================================================================================== -// 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_ diff --git a/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffectsSystemDefines.h b/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffectsSystemDefines.h deleted file mode 100644 index 296a9975e2..0000000000 --- a/Gems/GameEffectSystem/Code/include/GameEffectSystem/GameEffectsSystemDefines.h +++ /dev/null @@ -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 - -// 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(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 IGameRenderNodePtr; -typedef _smart_ptr IGameRenderElementPtr; - -#endif//_EFFECTS_GAMEEFFECTSSYSTEMDEFINES_H_ diff --git a/Gems/GameEffectSystem/Code/include/GameEffectSystem/IGameEffectSystem.h b/Gems/GameEffectSystem/Code/include/GameEffectSystem/IGameEffectSystem.h deleted file mode 100644 index 22ca06b781..0000000000 --- a/Gems/GameEffectSystem/Code/include/GameEffectSystem/IGameEffectSystem.h +++ /dev/null @@ -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 -#include -#include -#include - -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; - -/** - * 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; - -/// 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& GetEnteredGameCallbackList() - { - static PodArray enteredGameCallbackList; - return enteredGameCallbackList; - } - -#if DEBUG_GAME_FX_SYSTEM - static PodArray& GetEffectDebugList() - { - static PodArray 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_ diff --git a/Gems/GameEffectSystem/Code/include/GameEffectSystem/IGameRenderNode.h b/Gems/GameEffectSystem/Code/include/GameEffectSystem/IGameRenderNode.h deleted file mode 100644 index e236dbc8a6..0000000000 --- a/Gems/GameEffectSystem/Code/include/GameEffectSystem/IGameRenderNode.h +++ /dev/null @@ -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 -#include - -// 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_ diff --git a/Gems/GameEffectSystem/Code/source/GameEffectSystemGem.cpp b/Gems/GameEffectSystem/Code/source/GameEffectSystemGem.cpp deleted file mode 100644 index 589364a33a..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffectSystemGem.cpp +++ /dev/null @@ -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(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) diff --git a/Gems/GameEffectSystem/Code/source/GameEffectSystemGem.h b/Gems/GameEffectSystem/Code/source/GameEffectSystemGem.h deleted file mode 100644 index 930bbca726..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffectSystemGem.h +++ /dev/null @@ -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_ diff --git a/Gems/GameEffectSystem/Code/source/GameEffectSystem_precompiled.cpp b/Gems/GameEffectSystem/Code/source/GameEffectSystem_precompiled.cpp deleted file mode 100644 index 9a1af37a08..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffectSystem_precompiled.cpp +++ /dev/null @@ -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" diff --git a/Gems/GameEffectSystem/Code/source/GameEffectSystem_precompiled.h b/Gems/GameEffectSystem/Code/source/GameEffectSystem_precompiled.h deleted file mode 100644 index a551219e7c..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffectSystem_precompiled.h +++ /dev/null @@ -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 -#include -#include -#include -#include - -#endif//AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_ diff --git a/Gems/GameEffectSystem/Code/source/GameEffects/GameEffectSoftCodeLibrary.cpp b/Gems/GameEffectSystem/Code/source/GameEffects/GameEffectSoftCodeLibrary.cpp deleted file mode 100644 index 14f55b2af6..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffects/GameEffectSoftCodeLibrary.cpp +++ /dev/null @@ -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 diff --git a/Gems/GameEffectSystem/Code/source/GameEffectsSystem.cpp b/Gems/GameEffectSystem/Code/source/GameEffectsSystem.cpp deleted file mode 100644 index b9a2d4dfa7..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffectsSystem.cpp +++ /dev/null @@ -1,1012 +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: CGameEffectsSystem -// Desc: System to handle game effects, render nodes and render elements -// Author: James Chilvers -//================================================================================================== - -// Includes -#include "GameEffectSystem_precompiled.h" -#include "GameEffectsSystem.h" -#include "BitFiddling.h" -#include "RenderElements/GameRenderElement.h" -#include -#include - -#include - -//-------------------------------------------------------------------------------------------------- -// Desc: Defines -//-------------------------------------------------------------------------------------------------- -#define GAME_FX_DATA_FILE "scripts/effects/gameeffects.xml" -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Desc: Debug data -//-------------------------------------------------------------------------------------------------- -#if DEBUG_GAME_FX_SYSTEM -int CGameEffectsSystem::s_currentDebugEffectId = 0; - -const char* GAME_FX_DEBUG_VIEW_NAMES[eMAX_GAME_FX_DEBUG_VIEWS] = { - "None", "Profiling", - "Effect List", "Bounding Box", - "Bounding Sphere", "Particles" -}; - -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Desc: Static data -//-------------------------------------------------------------------------------------------------- -int CGameEffectsSystem::s_postEffectCVarNameOffset = 0; -//-------------------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------------------- - -//================================================================================================== -// Name: CGameRenderNodeSoftCodeListener -// Desc: Game Render Node Soft Code Listener -// Author: James Chilvers -//================================================================================================== -class CGameRenderNodeSoftCodeListener - : public ISoftCodeListener -{ -public: - CGameRenderNodeSoftCodeListener() - { - if (gEnv->pSoftCodeMgr) - { - gEnv->pSoftCodeMgr->AddListener(GAME_RENDER_NODE_LIBRARY_NAME, this, - GAME_RENDER_NODE_LISTENER_NAME); - } - } - virtual ~CGameRenderNodeSoftCodeListener() - { - if (gEnv->pSoftCodeMgr) - { - gEnv->pSoftCodeMgr->RemoveListener(GAME_RENDER_NODE_LIBRARY_NAME, this); - } - } - - virtual void InstanceReplaced(void* pOldInstance, void* pNewInstance) - { - GAME_FX_SYSTEM.GameRenderNodeInstanceReplaced(pOldInstance, pNewInstance); - } -}; //------------------------------------------------------------------------------------------------ - -//================================================================================================== -// Name: CGameRenderElementSoftCodeListener -// Desc: Game Render Element Soft Code Listener -// Author: James Chilvers -//================================================================================================== -class CGameRenderElementSoftCodeListener - : public ISoftCodeListener -{ -public: - CGameRenderElementSoftCodeListener() - { - if (gEnv->pSoftCodeMgr) - { - gEnv->pSoftCodeMgr->AddListener(GAME_RENDER_ELEMENT_LIBRARY_NAME, this, - GAME_RENDER_ELEMENT_LISTENER_NAME); - } - } - virtual ~CGameRenderElementSoftCodeListener() - { - if (gEnv->pSoftCodeMgr) - { - gEnv->pSoftCodeMgr->RemoveListener(GAME_RENDER_ELEMENT_LIBRARY_NAME, this); - } - } - - virtual void InstanceReplaced(void* pOldInstance, void* pNewInstance) - { - GAME_FX_SYSTEM.GameRenderElementInstanceReplaced(pOldInstance, pNewInstance); - } -}; //------------------------------------------------------------------------------------------------ - -//-------------------------------------------------------------------------------------------------- -// Name: CGameEffectsSystem -// Desc: Constructor -//-------------------------------------------------------------------------------------------------- -CGameEffectsSystem::CGameEffectsSystem() - : AzFramework::InputChannelEventListener(AzFramework::InputChannelEventListener::GetPriorityDebug()) -{ -#if DEBUG_GAME_FX_SYSTEM - AzFramework::InputChannelEventListener::Connect(); -#endif - -#ifdef SOFTCODE_ENABLED - if (gEnv->pSoftCodeMgr) - { - gEnv->pSoftCodeMgr->AddListener(GAME_FX_LIBRARY_NAME, this, GAME_FX_LISTENER_NAME); - } - - m_gameRenderNodes.clear(); - m_gameRenderNodeSoftCodeListener = new CGameRenderNodeSoftCodeListener; - - m_gameRenderElements.clear(); - m_gameRenderElementSoftCodeListener = new CGameRenderElementSoftCodeListener; - - RegisterSoftCodeLib(IGameEffect::TLibrary::Instance()); - RegisterSoftCodeLib(IGameRenderNode::TLibrary::Instance()); - RegisterSoftCodeLib(IGameRenderElement::TLibrary::Instance()); -#endif - - Reset(); -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: ~CGameEffectsSystem -// Desc: Destructor -//-------------------------------------------------------------------------------------------------- -CGameEffectsSystem::~CGameEffectsSystem() -{ -#if DEBUG_GAME_FX_SYSTEM - AzFramework::InputChannelEventListener::Disconnect(); -#endif - -#ifdef SOFTCODE_ENABLED - if (gEnv->pSoftCodeMgr) - { - gEnv->pSoftCodeMgr->RemoveListener(GAME_FX_LIBRARY_NAME, this); - } - - SAFE_DELETE(m_gameRenderNodeSoftCodeListener); - SAFE_DELETE(m_gameRenderElementSoftCodeListener); - m_softCodeTypeLibs.clear(); - m_gameRenderNodes.clear(); - m_gameRenderElements.clear(); -#endif - - AZ::TickBus::Handler::BusDisconnect(); -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: Destroy -// Desc: Destroys effects system -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::Destroy() -{ - EBUS_EVENT(GameEffectSystemNotificationBus, OnReleaseGameEffects); - AutoReleaseAndDeleteFlaggedEffects(m_effectsToUpdate); - AutoReleaseAndDeleteFlaggedEffects(m_effectsNotToUpdate); - FX_ASSERT_MESSAGE(m_effectsToUpdate == nullptr && m_effectsNotToUpdate == nullptr, - "Game Effects System being destroyed even though game effects still exist!"); -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: Reset -// Desc: Resets effects systems data -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::Reset() -{ - m_isInitialised = false; - m_effectsToUpdate = NULL; - m_effectsNotToUpdate = NULL; - m_nextEffectToUpdate = NULL; - s_postEffectCVarNameOffset = 0; - -#if DEBUG_GAME_FX_SYSTEM - m_debugView = eGAME_FX_DEBUG_VIEW_None; -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: Initialize -// Desc: Initializes effects system -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::Initialize() -{ - if (m_isInitialised == false) - { - Reset(); - SetPostEffectCVarCallbacks(); - - AZ::TickBus::Handler::BusConnect(); - - m_isInitialised = true; - } -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: GameRulesInitialise -// Desc: Game Rules initialise -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::GameRulesInitialise() -{ -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: LoadData -// Desc: Loads data for game effects system and effects -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::LoadData() -{ -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: ReleaseData -// Desc: Releases any loaded data for game effects system and any effects with registered callbacks -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::ReleaseData() -{ - if (s_hasLoadedData) - { -#if DEBUG_GAME_FX_SYSTEM - // Unload all debug effects which rely on effect data - for (size_t i = 0; i < s_effectDebugList.Size(); i++) - { - if (s_effectDebugList[i].inputCallback) - { - s_effectDebugList[i].inputCallback(GAME_FX_INPUT_ReleaseDebugEffect); - } - } -#endif - - for (IGameEffect* ge = m_effectsToUpdate; ge; ge = ge->Next()) - { - ge->UnloadData(); - } - for (IGameEffect* ge = m_effectsNotToUpdate; ge; ge = ge->Next()) - { - ge->UnloadData(); - } - s_hasLoadedData = false; - } -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: ReloadData -// Desc: Reloads any loaded data for game effects registered callbacks -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::ReloadData() -{ -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: EnteredGame -// Desc: Called when entering a game -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::EnteredGame() -{ - const int callbackCount = s_enteredGameCallbackList.size(); - EnteredGameCallback enteredGameCallbackFunc = NULL; - for (int i = 0; i < callbackCount; i++) - { - enteredGameCallbackFunc = s_enteredGameCallbackList[i]; - if (enteredGameCallbackFunc) - { - enteredGameCallbackFunc(); - } - } -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: AutoReleaseAndDeleteFlaggedEffects -// Desc: Calls release and delete on any effects with the these flags set -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::AutoReleaseAndDeleteFlaggedEffects(IGameEffect* effectList) -{ - if (effectList) - { - IGameEffect* effect = effectList; - while (effect) - { - m_nextEffectToUpdate = effect->Next(); - - bool autoRelease = effect->IsFlagSet(GAME_EFFECT_AUTO_RELEASE); - bool autoDelete = effect->IsFlagSet(GAME_EFFECT_AUTO_DELETE); - - if (autoRelease || autoDelete) - { - SOFTCODE_RETRY(effect, effect->Release()); - if (autoDelete) - { - SAFE_DELETE(effect); - } - } - - effect = m_nextEffectToUpdate; - } - m_nextEffectToUpdate = NULL; - } -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: InstanceReplaced -// Desc: Replaces instance for soft coding -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::InstanceReplaced([[maybe_unused]] void* pOldInstance, [[maybe_unused]] void* pNewInstance) -{ -#ifdef SOFTCODE_ENABLED - if (pNewInstance && pOldInstance) - { - IGameEffect* pNewGameEffectInstance = static_cast(pNewInstance); - IGameEffect* pOldGameEffectInstance = static_cast(pOldInstance); - - // Copy over flags and remove registered flag so new effect instance can be registered - // We haven't used the SOFT macro on the m_flags member because the oldInstance's flags - // would then be Nulled out, and they are needed for the effect to be deregistered - uint32 oldGameEffectFlags = pOldGameEffectInstance->GetFlags(); - SET_FLAG(oldGameEffectFlags, GAME_EFFECT_REGISTERED, false); - pNewGameEffectInstance->SetFlags(oldGameEffectFlags); - - // Register new effect instance, old instance will get unregistered by destructor - GAME_FX_SYSTEM.RegisterEffect(pNewGameEffectInstance); - - // Reload all data used by effects, then data can be added/removed for soft coding - ReloadData(); - - // Data used by effect will be copied to new effect, so mustn't release it but - // must set flag so destructor doesn't assert - pOldGameEffectInstance->SetFlag(GAME_EFFECT_RELEASED, true); - } -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: GameRenderNodeInstanceReplaced -// Desc: Replaces Game Render Node instance for soft coding -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::GameRenderNodeInstanceReplaced([[maybe_unused]] void* pOldInstance, [[maybe_unused]] void* pNewInstance) -{ -#ifdef SOFTCODE_ENABLED - if (pOldInstance && pNewInstance) - { - IGameRenderNode* pOldGameRenderNodeInstance = (IGameRenderNode*)pOldInstance; - IGameRenderNode* pNewGameRenderNodeInstance = (IGameRenderNode*)pNewInstance; - - // Unregister old node from engine - gEnv->p3DEngine->FreeRenderNodeState(pOldGameRenderNodeInstance); - - // Register new node with engine - gEnv->p3DEngine->RegisterEntity(pNewGameRenderNodeInstance); - - for (TGameRenderNodeVec::iterator iter(m_gameRenderNodes.begin()); - iter != m_gameRenderNodes.end(); ++iter) - { - IGameRenderNodePtr* ppRenderNode = *iter; - if (ppRenderNode) - { - IGameRenderNodePtr& pRenderNode = *ppRenderNode; - - if (pRenderNode == pOldGameRenderNodeInstance) - { - pRenderNode = pNewGameRenderNodeInstance; - } - } - } - } -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: GameRenderElementInstanceReplaced -// Desc: Replaces Game Render Element instance for soft coding -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::GameRenderElementInstanceReplaced([[maybe_unused]] void* pOldInstance, [[maybe_unused]] void* pNewInstance) -{ -#ifdef SOFTCODE_ENABLED - if (pOldInstance && pNewInstance) - { - IGameRenderElement* pOldGameRenderElementInstance = (IGameRenderElement*)pOldInstance; - IGameRenderElement* pNewGameRenderElementInstance = (IGameRenderElement*)pNewInstance; - - pNewGameRenderElementInstance->UpdatePrivateImplementation(); - - for (TGameRenderElementVec::iterator iter(m_gameRenderElements.begin()); - iter != m_gameRenderElements.end(); ++iter) - { - IGameRenderElementPtr* ppRenderElement = *iter; - if (ppRenderElement) - { - IGameRenderElementPtr& pRenderElement = *ppRenderElement; - - if (pRenderElement == pOldGameRenderElementInstance) - { - pRenderElement = pNewGameRenderElementInstance; - } - } - } - } -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: SetPostEffectCVarCallbacks -// Desc: Sets Post effect CVar callbacks for testing and tweaking post effect values -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::SetPostEffectCVarCallbacks() -{ -#if DEBUG_GAME_FX_SYSTEM - ICVar* postEffectCvar = NULL; - const char postEffectNames[][64] = - { - "g_postEffect.FilterGrain_Amount", "g_postEffect.FilterRadialBlurring_Amount", - "g_postEffect.FilterRadialBlurring_ScreenPosX", - "g_postEffect.FilterRadialBlurring_ScreenPosY", "g_postEffect.FilterRadialBlurring_Radius", - "g_postEffect.Global_User_ColorC", "g_postEffect.Global_User_ColorM", - "g_postEffect.Global_User_ColorY", "g_postEffect.Global_User_ColorK", - "g_postEffect.Global_User_Brightness", "g_postEffect.Global_User_Contrast", - "g_postEffect.Global_User_Saturation", "g_postEffect.Global_User_ColorHue" - }; - - int postEffectNameCount = sizeof(postEffectNames) / sizeof(*postEffectNames); - - if (postEffectNameCount > 0) - { - // Calc name offset - const char* postEffectName = postEffectNames[0]; - s_postEffectCVarNameOffset = 0; - while ((*postEffectName) != 0) - { - s_postEffectCVarNameOffset++; - if ((*postEffectName) == '.') - { - break; - } - postEffectName++; - } - - // Set callback functions - for (int i = 0; i < postEffectNameCount; i++) - { - postEffectCvar = gEnv->pConsole->GetCVar(postEffectNames[i]); - if (postEffectCvar) - { - postEffectCvar->SetOnChangeCallback(PostEffectCVarCallback); - } - } - } -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: PostEffectCVarCallback -// Desc: Callback function of post effect cvars to set their values -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::PostEffectCVarCallback(ICVar* cvar) -{ - const char* effectName = cvar->GetName() + s_postEffectCVarNameOffset; - gEnv->p3DEngine->SetPostEffectParam(effectName, cvar->GetFVal()); -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: RegisterEffect -// Desc: Registers effect with effect system -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::RegisterEffect(IGameEffect* effect) -{ - FX_ASSERT_MESSAGE(m_isInitialised, - "Game Effects System trying to register an effect without being initialised"); - FX_ASSERT_MESSAGE(effect, "Trying to Register a NULL effect"); - - if (effect) - { - // If effect is registered, then unregister first - if (effect->IsFlagSet(GAME_EFFECT_REGISTERED)) - { - UnRegisterEffect(effect); - } - - // Add effect to effect list - IGameEffect** effectList = NULL; - bool isActive = effect->IsFlagSet(GAME_EFFECT_ACTIVE); - bool autoUpdatesWhenActive = effect->IsFlagSet(GAME_EFFECT_AUTO_UPDATES_WHEN_ACTIVE); - bool autoUpdatesWhenNotActive = effect->IsFlagSet(GAME_EFFECT_AUTO_UPDATES_WHEN_NOT_ACTIVE); - if ((isActive && autoUpdatesWhenActive) || ((!isActive) && autoUpdatesWhenNotActive)) - { - effectList = &m_effectsToUpdate; - } - else - { - effectList = &m_effectsNotToUpdate; - } - - if (*effectList) - { - (*effectList)->SetPrev(effect); - effect->SetNext(*effectList); - } - (*effectList) = effect; - - effect->SetFlag(GAME_EFFECT_REGISTERED, true); - } -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: UnRegisterEffect -// Desc: UnRegisters effect from effect system -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::UnRegisterEffect(IGameEffect* effect) -{ - FX_ASSERT_MESSAGE( - m_isInitialised, - "Game Effects System trying to unregister an effect without being initialised"); - FX_ASSERT_MESSAGE(effect, "Trying to UnRegister a NULL effect"); - - if (effect && effect->IsFlagSet(GAME_EFFECT_REGISTERED)) - { - // If the effect is the next one to be updated, then point m_nextEffectToUpdate to the next - // effect after it - if (effect == m_nextEffectToUpdate) - { - m_nextEffectToUpdate = m_nextEffectToUpdate->Next(); - } - - if (effect->Prev()) - { - effect->Prev()->SetNext(effect->Next()); - } - else - { - if (m_effectsToUpdate == effect) - { - m_effectsToUpdate = effect->Next(); - } - else - { - FX_ASSERT_MESSAGE((m_effectsNotToUpdate == effect), - "Effect isn't either updating list"); - m_effectsNotToUpdate = effect->Next(); - } - } - - if (effect->Next()) - { - effect->Next()->SetPrev(effect->Prev()); - } - - effect->SetNext(NULL); - effect->SetPrev(NULL); - - effect->SetFlag(GAME_EFFECT_REGISTERED, false); - } -} //------------------------------------------------------------------------------------------------- - -void CGameEffectsSystem::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) -{ - Update(deltaTime); -} - -//-------------------------------------------------------------------------------------------------- -// Name: Update -// Desc: Updates effects system and any effects registered in it's update list -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::Update(float frameTime) -{ - FX_ASSERT_MESSAGE(m_isInitialised, - "Game Effects System trying to update without being initialised"); - - // Update effects - if (m_effectsToUpdate) - { - IGameEffect* effect = m_effectsToUpdate; - while (effect) - { - m_nextEffectToUpdate = effect->Next(); - if (effect->IsFlagSet(GAME_EFFECT_UPDATE_WHEN_PAUSED)) - { - SOFTCODE_RETRY(effect, effect->Update(frameTime)); - } - effect = m_nextEffectToUpdate; - } - } - - m_nextEffectToUpdate = NULL; - -#if DEBUG_GAME_FX_SYSTEM - DrawDebugDisplay(); -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: CreateSoftCodeInstance -// Desc: Creates soft code instance -//-------------------------------------------------------------------------------------------------- -#ifdef SOFTCODE_ENABLED -void* CGameEffectsSystem::CreateSoftCodeInstance(const char* pTypeName) -{ - void* pNewInstance = NULL; - - if (pTypeName) - { - for (std::vector::iterator iter(m_softCodeTypeLibs.begin()); - iter != m_softCodeTypeLibs.end(); ++iter) - { - ITypeLibrary* pLib = *iter; - if (pLib) - { - if (pNewInstance = pLib->CreateInstanceVoid(pTypeName)) - { - break; - } - } - } - } - - return pNewInstance; -} -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: RegisterSoftCodeLib -// Desc: Register soft code lib for creation of instances -//-------------------------------------------------------------------------------------------------- -#ifdef SOFTCODE_ENABLED -void CGameEffectsSystem::RegisterSoftCodeLib(ITypeLibrary* pLib) -{ - m_softCodeTypeLibs.push_back(pLib); -}; -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: RegisterGameRenderNode -// Desc: Registers game render node -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::RegisterGameRenderNode([[maybe_unused]] IGameRenderNodePtr& pGameRenderNode) -{ -#ifdef SOFTCODE_ENABLED - for (TGameRenderNodeVec::iterator iter(m_gameRenderNodes.begin()); - iter != m_gameRenderNodes.end(); ++iter) - { - IGameRenderNodePtr* ppIterRenderNode = *iter; - if (ppIterRenderNode == NULL) - { - *iter = &pGameRenderNode; - return; - } - } - m_gameRenderNodes.push_back(&pGameRenderNode); -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: UnregisterGameRenderNode -// Desc: Unregisters game render node -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::UnregisterGameRenderNode([[maybe_unused]] IGameRenderNodePtr& pGameRenderNode) -{ -#ifdef SOFTCODE_ENABLED - TGameRenderNodeVec::iterator iter( - std::find(m_gameRenderNodes.begin(), m_gameRenderNodes.end(), &pGameRenderNode)); - if (iter != m_gameRenderNodes.end()) - { - *iter = NULL; - } -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: RegisterGameRenderElement -// Desc: Registers game render element -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::RegisterGameRenderElement([[maybe_unused]] IGameRenderElementPtr& pGameRenderElement) -{ -#ifdef SOFTCODE_ENABLED - for (TGameRenderElementVec::iterator iter(m_gameRenderElements.begin()); - iter != m_gameRenderElements.end(); ++iter) - { - IGameRenderElementPtr* ppIterRenderElement = *iter; - if (ppIterRenderElement == NULL) - { - *iter = &pGameRenderElement; - return; - } - } - m_gameRenderElements.push_back(&pGameRenderElement); -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: UnregisterGameRenderElement -// Desc: Unregisters game render element -//-------------------------------------------------------------------------------------------------- -void CGameEffectsSystem::UnregisterGameRenderElement([[maybe_unused]] IGameRenderElementPtr& pGameRenderElement) -{ -#ifdef SOFTCODE_ENABLED - TGameRenderElementVec::iterator iter( - std::find(m_gameRenderElements.begin(), m_gameRenderElements.end(), &pGameRenderElement)); - if (iter != m_gameRenderElements.end()) - { - *iter = NULL; - } -#endif -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: DrawDebugDisplay -// Desc: Draws debug display -//-------------------------------------------------------------------------------------------------- -#if DEBUG_GAME_FX_SYSTEM -void CGameEffectsSystem::DrawDebugDisplay() -{ - static ColorF textCol(1.0f, 1.0f, 1.0f, 1.0f); - static ColorF controlCol(0.6f, 0.6f, 0.6f, 1.0f); - - static Vec2 textPos(10.0f, 10.0f); - static float textSize = 1.4f; - static float textYSpacing = 18.0f; - - static float effectNameXOffset = 100.0f; - static ColorF effectNameCol(0.0f, 1.0f, 0.0f, 1.0f); - - Vec2 currentTextPos = textPos; - - int debugEffectCount = s_effectDebugList.Size(); - if (GetISystem()->GetIConsole()->GetCVar("g_gameFXSystemDebug")->GetIVal() && debugEffectCount > 0) - { - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &textCol.r, - false, "Debug view:"); - gEnv->pRenderer->Draw2dLabel(currentTextPos.x + effectNameXOffset, currentTextPos.y, - textSize, &effectNameCol.r, false, - GAME_FX_DEBUG_VIEW_NAMES[m_debugView]); - currentTextPos.y += textYSpacing; - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &controlCol.r, - false, "(Change debug view: Left/Right arrows)"); - currentTextPos.y += textYSpacing; - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &textCol.r, - false, "Debug effect:"); - gEnv->pRenderer->Draw2dLabel(currentTextPos.x + effectNameXOffset, currentTextPos.y, - textSize, &effectNameCol.r, false, - s_effectDebugList[s_currentDebugEffectId].effectName); - currentTextPos.y += textYSpacing; - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &controlCol.r, - false, "(Change effect: NumPad +/-)"); - currentTextPos.y += textYSpacing; - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &controlCol.r, - false, "(Reload effect data: NumPad .)"); - currentTextPos.y += textYSpacing; - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &controlCol.r, - false, "(Reset Particle System: Delete)"); - currentTextPos.y += textYSpacing; - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, &controlCol.r, - false, "(Pause Particle System: End)"); - currentTextPos.y += textYSpacing; - - if (s_effectDebugList[s_currentDebugEffectId].displayCallback) - { - s_effectDebugList[s_currentDebugEffectId].displayCallback(currentTextPos, textSize, - textYSpacing); - } - - if (m_debugView == eGAME_FX_DEBUG_VIEW_EffectList) - { - static Vec2 listPos(350.0f, 50.0f); - static float nameSize = 150.0f; - static float tabSize = 60.0f; - currentTextPos = listPos; - - const int EFFECT_LIST_COUNT = 2; - IGameEffect* pEffectListArray[EFFECT_LIST_COUNT] = { - m_effectsToUpdate, - m_effectsNotToUpdate - }; - - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, - &effectNameCol.r, false, "Name"); - currentTextPos.x += nameSize; - - const int FLAG_COUNT = 9; - - const char* flagName[FLAG_COUNT] = { - "Init", "Rel", "ARels", "ADels", "AUWA", - "AUWnA", "Reg", "Actv", "DBG" - }; - const int flag[FLAG_COUNT] = { - GAME_EFFECT_INITIALISED, GAME_EFFECT_RELEASED, - GAME_EFFECT_AUTO_RELEASE, GAME_EFFECT_AUTO_DELETE, - GAME_EFFECT_AUTO_UPDATES_WHEN_ACTIVE, - GAME_EFFECT_AUTO_UPDATES_WHEN_NOT_ACTIVE, - GAME_EFFECT_REGISTERED, GAME_EFFECT_ACTIVE, - GAME_EFFECT_DEBUG_EFFECT - }; - - for (int i = 0; i < FLAG_COUNT; i++) - { - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, - &effectNameCol.r, false, flagName[i]); - currentTextPos.x += tabSize; - } - - currentTextPos.y += textYSpacing; - - for (int l = 0; l < EFFECT_LIST_COUNT; l++) - { - IGameEffect* pCurrentEffect = pEffectListArray[l]; - while (pCurrentEffect) - { - currentTextPos.x = listPos.x; - - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, - &textCol.r, false, pCurrentEffect->GetName()); - currentTextPos.x += nameSize; - - for (int i = 0; i < FLAG_COUNT; i++) - { - gEnv->pRenderer->Draw2dLabel(currentTextPos.x, currentTextPos.y, textSize, - &textCol.r, false, - pCurrentEffect->IsFlagSet(flag[i]) ? "1" - : "0"); - currentTextPos.x += tabSize; - } - - currentTextPos.y += textYSpacing; - pCurrentEffect = pCurrentEffect->Next(); - } - } - } - } -} -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: OnInputChannelEventFiltered -// Desc: Handles any debug input for the game effects system to test effects -//-------------------------------------------------------------------------------------------------- -bool CGameEffectsSystem::OnInputChannelEventFiltered([[maybe_unused]] const AzFramework::InputChannel& inputChannel) -{ -#if DEBUG_GAME_FX_SYSTEM - - int debugEffectCount = s_effectDebugList.Size(); - - if ((GetISystem()->GetIConsole()->GetCVar("g_gameFXSystemDebug")->GetIVal()) && (debugEffectCount > 0)) - { - if (AzFramework::InputDeviceKeyboard::IsKeyboardDevice(inputChannel.GetInputDevice().GetInputDeviceId()) && - inputChannel.IsStateBegan()) - { - const AZ::Crc32& inputChannelNameCrc32 = inputChannel.GetInputChannelId().GetNameCrc32(); - if (inputChannelNameCrc32 == GAME_FX_INPUT_IncrementDebugEffectId) - { - if (s_currentDebugEffectId < (debugEffectCount - 1)) - { - s_currentDebugEffectId++; - } - } - else if (inputChannelNameCrc32 == GAME_FX_INPUT_DecrementDebugEffectId) - { - if (s_currentDebugEffectId > 0) - { - s_currentDebugEffectId--; - } - } - else if (inputChannelNameCrc32 == GAME_FX_INPUT_DecrementDebugView) - { - if (m_debugView > 0) - { - OnDeActivateDebugView(m_debugView); - m_debugView--; - OnActivateDebugView(m_debugView); - } - } - else if (inputChannelNameCrc32 == GAME_FX_INPUT_IncrementDebugView) - { - if (m_debugView < (eMAX_GAME_FX_DEBUG_VIEWS - 1)) - { - OnDeActivateDebugView(m_debugView); - m_debugView++; - OnActivateDebugView(m_debugView); - } - } - else if (inputChannelNameCrc32 == GAME_FX_INPUT_ReloadEffectData) - { - ReloadData(); - } - - // Send input to current debug effect - if (s_effectDebugList[s_currentDebugEffectId].inputCallback) - { - s_effectDebugList[s_currentDebugEffectId].inputCallback(inputChannelNameCrc32); - } - } - } -#endif - - return false; // Return false so that other listeners will get this event -} //------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: GetDebugEffect -// Desc: Gets debug instance of effect -//-------------------------------------------------------------------------------------------------- -#if DEBUG_GAME_FX_SYSTEM -IGameEffect* CGameEffectsSystem::GetDebugEffect(const char* pEffectName) const -{ - const int EFFECT_LIST_COUNT = 2; - IGameEffect* pEffectListArray[EFFECT_LIST_COUNT] = {m_effectsToUpdate, m_effectsNotToUpdate}; - - for (int l = 0; l < EFFECT_LIST_COUNT; l++) - { - IGameEffect* pCurrentEffect = pEffectListArray[l]; - while (pCurrentEffect) - { - if (pCurrentEffect->IsFlagSet(GAME_EFFECT_DEBUG_EFFECT) && - (strcmp(pCurrentEffect->GetName(), pEffectName) == 0)) - { - return pCurrentEffect; - } - pCurrentEffect = pCurrentEffect->Next(); - } - } - - return NULL; -} -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: OnActivateDebugView -// Desc: Called on debug view activation -//-------------------------------------------------------------------------------------------------- -#if DEBUG_GAME_FX_SYSTEM -void CGameEffectsSystem::OnActivateDebugView(int debugView) -{ - switch (debugView) - { - case eGAME_FX_DEBUG_VIEW_Profiling: - { - ICVar* r_displayInfoCVar = gEnv->pConsole->GetCVar("r_DisplayInfo"); - if (r_displayInfoCVar) - { - r_displayInfoCVar->Set(1); - } - break; - } - } -} -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: OnDeActivateDebugView -// Desc: Called on debug view de-activation -//-------------------------------------------------------------------------------------------------- -#if DEBUG_GAME_FX_SYSTEM -void CGameEffectsSystem::OnDeActivateDebugView(int debugView) -{ - switch (debugView) - { - case eGAME_FX_DEBUG_VIEW_Profiling: - { - ICVar* r_displayInfoCVar = gEnv->pConsole->GetCVar("r_DisplayInfo"); - if (r_displayInfoCVar) - { - r_displayInfoCVar->Set(0); - } - break; - } - } -} -#endif -//-------------------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------------------- -// Name: RegisterEffectDebugData -// Desc: Registers effect's debug data with the game effects system, which will then call the -// relevant debug callback functions for the for the effect when its selected -//using the -// s_currentDebugEffectId -//-------------------------------------------------------------------------------------------------- -#if DEBUG_GAME_FX_SYSTEM -void IGameEffectSystem::RegisterEffectDebugData(DebugOnInputEventCallback inputEventCallback, - DebugDisplayCallback displayCallback, - const char* effectName) -{ - s_effectDebugList.push_back(SEffectDebugData(inputEventCallback, displayCallback, effectName)); -} -#endif -//-------------------------------------------------------------------------------------------------- diff --git a/Gems/GameEffectSystem/Code/source/GameEffectsSystem.h b/Gems/GameEffectSystem/Code/source/GameEffectsSystem.h deleted file mode 100644 index 4dd6fe0435..0000000000 --- a/Gems/GameEffectSystem/Code/source/GameEffectsSystem.h +++ /dev/null @@ -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 -#include - -//================================================================================================== -// 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 - 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 m_softCodeTypeLibs; - - typedef std::vector TGameRenderNodeVec; - TGameRenderNodeVec m_gameRenderNodes; - CGameRenderNodeSoftCodeListener* m_gameRenderNodeSoftCodeListener; - - typedef std::vector 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_ diff --git a/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElement.cpp b/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElement.cpp deleted file mode 100644 index c68b8526b0..0000000000 --- a/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElement.cpp +++ /dev/null @@ -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; -} //------------------------------------------------------------------------------------------------- diff --git a/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElement.h b/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElement.h deleted file mode 100644 index 37d149cdde..0000000000 --- a/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElement.h +++ /dev/null @@ -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 - -// 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_ diff --git a/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElementSoftCodeLibrary.cpp b/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElementSoftCodeLibrary.cpp deleted file mode 100644 index 76bb0eb325..0000000000 --- a/Gems/GameEffectSystem/Code/source/RenderElements/GameRenderElementSoftCodeLibrary.cpp +++ /dev/null @@ -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 -#include "RenderElements/GameRenderElement.h" - -IMPLEMENT_TYPELIB(IGameRenderElement, - GAME_RENDER_ELEMENT_LIBRARY_NAME); // Implementation of Soft Coding library diff --git a/Gems/GameEffectSystem/Code/source/RenderNodes/GameRenderNodeSoftCodeLibrary.cpp b/Gems/GameEffectSystem/Code/source/RenderNodes/GameRenderNodeSoftCodeLibrary.cpp deleted file mode 100644 index a46e964016..0000000000 --- a/Gems/GameEffectSystem/Code/source/RenderNodes/GameRenderNodeSoftCodeLibrary.cpp +++ /dev/null @@ -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 -#include -#include - -IMPLEMENT_TYPELIB(IGameRenderNode, GAME_RENDER_NODE_LIBRARY_NAME); // Implementation of Soft Coding library diff --git a/Gems/GameEffectSystem/Code/source/RenderNodes/IGameRenderNode.h b/Gems/GameEffectSystem/Code/source/RenderNodes/IGameRenderNode.h deleted file mode 100644 index 7a88db116d..0000000000 --- a/Gems/GameEffectSystem/Code/source/RenderNodes/IGameRenderNode.h +++ /dev/null @@ -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 diff --git a/Gems/GameEffectSystem/gem.json b/Gems/GameEffectSystem/gem.json deleted file mode 100644 index ad97bc61ea..0000000000 --- a/Gems/GameEffectSystem/gem.json +++ /dev/null @@ -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" -} diff --git a/Gems/GameStateSamples/Code/Include/GameStateSamples/GameStateLevelRunning.inl b/Gems/GameStateSamples/Code/Include/GameStateSamples/GameStateLevelRunning.inl index 174a5b43c4..335291d57e 100644 --- a/Gems/GameStateSamples/Code/Include/GameStateSamples/GameStateLevelRunning.inl +++ b/Gems/GameStateSamples/Code/Include/GameStateSamples/GameStateLevelRunning.inl @@ -27,7 +27,6 @@ #include #include -#include #include #include @@ -59,10 +58,6 @@ namespace GameStateSamples { // Unload the currently loaded level levelSystem->UnloadLevel(); - if (iSystem->GetI3DEngine()) - { - iSystem->GetI3DEngine()->LoadEmptyLevel(); - } } } diff --git a/Gems/Gestures/Code/Source/Gestures_precompiled.h b/Gems/Gestures/Code/Source/Gestures_precompiled.h index c51e121abc..926c68d091 100644 --- a/Gems/Gestures/Code/Source/Gestures_precompiled.h +++ b/Gems/Gestures/Code/Source/Gestures_precompiled.h @@ -13,5 +13,4 @@ #pragma once #include -#include #include diff --git a/Gems/GradientSignal/Code/CMakeLists.txt b/Gems/GradientSignal/Code/CMakeLists.txt index 362ef61185..7b8c9813e6 100644 --- a/Gems/GradientSignal/Code/CMakeLists.txt +++ b/Gems/GradientSignal/Code/CMakeLists.txt @@ -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 diff --git a/Gems/GradientSignal/Code/Include/GradientSignal/ImageAsset.h b/Gems/GradientSignal/Code/Include/GradientSignal/ImageAsset.h index 20db212da1..3114b4e811 100644 --- a/Gems/GradientSignal/Code/Include/GradientSignal/ImageAsset.h +++ b/Gems/GradientSignal/Code/Include/GradientSignal/ImageAsset.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include 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 m_imageData; }; diff --git a/Gems/GradientSignal/Code/Source/Editor/EditorImageBuilderComponent.cpp b/Gems/GradientSignal/Code/Source/Editor/EditorImageBuilderComponent.cpp index cc207b59a3..ceaf2268e1 100644 --- a/Gems/GradientSignal/Code/Source/Editor/EditorImageBuilderComponent.cpp +++ b/Gems/GradientSignal/Code/Source/Editor/EditorImageBuilderComponent.cpp @@ -28,8 +28,6 @@ #include #include #include -#include -#include #include #include @@ -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(atomPixFormat); - return static_cast(pixelFormatInt); - } - static AZStd::unique_ptr 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; diff --git a/Gems/GradientSignal/Code/Source/GradientImageConversion.cpp b/Gems/GradientSignal/Code/Source/GradientImageConversion.cpp index cfbb71936b..4ed9107c47 100644 --- a/Gems/GradientSignal/Code/Source/GradientImageConversion.cpp +++ b/Gems/GradientSignal/Code/Source/GradientImageConversion.cpp @@ -13,7 +13,7 @@ #include "GradientSignal_precompiled.h" #include -#include +#include 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 + template struct Underlying {}; template <> - struct Underlying + struct Underlying { using type = AZ::u8; }; template <> - struct Underlying + struct Underlying { using type = AZ::u16; }; template <> - struct Underlying + struct Underlying { using type = AZ::u32; }; template <> - struct Underlying + struct Underlying { using type = float; }; @@ -167,10 +167,10 @@ namespace buffer = AZStd::move(newBuffer); } - template - void ConvertBufferType(AZStd::vector& buffer, ImageProcessing::EPixelFormat newFormat, bool autoScale, AZStd::pair userRange) + template + void ConvertBufferType(AZStd::vector& buffer, ImageProcessingAtom::EPixelFormat newFormat, bool autoScale, AZStd::pair userRange) { - using namespace ImageProcessing; + using namespace ImageProcessingAtom; switch (newFormat) { @@ -195,9 +195,9 @@ namespace } } - ImageProcessing::EPixelFormat ConvertBufferType(AZStd::vector& buffer, ImageProcessing::EPixelFormat old, ImageProcessing::EPixelFormat newFormat, bool autoScale, AZStd::pair userRange) + ImageProcessingAtom::EPixelFormat ConvertBufferType(AZStd::vector& buffer, ImageProcessingAtom::EPixelFormat old, ImageProcessingAtom::EPixelFormat newFormat, bool autoScale, AZStd::pair 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