Sfoglia il codice sorgente

Merge branch 'development' into mobile_pipeline

Akio Gaule 1 anno fa
parent
commit
828a42c50d
100 ha cambiato i file con 1072 aggiunte e 6403 eliminazioni
  1. 3 0
      Assets/Editor/Prefabs/Basic.png
  2. 387 0
      Assets/Editor/Prefabs/Basic.prefab
  3. 3 0
      Assets/Editor/Prefabs/Default_Level.png
  4. 3 0
      Assets/Editor/Prefabs/Empty.png
  5. 49 0
      Assets/Editor/Prefabs/Empty.prefab
  6. 1 0
      AutomatedTesting/Gem/PythonTests/editor/TestSuite_Main.py
  7. 1 1
      Code/Editor/AnimationContext.cpp
  8. 58 110
      Code/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp
  9. 33 35
      Code/Editor/Controls/SplineCtrlEx.cpp
  10. 4 4
      Code/Editor/Controls/TimelineCtrl.cpp
  11. 60 58
      Code/Editor/Controls/WndGridHelper.h
  12. 17 168
      Code/Editor/CryEdit.cpp
  13. 1 6
      Code/Editor/CryEdit.h
  14. 0 21
      Code/Editor/CryEditDoc.cpp
  15. 6 6
      Code/Editor/CryEditPy.cpp
  16. 18 4
      Code/Editor/EditorPreferencesPageGeneral.cpp
  17. 3 1
      Code/Editor/EditorPreferencesPageGeneral.h
  18. 8 4
      Code/Editor/EditorToolsApplication.cpp
  19. 2 2
      Code/Editor/EditorToolsApplication.h
  20. 2 2
      Code/Editor/EditorToolsApplicationAPI.h
  21. 1 0
      Code/Editor/EditorViewportSettings.cpp
  22. 0 84
      Code/Editor/EditorViewportWidget.cpp
  23. 0 10
      Code/Editor/EditorViewportWidget.h
  24. 0 2
      Code/Editor/Include/IDisplayViewport.h
  25. 0 3
      Code/Editor/Include/IObjectManager.h
  26. 0 13
      Code/Editor/MainWindow.cpp
  27. 0 1
      Code/Editor/MainWindow.h
  28. 79 19
      Code/Editor/NewLevelDialog.cpp
  29. 4 17
      Code/Editor/NewLevelDialog.h
  30. 6 0
      Code/Editor/NewLevelDialog.qrc
  31. 89 115
      Code/Editor/NewLevelDialog.ui
  32. 0 228
      Code/Editor/Objects/BaseObject.cpp
  33. 5 21
      Code/Editor/Objects/BaseObject.h
  34. 0 12
      Code/Editor/Objects/DisplayContext.cpp
  35. 0 323
      Code/Editor/Objects/DisplayContext.h
  36. 0 1336
      Code/Editor/Objects/DisplayContextShared.inl
  37. 0 203
      Code/Editor/Objects/EntityObject.cpp
  38. 0 8
      Code/Editor/Objects/EntityObject.h
  39. 0 26
      Code/Editor/Objects/ObjectManager.cpp
  40. 0 2
      Code/Editor/Objects/ObjectManager.h
  41. 0 1
      Code/Editor/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp
  42. 0 32
      Code/Editor/Plugins/ComponentEntityEditorPlugin/ContextMenuHandlers.cpp
  43. 2 7
      Code/Editor/Plugins/ComponentEntityEditorPlugin/ContextMenuHandlers.h
  44. 0 114
      Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp
  45. 0 17
      Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h
  46. 0 2
      Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/AssetCatalogModel.cpp
  47. 0 7
      Code/Editor/Resource.h
  48. 0 1
      Code/Editor/TrackView/TrackViewDialog.cpp
  49. 3 4
      Code/Editor/TrackView/TrackViewNodes.cpp
  50. 6 6
      Code/Editor/TrackView/TrackViewSplineCtrl.cpp
  51. 0 5
      Code/Editor/Viewport.h
  52. 2 3
      Code/Editor/editor_lib_files.cmake
  53. 3 0
      Code/Editor/res/Prefab_80.svg
  54. 2 2
      Code/Editor/splashscreen_background.png
  55. 6 3
      Code/Framework/AzFramework/AzFramework/DocumentPropertyEditor/AggregateAdapter.cpp
  56. 1 2
      Code/Framework/AzFramework/AzFramework/Entity/EntityDebugDisplayBus.h
  57. 0 84
      Code/Framework/AzFramework/AzFramework/Viewport/DisplayContextRequestBus.h
  58. 0 1
      Code/Framework/AzFramework/AzFramework/azframework_files.cmake
  59. 3 1
      Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp
  60. 0 3
      Code/Framework/AzToolsFramework/AzToolsFramework/API/ComponentEntityObjectBus.h
  61. 36 0
      Code/Framework/AzToolsFramework/AzToolsFramework/API/EntityPropertyEditorNotificationBus.h
  62. 6 2
      Code/Framework/AzToolsFramework/AzToolsFramework/API/EntityPropertyEditorRequestsBus.h
  63. 2 2
      Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.cpp
  64. 55 0
      Code/Framework/AzToolsFramework/AzToolsFramework/API/SettingsRegistryUtils.h
  65. 0 20
      Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h
  66. 0 228
      Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp
  67. 0 15
      Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.h
  68. 2 2
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp
  69. 44 7
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTreeToTableProxyModel.cpp
  70. 2 1
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTreeToTableProxyModel.h
  71. 20 2
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetEntryChangeset.cpp
  72. 5 4
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp
  73. 4 3
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp
  74. 0 117
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/BaseSliceCommand.cpp
  75. 0 46
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/BaseSliceCommand.h
  76. 0 218
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/CreateSliceCommand.cpp
  77. 0 42
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/CreateSliceCommand.h
  78. 0 31
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/DetachSubSliceInstanceCommand.cpp
  79. 0 32
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/DetachSubSliceInstanceCommand.h
  80. 0 292
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/EntityStateCommand.cpp
  81. 0 115
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/EntityStateCommand.h
  82. 0 181
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PreemptiveUndoCache.cpp
  83. 0 65
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PreemptiveUndoCache.h
  84. 0 95
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PushToSliceCommand.cpp
  85. 0 31
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PushToSliceCommand.h
  86. 0 28
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/SliceDetachEntityCommand.cpp
  87. 0 40
      Code/Framework/AzToolsFramework/AzToolsFramework/Commands/SliceDetachEntityCommand.h
  88. 20 2
      Code/Framework/AzToolsFramework/AzToolsFramework/ContainerEntity/ContainerEntitySystemComponent.cpp
  89. 1 0
      Code/Framework/AzToolsFramework/AzToolsFramework/Editor/ActionManagerIdentifiers/EditorActionUpdaterIdentifiers.h
  90. 2 0
      Code/Framework/AzToolsFramework/AzToolsFramework/Editor/ActionManagerIdentifiers/EditorMenuIdentifiers.h
  91. 0 92
      Code/Framework/AzToolsFramework/AzToolsFramework/Editor/EditorContextMenuBus.h
  92. 0 27
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.cpp
  93. 2 11
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.h
  94. 0 274
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp
  95. 0 38
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.cpp
  96. 0 10
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.h
  97. 0 67
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
  98. 0 33
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h
  99. 0 941
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.cpp
  100. 0 149
      Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.h

+ 3 - 0
Assets/Editor/Prefabs/Basic.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2f5c619a11b07935d87063ed253e2a15b83ecaa3a87f07a5e350b2ce89187c51
+size 26878

+ 387 - 0
Assets/Editor/Prefabs/Basic.prefab

@@ -0,0 +1,387 @@
+{
+    "ContainerEntity": {
+        "Id": "ContainerEntity",
+        "Name": "Basic",
+        "Components": {
+            "EditorDisabledCompositionComponent": {
+                "$type": "EditorDisabledCompositionComponent",
+                "Id": 10593268821715458406
+            },
+            "EditorEntityIconComponent": {
+                "$type": "EditorEntityIconComponent",
+                "Id": 7904397583211057659
+            },
+            "EditorEntitySortComponent": {
+                "$type": "EditorEntitySortComponent",
+                "Id": 15097443382011872719,
+                "Child Entity Order": [
+                    "Entity_[1379449802595]"
+                ]
+            },
+            "EditorInspectorComponent": {
+                "$type": "EditorInspectorComponent",
+                "Id": 9028208142210445783
+            },
+            "EditorLockComponent": {
+                "$type": "EditorLockComponent",
+                "Id": 18150128499906753747
+            },
+            "EditorOnlyEntityComponent": {
+                "$type": "EditorOnlyEntityComponent",
+                "Id": 7216229212231741030
+            },
+            "EditorPendingCompositionComponent": {
+                "$type": "EditorPendingCompositionComponent",
+                "Id": 5166675226912254616
+            },
+            "EditorPrefabComponent": {
+                "$type": "EditorPrefabComponent",
+                "Id": 17348824920491302694
+            },
+            "EditorVisibilityComponent": {
+                "$type": "EditorVisibilityComponent",
+                "Id": 3716381488483090297
+            },
+            "TransformComponent": {
+                "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                "Id": 2964698134789647987,
+                "Parent Entity": ""
+            }
+        }
+    },
+    "Entities": {
+        "Entity_[1362269933411]": {
+            "Id": "Entity_[1362269933411]",
+            "Name": "Global Sky",
+            "Components": {
+                "Component_[1428633914413949476]": {
+                    "$type": "EditorLockComponent",
+                    "Id": 1428633914413949476
+                },
+                "Component_[14936200426671614999]": {
+                    "$type": "AZ::Render::EditorImageBasedLightComponent",
+                    "Id": 14936200426671614999,
+                    "Controller": {
+                        "Configuration": {
+                            "diffuseImageAsset": {
+                                "assetId": {
+                                    "guid": "{3FD09945-D0F2-55C8-B9AF-B2FD421FE3BE}",
+                                    "subId": 3000
+                                },
+                                "assetHint": "lightingpresets/highcontrast/goegap_4k_iblglobalcm_ibldiffuse.exr.streamingimage"
+                            },
+                            "specularImageAsset": {
+                                "assetId": {
+                                    "guid": "{3FD09945-D0F2-55C8-B9AF-B2FD421FE3BE}",
+                                    "subId": 2000
+                                },
+                                "assetHint": "lightingpresets/highcontrast/goegap_4k_iblglobalcm_iblspecular.exr.streamingimage"
+                            }
+                        }
+                    },
+                    "diffuseImageAsset": {
+                        "assetId": {
+                            "guid": "{3FD09945-D0F2-55C8-B9AF-B2FD421FE3BE}",
+                            "subId": 3000
+                        },
+                        "assetHint": "lightingpresets/highcontrast/goegap_4k_iblglobalcm_ibldiffuse.exr.streamingimage"
+                    },
+                    "specularImageAsset": {
+                        "assetId": {
+                            "guid": "{3FD09945-D0F2-55C8-B9AF-B2FD421FE3BE}",
+                            "subId": 2000
+                        },
+                        "assetHint": "lightingpresets/highcontrast/goegap_4k_iblglobalcm_iblspecular.exr.streamingimage"
+                    }
+                },
+                "Component_[14994774102579326069]": {
+                    "$type": "EditorDisabledCompositionComponent",
+                    "Id": 14994774102579326069
+                },
+                "Component_[15417479889044493340]": {
+                    "$type": "EditorPendingCompositionComponent",
+                    "Id": 15417479889044493340
+                },
+                "Component_[15826613364991382688]": {
+                    "$type": "EditorEntitySortComponent",
+                    "Id": 15826613364991382688
+                },
+                "Component_[1665003113283562343]": {
+                    "$type": "EditorOnlyEntityComponent",
+                    "Id": 1665003113283562343
+                },
+                "Component_[3704934735944502280]": {
+                    "$type": "EditorEntityIconComponent",
+                    "Id": 3704934735944502280
+                },
+                "Component_[5698542331457326479]": {
+                    "$type": "EditorVisibilityComponent",
+                    "Id": 5698542331457326479
+                },
+                "Component_[6644513399057217122]": {
+                    "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                    "Id": 6644513399057217122,
+                    "Parent Entity": "Entity_[1379449802595]"
+                },
+                "Component_[931091830724002070]": {
+                    "$type": "EditorInspectorComponent",
+                    "Id": 931091830724002070
+                }
+            }
+        },
+        "Entity_[1366564900707]": {
+            "Id": "Entity_[1366564900707]",
+            "Name": "Grid",
+            "Components": {
+                "Component_[11443347433215807130]": {
+                    "$type": "EditorEntityIconComponent",
+                    "Id": 11443347433215807130
+                },
+                "Component_[14249419413039427459]": {
+                    "$type": "EditorInspectorComponent",
+                    "Id": 14249419413039427459
+                },
+                "Component_[15448581635946161318]": {
+                    "$type": "AZ::Render::EditorGridComponent",
+                    "Id": 15448581635946161318,
+                    "Controller": {
+                        "Configuration": {
+                            "primarySpacing": 4.0,
+                            "primaryColor": [
+                                0.501960813999176,
+                                0.501960813999176,
+                                0.501960813999176
+                            ],
+                            "secondarySpacing": 0.5,
+                            "secondaryColor": [
+                                0.250980406999588,
+                                0.250980406999588,
+                                0.250980406999588
+                            ]
+                        }
+                    }
+                },
+                "Component_[1843303322527297409]": {
+                    "$type": "EditorDisabledCompositionComponent",
+                    "Id": 1843303322527297409
+                },
+                "Component_[380249072065273654]": {
+                    "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                    "Id": 380249072065273654,
+                    "Parent Entity": "Entity_[1379449802595]"
+                },
+                "Component_[7476660583684339787]": {
+                    "$type": "EditorPendingCompositionComponent",
+                    "Id": 7476660583684339787
+                },
+                "Component_[7557626501215118375]": {
+                    "$type": "EditorEntitySortComponent",
+                    "Id": 7557626501215118375
+                },
+                "Component_[7984048488947365511]": {
+                    "$type": "EditorVisibilityComponent",
+                    "Id": 7984048488947365511
+                },
+                "Component_[8118181039276487398]": {
+                    "$type": "EditorOnlyEntityComponent",
+                    "Id": 8118181039276487398
+                },
+                "Component_[9189909764215270515]": {
+                    "$type": "EditorLockComponent",
+                    "Id": 9189909764215270515
+                }
+            }
+        },
+        "Entity_[1370859868003]": {
+            "Id": "Entity_[1370859868003]",
+            "Name": "Camera",
+            "Components": {
+                "Component_[11895140916889160460]": {
+                    "$type": "EditorEntityIconComponent",
+                    "Id": 11895140916889160460
+                },
+                "Component_[16880285896855930892]": {
+                    "$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent",
+                    "Id": 16880285896855930892,
+                    "Controller": {
+                        "Configuration": {
+                            "Field of View": 55.0
+                        }
+                    }
+                },
+                "Component_[17187464423780271193]": {
+                    "$type": "EditorLockComponent",
+                    "Id": 17187464423780271193
+                },
+                "Component_[17495696818315413311]": {
+                    "$type": "EditorEntitySortComponent",
+                    "Id": 17495696818315413311
+                },
+                "Component_[18086214374043522055]": {
+                    "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                    "Id": 18086214374043522055,
+                    "Parent Entity": "Entity_[1379449802595]",
+                    "Transform Data": {
+                        "Translate": [
+                            0.0,
+                            -12.883666038513184,
+                            5.73760986328125
+                        ],
+                        "Rotate": [
+                            -25.0,
+                            0.0,
+                            0.0
+                        ]
+                    }
+                },
+                "Component_[2654521436129313160]": {
+                    "$type": "EditorVisibilityComponent",
+                    "Id": 2654521436129313160
+                },
+                "Component_[5265045084611556958]": {
+                    "$type": "EditorDisabledCompositionComponent",
+                    "Id": 5265045084611556958
+                },
+                "Component_[7169798125182238623]": {
+                    "$type": "EditorPendingCompositionComponent",
+                    "Id": 7169798125182238623
+                },
+                "Component_[7255796294953281766]": {
+                    "$type": "GenericComponentWrapper",
+                    "Id": 7255796294953281766,
+                    "m_template": {
+                        "$type": "FlyCameraInputComponent"
+                    }
+                },
+                "Component_[8866210352157164042]": {
+                    "$type": "EditorInspectorComponent",
+                    "Id": 8866210352157164042
+                },
+                "Component_[9129253381063760879]": {
+                    "$type": "EditorOnlyEntityComponent",
+                    "Id": 9129253381063760879
+                }
+            }
+        },
+        "Entity_[1375154835299]": {
+            "Id": "Entity_[1375154835299]",
+            "Name": "Sun",
+            "Components": {
+                "Component_[13620450453324765907]": {
+                    "$type": "EditorLockComponent",
+                    "Id": 13620450453324765907
+                },
+                "Component_[2134313378593666258]": {
+                    "$type": "EditorInspectorComponent",
+                    "Id": 2134313378593666258
+                },
+                "Component_[234010807770404186]": {
+                    "$type": "EditorVisibilityComponent",
+                    "Id": 234010807770404186
+                },
+                "Component_[2970359110423865725]": {
+                    "$type": "EditorEntityIconComponent",
+                    "Id": 2970359110423865725
+                },
+                "Component_[3722854130373041803]": {
+                    "$type": "EditorOnlyEntityComponent",
+                    "Id": 3722854130373041803
+                },
+                "Component_[5992533738676323195]": {
+                    "$type": "EditorDisabledCompositionComponent",
+                    "Id": 5992533738676323195
+                },
+                "Component_[7378860763541895402]": {
+                    "$type": "AZ::Render::EditorDirectionalLightComponent",
+                    "Id": 7378860763541895402,
+                    "Controller": {
+                        "Configuration": {
+                            "Intensity": 1.0,
+                            "CameraEntityId": "",
+                            "ShadowFilterMethod": 1
+                        }
+                    }
+                },
+                "Component_[7892834440890947578]": {
+                    "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                    "Id": 7892834440890947578,
+                    "Parent Entity": "Entity_[1379449802595]",
+                    "Transform Data": {
+                        "Translate": [
+                            0.0,
+                            0.0,
+                            13.487043380737305
+                        ],
+                        "Rotate": [
+                            -76.13099670410156,
+                            -0.847000002861023,
+                            -15.8100004196167
+                        ]
+                    }
+                },
+                "Component_[8599729549570828259]": {
+                    "$type": "EditorEntitySortComponent",
+                    "Id": 8599729549570828259
+                },
+                "Component_[952797371922080273]": {
+                    "$type": "EditorPendingCompositionComponent",
+                    "Id": 952797371922080273
+                }
+            }
+        },
+        "Entity_[1379449802595]": {
+            "Id": "Entity_[1379449802595]",
+            "Name": "Basic",
+            "Components": {
+                "Component_[10757302973393310045]": {
+                    "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                    "Id": 10757302973393310045,
+                    "Parent Entity": "ContainerEntity"
+                },
+                "Component_[14505817420424255464]": {
+                    "$type": "EditorInspectorComponent",
+                    "Id": 14505817420424255464,
+                    "ComponentOrderEntryArray": [
+                        {
+                            "ComponentId": 10757302973393310045
+                        }
+                    ]
+                },
+                "Component_[14988041764659020032]": {
+                    "$type": "EditorLockComponent",
+                    "Id": 14988041764659020032
+                },
+                "Component_[15900837685796817138]": {
+                    "$type": "EditorVisibilityComponent",
+                    "Id": 15900837685796817138
+                },
+                "Component_[3298767348226484884]": {
+                    "$type": "EditorOnlyEntityComponent",
+                    "Id": 3298767348226484884
+                },
+                "Component_[4076975109609220594]": {
+                    "$type": "EditorPendingCompositionComponent",
+                    "Id": 4076975109609220594
+                },
+                "Component_[5679760548946028854]": {
+                    "$type": "EditorDisabledCompositionComponent",
+                    "Id": 5679760548946028854
+                },
+                "Component_[5855590796136709437]": {
+                    "$type": "EditorEntitySortComponent",
+                    "Id": 5855590796136709437,
+                    "Child Entity Order": [
+                        "Entity_[1375154835299]",
+                        "Entity_[1362269933411]",
+                        "Entity_[1366564900707]",
+                        "Entity_[1370859868003]"
+                    ]
+                },
+                "Component_[9277695270015777859]": {
+                    "$type": "EditorEntityIconComponent",
+                    "Id": 9277695270015777859
+                }
+            }
+        }
+    }
+}

+ 3 - 0
Assets/Editor/Prefabs/Default_Level.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c8fa9cb2cf60a98ca88e2f5b299be4f459101aec2be1ddd2deb5e716e06bd96a
+size 96788

+ 3 - 0
Assets/Editor/Prefabs/Empty.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5dfad8c6f5bde570ef574d6daf4f68a39507ad9d0a5193bdc75816b62528de4f
+size 5973

+ 49 - 0
Assets/Editor/Prefabs/Empty.prefab

@@ -0,0 +1,49 @@
+{
+    "ContainerEntity": {
+        "Id": "ContainerEntity",
+        "Name": "Empty",
+        "Components": {
+            "EditorDisabledCompositionComponent": {
+                "$type": "EditorDisabledCompositionComponent",
+                "Id": 16616931740997949210
+            },
+            "EditorEntityIconComponent": {
+                "$type": "EditorEntityIconComponent",
+                "Id": 2778716686621881360
+            },
+            "EditorEntitySortComponent": {
+                "$type": "EditorEntitySortComponent",
+                "Id": 1069995033707506449
+            },
+            "EditorInspectorComponent": {
+                "$type": "EditorInspectorComponent",
+                "Id": 4185413252280323606
+            },
+            "EditorLockComponent": {
+                "$type": "EditorLockComponent",
+                "Id": 4068240492793213930
+            },
+            "EditorOnlyEntityComponent": {
+                "$type": "EditorOnlyEntityComponent",
+                "Id": 1499221618774487829
+            },
+            "EditorPendingCompositionComponent": {
+                "$type": "EditorPendingCompositionComponent",
+                "Id": 10852705643903064770
+            },
+            "EditorPrefabComponent": {
+                "$type": "EditorPrefabComponent",
+                "Id": 12239744644494076517
+            },
+            "EditorVisibilityComponent": {
+                "$type": "EditorVisibilityComponent",
+                "Id": 17437522806552955660
+            },
+            "TransformComponent": {
+                "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
+                "Id": 4584354821622104079,
+                "Parent Entity": ""
+            }
+        }
+    }
+}

+ 1 - 0
AutomatedTesting/Gem/PythonTests/editor/TestSuite_Main.py

@@ -58,6 +58,7 @@ class TestAutomationNoAutoTestMode(EditorTestSuite):
 
         from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module
 
+    @pytest.mark.skip(reason="Skipped for intermittently failing.")
     class test_InputBindings_Add_Remove_Input_Events(EditorBatchedTest):
         from .EditorScripts import InputBindings_Add_Remove_Input_Events as test_module
 

+ 1 - 1
Code/Editor/AnimationContext.cpp

@@ -251,7 +251,7 @@ void CAnimationContext::SetSequence(CTrackViewSequence* sequence, bool force, bo
     {
         // If this was a sequence that was selected by the user in Track View
         // and it was "No Sequence" clear the m_mostRecentSequenceId so the sequence
-        // will not be reselected at unwanted events like a slice reload or an undo operation.
+        // will not be reselected at unwanted events like an undo operation.
         m_mostRecentSequenceId.SetInvalid();
     }
 

+ 58 - 110
Code/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp

@@ -41,14 +41,10 @@
 #include <AzToolsFramework/AssetBrowser/Views/AssetBrowserThumbnailView.h>
 #include <AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.h>
 #include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
 #include <AzToolsFramework/Entity/EditorEntityHelpers.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-#include <AzToolsFramework/Slice/SliceUtilities.h>
 #include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
 #include <AzToolsFramework/ToolsComponents/GenericComponentWrapper.h>
 #include <AzToolsFramework/ToolsComponents/TransformComponent.h>
-#include <AzToolsFramework/UI/Slice/SliceRelationshipBus.h>
 #include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
 
 // AzQtComponents
@@ -201,11 +197,6 @@ namespace AzAssetBrowserRequestHandlerPrivate
             return false;
         }
 
-        if (product->GetAssetType() == AZ::AzTypeInfo<AZ::SliceAsset>::Uuid())
-        {
-            return true; // we can always instantiate slices.
-        }
-
         bool canCreateComponent = false;
         AZ::AssetTypeInfoBus::EventResult(canCreateComponent, product->GetAssetType(), &AZ::AssetTypeInfo::CanCreateComponent, product->GetAssetId());
         if (!canCreateComponent)
@@ -231,8 +222,7 @@ namespace AzAssetBrowserRequestHandlerPrivate
         AZStd::vector<const ProductAssetBrowserEntry*> products,
         AZ::Vector3 location,
         AZ::EntityId parentEntityId, // if valid, will treat the location as a local transform relative to this entity.
-        EntityIdList& createdEntities,
-        AzFramework::SliceInstantiationTicket& sliceTicket)
+        EntityIdList& createdEntities)
     {
         if (products.empty())
         {
@@ -259,96 +249,80 @@ namespace AzAssetBrowserRequestHandlerPrivate
 
         for (const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product : products)
         {
-            // Handle instantiation of slices.
-            if (product->GetAssetType() == AZ::AzTypeInfo<AZ::SliceAsset>::Uuid())
+            AZ::Uuid componentTypeId = AZ::Uuid::CreateNull();
+            AZ::AssetTypeInfoBus::EventResult(componentTypeId, product->GetAssetType(), &AZ::AssetTypeInfo::GetComponentTypeId);
+            if (!componentTypeId.IsNull())
             {
-                // Instantiate the slice at the specified location.
-                AZ::Data::Asset<AZ::SliceAsset> asset = AZ::Data::AssetManager::Instance().FindOrCreateAsset<AZ::SliceAsset>(
-                    product->GetAssetId(), AZ::Data::AssetLoadBehavior::Default);
-                if (asset)
+                AZ::IO::Path entryPath(product->GetName());
+                AZStd::string entityName = entryPath.Stem().Native();
+                if (entityName.empty())
                 {
-                    SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(
-                        sliceTicket, &SliceEditorEntityOwnershipServiceRequests::InstantiateEditorSlice, asset, worldTransform);
-                }
-            }
-            else
-            {
-                // non-slices, regular entities:
-
-                AZ::Uuid componentTypeId = AZ::Uuid::CreateNull();
-                AZ::AssetTypeInfoBus::EventResult(componentTypeId, product->GetAssetType(), &AZ::AssetTypeInfo::GetComponentTypeId);
-                if (!componentTypeId.IsNull())
-                {
-                    AZ::IO::Path entryPath(product->GetName());
-                    AZStd::string entityName = entryPath.Stem().Native();
+                    // if we can't use the file name, use the type of asset like "Model".
+                    AZ::AssetTypeInfoBus::EventResult(entityName, product->GetAssetType(), &AZ::AssetTypeInfo::GetAssetTypeDisplayName);
                     if (entityName.empty())
                     {
-                        // if we can't use the file name, use the type of asset like "Model".
-                        AZ::AssetTypeInfoBus::EventResult(entityName, product->GetAssetType(), &AZ::AssetTypeInfo::GetAssetTypeDisplayName);
-                        if (entityName.empty())
-                        {
-                            entityName = "Entity";
-                        }
+                        entityName = "Entity";
                     }
+                }
 
-                    AZ::EntityId targetEntityId;
-                    EditorRequests::Bus::BroadcastResult(
-                        targetEntityId, &EditorRequests::CreateNewEntityAtPosition, worldTransform.GetTranslation(), parentEntityId);
+                AZ::EntityId targetEntityId;
+                EditorRequests::Bus::BroadcastResult(
+                    targetEntityId, &EditorRequests::CreateNewEntityAtPosition, worldTransform.GetTranslation(), parentEntityId);
 
-                    AZ::Entity* newEntity = nullptr;
-                    AZ::ComponentApplicationBus::BroadcastResult(newEntity, &AZ::ComponentApplicationRequests::FindEntity, targetEntityId);
+                AZ::Entity* newEntity = nullptr;
+                AZ::ComponentApplicationBus::BroadcastResult(newEntity, &AZ::ComponentApplicationRequests::FindEntity, targetEntityId);
 
-                    if (newEntity == nullptr)
-                    {
-                        QMessageBox::warning(
-                            mainWindow,
-                            QObject::tr("Asset Drop Failed"),
-                            QStringLiteral("Could not create entity from selected asset(s)."));
-                        return;
-                    }
+                if (newEntity == nullptr)
+                {
+                    QMessageBox::warning(
+                        mainWindow,
+                        QObject::tr("Asset Drop Failed"),
+                        QStringLiteral("Could not create entity from selected asset(s)."));
+                    return;
+                }
 
-                    // Deactivate the entity so the properties on the components can be set.
-                    newEntity->Deactivate();
+                // Deactivate the entity so the properties on the components can be set.
+                newEntity->Deactivate();
 
-                    newEntity->SetName(entityName);
+                newEntity->SetName(entityName);
 
-                    AZ::ComponentTypeList componentsToAdd;
-                    componentsToAdd.push_back(componentTypeId);
+                AZ::ComponentTypeList componentsToAdd;
+                componentsToAdd.push_back(componentTypeId);
 
-                     // Add the product as components to this entity.
-                    AZStd::vector<AZ::EntityId> entityIds = { targetEntityId };
-                    EntityCompositionRequests::AddComponentsOutcome addComponentsOutcome = AZ::Failure(AZStd::string());
-                    EntityCompositionRequestBus::BroadcastResult(
-                        addComponentsOutcome, &EntityCompositionRequests::AddComponentsToEntities, entityIds, componentsToAdd);
+                    // Add the product as components to this entity.
+                AZStd::vector<AZ::EntityId> entityIds = { targetEntityId };
+                EntityCompositionRequests::AddComponentsOutcome addComponentsOutcome = AZ::Failure(AZStd::string());
+                EntityCompositionRequestBus::BroadcastResult(
+                    addComponentsOutcome, &EntityCompositionRequests::AddComponentsToEntities, entityIds, componentsToAdd);
                     
-                    if (!addComponentsOutcome.IsSuccess())
-                    {
-                        AZ_Error(
-                            "AssetBrowser",
-                            false,
-                            "Could not create the requested components from the selected assets: %s",
-                            addComponentsOutcome.GetError().c_str());
-                        EditorEntityContextRequestBus::Broadcast(&EditorEntityContextRequests::DestroyEditorEntity, targetEntityId);
-                        return;
-                    }
-                    // activate the entity first, so that the primary asset change is done in the context of it being awake.
-                    newEntity->Activate();
+                if (!addComponentsOutcome.IsSuccess())
+                {
+                    AZ_Error(
+                        "AssetBrowser",
+                        false,
+                        "Could not create the requested components from the selected assets: %s",
+                        addComponentsOutcome.GetError().c_str());
+                    EditorEntityContextRequestBus::Broadcast(&EditorEntityContextRequests::DestroyEditorEntity, targetEntityId);
+                    return;
+                }
+                // activate the entity first, so that the primary asset change is done in the context of it being awake.
+                newEntity->Activate();
 
-                    AZ::Component* componentAdded = newEntity->FindComponent(componentTypeId);
-                    if (componentAdded)
+                AZ::Component* componentAdded = newEntity->FindComponent(componentTypeId);
+                if (componentAdded)
+                {
+                    Components::EditorComponentBase* editorComponent = GetEditorComponent(componentAdded);
+                    if (editorComponent)
                     {
-                        Components::EditorComponentBase* editorComponent = GetEditorComponent(componentAdded);
-                        if (editorComponent)
-                        {
-                            editorComponent->SetPrimaryAsset(product->GetAssetId());
-                        }
+                        editorComponent->SetPrimaryAsset(product->GetAssetId());
                     }
-
-                    ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::AddDirtyEntity, newEntity->GetId());
-                    createdEntities.push_back(newEntity->GetId());
                 }
+
+                ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::AddDirtyEntity, newEntity->GetId());
+                createdEntities.push_back(newEntity->GetId());
             }
         }
+
         // Select the new entity (and deselect others).
         if (!createdEntities.empty())
         {
@@ -700,29 +674,6 @@ void AzAssetBrowserRequestHandler::AddContextMenuActions(QWidget* caller, QMenu*
             AZStd::vector<const ProductAssetBrowserEntry*> products;
             entry->GetChildrenRecursively<ProductAssetBrowserEntry>(products);
 
-            // slice source files need to react by adding additional menu items, regardless of status of compile or presence of products.
-            if (AzFramework::StringFunc::Equal(extension.c_str(), AzToolsFramework::SliceUtilities::GetSliceFileExtension().c_str(), false))
-            {
-                AzToolsFramework::SliceUtilities::CreateSliceAssetContextMenu(menu, fullFilePath);
-
-                // SliceUtilities is in AZToolsFramework and can't open viewports, so add the relationship view open command here.
-                if (!products.empty())
-                {
-                    const ProductAssetBrowserEntry* productEntry = products[0];
-                    menu->addAction(
-                        "Open in Slice Relationship View",
-                        [productEntry]()
-                        {
-                            QtViewPaneManager::instance()->OpenPane(LyViewPane::SliceRelationships);
-
-                            const ProductAssetBrowserEntry* product = azrtti_cast<const ProductAssetBrowserEntry*>(productEntry);
-
-                            AzToolsFramework::SliceRelationshipRequestBus::Broadcast(
-                                &AzToolsFramework::SliceRelationshipRequests::OnSliceRelationshipViewRequested, product->GetAssetId());
-                        });
-                }
-            }
-
             if (!products.empty() || (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source))
             {
                 CFileUtil::PopulateQMenu(caller, menu, fullFilePath);
@@ -1082,8 +1033,7 @@ void AzAssetBrowserRequestHandler::DoDropItemView(bool& accepted, AzQtComponents
             }
 
             EntityIdList createdEntities;
-            AzFramework::SliceInstantiationTicket sliceTicket;
-            CreateEntitiesAtPoint(products, createLocation, outlinerContext->m_parentEntity, createdEntities, sliceTicket);
+            CreateEntitiesAtPoint(products, createLocation, outlinerContext->m_parentEntity, createdEntities);
         }
     }
 }
@@ -1114,9 +1064,7 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
     event->setAccepted(true);
 
     EntityIdList createdEntities;
-    AzFramework::SliceInstantiationTicket sliceTicket;
-
-    CreateEntitiesAtPoint(products, viewportDragContext->m_hitLocation, AZ::EntityId(), createdEntities, sliceTicket);
+    CreateEntitiesAtPoint(products, viewportDragContext->m_hitLocation, AZ::EntityId(), createdEntities);
 }
 
 void AzAssetBrowserRequestHandler::AddSourceFileOpeners(

+ 33 - 35
Code/Editor/Controls/SplineCtrlEx.cpp

@@ -290,9 +290,7 @@ AbstractSplineWidget::AbstractSplineWidget()
 
     m_nLeftOffset = LEFT_BORDER_OFFSET;
 
-    m_grid.zoom.x = 200;
-    m_grid.zoom.y = 100;
-
+    m_grid.zoom = AZ::Vector2(200,100);
     m_bKeyTimesDirty = false;
 
     m_rcSelect = QRect();
@@ -326,22 +324,22 @@ AbstractSplineWidget::~AbstractSplineWidget()
 //////////////////////////////////////////////////////////////////////////
 Vec2 AbstractSplineWidget::GetZoom()
 {
-    return m_grid.zoom;
+    return Vec2(m_grid.zoom.GetX(), m_grid.zoom.GetY());
 }
 
 Vec2 AbstractSplineWidget::GetScrollOffset()
 {
-    return m_grid.origin;
+    return Vec2(m_grid.origin.GetX(), m_grid.origin.GetY());
 }
 
 //////////////////////////////////////////////////////////////////////////
 void AbstractSplineWidget::SetZoom(Vec2 zoom, const QPoint& center)
 {
     m_grid.SetZoom(zoom, QPoint(center.x(), m_rcSpline.bottom() + 1 - center.y()));
-    SetScrollOffset(m_grid.origin);
+    SetScrollOffset(Vec2(m_grid.origin.GetX(), m_grid.origin.GetY()));
     if (m_pTimelineCtrl)
     {
-        m_pTimelineCtrl->setZoom(zoom.x, m_grid.origin.x);
+        m_pTimelineCtrl->setZoom(zoom.x, m_grid.origin.GetX());
     }
     update();
 }
@@ -349,11 +347,11 @@ void AbstractSplineWidget::SetZoom(Vec2 zoom, const QPoint& center)
 //////////////////////////////////////////////////////////////////////////
 void AbstractSplineWidget::SetZoom(Vec2 zoom)
 {
-    m_grid.zoom = zoom;
-    SetScrollOffset(m_grid.origin);
+    m_grid.zoom = AZ::Vector2(zoom.x,zoom.y);
+    SetScrollOffset(Vec2(m_grid.origin.GetX(), m_grid.origin.GetY()));
     if (m_pTimelineCtrl)
     {
-        m_pTimelineCtrl->setZoom(zoom.x, m_grid.origin.x);
+        m_pTimelineCtrl->setZoom(zoom.x, m_grid.origin.GetX());
     }
     SendNotifyEvent(SPLN_SCROLL_ZOOM);
     update();
@@ -362,10 +360,10 @@ void AbstractSplineWidget::SetZoom(Vec2 zoom)
 //////////////////////////////////////////////////////////////////////////
 void AbstractSplineWidget::SetScrollOffset(Vec2 ofs)
 {
-    m_grid.origin = ofs;
+    m_grid.origin = AZ::Vector2(ofs.x, ofs.y);
     if (m_pTimelineCtrl)
     {
-        m_pTimelineCtrl->setZoom(m_grid.zoom.x, m_grid.origin.x);
+        m_pTimelineCtrl->setZoom(m_grid.zoom.GetX(), m_grid.origin.GetX());
     }
     SendNotifyEvent(SPLN_SCROLL_ZOOM);
     update();
@@ -376,7 +374,7 @@ float AbstractSplineWidget::SnapTime(float time)
 {
     if (m_bSnapTime)
     {
-        float step = m_grid.step.x / 10.0f;
+        const float step = m_grid.step.GetX() / 10.0f;
         return floor((time / step) + 0.5f) * step;
     }
     return time;
@@ -387,7 +385,7 @@ float AbstractSplineWidget::SnapValue(float val)
 {
     if (m_bSnapValue)
     {
-        float step = m_grid.step.y;
+        const float step = m_grid.step.GetY();
         return floor((val / step) + 0.5f) * step;
     }
     return val;
@@ -790,7 +788,7 @@ void SplineWidget::DrawGrid(QPainter* painter)
 
     // Draw vertical grid lines.
     SplineControlVerticalLineDrawer verticalLineDrawer(painter, m_rcSpline);
-    GridUtils::IterateGrid(verticalLineDrawer, 50.0f, m_grid.zoom.x, m_grid.origin.x, m_fGridTimeScale, m_grid.rect.left(), m_grid.rect.right() + 1);
+    GridUtils::IterateGrid(verticalLineDrawer, 50.0f, m_grid.zoom.GetX(), m_grid.origin.GetX(), m_fGridTimeScale, m_grid.rect.left(), m_grid.rect.right() + 1);
 
     //////////////////////////////////////////////////////////////////////////
     {
@@ -1392,8 +1390,8 @@ void SplineWidget::mouseMoveEvent(QMouseEvent* event)
     case ScrollMode:
     {
         // Set the new scrolled coordinates
-        float ofsx = m_grid.origin.x - (event->x() - m_cMouseDownPos.x()) / m_grid.zoom.x;
-        float ofsy = m_grid.origin.y + (event->y() - m_cMouseDownPos.y()) / m_grid.zoom.y;
+        float ofsx = m_grid.origin.GetX() - (event->x() - m_cMouseDownPos.x()) / m_grid.zoom.GetX();
+        float ofsy = m_grid.origin.GetY() + (event->y() - m_cMouseDownPos.y()) / m_grid.zoom.GetY();
         SetScrollOffset(Vec2(ofsx, ofsy));
         m_cMouseDownPos = event->pos();
     }
@@ -1404,16 +1402,16 @@ void SplineWidget::mouseMoveEvent(QMouseEvent* event)
         float ofsx = (event->x() - m_cMouseDownPos.x()) * 0.01f;
         float ofsy = (event->y() - m_cMouseDownPos.y()) * 0.01f;
 
-        Vec2 z = m_grid.zoom;
+        AZ::Vector2 z = m_grid.zoom;
         if (ofsx != 0)
         {
-            z.x = max(z.x * (1.0f + ofsx), 0.001f);
+            z.SetX(max(z.GetX() * (1.0f + ofsx), 0.001f));
         }
         if (ofsy != 0)
         {
-            z.y = max(z.y * (1.0f + ofsy), 0.001f);
+            z.SetY(max(z.GetY() * (1.0f + ofsy), 0.001f));
         }
-        SetZoom(z, m_cMouseDownPos);
+        SetZoom(Vec2(z.GetX(), z.GetY()), m_cMouseDownPos);
         m_cMouseDownPos = event->pos();
     }
     break;
@@ -1608,7 +1606,7 @@ void SplineWidget::wheelEvent(QWheelEvent* event)
     {
         return;
     }
-    Vec2 z = m_grid.zoom;
+    AZ::Vector2 z = m_grid.zoom;
     float scale = 1.2f * fabs(zDelta / 120.0f);
     if (zDelta > 0)
     {
@@ -1618,7 +1616,7 @@ void SplineWidget::wheelEvent(QWheelEvent* event)
     {
         z /= scale;
     }
-    SetZoom(z, m_cMousePos);
+    SetZoom(Vec2(z.GetX(), z.GetY()), m_cMousePos);
 
     event->accept();
 }
@@ -2709,8 +2707,8 @@ void SplineWidget::SetTimelineCtrl(TimelineWidget* pTimelineCtrl)
     if (m_pTimelineCtrl)
     {
         pTimelineCtrl->setParent(this);
-        pTimelineCtrl->SetZoom(m_grid.zoom.x);
-        pTimelineCtrl->SetOrigin(m_grid.origin.x);
+        pTimelineCtrl->SetZoom(m_grid.zoom.GetX());
+        pTimelineCtrl->SetOrigin(m_grid.origin.GetX());
         pTimelineCtrl->SetKeyTimeSet(this);
         pTimelineCtrl->update();
     }
@@ -3085,8 +3083,8 @@ void AbstractSplineWidget::FitSplineToViewWidth()
     }
 
     float zoom = abs(m_rcSpline.width() - 20) / max(1.0f, fabs(t1 - t0));
-    SetZoom(Vec2(zoom, m_grid.zoom.y));
-    SetScrollOffset(Vec2(t0, m_grid.origin.y));
+    SetZoom(Vec2(zoom, m_grid.zoom.GetY()));
+    SetScrollOffset(Vec2(t0, m_grid.origin.GetY()));
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -3100,12 +3098,12 @@ void AbstractSplineWidget::FitSplineToViewHeight()
     }
 
     float zoom = abs(m_rcSpline.height() - 40) / max(minViewRange, splineRange.Length());
-    SetZoom(Vec2(m_grid.zoom.x, zoom));
+    SetZoom(Vec2(m_grid.zoom.GetX(), zoom));
 
     // Center the range if it's less than the minRange by adjusting it's offset.
     float scrollOffset = max(0.0f, minViewRange - splineRange.Length()) / 2.0f;
 
-    SetScrollOffset(Vec2(m_grid.origin.x, splineRange.start - scrollOffset));
+    SetScrollOffset(Vec2(m_grid.origin.GetX(), splineRange.start - scrollOffset));
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -3116,8 +3114,8 @@ void AbstractSplineWidget::FitSplineHeightToValueRange()
     splineRange.end = max(splineRange.end, m_valueRange.end);
 
     float zoom = abs(m_rcSpline.height() - 40) / max(minViewRange, splineRange.Length());
-    SetZoom(Vec2(m_grid.zoom.x, zoom));
-    SetScrollOffset(Vec2(m_grid.origin.x, splineRange.start));
+    SetZoom(Vec2(m_grid.zoom.GetX(), zoom));
+    SetScrollOffset(Vec2(m_grid.origin.GetX(), splineRange.start));
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -3205,8 +3203,8 @@ void AbstractSplineWidget::GotoNextKey(bool previousKey)
                             pSpline->SelectKeyAtDimension(nextKey, nCurrentDimension, true);
 
                             // Set the new scrolled coordinates
-                            float ofsx = keyTime - ((m_grid.rect.right() + 1) / 2) / m_grid.zoom.x;
-                            float ofsy = afValue[nCurrentDimension] - ((m_grid.rect.bottom() + 1) / 2) / m_grid.zoom.y;
+                            float ofsx = keyTime - ((m_grid.rect.right() + 1) / 2) / m_grid.zoom.GetX();
+                            float ofsy = afValue[nCurrentDimension] - ((m_grid.rect.bottom() + 1) / 2) / m_grid.zoom.GetY();
 
                             SetScrollOffset(Vec2(ofsx, ofsy));
                         }
@@ -3258,8 +3256,8 @@ void AbstractSplineWidget::GotoNextKey(bool previousKey)
                 }
 
                 // Set the new scrolled coordinates
-                float ofsx = fClosestKeyTime - ((m_grid.rect.right() + 1) / 2) / m_grid.zoom.x;
-                float ofsy = averageValue / dimensions - ((m_grid.rect.bottom() + 1) / 2) / m_grid.zoom.y;
+                const float ofsx = fClosestKeyTime - ((m_grid.rect.right() + 1) / 2) / m_grid.zoom.GetX();
+                const float ofsy = averageValue / dimensions - ((m_grid.rect.bottom() + 1) / 2) / m_grid.zoom.GetY();
 
                 SetScrollOffset(Vec2(ofsx, ofsy));
             }

+ 4 - 4
Code/Editor/Controls/TimelineCtrl.cpp

@@ -49,7 +49,7 @@ TimelineWidget::TimelineWidget(QWidget* parent /* = nullptr */)
 
     m_ticksStep = 10.0f;
 
-    m_grid.zoom.x = 100;
+    m_grid.zoom.SetX(100);
 
     m_bIgnoreSetTime = false;
 
@@ -513,13 +513,13 @@ void TimelineWidget::SetTimeMarker(float fTime)
 //////////////////////////////////////////////////////////////////////////
 void TimelineWidget::SetZoom(float fZoom)
 {
-    m_grid.zoom.x = fZoom;
+    m_grid.zoom.SetX(fZoom);
 }
 
 //////////////////////////////////////////////////////////////////////////
 void TimelineWidget::SetOrigin(float fOffset)
 {
-    m_grid.origin.x = fOffset;
+    m_grid.origin.SetX(fOffset);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -657,7 +657,7 @@ public:
 void TimelineWidget::DrawFrameTicks(QPainter* painter)
 {
     TickDrawer tickDrawer(painter, m_rcTimeline);
-    GridUtils::IterateGrid(tickDrawer, 50.0f, m_grid.zoom.x, m_grid.origin.x, m_fps, m_grid.rect.left(), m_grid.rect.right() + 1);
+    GridUtils::IterateGrid(tickDrawer, 50.0f, m_grid.zoom.GetX(), m_grid.origin.GetX(), m_fps, m_grid.rect.left(), m_grid.rect.right() + 1);
 }
 
 void TimelineWidget::SetPlayCallback(const std::function<void()>& callback)

+ 60 - 58
Code/Editor/Controls/WndGridHelper.h

@@ -15,30 +15,29 @@
 #include <QRect>
 #include "Cry_Vector2.h"
 #include <AzCore/Casting/numeric_cast.h>
+#include <AzCore/Math/Vector2.h>
 
-//////////////////////////////////////////////////////////////////////////
 class CWndGridHelper
 {
 public:
-    Vec2 zoom;
-    Vec2 origin;
-    Vec2 step;
-    Vec2 pixelsPerGrid;
+    AZ::Vector2 zoom;
+    AZ::Vector2 origin;
+    AZ::Vector2 step;
+    AZ::Vector2 pixelsPerGrid;
     int nMajorLines;
     QRect rect;
     QPoint nMinPixelsPerGrid;
     QPoint nMaxPixelsPerGrid;
-    //////////////////////////////////////////////////////////////////////////
+    
     QPoint firstGridLine;
     QPoint numGridLines;
 
-    //////////////////////////////////////////////////////////////////////////
     CWndGridHelper()
     {
-        zoom = Vec2(1, 1);
-        step = Vec2(10, 10);
-        pixelsPerGrid = Vec2(10, 10);
-        origin = Vec2(0, 0);
+        zoom = AZ::Vector2(1, 1);
+        step = AZ::Vector2(10, 10);
+        pixelsPerGrid = AZ::Vector2(10, 10);
+        origin = AZ::Vector2(0, 0);
         nMajorLines = 10;
         nMinPixelsPerGrid = QPoint(50, 10);
         nMaxPixelsPerGrid = QPoint(100, 20);
@@ -50,123 +49,126 @@ public:
     Vec2 ClientToWorld(const QPoint& point)
     {
         Vec2 v;
-        v.x = (point.x() - rect.left()) / zoom.x + origin.x;
-        v.y = (point.y() - rect.top()) / zoom.y + origin.y;
+        v.x = (point.x() - rect.left()) / zoom.GetX() + origin.GetX();
+        v.y = (point.y() - rect.top()) / zoom.GetY() + origin.GetY();
         return v;
     }
-    //////////////////////////////////////////////////////////////////////////
-   QPoint WorldToClient(Vec2 v)
+    
+    QPoint WorldToClient(Vec2 v)
     {
-        QPoint p(aznumeric_cast<int>(floor((v.x - origin.x) * zoom.x + 0.5f) + rect.left()),
-            aznumeric_cast<int>(floor((v.y - origin.y) * zoom.y + 0.5f) + rect.top()));
+        QPoint p(aznumeric_cast<int>(floor((v.x - origin.GetX()) * zoom.GetX() + 0.5f) + rect.left()),
+            aznumeric_cast<int>(floor((v.y - origin.GetY()) * zoom.GetY() + 0.5f) + rect.top()));
         return p;
     }
 
     void SetOrigin(Vec2 neworigin)
     {
-        origin = neworigin;
+        origin = AZ::Vector2(neworigin.x, neworigin.y);
     }
     void SetZoom(Vec2 newzoom)
     {
-        zoom = newzoom;
+        zoom = AZ::Vector2(newzoom.x, newzoom.y);
     }
-    //////////////////////////////////////////////////////////////////////////
-    void SetZoom(Vec2 newzoom, const QPoint& center)
+    void SetZoom(AZ::Vector2 newzoom, const QPoint& center)
     {
-        if (newzoom.x < 0.01f)
+
+        if (newzoom.GetX() < 0.01f)
         {
-            newzoom.x = 0.01f;
+            newzoom.SetX(0.01f);
         }
-        if (newzoom.y < 0.01f)
+        if (newzoom.GetY() < 0.01f)
         {
-            newzoom.y = 0.01f;
+            newzoom.SetY(0.01f);
         }
 
         // Zoom to mouse position.
-        float ofsx = origin.x;
-        float ofsy = origin.y;
+        float ofsx = origin.GetX();
+        float ofsy = origin.GetY();
 
-        Vec2 z1 = zoom;
-        Vec2 z2 = newzoom;
+        AZ::Vector2 z1 = zoom;
+        AZ::Vector2 z2 = newzoom;
 
         zoom = newzoom;
 
         // Calculate new offset to center zoom on mouse.
         float x2 = aznumeric_cast<float>(center.x() - rect.left());
         float y2 = aznumeric_cast<float>(center.y() - rect.top());
-        ofsx = -(x2 / z2.x - x2 / z1.x - ofsx);
-        ofsy = -(y2 / z2.y - y2 / z1.y - ofsy);
-        origin.x = ofsx;
-        origin.y = ofsy;
+        ofsx = -(x2 / z2.GetX() - x2 / z1.GetX() - ofsx);
+        ofsy = -(y2 / z2.GetY() - y2 / z1.GetY() - ofsy);
+        origin.SetX(ofsx);
+        origin.SetY(ofsy);
+    }
+    void SetZoom(Vec2 newzoom, const QPoint& center)
+    {
+        SetZoom(AZ::Vector2(newzoom.x, newzoom.y), center);
     }
     void CalculateGridLines()
     {
-        pixelsPerGrid.x = zoom.x;
-        pixelsPerGrid.y = zoom.y;
+        pixelsPerGrid = zoom;
 
-        step = Vec2(1.00f, 1.00f);
+        step = AZ::Vector2(1.00f, 1.00f);
         nMajorLines = 2;
 
         int griditers;
-        if (pixelsPerGrid.x <= nMinPixelsPerGrid.x())
+        if (pixelsPerGrid.GetX() <= nMinPixelsPerGrid.x())
         {
             griditers = 0;
-            while (pixelsPerGrid.x <= nMinPixelsPerGrid.x() && griditers++ < 1000)
+            while (pixelsPerGrid.GetX() <= nMinPixelsPerGrid.x() && griditers++ < 1000)
             {
-                step.x = step.x * nMajorLines;
-                pixelsPerGrid.x = step.x * zoom.x;
+                step.SetX(step.GetX() * nMajorLines);
+                pixelsPerGrid.SetX(step.GetX() * zoom.GetX());
             }
         }
         else
         {
             griditers = 0;
-            while (pixelsPerGrid.x >= nMaxPixelsPerGrid.x() && griditers++ < 1000)
+            while (pixelsPerGrid.GetX() >= nMaxPixelsPerGrid.x() && griditers++ < 1000)
             {
-                step.x = step.x / nMajorLines;
-                pixelsPerGrid.x = step.x * zoom.x;
+                step.SetX(step.GetX() / nMajorLines);
+                pixelsPerGrid.SetX(step.GetX() * zoom.GetX());
             }
         }
 
-        if (pixelsPerGrid.y <= nMinPixelsPerGrid.y())
+        if (pixelsPerGrid.GetY() <= nMinPixelsPerGrid.y())
         {
             griditers = 0;
-            while (pixelsPerGrid.y <= nMinPixelsPerGrid.y() && griditers++ < 1000)
+            while (pixelsPerGrid.GetY() <= nMinPixelsPerGrid.y() && griditers++ < 1000)
             {
-                step.y = step.y * nMajorLines;
-                pixelsPerGrid.y = step.y * zoom.y;
+                step.SetY(step.GetY() * nMajorLines);
+                pixelsPerGrid.SetY(step.GetY() * zoom.GetY());
             }
         }
         else
         {
             griditers = 0;
-            while (pixelsPerGrid.y >= nMaxPixelsPerGrid.y() && griditers++ < 1000)
+            while (pixelsPerGrid.GetY() >= nMaxPixelsPerGrid.y() && griditers++ < 1000)
             {
-                step.y = step.y / nMajorLines;
-                pixelsPerGrid.y = step.y * zoom.y;
+                step.SetY(step.GetY() / nMajorLines);
+                pixelsPerGrid.SetY(step.GetY() * zoom.GetY());
             }
         }
 
-        firstGridLine.rx() = aznumeric_cast<int>(origin.x / step.x);
-        firstGridLine.ry() = aznumeric_cast<int>(origin.y / step.y);
+        firstGridLine.rx() = aznumeric_cast<int>(origin.GetX() / step.GetX());
+        firstGridLine.ry() = aznumeric_cast<int>(origin.GetY() / step.GetY());
 
-        numGridLines.rx() = aznumeric_cast<int>((rect.width() / zoom.x) / step.x + 1);
-        numGridLines.ry() = aznumeric_cast<int>((rect.height() / zoom.y) / step.y + 1);
+        numGridLines.rx() = aznumeric_cast<int>((rect.width() / zoom.GetX()) / step.GetX() + 1);
+        numGridLines.ry() = aznumeric_cast<int>((rect.height() / zoom.GetY()) / step.GetY() + 1);
     }
     int GetGridLineX(int nGridLineX) const
     {
-        return aznumeric_cast<int>(floor((nGridLineX * step.x - origin.x) * zoom.x + 0.5f));
+        return aznumeric_cast<int>(floor((nGridLineX * step.GetX() - origin.GetX()) * zoom.GetX() + 0.5f));
     }
     int GetGridLineY(int nGridLineY) const
     {
-        return aznumeric_cast<int>(floor((nGridLineY * step.y - origin.y) * zoom.y + 0.5f));
+        return aznumeric_cast<int>(floor((nGridLineY * step.GetY() - origin.GetY()) * zoom.GetY() + 0.5f));
     }
     float GetGridLineXValue(int nGridLineX) const
     {
-        return (nGridLineX * step.x);
+        return (nGridLineX * step.GetX());
     }
     float GetGridLineYValue(int nGridLineY) const
     {
-        return (nGridLineY * step.y);
+        return (nGridLineY * step.GetY());
     }
 };
 

+ 17 - 168
Code/Editor/CryEdit.cpp

@@ -67,7 +67,6 @@ AZ_POP_DISABLE_WARNING
 #include <AzToolsFramework/Editor/ActionManagerUtils.h>
 #include <AzToolsFramework/UI/UICore/ProgressShield.hxx>
 #include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
-#include <AzToolsFramework/Slice/SliceUtilities.h>
 #include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
 #include <AzToolsFramework/API/EditorPythonConsoleBus.h>
 #include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
@@ -728,17 +727,15 @@ CCrySingleDocTemplate::Confidence CCrySingleDocTemplate::MatchDocType(const char
     }
 
     // see if it matches our default suffix
-
     const QString strFilterExt = EditorUtils::LevelFile::GetDefaultFileExtension();
     const QString strOldFilterExt = EditorUtils::LevelFile::GetOldCryFileExtension();
-    const QString strSliceFilterExt = AzToolsFramework::SliceUtilities::GetSliceFileExtension().c_str();
 
     // see if extension matches
     assert(strFilterExt[0] == '.');
     QString strDot = "." + Path::GetExt(lpszPathName);
     if (!strDot.isEmpty())
     {
-        if(strDot == strFilterExt || strDot == strOldFilterExt || strDot == strSliceFilterExt)
+        if(strDot == strFilterExt || strDot == strOldFilterExt)
         {
             return yesAttemptNative; // extension matches, looks like ours
         }
@@ -1123,10 +1120,6 @@ void CCryEditApp::InitLevel(const CEditCommandLineInfo& cmdInfo)
                     }
                     ;
                 }
-                else if (levelName == "new slice")
-                {
-                    QMessageBox::warning(AzToolsFramework::GetActiveWindow(), "Not implemented", "New Slice is not yet implemented.");
-                }
                 else
                 {
                     //implies that the user wants to open an existing level
@@ -1223,6 +1216,9 @@ void CCryEditApp::CompileCriticalAssets() const
                 assetCatalogRequests->LoadCatalog(assetCatalogPath.c_str());
             }
         };
+
+        CCryEditApp::OutputStartupMessage(QString("Loading Asset Catalog..."));
+
         AZ::Data::AssetCatalogRequestBus::Broadcast(AZStd::move(LoadCatalog));
 
         // Only signal the event *after* the asset catalog has been loaded.
@@ -1605,6 +1601,8 @@ bool CCryEditApp::InitInstance()
     // It will be launched if not running
     ConnectToAssetProcessor();
 
+    CCryEditApp::OutputStartupMessage(QString("Initializing Game System..."));
+
     auto initGameSystemOutcome = InitGameSystem(mainWindowWrapperHwnd);
     if (!initGameSystemOutcome.IsSuccess())
     {
@@ -1642,6 +1640,8 @@ bool CCryEditApp::InitInstance()
     // Meant to be called before MainWindow::Initialize
     InitPlugins();
 
+    CCryEditApp::OutputStartupMessage(QString("Initializing Main Window..."));
+
     mainWindow->Initialize();
 
     GetIEditor()->GetCommandManager()->RegisterAutoCommands();
@@ -1691,6 +1691,8 @@ bool CCryEditApp::InitInstance()
     SetEditorWindowTitle(nullptr, AZ::Utils::GetProjectDisplayName().c_str(), nullptr);
     m_pEditor->InitFinished();
 
+    CCryEditApp::OutputStartupMessage(QString("Activating Python..."));
+
     // Make sure Python is started before we attempt to restore the Editor layout, since the user
     // might have custom view panes in the saved layout that will need to be registered.
     auto editorPythonEventsInterface = AZ::Interface<AzToolsFramework::EditorPythonEventsInterface>::Get();
@@ -1699,6 +1701,9 @@ bool CCryEditApp::InitInstance()
         editorPythonEventsInterface->StartPython();
     }
 
+    CCryEditApp::OutputStartupMessage(QString("")); // add a blank line so that python is not blamed for anything that happens here
+
+
     if (!GetIEditor()->IsInConsolewMode())
     {
         bool restoreDefaults = !mainWindowWrapper->restoreGeometryFromSettings();
@@ -1912,10 +1917,6 @@ void CCryEditApp::OnAppShowWelcomeScreen()
                 levelName.clear();
             }
         }
-        else if (levelName == "new slice")
-        {
-            QMessageBox::warning(AzToolsFramework::GetActiveWindow(), "Not implemented", "New Slice is not yet implemented.");
-        }
         else
         {
             // The user has selected an existing level to open
@@ -2425,139 +2426,6 @@ void CCryEditApp::OnFileEditLogFile()
     QDesktopServices::openUrl(QUrl::fromLocalFile(fullPathName));
 }
 
-#ifdef ENABLE_SLICE_EDITOR
-void CCryEditApp::OnFileResaveSlices()
-{
-    AZStd::vector<AZ::Data::AssetInfo> sliceAssetInfos;
-    sliceAssetInfos.reserve(5000);
-    AZ::Data::AssetCatalogRequests::AssetEnumerationCB sliceCountCb = [&sliceAssetInfos]([[maybe_unused]] const AZ::Data::AssetId id, const AZ::Data::AssetInfo& info)
-    {
-        // Only add slices and nothing that has been temporarily added to the catalog with a macro in it (ie @engroot@)
-        if (info.m_assetType == azrtti_typeid<AZ::SliceAsset>() && info.m_relativePath[0] != '@')
-        {
-            sliceAssetInfos.push_back(info);
-        }
-    };
-    AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequestBus::Events::EnumerateAssets, nullptr, sliceCountCb, nullptr);
-
-    QString warningMessage = QString("Resaving all slices can be *extremely* slow depending on source control and on the number of slices in your project!\n\nYou can speed this up dramatically by checking out all your slices before starting this!\n\n Your project has %1 slices.\n\nDo you want to continue?").arg(sliceAssetInfos.size());
-
-    if (QMessageBox::Cancel == QMessageBox::warning(MainWindow::instance(), tr("!!!WARNING!!!"), warningMessage, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
-    {
-        return;
-    }
-
-    AZ::SerializeContext* serialize = nullptr;
-    AZ::ComponentApplicationBus::BroadcastResult(serialize, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
-
-    if (!serialize)
-    {
-        AZ_TracePrintf("Resave Slices", "Couldn't get the serialize context.  Something is very wrong.  Aborting!!!");
-        return;
-    }
-
-    AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
-    if (!fileIO)
-    {
-        AZ_Error("Resave Slices", false, "File IO is not initialized.");
-        return;
-    }
-
-    int numFailures = 0;
-
-    // Create a lambda for load & save logic to make the lambda below easier to read
-    auto LoadAndSaveSlice = [serialize, &numFailures](const AZStd::string& filePath)
-    {
-        AZ::Entity* newRootEntity = nullptr;
-
-        // Read in the slice file first
-        {
-            AZ::IO::FileIOStream readStream(filePath.c_str(), AZ::IO::OpenMode::ModeRead);
-            newRootEntity = AZ::Utils::LoadObjectFromStream<AZ::Entity>(readStream, serialize, AZ::ObjectStream::FilterDescriptor(AZ::Data::AssetFilterNoAssetLoading));
-        }
-
-        // If we successfully loaded the file
-        if (newRootEntity)
-        {
-            if (!AZ::Utils::SaveObjectToFile(filePath, AZ::DataStream::ST_XML, newRootEntity))
-            {
-                AZ_TracePrintf("Resave Slices", "Unable to serialize the slice (%s) out to a file.  Unable to resave this slice\n", filePath.c_str());
-                numFailures++;
-            }
-        }
-        else
-        {
-            AZ_TracePrintf("Resave Slices", "Unable to read a slice (%s) file from disk.  Unable to resave this slice.\n", filePath.c_str());
-            numFailures++;
-        }
-    };
-
-    const size_t numSlices = sliceAssetInfos.size();
-    int slicesProcessed = 0;
-    int slicesRequestedForProcessing = 0;
-
-    if (numSlices > 0)
-    {
-        AzToolsFramework::ProgressShield::LegacyShowAndWait(MainWindow::instance(), tr("Checking out and resaving slices..."),
-            [numSlices, &slicesProcessed, &sliceAssetInfos, &LoadAndSaveSlice, &slicesRequestedForProcessing, &numFailures](int& current, int& max)
-            {
-                const static int numToProcessPerCall = 5;
-
-                if (slicesRequestedForProcessing < numSlices)
-                {
-                    for (int index = 0; index < numToProcessPerCall; index++)
-                    {
-                        if (slicesRequestedForProcessing < numSlices)
-                        {
-                            AZStd::string sourceFile;
-                            AzToolsFramework::AssetSystemRequestBus::Broadcast(&AzToolsFramework::AssetSystemRequestBus::Events::GetFullSourcePathFromRelativeProductPath, sliceAssetInfos[slicesRequestedForProcessing].m_relativePath, sourceFile);
-
-                            AzToolsFramework::ToolsApplicationRequestBus::Broadcast(&AzToolsFramework::ToolsApplicationRequestBus::Events::RequestEditForFile, sourceFile.c_str(), [&slicesProcessed, sourceFile, &LoadAndSaveSlice, &numFailures](bool success)
-                                {
-                                    slicesProcessed++;
-
-                                    if (success)
-                                    {
-                                        LoadAndSaveSlice(sourceFile);
-                                    }
-                                    else
-                                    {
-                                        AZ_TracePrintf("Resave Slices", "Unable to check a slice (%s) out of source control.  Unable to resave this slice\n", sourceFile.c_str());
-                                        numFailures++;
-                                    }
-                                }
-                            );
-                            slicesRequestedForProcessing++;
-                        }
-                    }
-                }
-
-                current = slicesProcessed;
-                max = static_cast<int>(numSlices);
-                return slicesProcessed == numSlices;
-            }
-        );
-
-        QString completeMessage;
-        if (numFailures > 0)
-        {
-            completeMessage = QString("All slices processed.  There were %1 slices that could not be resaved.  Please check the console for details.").arg(numFailures);
-        }
-        else
-        {
-            completeMessage = QString("All slices successfully process and re-saved!");
-        }
-
-        QMessageBox::information(MainWindow::instance(), tr("Re-saving complete"), completeMessage, QMessageBox::Ok);
-    }
-    else
-    {
-        QMessageBox::information(MainWindow::instance(), tr("No slices found"), tr("There were no slices found to resave."), QMessageBox::Ok);
-    }
-
-}
-#endif
-
 //////////////////////////////////////////////////////////////////////////
 void CCryEditApp::OnFileEditEditorini()
 {
@@ -2728,7 +2596,7 @@ void CCryEditApp::OnUpdatePlayGame(QAction* action)
 }
 
 //////////////////////////////////////////////////////////////////////////
-CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& levelName, QString& fullyQualifiedLevelName /* ={} */)
+CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& templateName, const QString& levelName, QString& fullyQualifiedLevelName /* ={} */)
 {
     // If we are creating a new level and we're in simulate mode, then switch it off before we do anything else
     if (GetIEditor()->GetGameEngine() && GetIEditor()->GetGameEngine()->GetSimulationMode())
@@ -2804,7 +2672,8 @@ CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& levelNam
     auto* service = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
     if (service)
     {
-        service->CreateNewLevelPrefab(fullyQualifiedLevelName.toUtf8().constData(), DefaultLevelTemplateName);
+        const AZStd::string templateNameString(templateName.toUtf8().constData());
+        service->CreateNewLevelPrefab(fullyQualifiedLevelName.toUtf8().constData(), templateNameString);
     }
 
     if (GetIEditor()->GetDocument()->Save())
@@ -2924,7 +2793,7 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
     GetIEditor()->StartLevelErrorReportRecording();
 
     QString fullyQualifiedLevelName;
-    ECreateLevelResult result = CreateLevel(levelNameWithPath, fullyQualifiedLevelName);
+    ECreateLevelResult result = CreateLevel(dlg.GetTemplateName(), levelNameWithPath, fullyQualifiedLevelName);
 
     if (result == ECLR_ALREADY_EXISTS)
     {
@@ -2989,12 +2858,6 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
     return true;
 }
 
-//////////////////////////////////////////////////////////////////////////
-void CCryEditApp::OnCreateSlice()
-{
-    QMessageBox::warning(AzToolsFramework::GetActiveWindow(), "Not implemented", "New Slice is not yet implemented.");
-}
-
 //////////////////////////////////////////////////////////////////////////
 void CCryEditApp::OnOpenLevel()
 {
@@ -3008,20 +2871,6 @@ void CCryEditApp::OnOpenLevel()
     }
 }
 
-//////////////////////////////////////////////////////////////////////////
-void CCryEditApp::OnOpenSlice()
-{
-    QString fileName = QFileDialog::getOpenFileName(MainWindow::instance(),
-        tr("Open Slice"),
-        Path::GetEditingGameDataFolder().c_str(),
-        tr("Slice (*.slice)"));
-
-    if (!fileName.isEmpty())
-    {
-        OpenDocumentFile(fileName.toUtf8().data());
-    }
-}
-
 //////////////////////////////////////////////////////////////////////////
 CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* filename, bool addToMostRecentFileList, COpenSameLevelOptions openSameLevelOptions)
 {

+ 1 - 6
Code/Editor/CryEdit.h

@@ -131,7 +131,7 @@ public:
     void SetEditorWindowTitle(QString sTitleStr = QString(), QString sPreTitleStr = QString(), QString sPostTitleStr = QString());
     RecentFileList* GetRecentFileList();
     virtual void AddToRecentFileList(const QString& lpszPathName);
-    ECreateLevelResult CreateLevel(const QString& levelName, QString& fullyQualifiedLevelName);
+    ECreateLevelResult CreateLevel(const QString& templateName, const QString& levelName, QString& fullyQualifiedLevelName);
     bool FirstInstance(bool bForceNewInstance = false);
     void InitFromCommandLine(CEditCommandLineInfo& cmdInfo);
     bool CheckIfAlreadyRunning();
@@ -175,8 +175,6 @@ public:
     // Implementation
     void OnCreateLevel();
     void OnOpenLevel();
-    void OnCreateSlice();
-    void OnOpenSlice();
     void OnAppAbout();
     void OnAppShowWelcomeScreen();
     void OnUpdateShowWelcomeScreen(QAction* action);
@@ -202,7 +200,6 @@ public:
     void OnOpenAssetImporter();
     void OnEditLevelData();
     void OnFileEditLogFile();
-    void OnFileResaveSlices();
     void OnFileEditEditorini();
     void OnPreferences();
     void OnOpenProjectManagerSettings();
@@ -337,8 +334,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
 AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
 
 private:
-    static inline constexpr const char* DefaultLevelTemplateName = "Prefabs/Default_Level.prefab";
-
     // Optional Uri to start an external lua debugger. If not specified,
     // then the Editor will open LuaIDE.exe.
     // For example, if using The Visual Studio Debugger Extension provided by lumbermixalot

+ 0 - 21
Code/Editor/CryEditDoc.cpp

@@ -29,7 +29,6 @@
 
 // AzToolsFramework
 #include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
-#include <AzToolsFramework/Slice/SliceUtilities.h>
 #include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
 #include <AzToolsFramework/API/EditorLevelNotificationBus.h>
 
@@ -302,26 +301,6 @@ void CCryEditDoc::Load(TDocMultiArchive& /* arrXmlAr */, const QString& szFilena
             GetIEditor()->GetGameEngine()->LoadLevel(true, true);
         }
 
-        {
-            // support old version of sequences
-            IMovieSystem* pMs = GetIEditor()->GetMovieSystem();
-
-            if (pMs)
-            {
-                for (int k = 0; k < pMs->GetNumSequences(); ++k)
-                {
-                    IAnimSequence* seq = pMs->GetSequence(k);
-                    QString fullname = seq->GetName();
-                    CBaseObject* pObj = GetIEditor()->GetObjectManager()->FindObject(fullname);
-
-                    if (!pObj)
-                    {
-                        pObj = GetIEditor()->GetObjectManager()->NewObject("SequenceObject", nullptr, fullname);
-                    }
-                }
-            }
-        }
-
         {
             CAutoLogTime logtime("Post Load");
 

+ 6 - 6
Code/Editor/CryEditPy.cpp

@@ -178,13 +178,13 @@ namespace
         return false;
     }
 
-    int PyCreateLevel(const char* levelName, [[maybe_unused]] int resolution, [[maybe_unused]] int unitSize, [[maybe_unused]] bool bUseTerrain)
+    int PyCreateLevel(const char* templateName, const char* levelName, [[maybe_unused]] int resolution, [[maybe_unused]] int unitSize, [[maybe_unused]] bool bUseTerrain)
     {
         QString qualifiedName;
-        return CCryEditApp::instance()->CreateLevel(levelName, qualifiedName);
+        return CCryEditApp::instance()->CreateLevel(templateName, levelName, qualifiedName);
     }
 
-    int PyCreateLevelNoPrompt(const char* levelName, [[maybe_unused]] int heightmapResolution, [[maybe_unused]] int heightmapUnitSize,
+    int PyCreateLevelNoPrompt(const char* templateName, const char* levelName, [[maybe_unused]] int heightmapResolution, [[maybe_unused]] int heightmapUnitSize,
         [[maybe_unused]] int terrainExportTextureSize, [[maybe_unused]] bool useTerrain)
     {
         // If a level was open, ignore any unsaved changes if it had been modified
@@ -194,7 +194,7 @@ namespace
         }
 
         QString qualifiedName;
-        return CCryEditApp::instance()->CreateLevel(levelName, qualifiedName);
+        return CCryEditApp::instance()->CreateLevel(templateName, levelName, qualifiedName);
     }
 
     const char* PyGetCurrentLevelName()
@@ -407,8 +407,8 @@ namespace AzToolsFramework
             addLegacyGeneral(behaviorContext->Method("open_level", ::PyOpenLevel, nullptr, "Opens a level."));
             addLegacyGeneral(behaviorContext->Method("open_level_no_prompt", ::PyOpenLevelNoPrompt, nullptr, "Opens a level. Doesn't prompt user about saving a modified level."));
             addLegacyGeneral(behaviorContext->Method("reload_current_level", ::PyReloadCurrentLevel, nullptr, "Re-loads the current level. If no level is loaded, then does nothing."));
-            addLegacyGeneral(behaviorContext->Method("create_level", ::PyCreateLevel, nullptr, "Creates a level with the parameters of 'levelName', 'resolution', 'unitSize' and 'bUseTerrain'."));
-            addLegacyGeneral(behaviorContext->Method("create_level_no_prompt", ::PyCreateLevelNoPrompt, nullptr, "Creates a level with the parameters of 'levelName', 'resolution', 'unitSize' and 'bUseTerrain'."));
+            addLegacyGeneral(behaviorContext->Method("create_level", ::PyCreateLevel, nullptr, "Creates a level with the parameters of 'templateName', 'levelName', 'resolution', 'unitSize' and 'bUseTerrain'."));
+            addLegacyGeneral(behaviorContext->Method("create_level_no_prompt", ::PyCreateLevelNoPrompt, nullptr, "Creates a level with the parameters of 'templateName','levelName', 'resolution', 'unitSize' and 'bUseTerrain'."));
             addLegacyGeneral(behaviorContext->Method("get_game_folder", PyGetGameFolderAsString, nullptr, "Gets the path to the Game folder of current project."));
             addLegacyGeneral(behaviorContext->Method("get_build_folder", PyGetBuildFolderAsString, nullptr, "Gets the build folder path of current project."));
             addLegacyGeneral(behaviorContext->Method("get_current_level_name", PyGetCurrentLevelName, nullptr, "Gets the name of the current level."));

+ 18 - 4
Code/Editor/EditorPreferencesPageGeneral.cpp

@@ -13,7 +13,9 @@
 #include <QMessageBox>
 
 // AzToolsFramework
+#include <AzToolsFramework/API/SettingsRegistryUtils.h>
 #include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
+#include <AzToolsFramework/Prefab/PrefabSettings.h>
 #include <AzQtComponents/Components/StyleManager.h>
 
 // Editor
@@ -25,6 +27,7 @@
 #define UNDOSLICESAVE_VALON "UndoSliceSaveValueOn"
 #define UNDOSLICESAVE_VALOFF "UndoSliceSaveValueOff"
 
+
 void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
 {
     serialize.Class<GeneralSettings>()
@@ -41,9 +44,13 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
         ->Field("EnableSceneInspector", &GeneralSettings::m_enableSceneInspector)
         ->Field("RestoreViewportCamera", &GeneralSettings::m_restoreViewportCamera);
 
+    // note, despite this class name being LevelSaveSettings, it is used for general prefab settings
+    // and the name is retained to avoid breaking things
     serialize.Class<LevelSaveSettings>()
         ->Version(1)
-        ->Field("SaveAllPrefabsPreference", &LevelSaveSettings::m_saveAllPrefabsPreference);
+        ->Field("SaveAllPrefabsPreference", &LevelSaveSettings::m_saveAllPrefabsPreference)
+        ->Field("DetachPrefabRemovesContainer", &LevelSaveSettings::m_bDetachPrefabRemovesContainer);
+
 
     serialize.Class<Messaging>()
         ->Version(2)
@@ -86,7 +93,9 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
                     "This option controls whether nested prefabs should be saved when a prefab is saved.")
                 ->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::AskEveryTime, "Ask every time")
                 ->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::SaveAll, "Save all")
-                ->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::SaveNone, "Save none");
+                ->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::SaveNone, "Save none")
+            ->DataElement(AZ::Edit::UIHandlers::CheckBox, &LevelSaveSettings::m_bDetachPrefabRemovesContainer, "Detach removes container entity", 
+                    "When you choose the 'detach' option on a prefab container, should the container entity be removed also?");
 
         editContext->Class<Messaging>("Messaging", "")
             ->DataElement(AZ::Edit::UIHandlers::CheckBox, &Messaging::m_showDashboard, "Show Welcome to Open 3D Engine at startup", "Show Welcome to Open 3D Engine at startup");
@@ -100,7 +109,7 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
             ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
             ->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
             ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_generalSettings, "General Settings", "General Editor Preferences")
-            ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_levelSaveSettings, "Prefab Save Settings", "File>Save")
+            ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_levelSaveSettings, "Prefab Settings", "General Prefab Settings")
             ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_messaging, "Messaging", "Messaging")
             ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_undo, "Undo", "Undo Preferences");
     }
@@ -125,6 +134,8 @@ QIcon& CEditorPreferencesPage_General::GetIcon()
 
 void CEditorPreferencesPage_General::OnApply()
 {
+    using namespace AzToolsFramework::Prefab::Settings;
+
     //general settings
     gSettings.bPreviewGeometryWindow = m_generalSettings.m_previewPanel;
     gSettings.enableSourceControl = m_generalSettings.m_enableSourceControl;
@@ -136,6 +147,7 @@ void CEditorPreferencesPage_General::OnApply()
     gSettings.stylusMode = m_generalSettings.m_stylusMode;
     gSettings.restoreViewportCamera = m_generalSettings.m_restoreViewportCamera;
     gSettings.enableSceneInspector = m_generalSettings.m_enableSceneInspector;
+    AzToolsFramework::SetRegistry(AzToolsFramework::Prefab::Settings::DetachPrefabRemovesContainerName, m_levelSaveSettings.m_bDetachPrefabRemovesContainer);
 
     if (static_cast<int>(m_generalSettings.m_toolbarIconSize) != gSettings.gui.nToolbarIconSize)
     {
@@ -152,6 +164,8 @@ void CEditorPreferencesPage_General::OnApply()
 
 void CEditorPreferencesPage_General::InitializeSettings()
 {
+    using namespace AzToolsFramework::Prefab::Settings;
+
     //general settings
     m_generalSettings.m_previewPanel = gSettings.bPreviewGeometryWindow;
     m_generalSettings.m_enableSourceControl = gSettings.enableSourceControl;
@@ -162,11 +176,11 @@ void CEditorPreferencesPage_General::InitializeSettings()
     m_generalSettings.m_stylusMode = gSettings.stylusMode;
     m_generalSettings.m_restoreViewportCamera = gSettings.restoreViewportCamera;
     m_generalSettings.m_enableSceneInspector = gSettings.enableSceneInspector;
-
     m_generalSettings.m_toolbarIconSize = static_cast<AzQtComponents::ToolBar::ToolBarIconSize>(gSettings.gui.nToolbarIconSize);
 
     //prefabs
     m_levelSaveSettings.m_saveAllPrefabsPreference = gSettings.levelSaveSettings.saveAllPrefabsPreference;
+    m_levelSaveSettings.m_bDetachPrefabRemovesContainer = AzToolsFramework::GetRegistry(DetachPrefabRemovesContainerName, DetachPrefabRemovesContainerDefault);
 
     //Messaging
     m_messaging.m_showDashboard = gSettings.bShowDashboardAtStartup;

+ 3 - 1
Code/Editor/EditorPreferencesPageGeneral.h

@@ -58,13 +58,15 @@ private:
         bool m_stylusMode;
         bool m_restoreViewportCamera;
         bool m_bShowNews;
+        
         bool m_enableSceneInspector;
     };
 
-    struct LevelSaveSettings
+    struct LevelSaveSettings // do not change the name or the UUID of this struct for backward settings compat.
     {
         AZ_TYPE_INFO(LevelSaveSettings, "{E297DAE3-3985-4BC2-8B43-45F3B1522F6B}");
         AzToolsFramework::Prefab::SaveAllPrefabsPreference m_saveAllPrefabsPreference;
+        bool m_bDetachPrefabRemovesContainer;
     };
 
     struct Messaging

+ 8 - 4
Code/Editor/EditorToolsApplication.cpp

@@ -227,14 +227,16 @@ namespace EditorInternal
         return OpenLevel(levelName);
     }
 
-    int EditorToolsApplication::CreateLevel(AZStd::string_view levelName, bool /*bUseTerrain*/)
+    int EditorToolsApplication::CreateLevel(AZStd::string_view templateName, AZStd::string_view levelName, bool /*bUseTerrain*/)
     {
         // Clang warns about a temporary being created in a function's argument list, so fullyQualifiedLevelName before the call
         QString fullyQualifiedLevelName;
-        return CCryEditApp::instance()->CreateLevel(QString::fromUtf8(levelName.data(), static_cast<int>(levelName.size())), fullyQualifiedLevelName);
+        return CCryEditApp::instance()->CreateLevel(QString::fromUtf8(templateName.data(), static_cast<int>(templateName.size())),
+                                                    QString::fromUtf8(levelName.data(), static_cast<int>(levelName.size())),
+                                                    fullyQualifiedLevelName);
     }
 
-    int EditorToolsApplication::CreateLevelNoPrompt(AZStd::string_view levelName, int /*terrainExportTextureSize*/, bool /*useTerrain*/)
+    int EditorToolsApplication::CreateLevelNoPrompt(AZStd::string_view templateName, AZStd::string_view levelName, int /*terrainExportTextureSize*/, bool /*useTerrain*/)
     {
         // If a level was open, ignore any unsaved changes if it had been modified
         if (GetIEditor()->IsLevelLoaded())
@@ -244,7 +246,9 @@ namespace EditorInternal
 
         // Clang warns about a temporary being created in a function's argument list, so fullyQualifiedLevelName before the call
         QString fullyQualifiedLevelName;
-        return CCryEditApp::instance()->CreateLevel(QString::fromUtf8(levelName.data(), static_cast<int>(levelName.size())), fullyQualifiedLevelName);
+        return CCryEditApp::instance()->CreateLevel(QString::fromUtf8(templateName.data(), static_cast<int>(templateName.size())),
+                                                    QString::fromUtf8(levelName.data(), static_cast<int>(levelName.size())),
+                                                    fullyQualifiedLevelName);
     }
 
     AZStd::string EditorToolsApplication::GetCurrentLevelName() const

+ 2 - 2
Code/Editor/EditorToolsApplication.h

@@ -62,8 +62,8 @@ namespace EditorInternal
         bool OpenLevel(AZStd::string_view levelName) override;
         bool OpenLevelNoPrompt(AZStd::string_view levelName) override;
 
-        int CreateLevel(AZStd::string_view levelName, bool bUseTerrain) override;
-        int CreateLevelNoPrompt(AZStd::string_view levelName, int terrainExportTextureSize, bool useTerrain) override;
+        int CreateLevel(AZStd::string_view templateName, AZStd::string_view levelName, bool bUseTerrain) override;
+        int CreateLevelNoPrompt(AZStd::string_view templateName, AZStd::string_view levelName, int terrainExportTextureSize, bool useTerrain) override;
 
         void Exit() override;
         void ExitNoPrompt() override;

+ 2 - 2
Code/Editor/EditorToolsApplicationAPI.h

@@ -30,8 +30,8 @@ namespace EditorInternal
         virtual bool OpenLevel(AZStd::string_view levelName) = 0;
         virtual bool OpenLevelNoPrompt(AZStd::string_view levelName) = 0;
 
-        virtual int CreateLevel(AZStd::string_view levelName, bool bUseTerrain) = 0;
-        virtual int CreateLevelNoPrompt(AZStd::string_view levelName, int terrainExportTextureSize, bool useTerrain) = 0;
+        virtual int CreateLevel(AZStd::string_view templateName, AZStd::string_view levelName, bool bUseTerrain) = 0;
+        virtual int CreateLevelNoPrompt(AZStd::string_view templateName, AZStd::string_view levelName, int terrainExportTextureSize, bool useTerrain) = 0;
 
         virtual AZStd::string GetGameFolder() const = 0;
         virtual AZStd::string GetCurrentLevelName() const = 0;

+ 1 - 0
Code/Editor/EditorViewportSettings.cpp

@@ -16,6 +16,7 @@
 #include <AzCore/Settings/SettingsRegistryMergeUtils.h>
 #include <AzCore/std/string/string_view.h>
 #include <AzToolsFramework/Viewport/ViewportSettings.h>
+#include <AzToolsFramework/API/SettingsRegistryUtils.h>
 
 namespace SandboxEditor
 {

+ 0 - 84
Code/Editor/EditorViewportWidget.cpp

@@ -29,7 +29,6 @@
 
 // AzFramework
 #include <AzFramework/Components/CameraBus.h>
-#include <AzFramework/Viewport/DisplayContextRequestBus.h>
 #if defined(AZ_PLATFORM_WINDOWS)
 #include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
 #endif // defined(AZ_PLATFORM_WINDOWS)
@@ -75,7 +74,6 @@
 #include "LayoutWnd.h"
 #include "MainWindow.h"
 #include "Objects/EntityObject.h"
-#include "Objects/DisplayContext.h"
 #include "Objects/ObjectManager.h"
 #include "ProcessInfo.h"
 #include "Util/fastlib.h"
@@ -510,8 +508,6 @@ void EditorViewportWidget::Update()
 
     // Render
     {
-        m_displayContext.Flush2D();
-
         // Post Render Callback
         {
             PostRenderers::iterator itr = m_postRenderers.begin();
@@ -752,43 +748,6 @@ float EditorViewportWidget::GetAspectRatio() const
     return gSettings.viewports.fDefaultAspectRatio;
 }
 
-//////////////////////////////////////////////////////////////////////////
-void EditorViewportWidget::RenderSnapMarker()
-{
-    if (!gSettings.snap.markerDisplay)
-    {
-        return;
-    }
-
-    QPoint point = QCursor::pos();
-    ScreenToClient(point);
-    Vec3 p = MapViewToCP(point);
-
-    DisplayContext& dc = m_displayContext;
-
-    float fScreenScaleFactor = GetScreenScaleFactor(p);
-
-    Vec3 x(1, 0, 0);
-    Vec3 y(0, 1, 0);
-    Vec3 z(0, 0, 1);
-    x = x * gSettings.snap.markerSize * fScreenScaleFactor * 0.1f;
-    y = y * gSettings.snap.markerSize * fScreenScaleFactor * 0.1f;
-    z = z * gSettings.snap.markerSize * fScreenScaleFactor * 0.1f;
-
-    dc.SetColor(gSettings.snap.markerColor);
-    dc.DrawLine(p - x, p + x);
-    dc.DrawLine(p - y, p + y);
-    dc.DrawLine(p - z, p + z);
-
-    point = WorldToView(p);
-
-    int s = 8;
-    dc.DrawLine2d(point + QPoint(-s, -s), point + QPoint(s, -s), 0);
-    dc.DrawLine2d(point + QPoint(-s, s), point + QPoint(s, s), 0);
-    dc.DrawLine2d(point + QPoint(-s, -s), point + QPoint(-s, s), 0);
-    dc.DrawLine2d(point + QPoint(s, -s), point + QPoint(s, s), 0);
-}
-
 //////////////////////////////////////////////////////////////////////////
 void EditorViewportWidget::OnMenuCreateCameraEntityFromCurrentView()
 {
@@ -1565,49 +1524,6 @@ void EditorViewportWidget::CenterOnAABB(const AABB& aabb)
     SetViewTM(newTM);
 }
 
-void EditorViewportWidget::CenterOnSliceInstance()
-{
-    AzToolsFramework::EntityIdList selectedEntityList;
-    AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-        selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
-
-    AZ::SliceComponent::SliceInstanceAddress sliceAddress;
-    AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-        sliceAddress, &AzToolsFramework::ToolsApplicationRequestBus::Events::FindCommonSliceInstanceAddress, selectedEntityList);
-
-    if (!sliceAddress.IsValid())
-    {
-        return;
-    }
-
-    AZ::EntityId sliceRootEntityId;
-    AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-        sliceRootEntityId, &AzToolsFramework::ToolsApplicationRequestBus::Events::GetRootEntityIdOfSliceInstance, sliceAddress);
-
-    if (!sliceRootEntityId.IsValid())
-    {
-        return;
-    }
-
-    AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
-        &AzToolsFramework::ToolsApplicationRequestBus::Events::SetSelectedEntities, AzToolsFramework::EntityIdList{ sliceRootEntityId });
-
-    const AZ::SliceComponent::InstantiatedContainer* instantiatedContainer = sliceAddress.GetInstance()->GetInstantiated();
-
-    AABB aabb(Vec3(std::numeric_limits<float>::max()), Vec3(-std::numeric_limits<float>::max()));
-    for (AZ::Entity* entity : instantiatedContainer->m_entities)
-    {
-        CEntityObject* entityObject = nullptr;
-        AzToolsFramework::ComponentEntityEditorRequestBus::EventResult(
-            entityObject, entity->GetId(), &AzToolsFramework::ComponentEntityEditorRequestBus::Events::GetSandboxObject);
-        AABB box;
-        entityObject->GetBoundBox(box);
-        aabb.Add(box.min);
-        aabb.Add(box.max);
-    }
-    CenterOnAABB(aabb);
-}
-
 //////////////////////////////////////////////////////////////////////////
 void EditorViewportWidget::SetFOV(const float fov)
 {

+ 0 - 10
Code/Editor/EditorViewportWidget.h

@@ -13,7 +13,6 @@
 
 #include "EditorModularViewportCameraComposer.h"
 #include "EditorViewportSettings.h"
-#include "Objects/DisplayContext.h"
 #include "Undo/Undo.h"
 #include "Util/PredefinedAspectRatios.h"
 #include "Viewport.h"
@@ -195,7 +194,6 @@ private:
     bool HitTest(const QPoint& point, HitContext& hitInfo) override;
     bool IsBoundsVisible(const AABB& box) const override;
     void CenterOnAABB(const AABB& aabb) override;
-    void CenterOnSliceInstance() override;
     void OnTitleMenu(QMenu* menu) override;
     void SetViewTM(const Matrix34& tm) override;
     const Matrix34& GetViewTM() const override;
@@ -249,7 +247,6 @@ private:
     // Private helpers...
     void SetViewTM(const Matrix34& tm, bool bMoveOnly);
     void SetDefaultCameraNearFar();
-    void RenderSnapMarker();
     void RenderAll();
 
     bool RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const;
@@ -307,10 +304,6 @@ private:
     QPoint ViewportToWidget(const QPoint& point) const;
     QSize WidgetToViewport(const QSize& size) const;
 
-    const DisplayContext& GetDisplayContext() const
-    {
-        return m_displayContext;
-    }
 
     CBaseObject* GetCameraObject() const;
 
@@ -361,9 +354,6 @@ private:
     // The name to use for the default editor camera
     const QString m_defaultViewName;
 
-    // Note that any attempts to draw anything with this object will crash. Exists here for legacy "reasons"
-    DisplayContext m_displayContext;
-
     // Reentrancy guard for on paint events
     bool m_isOnPaint = false;
 

+ 0 - 2
Code/Editor/Include/IDisplayViewport.h

@@ -8,13 +8,11 @@
 
 #pragma once
 
-struct DisplayContext;
 class CBaseObjectsCache;
 class QPoint;
 struct AABB;
 class CViewport;
 
-// Viewport functionality required for DisplayContext
 struct IDisplayViewport
 {
     virtual void Update() = 0;

+ 0 - 3
Code/Editor/Include/IObjectManager.h

@@ -15,7 +15,6 @@
 
 // forward declarations.
 class CEntityObject;
-struct DisplayContext;
 class CTrackViewAnimNode;
 class CUsedResources;
 class CObjectClassDesc;
@@ -105,6 +104,4 @@ public:
     //////////////////////////////////////////////////////////////////////////
     // Gathers all resources used by all objects.
     virtual void GatherUsedResources(CUsedResources& resources) = 0;
-
-    virtual bool IsLightClass(CBaseObject* pObject) = 0;
 };

+ 0 - 13
Code/Editor/MainWindow.cpp

@@ -1162,19 +1162,6 @@ void MainWindow::OnGotoSelected()
     AzToolsFramework::EditorRequestBus::Broadcast(&AzToolsFramework::EditorRequestBus::Events::GoToSelectedEntitiesInViewports);
 }
 
-void MainWindow::OnGotoSliceRoot()
-{
-    int numViews = GetIEditor()->GetViewManager()->GetViewCount();
-    for (int i = 0; i < numViews; ++i)
-    {
-        CViewport* viewport = GetIEditor()->GetViewManager()->GetView(i);
-        if (viewport)
-        {
-            viewport->CenterOnSliceInstance();
-        }
-    }
-}
-
 // don't want to eat escape as if it were a shortcut, as it would eat it for other windows that also care about escape
 // and are reading it as an event rather.
 void MainWindow::keyPressEvent(QKeyEvent* e)

+ 0 - 1
Code/Editor/MainWindow.h

@@ -152,7 +152,6 @@ public:
 
     bool event(QEvent* event) override;
 
-    void OnGotoSliceRoot();
 Q_SIGNALS:
     void ToggleRefCoordSys();
     void UpdateRefCoordSys();

+ 79 - 19
Code/Editor/NewLevelDialog.cpp

@@ -8,7 +8,8 @@
 
 
 #include "EditorDefs.h"
-
+#include <AzCore/Utils/Utils.h>
+#include <AzCore/Settings/SettingsRegistryVisitorUtils.h>
 #include "NewLevelDialog.h"
 
 // Qt
@@ -17,6 +18,7 @@
 #include <QMessageBox>
 #include <QTimer>
 #include <QToolButton>
+#include <QListWidgetItem>
 
 AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
 #include <ui_NewLevelDialog.h>
@@ -25,6 +27,7 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
 
 // Folder in which levels are stored
 static const char kNewLevelDialog_LevelsFolder[] = "Levels";
+static constexpr const char* RegistryKey_CustomTemplatePaths = "/O3DE/Preferences/Prefab/CustomTemplatePaths";
 
 class LevelFolderValidator : public QValidator
 {
@@ -49,11 +52,17 @@ private:
     CNewLevelDialog* m_parentDialog;
 };
 
+static QString ChangeFileExtension(const QString& filePath, const QString& newExtension)
+{
+    QFileInfo fileInfo(filePath);
+    QString newFilePath = fileInfo.absolutePath() + QDir::separator() + fileInfo.baseName() + "." + newExtension;
+    return newFilePath;
+}
+
 // CNewLevelDialog dialog
 
 CNewLevelDialog::CNewLevelDialog(QWidget* pParent /*=nullptr*/)
     : QDialog(pParent)
-    , m_bUpdate(false)
     , ui(new Ui::CNewLevelDialog)
     , m_initialized(false)
 {
@@ -61,15 +70,8 @@ CNewLevelDialog::CNewLevelDialog(QWidget* pParent /*=nullptr*/)
 
     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
     setWindowTitle(tr("New Level"));
-    setMaximumSize(QSize(320, 180));
-    adjustSize();
-
-    m_bIsResize = false;
-
-
-    ui->TITLE->setText(tr("Assign a name and location to the new level."));
-    ui->STATIC1->setText(tr("Location:"));
-    ui->STATIC2->setText(tr("Name:"));
+    setStyleSheet("QListWidget::item {height: 148px; padding-left: 0px; padding-right: 0px; background-color: transparent;}");
+    InitTemplateListWidget();
 
     // Level name only supports ASCII characters
     QRegExp rx("[_a-zA-Z0-9-]+");
@@ -90,7 +92,6 @@ CNewLevelDialog::CNewLevelDialog(QWidget* pParent /*=nullptr*/)
 
     connect(ui->LEVEL_FOLDERS->lineEdit(), &QLineEdit::textEdited, this, &CNewLevelDialog::OnLevelNameChange);
     connect(ui->LEVEL_FOLDERS, &AzQtComponents::BrowseEdit::attachedButtonTriggered, this, &CNewLevelDialog::PopupAssetPicker);
-
     connect(ui->LEVEL, &QLineEdit::textChanged, this, &CNewLevelDialog::OnLevelNameChange);
 
     m_levelFolders = GetLevelsFolder();
@@ -105,10 +106,76 @@ CNewLevelDialog::CNewLevelDialog(QWidget* pParent /*=nullptr*/)
     ReloadLevelFolder();
 }
 
+
+
 CNewLevelDialog::~CNewLevelDialog()
 {
 }
 
+void CNewLevelDialog::InitTemplateListWidget() const
+{
+    ui->listTemplates->clear();
+
+    QStringList templatePaths;
+    if (AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry)
+    {
+        auto AppendCustomTemplatePath = [&templatePaths](const AZ::SettingsRegistryInterface::VisitArgs& visitArgs)
+        {
+            AZ::IO::FixedMaxPath customTemplatePath;
+            if (visitArgs.m_registry.Get(customTemplatePath.Native(), visitArgs.m_jsonKeyPath))
+            {
+                if (AZ::IO::FileIOBase::GetInstance()->ResolvePath(customTemplatePath, customTemplatePath))
+                {
+                    templatePaths.push_back(QString::fromUtf8(customTemplatePath.c_str(), int(customTemplatePath.Native().size())));
+                }
+            }
+
+            return AZ::SettingsRegistryInterface::VisitResponse::Skip;
+        };
+
+        AZ::SettingsRegistryVisitorUtils::VisitObject(*settingsRegistry, AppendCustomTemplatePath, RegistryKey_CustomTemplatePaths);
+    }
+
+    // Get all prefab files.
+    const QStringList fileFilter = {"*.prefab"};
+    QStringList allTemplateFiles;
+    for(const QString& path: templatePaths)
+    {
+        QDir projectTemplateDirectory(path);
+        projectTemplateDirectory.setNameFilters(fileFilter);
+
+        const QStringList projectTemplateFiles = projectTemplateDirectory.entryList(QDir::Files);
+        for (const QString& fileName: projectTemplateFiles)
+        {
+            allTemplateFiles.push_back(projectTemplateDirectory.filePath(fileName));
+        }
+    }
+
+    // Create the item with its icons to the QListWidget.
+    const QIcon defaultIcon(":/NewLevel/res/Prefab_80.svg");
+    for (const QString& fileName: allTemplateFiles)
+    {
+        QFileInfo info(fileName);
+        auto* item = new QListWidgetItem(info.baseName());
+        const QString iconPath = ChangeFileExtension(fileName, "png");
+        const QIcon itemIcon = QFile::exists(iconPath) ? QIcon(iconPath) : defaultIcon;
+        item->setIcon(itemIcon);
+        item->setData(Qt::UserRole, fileName);
+        ui->listTemplates->addItem(item);
+    }
+
+    const QSize iconSize(128, 128);
+    ui->listTemplates->setViewMode(QListWidget::IconMode);
+    ui->listTemplates->setIconSize(iconSize);
+    ui->listTemplates->setDragDropMode(QAbstractItemView::NoDragDrop);
+}
+
+QString CNewLevelDialog::GetTemplateName() const
+{
+    const QString name = ui->listTemplates->currentItem()->data(Qt::UserRole).toString();
+    return name;
+}
+
 void CNewLevelDialog::OnStartup()
 {
     UpdateData(false);
@@ -148,7 +215,6 @@ void CNewLevelDialog::OnInitDialog()
 //////////////////////////////////////////////////////////////////////////
 void CNewLevelDialog::ReloadLevelFolder()
 {
-    m_itemFolders.clear();
     ui->LEVEL_FOLDERS->lineEdit()->clear();
     ui->LEVEL_FOLDERS->setText(QString(kNewLevelDialog_LevelsFolder) + '/');
 }
@@ -233,12 +299,6 @@ void CNewLevelDialog::PopupAssetPicker()
     }
 }
 
-//////////////////////////////////////////////////////////////////////////
-void CNewLevelDialog::IsResize(bool bIsResize)
-{
-    m_bIsResize = bIsResize;
-}
-
 //////////////////////////////////////////////////////////////////////////
 void CNewLevelDialog::showEvent(QShowEvent* event)
 {

+ 4 - 17
Code/Editor/NewLevelDialog.h

@@ -8,14 +8,9 @@
 
 
 #pragma once
-#ifndef CRYINCLUDE_EDITOR_NEWLEVELDIALOG_H
-#define CRYINCLUDE_EDITOR_NEWLEVELDIALOG_H
 
 #if !defined(Q_MOC_RUN)
 #include <QScopedPointer>
-
-#include <vector>
-
 #include <QAbstractButton>
 #include <QDialog>
 #endif
@@ -30,22 +25,20 @@ class CNewLevelDialog
     Q_OBJECT
 
 public:
-    CNewLevelDialog(QWidget* pParent = nullptr);   // standard constructor
+    CNewLevelDialog(QWidget* pParent = nullptr);
     ~CNewLevelDialog();
 
     QString GetLevel() const;
-    void IsResize(bool bIsResize);
     bool ValidateLevel();
+    QString GetTemplateName() const;
 
 protected:
     void UpdateData(bool fromUi = true);
     void OnInitDialog();
-
     void ReloadLevelFolder();
-
-    void showEvent(QShowEvent* event);
-
+    void showEvent(QShowEvent* event) override;
     QString GetLevelsFolder() const;
+    void InitTemplateListWidget() const;
 
 protected slots:
     void OnLevelNameChange();
@@ -56,12 +49,6 @@ protected slots:
 public:
     QString         m_level;
     QString         m_levelFolders;
-    bool                m_bIsResize;
-    bool                m_bUpdate;
-
-    std::vector<QString>    m_itemFolders;
-
     QScopedPointer<Ui::CNewLevelDialog> ui;
     bool m_initialized;
 };
-#endif // CRYINCLUDE_EDITOR_NEWLEVELDIALOG_H

+ 6 - 0
Code/Editor/NewLevelDialog.qrc

@@ -0,0 +1,6 @@
+<RCC>
+  <qresource prefix="/NewLevel">
+    <file>res/folder.png</file>
+    <file>res/Prefab_80.svg</file>
+  </qresource>
+</RCC>

+ 89 - 115
Code/Editor/NewLevelDialog.ui

@@ -6,124 +6,96 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>430</width>
-    <height>180</height>
+    <width>471</width>
+    <height>371</height>
    </rect>
   </property>
-   <layout class="QVBoxLayout" name="verticalLayout">
-     <item>
-       <spacer name="topVerticalSpacer">
-         <property name="orientation">
-           <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-           <size>
-             <width>20</width>
-             <height>10</height>
-           </size>
-         </property>
-       </spacer>
-     </item>
-     <item>
-       <widget class="QLabel" name="TITLE">
-         <property name="text">
-           <string>Assign a name and location to the new level.</string>
-         </property>
-         <property name="alignment">
-           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-         </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QListWidget" name="listTemplates">
+     <property name="movement">
+      <enum>QListView::Static</enum>
+     </property>
+     <property name="resizeMode">
+      <enum>QListView::Adjust</enum>
+     </property>
+     <property name="spacing">
+      <number>4</number>
+     </property>
+     <property name="viewMode">
+      <enum>QListView::IconMode</enum>
+     </property>
+     <property name="uniformItemSizes">
+      <bool>true</bool>
+     </property>
+     <property name="selectionRectVisible">
+      <bool>false</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="STATIC_GROUP1">
+     <layout class="QFormLayout" name="formLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="STATIC2">
+        <property name="text">
+         <string>Name</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="buddy">
+         <cstring>LEVEL</cstring>
+        </property>
        </widget>
-     </item>
-     <item>
-       <spacer name="verticalSpacer">
-         <property name="orientation">
-           <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-           <size>
-             <width>20</width>
-             <height>20</height>
-           </size>
-         </property>
-       </spacer>
-     </item>
-     <item>
-       <layout class="QGridLayout" name="gridLayout">
-         <item row="0" column="0" colspan="2">
-           <widget class="QGroupBox" name="STATIC_GROUP1">
-             <property name="styleSheet">
-               <string notr="true">border: 0px;</string>
-             </property>
-             <layout class="QFormLayout" name="formLayout">
-               <item row="0" column="0">
-                 <widget class="QLabel" name="STATIC2">
-                   <property name="text">
-                     <string>Name</string>
-                   </property>
-                   <property name="alignment">
-                     <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-                   </property>
-                   <property name="buddy">
-                     <cstring>LEVEL</cstring>
-                   </property>
-                 </widget>
-               </item>
-               <item row="0" column="1">
-                 <widget class="QLineEdit" name="LEVEL">
-                   <property name="alignment">
-                     <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
-                   </property>
-                 </widget>
-               </item>
-               <item row="1" column="0">
-                 <widget class="QLabel" name="STATIC1">
-                   <property name="minimumSize">
-                     <size>
-                       <width>100</width>
-                       <height>0</height>
-                     </size>
-                   </property>
-                   <property name="text">
-                     <string>Location</string>
-                   </property>
-                   <property name="alignment">
-                     <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-                   </property>
-                   <property name="buddy">
-                     <cstring>LEVEL_FOLDERS</cstring>
-                   </property>
-                 </widget>
-               </item>
-               <item row="1" column="1">
-                 <widget class="AzQtComponents::BrowseEdit" name="LEVEL_FOLDERS" native="true">
-                   <property name="sizePolicy">
-                     <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
-                       <horstretch>0</horstretch>
-                       <verstretch>0</verstretch>
-                     </sizepolicy>
-                   </property>
-                 </widget>
-               </item>
-             </layout>
-           </widget>
-         </item>
-       </layout>
-     </item>
-     <item>
-       <spacer name="verticalSpacer2">
-         <property name="orientation">
-           <enum>Qt::Vertical</enum>
-         </property>
-       </spacer>
-     </item>
-     <item row="1" column="0" colspan="2">
-       <widget class="QDialogButtonBox" name="buttonBox">
-         <property name="standardButtons">
-           <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-         </property>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLineEdit" name="LEVEL">
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+        </property>
        </widget>
-     </item>
-   </layout>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="STATIC1">
+        <property name="minimumSize">
+         <size>
+          <width>100</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>Location</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="buddy">
+         <cstring>LEVEL_FOLDERS</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="AzQtComponents::BrowseEdit" name="LEVEL_FOLDERS" native="true">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
  </widget>
  <customwidgets>
   <customwidget>
@@ -136,7 +108,9 @@
  <tabstops>
   <tabstop>LEVEL</tabstop>
  </tabstops>
- <resources/>
+ <resources>
+  <include location="NewLevelDialog.qrc"/>
+ </resources>
  <connections>
   <connection>
    <sender>buttonBox</sender>

+ 0 - 228
Code/Editor/Objects/BaseObject.cpp

@@ -208,9 +208,6 @@ void CUndoBaseObject::Undo(bool bUndo)
     pObject->Serialize(ar);
 
     GetIEditor()->ResumeUndo();
-
-    using namespace AzToolsFramework;
-    ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -230,9 +227,6 @@ void CUndoBaseObject::Redo()
     pObject->Serialize(ar);
 
     GetIEditor()->ResumeUndo();
-
-    using namespace AzToolsFramework;
-    ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -285,9 +279,6 @@ void CUndoBaseObjectMinimal::Undo(bool bUndo)
 
     pObject->ChangeColor(m_undoState.color);
     pObject->SetArea(m_undoState.area);
-
-    using namespace AzToolsFramework;
-    ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -303,9 +294,6 @@ void CUndoBaseObjectMinimal::Redo()
 
     pObject->ChangeColor(m_redoState.color);
     pObject->SetArea(m_redoState.area);
-
-    using namespace AzToolsFramework;
-    ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -744,222 +732,6 @@ void CBaseObject::SetModified(bool)
 {
 }
 
-//////////////////////////////////////////////////////////////////////////
-void CBaseObject::DrawDimensions(DisplayContext&, AABB*)
-{
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CBaseObject::DrawSelectionHelper(DisplayContext& dc, const Vec3& pos, const QColor& labelColor, [[maybe_unused]] float alpha)
-{
-    DrawLabel(dc, pos, labelColor);
-
-    dc.SetColor(GetColor());
-    if (IsHighlighted() || IsSelected() || IsInSelectionBox())
-    {
-        dc.SetColor(dc.GetSelectedColor());
-    }
-
-    uint32 nPrevState = dc.GetState();
-    dc.DepthTestOff();
-    float r = dc.view->GetScreenScaleFactor(pos) * 0.006f;
-    dc.DrawWireBox(pos - Vec3(r, r, r), pos + Vec3(r, r, r));
-    dc.SetState(nPrevState);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& lC, float alpha, float size)
-{
-    QColor labelColor = lC;
-
-    AABB box;
-    GetBoundBox(box);
-
-    //p.z = box.max.z + 0.2f;
-    if ((dc.flags & DISPLAY_2D) && labelColor == QColor(255, 255, 255))
-    {
-        labelColor = QColor(0, 0, 0);
-    }
-
-    if (dc.flags & DISPLAY_SELECTION_HELPERS)
-    {
-        Vec3 c(static_cast<f32>(labelColor.redF()), static_cast<f32>(labelColor.greenF()), static_cast<f32>(labelColor.redF()));
-        if (IsSelected())
-        {
-            c = Vec3(static_cast<f32>(dc.GetSelectedColor().redF()), static_cast<f32>(dc.GetSelectedColor().greenF()), static_cast<f32>(dc.GetSelectedColor().blueF()));
-        }
-
-        float col[4] = { c.x, c.y, c.z, 1 };
-        if (dc.flags & DISPLAY_SELECTION_HELPERS)
-        {
-            if (IsHighlighted())
-            {
-                c = Vec3(static_cast<f32>(dc.GetSelectedColor().redF()), static_cast<f32>(dc.GetSelectedColor().greenF()), static_cast<f32>(dc.GetSelectedColor().blueF()));
-            }
-            col[0] = c.x;
-            col[1] = c.y;
-            col[2] = c.z;
-        }
-
-        dc.SetColor(col[0], col[1], col[2], col[3] * alpha);
-        dc.DrawTextLabel(pos, size, GetName().toUtf8().data());
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CBaseObject::DrawHighlight(DisplayContext& dc)
-{
-    if (!m_nTextureIcon)
-    {
-        AABB box;
-        GetLocalBounds(box);
-
-        dc.PushMatrix(GetWorldTM());
-        dc.DrawWireBox(box.min, box.max);
-        dc.SetLineWidth(1);
-        dc.PopMatrix();
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CBaseObject::DrawBudgetUsage(DisplayContext& dc, const QColor& color)
-{
-    AABB box;
-    GetLocalBounds(box);
-
-    dc.SetColor(color);
-
-    dc.PushMatrix(GetWorldTM());
-    dc.DrawWireBox(box.min, box.max);
-    dc.PopMatrix();
-}
-
-//////////////////////////////////////////////////////////////////////////
-void    CBaseObject::DrawAxis([[maybe_unused]] DisplayContext& dc, [[maybe_unused]] const Vec3& pos, [[maybe_unused]] float size)
-{
-    /*
-    dc.renderer->EnableDepthTest(false);
-    Vec3 x(size,0,0);
-    Vec3 y(0,size,0);
-    Vec3 z(0,0,size);
-
-    bool bWorldSpace = false;
-    if (dc.flags & DISPLAY_WORLDSPACEAXIS)
-        bWorldSpace = true;
-
-    Matrix tm = GetWorldTM();
-    Vec3 org = tm.TransformPoint( pos );
-
-    if (!bWorldSpace)
-    {
-        tm.NoScale();
-        x = tm.TransformVector(x);
-        y = tm.TransformVector(y);
-        z = tm.TransformVector(z);
-    }
-
-    float fScreenScale = dc.view->GetScreenScaleFactor(org);
-    x = x * fScreenScale;
-    y = y * fScreenScale;
-    z = z * fScreenScale;
-
-    float col[4] = { 1,1,1,1 };
-    float hcol[4] = { 1,0,0,1 };
-    dc.renderer->DrawLabelEx( org+x,1.2f,col,true,true,"X" );
-    dc.renderer->DrawLabelEx( org+y,1.2f,col,true,true,"Y" );
-    dc.renderer->DrawLabelEx( org+z,1.2f,col,true,true,"Z" );
-
-    Vec3 colX(1,0,0),colY(0,1,0),colZ(0,0,1);
-    if (s_highlightAxis)
-    {
-        float col[4] = { 1,0,0,1 };
-        if (s_highlightAxis == 1)
-        {
-            colX.Set(1,1,0);
-            dc.renderer->DrawLabelEx( org+x,1.2f,col,true,true,"X" );
-        }
-        if (s_highlightAxis == 2)
-        {
-            colY.Set(1,1,0);
-            dc.renderer->DrawLabelEx( org+y,1.2f,col,true,true,"Y" );
-        }
-        if (s_highlightAxis == 3)
-        {
-            colZ.Set(1,1,0);
-            dc.renderer->DrawLabelEx( org+z,1.2f,col,true,true,"Z" );
-        }
-    }
-
-    x = x * 0.8f;
-    y = y * 0.8f;
-    z = z * 0.8f;
-    float fArrowScale = fScreenScale * 0.07f;
-    dc.SetColor( colX );
-    dc.DrawArrow( org,org+x,fArrowScale );
-    dc.SetColor( colY );
-    dc.DrawArrow( org,org+y,fArrowScale );
-    dc.SetColor( colZ );
-    dc.DrawArrow( org,org+z,fArrowScale );
-
-    //dc.DrawLine( org,org+x,colX,colX );
-    //dc.DrawLine( org,org+y,colY,colY );
-    //dc.DrawLine( org,org+z,colZ,colZ );
-
-    dc.renderer->EnableDepthTest(true);
-    ///dc.SetColor( 0,1,1,1 );
-    //dc.DrawLine( p,p+dc.view->m_constructionPlane.m_normal*10.0f );
-    */
-}
-
-void CBaseObject::DrawArea(DisplayContext& dc)
-{
-    float area = m_flattenArea;
-    if (area > 0)
-    {
-        dc.SetColor(QColor(5, 5, 255), 1.f); // make it different color from the AI sight radius
-        Vec3 wp = GetWorldPos();
-        float z = GetIEditor()->GetTerrainElevation(wp.x, wp.y);
-        if (fabs(wp.z - z) < 5)
-        {
-            dc.DrawTerrainCircle(wp, area, 0.2f);
-        }
-        else
-        {
-            dc.DrawCircle(wp, area);
-        }
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool CBaseObject::CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelectionHelper) const
-{
-    bool bResult = true;
-    outDisplaySelectionHelper = false;
-
-    if (dc.flags & DISPLAY_SELECTION_HELPERS)
-    {
-        // Check if this object type is masked for selection.
-        if ((GetType() & gSettings.objectSelectMask) && !IsFrozen())
-        {
-            if (IsSkipSelectionHelper())
-            {
-                return bResult;
-            }
-            if (CanBeHightlighted())
-            {
-                outDisplaySelectionHelper = true;
-            }
-        }
-        else
-        {
-            // Object helpers should not be displayed when object is not for selection.
-            bResult = false;
-        }
-    }
-
-    return bResult;
-}
-
 //////////////////////////////////////////////////////////////////////////
 void CBaseObject::OnEvent(ObjectEvent event)
 {

+ 5 - 21
Code/Editor/Objects/BaseObject.h

@@ -18,11 +18,15 @@
 #if !defined(Q_MOC_RUN)
 #include "Include/HitContext.h"
 #include "ClassDesc.h"
-#include "DisplayContext.h"
 #include "ObjectLoader.h"
 #include "Util/Variable.h"
 
 #include "AzCore/Math/Guid.h"
+
+#include "SandboxAPI.h"
+#include <Cry_Color.h>
+#include <Cry_Geo.h>
+#include <AzCore/std/containers/vector.h>
 #endif
 
 //////////////////////////////////////////////////////////////////////////
@@ -465,9 +469,6 @@ public:
     //! In This function variables of the object must be initialized.
     virtual void InitVariables() {};
 
-    //! Draw a reddish highlight indicating its budget usage.
-    virtual void DrawBudgetUsage(DisplayContext& dc, const QColor& color);
-
     bool CanBeHightlighted() const;
     bool IsSkipSelectionHelper() const;
 
@@ -516,23 +517,6 @@ protected:
     void ResolveParent(CBaseObject* object);
     void SetColor(const QColor& color);
 
-    //! Draw object label.
-    void    DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& labelColor = QColor(255, 255, 255), float alpha = 1.0f, float size = 1.f);
-    //! Draw 3D Axis at object position.
-    void    DrawAxis(DisplayContext& dc, const Vec3& pos, float size);
-    //! Draw area around object.
-    void    DrawArea(DisplayContext& dc);
-    //! Draw selection helper.
-    void    DrawSelectionHelper(DisplayContext& dc, const Vec3& pos, const QColor& labelColor = QColor(255, 255, 255), float alpha = 1.0f);
-    //! Check if dimension's figures can be displayed before draw them.
-    virtual void DrawDimensions(DisplayContext& dc, AABB* pMergedBoundBox = nullptr);
-
-    //! Draw highlight.
-    virtual void DrawHighlight(DisplayContext& dc);
-
-    //! Returns if the object can be drawn, and if its selection helper should also be drawn.
-    bool CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelectionHelper) const;
-
     // Do basic intersection tests
     virtual bool IntersectRectBounds(const AABB& bbox);
     virtual bool IntersectRayBounds(const Ray& ray);

+ 0 - 12
Code/Editor/Objects/DisplayContext.cpp

@@ -1,12 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-
-#include "EditorDefs.h"
-
-#include "DisplayContextShared.inl"

+ 0 - 323
Code/Editor/Objects/DisplayContext.h

@@ -1,323 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-
-// Description : DisplayContext definition.
-
-
-#ifndef CRYINCLUDE_EDITOR_OBJECTS_DISPLAYCONTEXT_H
-#define CRYINCLUDE_EDITOR_OBJECTS_DISPLAYCONTEXT_H
-#pragma once
-
-
-#include "SandboxAPI.h"
-#include <Cry_Color.h>
-#include <Cry_Geo.h>
-#include <AzCore/std/containers/vector.h>
-
-#include <QColor>
-
-#define DC_DEFAULT_DOTLINE_STEPS 10
-#define DC_UNIT_DEGREE 1
-
-// forward declarations.
-struct IDisplayViewport;
-struct IRenderer;
-struct IRenderAuxGeom;
-class CDisplaySettings;
-class QPoint;
-
-enum DisplayFlags
-{
-    DISPLAY_2D = 0x01,
-    DISPLAY_HIDENAMES = 0x02,
-    DISPLAY_BBOX = 0x04,
-    DISPLAY_TRACKS = 0x08,
-    DISPLAY_TRACKTICKS = 0x010,
-    DISPLAY_WORLDSPACEAXIS = 0x020, //!< Set if axis must be displayed in world space.
-    DISPLAY_LINKS = 0x040,
-    DISPLAY_DEGRADATED = 0x080, //!< Display Objects in degradated quality (When moving/modifying).
-    DISPLAY_SELECTION_HELPERS = 0x100,  //!< Display advanced selection helpers.
-};
-
-/*!
- *  DisplayContex is a structure passed to BaseObject Display method.
- *  It contains everything the object should know to display itself in a view.
- *  All fields must be filled before passing that structure to Display call.
- */
-struct SANDBOX_API DisplayContext
-{
-    enum ETextureIconFlags
-    {
-        TEXICON_ADDITIVE     = 0x0001,
-        TEXICON_ALIGN_BOTTOM = 0x0002,
-        TEXICON_ALIGN_TOP    = 0x0004,
-        TEXICON_ON_TOP       = 0x0008,
-    };
-
-    CDisplaySettings* settings;
-    IDisplayViewport* view;
-    IRenderAuxGeom* pRenderAuxGeom;
-    AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
-    AABB    box;    // Bounding box of volume that need to be repainted.
-    AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
-    int flags;
-
-    //! Ctor.
-    DisplayContext();
-    // Helper methods.
-    void SetView(IDisplayViewport* pView);
-    IDisplayViewport* GetView() const { return view; }
-    void Flush2D();
-
-    //////////////////////////////////////////////////////////////////////////
-    // Draw functions
-    //////////////////////////////////////////////////////////////////////////
-    //! Set current materialc color.
-    void SetColor(float r, float g, float b, float a = 1)
-    {
-        m_color4b = ColorB(
-            static_cast<uint8>(r * 255.0f), static_cast<uint8>(g * 255.0f), static_cast<uint8>(b * 255.0f), static_cast<uint8>(a * 255.0f));
-    };
-    void SetColor(const Vec3& color, float a = 1)
-    {
-        m_color4b = ColorB(
-            static_cast<uint8>(color.x * 255.0f), static_cast<uint8>(color.y * 255.0f), static_cast<uint8>(color.z * 255.0f),
-            static_cast<uint8>(a * 255.0f));
-    };
-    void SetColor(const AZ::Vector3& color, float a = 1)
-    {
-        m_color4b = ColorB(
-            static_cast<uint8>(color.GetX() * 255.0f), static_cast<uint8>(color.GetY() * 255.0f), static_cast<uint8>(color.GetZ() * 255.0f),
-            static_cast<uint8>(a * 255.0f));
-    };
-    void SetColor(const QColor& rgb, float a)
-    {
-        m_color4b = ColorB(
-            static_cast<uint8>(rgb.red()), static_cast<uint8>(rgb.green()), static_cast<uint8>(rgb.blue()), static_cast<uint8>(a * 255.0f));
-    };
-    void SetColor(const QColor& color)
-    {
-        m_color4b = ColorB(
-            static_cast<uint8>(color.red()), static_cast<uint8>(color.green()), static_cast<uint8>(color.blue()),
-            static_cast<uint8>(color.alpha()));
-    };
-    void SetColor(const ColorB& color)
-    {
-        m_color4b = color;
-    };
-    void SetAlpha(float a = 1) { m_color4b.a = static_cast<uint8>(a * 255.0f); };
-    ColorB GetColor() const { return m_color4b; }
-
-    void SetSelectedColor(float fAlpha = 1);
-    void SetFreezeColor();
-
-    //! Get color to draw selectin of object.
-    QColor GetSelectedColor();
-    QColor GetFreezeColor();
-
-    // Draw 3D quad.
-    void DrawQuad(const Vec3& p1, const Vec3& p2, const Vec3& p3, const Vec3& p4);
-    void DrawQuad(float width, float height);
-    void DrawQuadGradient(const Vec3& p1, const Vec3& p2, const Vec3& p3, const Vec3& p4, ColorB firstColor, ColorB secondColor);
-    void DrawWireQuad(const Vec3& p1, const Vec3& p2, const Vec3& p3, const Vec3& p4);
-    void DrawWireQuad(float width, float height);
-    // Draw 3D Triangle.
-    void DrawTri(const Vec3& p1, const Vec3& p2, const Vec3& p3);
-    void DrawTriangles(const AZStd::vector<Vec3>& vertices, const ColorB& color);
-    void DrawTrianglesIndexed(const AZStd::vector<Vec3>& vertices, const AZStd::vector<vtx_idx>& indices, const ColorB& color);
-    // Draw wireframe box.
-    void DrawWireBox(const Vec3& min, const Vec3& max);
-    void DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max);
-    // Draw filled box
-    void DrawSolidBox(const Vec3& min, const Vec3& max);
-    void DrawSolidOBB(const Vec3& center, const Vec3& axisX, const Vec3& axisY, const Vec3& axisZ, const Vec3& halfExtents);
-    void DrawPoint(const Vec3& p, int nSize = 1);
-    void DrawLine(const Vec3& p1, const Vec3& p2);
-    void DrawLine(const Vec3& p1, const Vec3& p2, const ColorF& col1, const ColorF& col2);
-    void DrawLine(const Vec3& p1, const Vec3& p2, const QColor& rgb1, const QColor& rgb2);
-    void DrawLines(const AZStd::vector<Vec3>& vertices, const ColorF& color);
-    void DrawPolyLine(const Vec3* pnts, int numPoints, bool cycled = true);
-
-    // Vera, Confetti
-    void DrawDottedLine(const Vec3& p1, const Vec3& p2, const ColorF& col1, const ColorF& col2, const float numOfSteps = DC_DEFAULT_DOTLINE_STEPS);
-    void DrawWireQuad2d(const QPoint& p1, const QPoint& p2, float z);
-    void DrawLine2d(const QPoint& p1, const QPoint& p2, float z);
-    void DrawLine2dGradient(const QPoint& p1, const QPoint& p2, float z, ColorB firstColor, ColorB secondColor);
-    void DrawWireCircle2d(const QPoint& center, float radius, float z);
-
-    // Draw circle from lines on terrain, position is in world space.
-    void DrawTerrainCircle(const Vec3& worldPos, float radius, float height);
-    void DrawTerrainCircle(const Vec3& center, float radius, float angle1, float angle2, float height);
-
-    /// DrawArc
-    /// Draws an arc around the specified position from a given angle across the angular length given by sweepAngleDegrees
-    /// it orients the arc around the index of the given basis axis.
-    /// \param pos World space position on which to center the arc.
-    /// \param radius Radius that defines the size of the arc.
-    /// \param startAngleDegrees Angle in degrees measured clockwise from the basis axis to the starting point of the arc.
-    /// \param sweepAngleDegreees Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.
-    /// \param angularStepDegrees Defines the distance between vertices, a small value will result in a greater number of vertices.
-    /// \param referenceAxis Axis on which to align the arc (0 for X, 1 for Y, 2 for Z)
-    void DrawArc(const Vec3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, int referenceAxis = 2);
-
-
-    /// DrawArc
-    /// Draws an arc around the specified position from a given angle across the angular length given by sweepAngleDegrees
-    /// oriented around the specified axis.
-    /// \param pos World space position on which to center the arc.
-    /// \param radius Radius that defines the size of the arc.
-    /// \param startAngleDegrees Angle in degrees measured clockwise from the basis axis to the starting point of the arc.
-    /// \param sweepAngleDegreees Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.
-    /// \param angularStepDegrees Defines the distance between vertices, a small value will result in a greater number of vertices.
-    /// \param fixedAxis Normal axis on which to align the arc.
-    void DrawArc(const Vec3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const Vec3& fixedAxis);
-
-    //Vera, Confetti:
-    //Draw an arc and an arrow at the end of the arc
-    void DrawArcWithArrow(const Vec3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const Vec3& fixedAxis);
-
-    // Draw circle.
-    void DrawCircle(const Vec3& pos, float radius, int nUnchangedAxis = 2 /*z axis*/);
-
-    void DrawHalfDottedCircle(const Vec3& pos, float radius, const Vec3& viewPos, int nUnchangedAxis = 2 /*z axis*/);
-
-    // Vera, Confetti :
-    // Draw a dotted circle.
-    void DrawDottedCircle(const Vec3& pos, float radius, const Vec3& nUnchangedAxis, int numberOfArrows = 0, float stepDegree = DC_UNIT_DEGREE);
-
-    // Draw cylinder.
-    void DrawCylinder(const Vec3& p1, const Vec3& p2, float radius, float height);
-
-    void DrawCone(const Vec3& pos, const Vec3& dir, float radius, float height, bool drawShaded = true);
-
-    /// DrawWireCylinder
-    /// \param center Center of cylinder.
-    /// \param axis Axis along which cylinder is tall.
-    /// \param radius Radius of cylinder.
-    /// \param height Total height of cylinder.
-    void DrawWireCylinder(const Vec3& center, const Vec3& axis, float radius, float height);
-
-    /// DrawSolidCylinder
-    /// \param center Center of cylinder.
-    /// \param axis Axis along which cylinder is tall.
-    /// \param radius Radius of cylinder.
-    /// \param height Total height of cylinder.
-    void DrawSolidCylinder(const Vec3& center, const Vec3& axis, float radius, float height, bool drawShaded = true);
-
-    /// DrawWireCapsule
-    /// \param pos Center of capsule.
-    /// \param axis Axis along which capsule is tall.
-    /// \param radius Radius of capsule.
-    /// \param heightStraightSection Height of capsule's straight section (does not include caps).
-    void DrawWireCapsule(const Vec3& center, const Vec3& axis, float radius, float heightStraightSection);
-
-    //! Draw rectangle on top of terrain.
-    //! Coordinates are in world space.
-    void DrawTerrainRect(float x1, float y1, float x2, float y2, float height);
-
-    void DrawTerrainLine (Vec3 worldPos1, Vec3 worldPos2);
-
-    void DrawWireSphere(const Vec3& pos, float radius);
-    void DrawWireSphere(const Vec3& pos, const Vec3 radius);
-
-    void DrawWireDisk(const Vec3& pos, const Vec3& dir, float radius);
-
-    void PushMatrix(const Matrix34& tm);
-    void PopMatrix();
-    const Matrix34& GetMatrix();
-
-    // Draw special 3D objects.
-    void DrawBall(const Vec3& pos, float radius, bool drawShaded = true);
-    void DrawDisk(const Vec3& pos, const Vec3& dir, float radius);
-
-    //! Draws 3d arrow.
-    void DrawArrow(const Vec3& src, const Vec3& trg, float fHeadScale = 1, bool b2SidedArrow = false);
-
-    // Draw texture label in 2d view coordinates.
-    // w,h in pixels.
-    void DrawTextureLabel(const Vec3& pos, int nWidth, int nHeight, int nTexId, int nTexIconFlags = 0, int srcOffsetX = 0, int scrOffsetY = 0, bool bDistanceScaleIcons = false, float fDistanceScale = 1.0f);
-
-    void RenderObject(int objectType, const Vec3& pos, float scale);
-    void RenderObject(int objectType, const Matrix34& tm);
-
-    void DrawTextLabel(const Vec3& pos, float size, const char* text, const bool bCenter = false, int srcOffsetX = 0, int scrOffsetY = 0);
-    void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter = false);
-    void SetLineWidth(float width);
-
-    //! Is given bbox visible in this display context.
-    bool IsVisible(const AABB& bounds);
-
-    //! Gets current render state.
-    uint32 GetState() const;
-    //! Set a new render state.
-    //! \param returns previous render state.
-    uint32 SetState(uint32 state);
-    //! Set a new render state flags.
-    //! \param returns previous render state.
-    uint32 SetStateFlag(uint32 state);
-    //! Clear specified flags in render state.
-    //! \param returns previous render state.
-    uint32 ClearStateFlag(uint32 state);
-
-    void DepthTestOff();
-    void DepthTestOn();
-
-    void DepthWriteOff();
-    void DepthWriteOn();
-
-    void CullOff();
-    void CullOn();
-
-    // Enables drawing helper lines in front of usual geometry, adds a small z offset to all drawn lines.
-    bool SetDrawInFrontMode(bool bOn);
-
-    // Description:
-    //   Changes fill mode.
-    // Arguments:
-    //    nFillMode is one of the values from EAuxGeomPublicRenderflags_FillMode
-    int  SetFillMode(int nFillMode);
-
-    //! Convert position to world space.
-    Vec3 ToWorldSpacePosition(const Vec3& v) { return m_matrixStack[m_currentMatrix].TransformPoint(v); }
-
-    //! Convert direction to world space (translation is not considered)
-    Vec3 ToWorldSpaceVector(const Vec3& v) { return m_matrixStack[m_currentMatrix].TransformVector(v); }
-
-    float ToWorldSpaceMaxScale(float value);
-
-    float GetLineWidth() const              {   return m_thickness; }
-
-private:
-
-    void InternalDrawLine(const Vec3& v0, const ColorB& colV0, const Vec3& v1, const ColorB& colV1);
-
-    AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
-    ColorB m_color4b;
-    uint32 m_renderState;
-    float m_thickness;
-    float m_width;
-    float m_height;
-
-    int m_currentMatrix;
-    //! Matrix stack.
-    Matrix34 m_matrixStack[32];
-
-    struct STextureLabel
-    {
-        float x, y, z; // 2D position (z in world space).
-        float w, h;  // Width height.
-        int nTexId; // Texture id.
-        int flags;  // ETextureIconFlags
-        float color[4];
-    };
-    std::vector<STextureLabel> m_textureLabels;
-    AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
-};
-
-#endif // CRYINCLUDE_EDITOR_OBJECTS_DISPLAYCONTEXT_H

+ 0 - 1336
Code/Editor/Objects/DisplayContextShared.inl

@@ -1,1336 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-
-#include <Cry_Geo.h>
-#include "DisplayContext.h"
-#include "IRenderAuxGeom.h"
-#include "IEditor.h"
-#include "Include/IDisplayViewport.h"
-#include <Editor/Util/EditorUtils.h>
-
-#include <QDateTime>
-#include <QPoint>
-
-#include <AzFramework/Terrain/TerrainDataRequestBus.h>
-
-#define FREEZE_COLOR QColor(100, 100, 100)
-
-//////////////////////////////////////////////////////////////////////////
-DisplayContext::DisplayContext()
-{
-    view = 0;
-    flags = 0;
-    settings = 0;
-    m_renderState = 0;
-
-    m_currentMatrix = 0;
-    m_matrixStack[m_currentMatrix].SetIdentity();
-    pRenderAuxGeom = nullptr; // ToDo: Remove DisplayContext or update to work with Atom: LYN-3670
-    m_thickness = 0;
-
-    m_width = 0;
-    m_height = 0;
-
-    m_textureLabels.reserve(100);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::SetView(IDisplayViewport* pView)
-{
-    view = pView;
-    int width, height;
-    view->GetDimensions(&width, &height);
-    m_width = static_cast<float>(width);
-    m_height = static_cast<float>(height);
-    m_textureLabels.resize(0);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::InternalDrawLine(const Vec3& v0, const ColorB& colV0, const Vec3& v1, const ColorB& colV1)
-{
-    pRenderAuxGeom->DrawLine(v0, colV0, v1, colV1, m_thickness);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawPoint(const Vec3& p, int nSize)
-{
-    pRenderAuxGeom->DrawPoint(ToWorldSpacePosition(p), m_color4b, static_cast<uint8>(nSize));
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTri(const Vec3& p1, const Vec3& p2, const Vec3& p3)
-{
-    pRenderAuxGeom->DrawTriangle(ToWorldSpacePosition(p1), m_color4b, ToWorldSpacePosition(p2), m_color4b, ToWorldSpacePosition(p3), m_color4b);
-}
-
-void DisplayContext::DrawTriangles(const AZStd::vector<Vec3>& vertices, const ColorB& color)
-{
-    pRenderAuxGeom->DrawTriangles(vertices.begin(), static_cast<uint32>(vertices.size()), color);
-}
-
-void DisplayContext::DrawTrianglesIndexed(const AZStd::vector<Vec3>& vertices, const AZStd::vector<vtx_idx>& indices, const ColorB& color)
-{
-    pRenderAuxGeom->DrawTriangles(vertices.begin(), static_cast<uint32>(vertices.size()), indices.begin(), static_cast<uint32_t>(indices.size()), color);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawQuad(const Vec3& p1, const Vec3& p2, const Vec3& p3, const Vec3& p4)
-{
-    Vec3 p[4] = { ToWorldSpacePosition(p1), ToWorldSpacePosition(p2), ToWorldSpacePosition(p3), ToWorldSpacePosition(p4) };
-    pRenderAuxGeom->DrawTriangle(p[0], m_color4b, p[1], m_color4b, p[2], m_color4b);
-    pRenderAuxGeom->DrawTriangle(p[2], m_color4b, p[3], m_color4b, p[0], m_color4b);
-}
-
-void DisplayContext::DrawQuad(float width, float height)
-{
-    pRenderAuxGeom->DrawQuad(width, height, m_matrixStack[m_currentMatrix], m_color4b);
-}
-
-void DisplayContext::DrawWireQuad(const Vec3& p1, const Vec3& p2, const Vec3& p3, const Vec3& p4)
-{
-    Vec3 p[4] = { ToWorldSpacePosition(p1), ToWorldSpacePosition(p2), ToWorldSpacePosition(p3), ToWorldSpacePosition(p4) };
-    pRenderAuxGeom->DrawPolyline(p, 4, true, m_color4b);
-}
-
-void DisplayContext::DrawWireQuad(float width, float height)
-{
-    const float halfWidth = width * 0.5f;
-    const float halfHeight = height * 0.5f;
-
-    const Vec3 p[4] =
-    {
-        ToWorldSpacePosition(Vec3(-halfWidth, 0.0f,  halfHeight)),
-        ToWorldSpacePosition(Vec3( halfWidth, 0.0f,  halfHeight)),
-        ToWorldSpacePosition(Vec3( halfWidth, 0.0f, -halfHeight)),
-        ToWorldSpacePosition(Vec3(-halfWidth, 0.0f, -halfHeight)),
-    };
-    pRenderAuxGeom->DrawPolyline(p, 4, true, m_color4b);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawCylinder(const Vec3& p1, const Vec3& p2, float radius, float height)
-{
-    Vec3 p[2] = { ToWorldSpacePosition(p1), ToWorldSpacePosition(p2) };
-    Vec3 dir = p[1] - p[0];
-    pRenderAuxGeom->DrawCylinder(p[0], dir, radius, height, m_color4b);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawCone(const Vec3& pos, const Vec3& dir, float radius, float height, bool drawShaded /*= true*/)
-{
-    const Vec3 worldPos = ToWorldSpacePosition(pos);
-    const Vec3 worldDir = ToWorldSpaceVector(dir);
-    pRenderAuxGeom->DrawCone(worldPos, worldDir, radius, height, m_color4b, drawShaded);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawWireCylinder(const Vec3& center, const Vec3& axis, float radius, float height)
-{
-    if (radius > FLT_EPSILON && height > FLT_EPSILON && axis.GetLengthSquared() > FLT_EPSILON)
-    {
-        Vec3 axisNormalized = axis.GetNormalized();
-
-        // Draw circles at bottom & top of cylinder
-        Vec3 centerToTop = axisNormalized * height * 0.5f;
-        Vec3 circle1Center = center - centerToTop;
-        Vec3 circle2Center = center + centerToTop;
-        // DrawArc() takes local coordinates
-        DrawArc(circle1Center, radius, 0.0f, 360.0f, 22.5f, axisNormalized);
-        DrawArc(circle2Center, radius, 0.0f, 360.0f, 22.5f, axisNormalized);
-
-        // Draw 4 lines up side of cylinder
-        Vec3 rightDirNormalized, frontDirNormalized;
-        GetBasisVectors(axisNormalized, rightDirNormalized, frontDirNormalized);
-        Vec3 centerToRightEdge = rightDirNormalized * radius;
-        Vec3 centerToFrontEdge = frontDirNormalized * radius;
-        // InternalDrawLine() takes world coordinates
-        InternalDrawLine(ToWorldSpacePosition(circle1Center + centerToRightEdge), m_color4b,
-            ToWorldSpacePosition(circle2Center + centerToRightEdge), m_color4b);
-        InternalDrawLine(ToWorldSpacePosition(circle1Center - centerToRightEdge), m_color4b,
-            ToWorldSpacePosition(circle2Center - centerToRightEdge), m_color4b);
-        InternalDrawLine(ToWorldSpacePosition(circle1Center + centerToFrontEdge), m_color4b,
-            ToWorldSpacePosition(circle2Center + centerToFrontEdge), m_color4b);
-        InternalDrawLine(ToWorldSpacePosition(circle1Center - centerToFrontEdge), m_color4b,
-            ToWorldSpacePosition(circle2Center - centerToFrontEdge), m_color4b);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawSolidCylinder(const Vec3& center, const Vec3& axis, float radius, float height, bool drawShaded)
-{
-    if (radius > FLT_EPSILON && height > FLT_EPSILON && axis.GetLengthSquared() > FLT_EPSILON)
-    {
-        // transform everything to world space
-        Vec3 wsCenter = ToWorldSpacePosition(center);
-
-        // determine scale in dir direction, apply to height
-        Vec3 axisNormalized = axis.GetNormalized();
-        Vec3 wsAxis = ToWorldSpaceVector(axisNormalized);
-        float wsAxisLength = wsAxis.GetLength();
-        float wsHeight = height * wsAxisLength;
-
-        // determine scale in orthogonal direction, apply to radius
-        Vec3 radiusDirNormalized = axisNormalized.GetOrthogonal();
-        radiusDirNormalized.Normalize();
-        Vec3 wsRadiusDir = ToWorldSpaceVector(radiusDirNormalized);
-        float wsRadiusDirLen = wsRadiusDir.GetLength();
-        float wsRadius = radius * wsRadiusDirLen;
-
-        pRenderAuxGeom->DrawCylinder(wsCenter, wsAxis, wsRadius, wsHeight, m_color4b, drawShaded);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-
-void DisplayContext::DrawWireCapsule(const Vec3& center, const Vec3& axis, float radius, float heightStraightSection)
-{
-    if (radius > FLT_EPSILON && axis.GetLengthSquared() > FLT_EPSILON)
-    {
-        Vec3 axisNormalized = axis.GetNormalizedFast();
-
-        // Draw cylinder part (or just a circle around the middle)
-        if (heightStraightSection > FLT_EPSILON)
-        {
-            DrawWireCylinder(center, axis, radius, heightStraightSection);
-        }
-        else
-        {
-            DrawArc(center, radius, 0.0f, 360.0f, 22.5f, axisNormalized);
-        }
-
-        // Draw top cap as two criss-crossing 180deg arcs
-        Vec3 ortho1Normalized, ortho2Normalized;
-        GetBasisVectors(axisNormalized, ortho1Normalized, ortho2Normalized);
-        Vec3 centerToTopCircleCenter = axisNormalized * heightStraightSection * 0.5f;
-        DrawArc(center + centerToTopCircleCenter, radius,  90.0f, 180.0f, 22.5f, ortho1Normalized);
-        DrawArc(center + centerToTopCircleCenter, radius, 180.0f, 180.0f, 22.5f, ortho2Normalized);
-
-        // Draw bottom cap
-        DrawArc(center - centerToTopCircleCenter, radius, -90.0f, 180.0f, 22.5f, ortho1Normalized);
-        DrawArc(center - centerToTopCircleCenter, radius,   0.0f, 180.0f, 22.5f, ortho2Normalized);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawWireBox(const Vec3& min, const Vec3& max)
-{
-    pRenderAuxGeom->DrawAABB(AABB(min, max), m_matrixStack[m_currentMatrix], false, m_color4b, eBBD_Faceted);
-}
-
-void DisplayContext::DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max)
-{
-    pRenderAuxGeom->DrawAABB(
-        AABB(Vec3(min.GetX(), min.GetY(), min.GetZ()), Vec3(max.GetX(), max.GetY(), max.GetZ())),
-        m_matrixStack[m_currentMatrix], false, m_color4b, eBBD_Faceted);
-}
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawSolidBox(const Vec3& min, const Vec3& max)
-{
-    pRenderAuxGeom->DrawAABB(AABB(min, max), m_matrixStack[m_currentMatrix], true, m_color4b, eBBD_Faceted);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawSolidOBB(const Vec3& center, const Vec3& axisX, const Vec3& axisY, const Vec3& axisZ, const Vec3& halfExtents)
-{
-    OBB obb;
-    obb.m33 = Matrix33::CreateFromVectors(axisX, axisY, axisZ);
-    obb.c = Vec3(0, 0, 0);
-    obb.h = halfExtents;
-    pRenderAuxGeom->DrawOBB(obb, center, true, m_color4b, eBBD_Faceted);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2)
-{
-    InternalDrawLine(ToWorldSpacePosition(p1), m_color4b, ToWorldSpacePosition(p2), m_color4b);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawPolyLine(const Vec3* pnts, int numPoints, bool cycled)
-{
-    MAKE_SURE(numPoints >= 2, return );
-    MAKE_SURE(pnts != 0, return );
-
-    int numSegments = cycled ? numPoints : (numPoints - 1);
-    Vec3 p1 = ToWorldSpacePosition(pnts[0]);
-    Vec3 p2;
-    for (int i = 0; i < numSegments; i++)
-    {
-        int j = (i + 1) % numPoints;
-        p2 = ToWorldSpacePosition(pnts[j]);
-        InternalDrawLine(p1, m_color4b, p2, m_color4b);
-        p1 = p2;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTerrainCircle(const Vec3& worldPos, float radius, float height)
-{
-    auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
-    // Draw circle with default radius.
-    Vec3 p0, p1;
-    p0.x = worldPos.x + radius * sin(0.0f);
-    p0.y = worldPos.y + radius * cos(0.0f);
-    const float defaultTerrainElevation = AzFramework::Terrain::TerrainDataRequests::GetDefaultTerrainHeight();
-    float terrainElevation = terrain ? terrain->GetHeightFromFloats(p0.x, p0.y) : defaultTerrainElevation;
-    p0.z = terrainElevation + height;
-
-    float step = 20.0f / 180 * gf_PI;
-    for (float angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = worldPos.x + radius * sin(angle);
-        p1.y = worldPos.y + radius * cos(angle);
-        terrainElevation = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) : defaultTerrainElevation;
-        p1.z = terrainElevation + height;
-
-        InternalDrawLine(ToWorldSpacePosition(p0), m_color4b, ToWorldSpacePosition(p1), m_color4b);
-        p0 = p1;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTerrainCircle(const Vec3& worldPos, float radius, float angle1, float angle2, float height)
-{
-    auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
-    // Draw circle with default radius.
-    Vec3 p0, p1;
-    p0.x = worldPos.x + radius * sin(angle1);
-    p0.y = worldPos.y + radius * cos(angle1);
-    float terrainElevation = terrain ? terrain->GetHeightFromFloats(p0.x, p0.y) : 0.0f;
-    p0.z = terrainElevation + height;
-
-    float step = 20.0f / 180 * gf_PI;
-    for (float angle = step + angle1; angle < angle2; angle += step)
-    {
-        p1.x = worldPos.x + radius * sin(angle);
-        p1.y = worldPos.y + radius * cos(angle);
-        terrainElevation = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) : 0.0f;
-        p1.z = terrainElevation + height;
-
-        InternalDrawLine(ToWorldSpacePosition(p0), m_color4b, ToWorldSpacePosition(p1), m_color4b);
-        p0 = p1;
-    }
-
-    p1.x = worldPos.x + radius * sin(angle2);
-    p1.y = worldPos.y + radius * cos(angle2);
-    terrainElevation = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) : 0.0f;
-    p1.z = terrainElevation + height;
-
-    InternalDrawLine(ToWorldSpacePosition(p0), m_color4b, ToWorldSpacePosition(p1), m_color4b);
-}
-
-
-void DisplayContext::DrawArc(const Vec3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, int referenceAxis)
-{
-    // angularStepDegrees cannot be zero as it is used to divide sweepAngleDegrees
-    if (fabs(angularStepDegrees) < FLT_EPSILON)
-    {
-        return;
-    }
-
-    float startAngleRadians = DEG2RAD(startAngleDegrees);
-    float sweepAngleRadians = DEG2RAD(sweepAngleDegrees);
-
-    float angle = startAngleRadians;
-
-    const uint referenceAxis0 = referenceAxis % 3;
-    const uint referenceAxis1 = (referenceAxis + 1) % 3;
-    const uint referenceAxis2 = (referenceAxis + 2) % 3;
-
-    Vec3 p0;
-    p0[referenceAxis0] = pos[referenceAxis0];
-    p0[referenceAxis1] = pos[referenceAxis1] + radius * sin(angle);
-    p0[referenceAxis2] = pos[referenceAxis2] + radius * cos(angle);
-    p0 = ToWorldSpacePosition(p0);
-
-    float step = DEG2RAD(angularStepDegrees);
-    int numSteps = std::abs(static_cast<int>(std::ceil(sweepAngleRadians / step)));
-
-    Vec3 p1;
-    for (int i = 0; i < numSteps; ++i)
-    {
-        angle += std::min(step, sweepAngleRadians); // Don't go past sweepAngleRadians when stepping or the arc will be too long.
-        sweepAngleRadians -= step;
-
-        p1[referenceAxis0] = pos[referenceAxis0];
-        p1[referenceAxis1] = pos[referenceAxis1] + radius * sin(angle);
-        p1[referenceAxis2] = pos[referenceAxis2] + radius * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-}
-
-void DisplayContext::DrawArc(const Vec3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const Vec3& fixedAxis)
-{
-    // angularStepDegrees cannot be zero as it is used to divide sweepAngleDegrees
-    if (fabs(angularStepDegrees) < FLT_EPSILON)
-    {
-        return;
-    }
-
-    float startAngleRadians = DEG2RAD(startAngleDegrees);
-    float sweepAngleRadians = DEG2RAD(sweepAngleDegrees);
-
-    Vec3 a;
-    Vec3 b;
-    GetBasisVectors(fixedAxis, a, b);
-
-    float angle = startAngleRadians;
-
-    float cosAngle = cos(angle) * radius;
-    float sinAngle = sin(angle) * radius;
-
-    Vec3 p0;
-    p0.x = pos.x + cosAngle * a.x + sinAngle * b.x;
-    p0.y = pos.y + cosAngle * a.y + sinAngle * b.y;
-    p0.z = pos.z + cosAngle * a.z + sinAngle * b.z;
-    p0 = ToWorldSpacePosition(p0);
-
-    float step = DEG2RAD(angularStepDegrees);
-    int numSteps = std::abs(static_cast<int>(std::ceil(sweepAngleRadians / step)));
-
-    Vec3 p1;
-    for (int i = 0; i < numSteps; ++i)
-    {
-        angle += std::min(step, sweepAngleRadians); // Don't go past sweepAngleRadians when stepping or the arc will be too long.
-        sweepAngleRadians -= step;
-
-        float cosAngle2 = cos(angle) * radius;
-        float sinAngle2 = sin(angle) * radius;
-
-        p1.x = pos.x + cosAngle2 * a.x + sinAngle2 * b.x;
-        p1.y = pos.y + cosAngle2 * a.y + sinAngle2 * b.y;
-        p1.z = pos.z + cosAngle2 * a.z + sinAngle2 * b.z;
-        p1 = ToWorldSpacePosition(p1);
-
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-
-        p0 = p1;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-// Vera, Confetti
-void DisplayContext::DrawArcWithArrow(const Vec3& pos, float radius, float startAngleDegrees, float sweepAngleDegrees, float angularStepDegrees, const Vec3& fixedAxis)
-{
-    // angularStepDegrees cannot be zero as it is used to divide sweepAngleDegrees
-    // Grab the code from draw arc to get the final p0 and p1;
-    if (fabs(angularStepDegrees) < FLT_EPSILON)
-    {
-        return;
-    }
-
-    float startAngleRadians = DEG2RAD(startAngleDegrees);
-    float sweepAngleRadians = DEG2RAD(sweepAngleDegrees);
-
-    Vec3 a;
-    Vec3 b;
-    GetBasisVectors(fixedAxis, a, b);
-
-    float angle = startAngleRadians;
-
-    float cosAngle = cos(angle) * radius;
-    float sinAngle = sin(angle) * radius;
-
-    Vec3 p0;
-    p0.x = pos.x + cosAngle * a.x + sinAngle * b.x;
-    p0.y = pos.y + cosAngle * a.y + sinAngle * b.y;
-    p0.z = pos.z + cosAngle * a.z + sinAngle * b.z;
-    p0 = ToWorldSpacePosition(p0);
-
-    float step = DEG2RAD(angularStepDegrees);
-    int numSteps = std::abs(static_cast<int>(std::ceil(sweepAngleRadians / step)));
-
-    Vec3 p1;
-    for (int i = 0; i < numSteps; ++i)
-    {
-        angle += step;
-        float cosAngle2 = cos(angle) * radius;
-        float sinAngle2 = sin(angle) * radius;
-
-        p1.x = pos.x + cosAngle2 * a.x + sinAngle2 * b.x;
-        p1.y = pos.y + cosAngle2 * a.y + sinAngle2 * b.y;
-        p1.z = pos.z + cosAngle2 * a.z + sinAngle2 * b.z;
-        p1 = ToWorldSpacePosition(p1);
-
-        if (i + 1 >= numSteps) // For last step, draw an arrow
-        {
-            // p0 and p1 are global position. We could like to map it to local
-            Matrix34 inverseMat =  m_matrixStack[m_currentMatrix].GetInverted();
-            Vec3 localP0 = inverseMat.TransformPoint(p0);
-            Vec3 localP1 = inverseMat.TransformPoint(p1);
-            DrawArrow(localP0, localP1, m_thickness);
-        }
-        else
-        {
-            InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        }
-
-        p0 = p1;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawCircle(const Vec3& pos, float radius, int nUnchangedAxis)
-{
-    // Draw circle with default radius.
-    Vec3 p0, p1;
-    p0[nUnchangedAxis] = pos[nUnchangedAxis];
-    p0[(nUnchangedAxis + 1) % 3] = pos[(nUnchangedAxis + 1) % 3] + radius * sin(0.0f);
-    p0[(nUnchangedAxis + 2) % 3] = pos[(nUnchangedAxis + 2) % 3] + radius * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    const float step = 10.0f / 180.0f * gf_PI;
-    for (float angle = step; angle < 360.0f / 180.0f * gf_PI + step; angle += step)
-    {
-        p1[nUnchangedAxis] = pos[nUnchangedAxis];
-        p1[(nUnchangedAxis + 1) % 3] = pos[(nUnchangedAxis + 1) % 3] + radius * sin(angle);
-        p1[(nUnchangedAxis + 2) % 3] = pos[(nUnchangedAxis + 2) % 3] + radius * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-}
-
-void DisplayContext::DrawHalfDottedCircle(const Vec3& pos, float radius, const Vec3& viewPos, int nUnchangedAxis)
-{
-    // Draw circle with default radius
-    Vec3 p0, p1;
-    p0[nUnchangedAxis] = pos[nUnchangedAxis];
-    p0[(nUnchangedAxis + 1) % 3] = pos[(nUnchangedAxis + 1) % 3] + radius * sin(0.0f);
-    p0[(nUnchangedAxis + 2) % 3] = pos[(nUnchangedAxis + 2) % 3] + radius * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    const Vec3 worldPos = ToWorldSpacePosition(pos);
-    const Vec3 worldView = ToWorldSpacePosition(viewPos);
-    const float step = 10.0f / 180.0f * gf_PI;
-    size_t count = 0;
-    for (float angle = step; angle < 360.0f / 180.0f * gf_PI + step; angle += step)
-    {
-        p1[nUnchangedAxis] = pos[nUnchangedAxis];
-        p1[(nUnchangedAxis + 1) % 3] = pos[(nUnchangedAxis + 1) % 3] + radius * sin(angle);
-        p1[(nUnchangedAxis + 2) % 3] = pos[(nUnchangedAxis + 2) % 3] + radius * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-        // is circle edge facing away from us or not
-        const float dot = (p0 - worldPos).Dot(worldView - worldPos);
-        const bool facing = dot > 0.0f;
-        // if so skip every other line to produce a dotted effect
-        if (facing || count % 2 == 0)
-        {
-            InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        }
-        count++;
-        p0 = p1;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-// Vera, Confetti
-void DisplayContext::DrawDottedCircle(const Vec3& pos, float radius, const Vec3& nUnchangedAxis, int numberOfArrows /*=0*/, float stepDegree /*= 1*/)
-{
-    float startAngleRadians = 0;
-
-    Vec3 a;
-    Vec3 b;
-    GetBasisVectors(nUnchangedAxis, a, b);
-
-    float angle = startAngleRadians;
-
-    float cosAngle = cos(angle) * radius;
-    float sinAngle = sin(angle) * radius;
-
-    Vec3 p0;
-    p0.x = pos.x + cosAngle * a.x + sinAngle * b.x;
-    p0.y = pos.y + cosAngle * a.y + sinAngle * b.y;
-    p0.z = pos.z + cosAngle * a.z + sinAngle * b.z;
-    p0 = ToWorldSpacePosition(p0);
-
-    float step = DEG2RAD(stepDegree); // one degree each step
-    int numSteps = aznumeric_cast<int>(2.0f * gf_PI / step);
-
-    // Prepare for drawing arrow
-    float arrowStep = 0;
-    float arrowAngle = 0;
-    if (numberOfArrows > 0)
-    {
-        arrowStep = 2 * gf_PI / numberOfArrows;
-        arrowAngle = arrowStep;
-    }
-
-    Vec3 p1;
-    for (int i = 0; i < numSteps; ++i)
-    {
-        angle += step;
-        float cosAngle2 = cos(angle) * radius;
-        float sinAngle2 = sin(angle) * radius;
-
-        p1.x = pos.x + cosAngle2 * a.x + sinAngle2 * b.x;
-        p1.y = pos.y + cosAngle2 * a.y + sinAngle2 * b.y;
-        p1.z = pos.z + cosAngle2 * a.z + sinAngle2 * b.z;
-        p1 = ToWorldSpacePosition(p1);
-
-
-        if (arrowStep > 0) // If user want to draw arrow on circle
-        {
-            // if the arraw should be drawn between current angel and next angel
-            if (angle <= arrowAngle && angle + step * 2 > arrowAngle)
-            {
-                // Get local position from global position
-                Matrix34 inverseMat = m_matrixStack[m_currentMatrix].GetInverted();
-                Vec3 localP0 = inverseMat.TransformPoint(p0);
-                Vec3 localP1 = inverseMat.TransformPoint(p1);
-                DrawArrow(localP0, localP1, m_thickness);
-                arrowAngle += arrowStep;
-                if (arrowAngle > 2 * gf_PI) // if the next arrow angle is greater than 2PI. Stop adding arrow.
-                {
-                    arrowStep = 0;
-                }
-            }
-        }
-
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-
-        // Skip a step
-        angle += step;
-        cosAngle2 = cos(angle) * radius;
-        sinAngle2 = sin(angle) * radius;
-
-        p1.x = pos.x + cosAngle2 * a.x + sinAngle2 * b.x;
-        p1.y = pos.y + cosAngle2 * a.y + sinAngle2 * b.y;
-        p1.z = pos.z + cosAngle2 * a.z + sinAngle2 * b.z;
-        p1 = ToWorldSpacePosition(p1);
-
-        p0 = p1;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawWireCircle2d(const QPoint& center, float radius, float z)
-{
-    Vec3 p0, p1, pos;
-    pos.x = static_cast<float>(center.x());
-    pos.y = static_cast<float>(center.y());
-    pos.z = z;
-    p0.x = pos.x + radius * sin(0.0f);
-    p0.y = pos.y + radius * cos(0.0f);
-    p0.z = z;
-    float step = 10.0f / 180 * gf_PI;
-
-    int prevState = GetState();
-    //SetState( (prevState|e_Mode2D) & (~e_Mode3D) );
-    for (float angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x + radius * sin(angle);
-        p1.y = pos.y + radius * cos(angle);
-        p1.z = z;
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-    SetState(prevState);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawWireSphere(const Vec3& pos, float radius)
-{
-    Vec3 p0, p1;
-    float step = 10.0f / 180 * gf_PI;
-    float angle;
-
-    // Z Axis
-    p0 = pos;
-    p1 = pos;
-    p0.x += radius * sin(0.0f);
-    p0.y += radius * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    for (angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x + radius * sin(angle);
-        p1.y = pos.y + radius * cos(angle);
-        p1.z = pos.z;
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-
-    // X Axis
-    p0 = pos;
-    p1 = pos;
-    p0.y += radius * sin(0.0f);
-    p0.z += radius * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    for (angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x;
-        p1.y = pos.y + radius * sin(angle);
-        p1.z = pos.z + radius * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-
-    // Y Axis
-    p0 = pos;
-    p1 = pos;
-    p0.x += radius * sin(0.0f);
-    p0.z += radius * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    for (angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x + radius * sin(angle);
-        p1.y = pos.y;
-        p1.z = pos.z + radius * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawWireSphere(const Vec3& pos, const Vec3 radius)
-{
-    Vec3 p0, p1;
-    float step = 10.0f / 180 * gf_PI;
-    float angle;
-
-    // Z Axis
-    p0 = pos;
-    p1 = pos;
-    p0.x += radius.x * sin(0.0f);
-    p0.y += radius.y * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    for (angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x + radius.x * sin(angle);
-        p1.y = pos.y + radius.y * cos(angle);
-        p1.z = pos.z;
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-
-    // X Axis
-    p0 = pos;
-    p1 = pos;
-    p0.y += radius.y * sin(0.0f);
-    p0.z += radius.z * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    for (angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x;
-        p1.y = pos.y + radius.y * sin(angle);
-        p1.z = pos.z + radius.z * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-
-    // Y Axis
-    p0 = pos;
-    p1 = pos;
-    p0.x += radius.x * sin(0.0f);
-    p0.z += radius.z * cos(0.0f);
-    p0 = ToWorldSpacePosition(p0);
-    for (angle = step; angle < 360.0f / 180 * gf_PI + step; angle += step)
-    {
-        p1.x = pos.x + radius.x * sin(angle);
-        p1.y = pos.y;
-        p1.z = pos.z + radius.z * cos(angle);
-        p1 = ToWorldSpacePosition(p1);
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        p0 = p1;
-    }
-}
-
-void DisplayContext::DrawWireDisk(const Vec3& pos, const Vec3& dir, float radius)
-{
-    // Draw circle
-    DrawArc(pos, radius, 0.0f, 360.0f, 11.25f, dir);
-
-    // Draw disk direction normal from center.
-    DrawLine(pos, pos + dir * radius * 0.2f);
-}
-
-void DisplayContext::DrawWireQuad2d(const QPoint& pmin, const QPoint& pmax, float z)
-{
-    int prevState = GetState();
-    SetState((prevState | e_Mode2D) & (~e_Mode3D));
-    float minX = static_cast<float>(pmin.x());
-    float minY = static_cast<float>(pmin.y());
-    float maxX = static_cast<float>(pmax.x());
-    float maxY = static_cast<float>(pmax.y());
-    InternalDrawLine(Vec3(minX, minY, z), m_color4b, Vec3(maxX, minY, z), m_color4b);
-    InternalDrawLine(Vec3(maxX, minY, z), m_color4b, Vec3(maxX, maxY, z), m_color4b);
-    InternalDrawLine(Vec3(maxX, maxY, z), m_color4b, Vec3(minX, maxY, z), m_color4b);
-    InternalDrawLine(Vec3(minX, maxY, z), m_color4b, Vec3(minX, minY, z), m_color4b);
-    SetState(prevState);
-}
-
-void DisplayContext::DrawLine2d(const QPoint& p1, const QPoint& p2, float z)
-{
-    int prevState = GetState();
-
-    SetState((prevState | e_Mode2D) & (~e_Mode3D));
-
-    // If we don't have correct information, we try to get it, but while we
-    // don't, we skip rendering this frame.
-    if (m_width == 0 || m_height == 0)
-    {
-        if (view)
-        {
-            // We tell the window to update itself, as it might be needed to
-            // get correct information.
-            view->Update();
-            int width, height;
-            view->GetDimensions(&width, &height);
-            m_width = static_cast<float>(width);
-            m_height = static_cast<float>(height);
-        }
-    }
-    else
-    {
-        InternalDrawLine(Vec3(p1.x() / m_width, p1.y() / m_height, z), m_color4b, Vec3(p2.x() / m_width, p2.y() / m_height, z), m_color4b);
-    }
-
-    SetState(prevState);
-}
-
-void DisplayContext::DrawLine2dGradient(const QPoint& p1, const QPoint& p2, float z, ColorB firstColor, ColorB secondColor)
-{
-    int prevState = GetState();
-
-    SetState((prevState | e_Mode2D) & (~e_Mode3D));
-    InternalDrawLine(Vec3(p1.x() / m_width, p1.y() / m_height, z), firstColor, Vec3(p2.x() / m_width, p2.y() / m_height, z), secondColor);
-    SetState(prevState);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawQuadGradient(const Vec3& p1, const Vec3& p2, const Vec3& p3, const Vec3& p4, ColorB firstColor, ColorB secondColor)
-{
-    Vec3 p[4] = { ToWorldSpacePosition(p1), ToWorldSpacePosition(p2), ToWorldSpacePosition(p3), ToWorldSpacePosition(p4) };
-    pRenderAuxGeom->DrawTriangle(p[0], firstColor, p[1], firstColor, p[2], secondColor);
-    pRenderAuxGeom->DrawTriangle(p[2], secondColor, p[3], secondColor, p[0], firstColor);
-}
-
-//////////////////////////////////////////////////////////////////////////
-QColor DisplayContext::GetSelectedColor()
-{
-    float t = aznumeric_cast<float>(QDateTime::currentMSecsSinceEpoch() / 1000);
-    float r1 = fabs(sin(t * 8.0f));
-    if (r1 > 255)
-    {
-        r1 = 255;
-    }
-    return QColor(255, 0, aznumeric_cast<int>(r1 * 255));
-    //          float r2 = cos(t*3);
-    //dc.renderer->SetMaterialColor( 1,0,r1,0.5f );
-}
-
-QColor DisplayContext::GetFreezeColor()
-{
-    return FREEZE_COLOR;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::SetSelectedColor(float fAlpha)
-{
-    SetColor(GetSelectedColor(), fAlpha);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::SetFreezeColor()
-{
-    SetColor(FREEZE_COLOR, 0.5f);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2, const ColorF& col1, const ColorF& col2)
-{
-    InternalDrawLine(ToWorldSpacePosition(p1), ColorB(col1), ToWorldSpacePosition(p2), ColorB(col2));
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2, const QColor& rgb1, const QColor& rgb2)
-{
-    InternalDrawLine(ToWorldSpacePosition(p1), 
-        ColorB(static_cast<uint8>(rgb1.red()), static_cast<uint8>(rgb1.green()), static_cast<uint8>(rgb1.blue()), 255), 
-        ToWorldSpacePosition(p2), 
-        ColorB(static_cast<uint8>(rgb2.red()), static_cast<uint8>(rgb2.green()), static_cast<uint8>(rgb2.blue()), 255));
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawLines(const AZStd::vector<Vec3>& points, const ColorF& color)
-{
-    pRenderAuxGeom->DrawLines(points.begin(), static_cast<uint32>(points.size()), color, m_thickness);
-}
-
-//////////////////////////////////////////////////////////////////////////
-// Vera, Confetti
-void DisplayContext::DrawDottedLine(const Vec3& p1, const Vec3& p2, [[maybe_unused]] const ColorF& col1, [[maybe_unused]] const ColorF& col2, const float numOfSteps)
-{
-    Vec3 direction =  Vec3(p2.x - p1.x, p2.y - p1.y, p2.z - p1.z);
-    //We only draw half of a step and leave the other half empty to make it a dotted line.
-    Vec3 halfstep = (direction / numOfSteps) * 0.5f;
-    Vec3 startPoint = p1;
-
-    for (int stepCount = 0; stepCount < numOfSteps; stepCount++)
-    {
-        InternalDrawLine(ToWorldSpacePosition(startPoint), m_color4b, ToWorldSpacePosition(startPoint + halfstep), m_color4b);
-        startPoint += 2 * halfstep; //skip a half step to make it dotted
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::PushMatrix(const Matrix34& tm)
-{
-    assert(m_currentMatrix < 31);
-    if (m_currentMatrix < 31)
-    {
-        m_currentMatrix++;
-        m_matrixStack[m_currentMatrix] = m_matrixStack[m_currentMatrix - 1] * tm;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::PopMatrix()
-{
-    assert(m_currentMatrix > 0);
-    if (m_currentMatrix > 0)
-    {
-        m_currentMatrix--;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-const Matrix34& DisplayContext::GetMatrix()
-{
-    return m_matrixStack[m_currentMatrix];
-}
-
-float DisplayContext::ToWorldSpaceMaxScale(float value)
-{
-    // get the max scaled value in case the transform on the stack is scaled non-uniformly
-    const float transformedValueX = ToWorldSpaceVector(Vec3(value, 0.0f, 0.0f)).GetLength();
-    const float transformedValueY = ToWorldSpaceVector(Vec3(0.0f, value, 0.0f)).GetLength();
-    const float transformedValueZ = ToWorldSpaceVector(Vec3(0.0f, 0.0f, value)).GetLength();
-    return AZ::GetMax(transformedValueX, AZ::GetMax(transformedValueY, transformedValueZ));
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawBall(const Vec3& pos, float radius, bool drawShaded)
-{
-    pRenderAuxGeom->DrawSphere(
-        ToWorldSpacePosition(pos), ToWorldSpaceMaxScale(radius), m_color4b, drawShaded);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawDisk(const Vec3& pos, const Vec3& dir, float radius)
-{
-    pRenderAuxGeom->DrawDisk(
-        ToWorldSpacePosition(pos), ToWorldSpaceVector(dir), ToWorldSpaceMaxScale(radius), m_color4b);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawArrow(const Vec3& src, const Vec3& trg, float fHeadScale, bool b2SidedArrow)
-{
-    float f2dScale = 1.0f;
-    float arrowLen = 0.4f * fHeadScale;
-    float arrowRadius = 0.1f * fHeadScale;
-    if (flags & DISPLAY_2D)
-    {
-        f2dScale = 1.2f * ToWorldSpaceVector(Vec3(1, 0, 0)).GetLength();
-    }
-    Vec3 dir = trg - src;
-    dir = ToWorldSpaceVector(dir.GetNormalized());
-    Vec3 p0 = ToWorldSpacePosition(src);
-    Vec3 p1 = ToWorldSpacePosition(trg);
-    if (!b2SidedArrow)
-    {
-        p1 = p1 - dir * arrowLen;
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        pRenderAuxGeom->DrawCone(p1, dir, arrowRadius * f2dScale, arrowLen * f2dScale, m_color4b);
-    }
-    else
-    {
-        p0 = p0 + dir * arrowLen;
-        p1 = p1 - dir * arrowLen;
-        InternalDrawLine(p0, m_color4b, p1, m_color4b);
-        pRenderAuxGeom->DrawCone(p0, -dir, arrowRadius * f2dScale, arrowLen * f2dScale, m_color4b);
-        pRenderAuxGeom->DrawCone(p1, dir, arrowRadius * f2dScale, arrowLen * f2dScale, m_color4b);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::RenderObject(int objectType, const Vec3& pos, float scale)
-{
-    Matrix34 tm;
-    tm.SetIdentity();
-
-    tm = Matrix33::CreateScale(Vec3(scale, scale, scale)) * tm;
-
-    tm.SetTranslation(pos);
-    RenderObject(objectType, tm);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::RenderObject(int, const Matrix34&)
-{
-}
-
-/////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTerrainRect(float x1, float y1, float x2, float y2, float height)
-{
-    AzFramework::Terrain::TerrainDataRequests* terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
-    if (terrain == nullptr)
-    {
-        return;
-    }
-
-    Vec3 p1, p2;
-    float x, y;
-
-    float step = MAX(y2 - y1, x2 - x1);
-    if (step < 0.1)
-    {
-        return;
-    }
-    step = step / 100.0f;
-    if (step > 10)
-    {
-        step /= 10;
-    }
-
-    for (y = y1; y < y2; y += step)
-    {
-        float ye = min(y + step, y2);
-
-        p1.x = x1;
-        p1.y = y;
-        p1.z = terrain->GetHeightFromFloats(p1.x, p1.y) + height;
-
-        p2.x = x1;
-        p2.y = ye;
-        p2.z = terrain->GetHeightFromFloats(p2.x, p2.y) + height;
-        DrawLine(p1, p2);
-
-        p1.x = x2;
-        p1.y = y;
-        p1.z = terrain->GetHeightFromFloats(p1.x, p1.y) + height;
-
-        p2.x = x2;
-        p2.y = ye;
-        p2.z = terrain->GetHeightFromFloats(p2.x, p2.y) + height;
-        DrawLine(p1, p2);
-    }
-    for (x = x1; x < x2; x += step)
-    {
-        float xe = min(x + step, x2);
-
-        p1.x = x;
-        p1.y = y1;
-        p1.z = terrain->GetHeightFromFloats(p1.x, p1.y) + height;
-
-        p2.x = xe;
-        p2.y = y1;
-        p2.z = terrain->GetHeightFromFloats(p2.x, p2.y) + height;
-        DrawLine(p1, p2);
-
-        p1.x = x;
-        p1.y = y2;
-        p1.z = terrain->GetHeightFromFloats(p1.x, p1.y) + height;
-
-        p2.x = xe;
-        p2.y = y2;
-        p2.z = terrain->GetHeightFromFloats(p2.x, p2.y) + height;
-        DrawLine(p1, p2);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTerrainLine(Vec3 worldPos1, Vec3 worldPos2)
-{
-    worldPos1.z = worldPos2.z = 0;
-
-    int steps = static_cast<int>((worldPos2 - worldPos1).GetLength() / 4);
-    if (steps == 0)
-    {
-        steps = 1;
-    }
-
-    Vec3 step = (worldPos2 - worldPos1) / static_cast<float>(steps);
-
-    AzFramework::Terrain::TerrainDataRequests* terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
-    AZ_Assert(terrain != nullptr, "If there's no terrain, %s shouldn't be called", __FUNCTION__);
-
-    Vec3 p1 = worldPos1;
-    p1.z = terrain->GetHeightFromFloats(worldPos1.x, worldPos1.y);
-    for (int i = 0; i < steps; ++i)
-    {
-        Vec3 p2 = p1 + step;
-        p2.z = 0.1f + terrain->GetHeightFromFloats(p2.x, p2.y);
-
-        DrawLine(p1, p2);
-
-        p1 = p2;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTextLabel(const Vec3& pos, float size, const char* text, const bool bCenter, [[maybe_unused]] int srcOffsetX, [[maybe_unused]] int scrOffsetY)
-{
-    AZ_ErrorOnce(AZ::Debug::Trace::GetDefaultSystemWindow(), false, "DisplayContext::DrawTextLabel needs to be removed/ported to use Atom");
-
-#if 0
-      ColorF col(m_color4b.r * (1.0f / 255.0f), m_color4b.g * (1.0f / 255.0f), m_color4b.b * (1.0f / 255.0f), m_color4b.a * (1.0f / 255.0f));
-
-    float fCol[4] = { col.r, col.g, col.b, col.a };
-    if (flags & DISPLAY_2D)
-    {
-        //We need to pass Screen coordinates to Draw2dLabel Function
-        Vec3 screenPos = GetView()->GetScreenTM().TransformPoint(pos);
-        renderer->Draw2dLabel(screenPos.x, screenPos.y, size, fCol, bCenter, "%s", text);
-    }
-    else
-    {
-        renderer->DrawLabelEx(pos, size, fCol, true, true, text);
-    }
-#else
-    AZ_UNUSED(pos);
-    AZ_UNUSED(size);
-    AZ_UNUSED(text);
-    AZ_UNUSED(bCenter);
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter)
-{
-    AZ_ErrorOnce(AZ::Debug::Trace::GetDefaultSystemWindow(), false, "DisplayContext::Draw2dTextLabel needs to be removed/ported to use Atom");
-#if 0
-    float col[4] = { m_color4b.r * (1.0f / 255.0f), m_color4b.g * (1.0f / 255.0f), m_color4b.b * (1.0f / 255.0f), m_color4b.a * (1.0f / 255.0f) };
-    renderer->Draw2dLabel(x, y, size, col, bCenter, "%s", text);
-#else
-    AZ_UNUSED(x);
-    AZ_UNUSED(y);
-    AZ_UNUSED(size);
-    AZ_UNUSED(text);
-    AZ_UNUSED(bCenter);
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::SetLineWidth(float width)
-{
-    m_thickness = width;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool DisplayContext::IsVisible(const AABB& bounds)
-{
-    if (flags & DISPLAY_2D)
-    {
-        if (box.IsIntersectBox(bounds))
-        {
-            return true;
-        }
-    }
-    return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-uint32 DisplayContext::GetState() const
-{
-    return m_renderState;
-}
-
-//! Set a new render state flags.
-//! @param returns previous render state.
-uint32 DisplayContext::SetState(uint32 state)
-{
-    uint32 old = m_renderState;
-    m_renderState = state;
-    pRenderAuxGeom->SetRenderFlags(m_renderState);
-    return old;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DepthTestOff()
-{
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    pRenderAuxGeom->SetRenderFlags((m_renderState | e_DepthTestOff) & (~e_DepthTestOn));
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DepthTestOn()
-{
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    pRenderAuxGeom->SetRenderFlags((m_renderState | e_DepthTestOn) & (~e_DepthTestOff));
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DepthWriteOff()
-{
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    pRenderAuxGeom->SetRenderFlags((m_renderState | e_DepthWriteOff) & (~e_DepthWriteOn));
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DepthWriteOn()
-{
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    pRenderAuxGeom->SetRenderFlags((m_renderState | e_DepthWriteOn) & (~e_DepthWriteOff));
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::CullOff()
-{
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    pRenderAuxGeom->SetRenderFlags((m_renderState | e_CullModeNone) & (~(e_CullModeBack | e_CullModeFront)));
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::CullOn()
-{
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    pRenderAuxGeom->SetRenderFlags((m_renderState | e_CullModeBack) & (~(e_CullModeNone | e_CullModeFront)));
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool DisplayContext::SetDrawInFrontMode(bool bOn)
-{
-    int prevState = m_renderState;
-    SAuxGeomRenderFlags renderFlags = m_renderState;
-    renderFlags.SetDrawInFrontMode((bOn) ? e_DrawInFrontOn : e_DrawInFrontOff);
-    pRenderAuxGeom->SetRenderFlags(renderFlags);
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    return (prevState & e_DrawInFrontOn) != 0;
-}
-
-int DisplayContext::SetFillMode(int nFillMode)
-{
-    int prevState = m_renderState;
-    SAuxGeomRenderFlags renderFlags = m_renderState;
-    renderFlags.SetFillMode((EAuxGeomPublicRenderflags_FillMode)nFillMode);
-    pRenderAuxGeom->SetRenderFlags(renderFlags);
-    m_renderState = pRenderAuxGeom->GetRenderFlags().m_renderFlags;
-    return prevState;
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::DrawTextureLabel(const Vec3& pos, int nWidth, int nHeight, int nTexId, int nTexIconFlags, int srcOffsetX, int srcOffsetY, bool bDistanceScaleIcons, float fDistanceScale)
-{
-    const float fLabelDepthPrecision = 0.05f;
-    Vec3 scrpos = view->WorldToView3D(pos);
-
-    float fWidth = (float)nWidth;
-    float fHeight = (float)nHeight;
-
-    if (bDistanceScaleIcons)
-    {
-        float fScreenScale = view->GetScreenScaleFactor(pos);
-
-        fWidth *= fDistanceScale / fScreenScale;
-        fHeight *= fDistanceScale / fScreenScale;
-    }
-
-    STextureLabel tl;
-    tl.x = scrpos.x + srcOffsetX;
-    tl.y = scrpos.y + srcOffsetY;
-    if (nTexIconFlags & TEXICON_ALIGN_BOTTOM)
-    {
-        tl.y -= fHeight / 2;
-    }
-    else if (nTexIconFlags & TEXICON_ALIGN_TOP)
-    {
-        tl.y += fHeight / 2;
-    }
-    tl.z = scrpos.z - (1.0f - scrpos.z) * fLabelDepthPrecision;
-    tl.w = fWidth;
-    tl.h = fHeight;
-    tl.nTexId = nTexId;
-    tl.flags = nTexIconFlags;
-    tl.color[0] = m_color4b.r * (1.0f / 255.0f);
-    tl.color[1] = m_color4b.g * (1.0f / 255.0f);
-    tl.color[2] = m_color4b.b * (1.0f / 255.0f);
-    tl.color[3] = m_color4b.a * (1.0f / 255.0f);
-
-    // Try to not overflood memory with labels.
-    if (m_textureLabels.size() < 100000)
-    {
-        m_textureLabels.push_back(tl);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-void DisplayContext::Flush2D()
-{
-    if (m_textureLabels.empty())
-    {
-        return;
-    }
-
-    int rcw, rch;
-    view->GetDimensions(&rcw, &rch);
-
-    AZ_ErrorOnce(AZ::Debug::Trace::GetDefaultSystemWindow(), false, "DisplayContext::Flush2D needs to be removed/ported to use Atom");
-#if 0
-
-    TransformationMatrices backupSceneMatrices;
-
-    renderer->Set2DMode(rcw, rch, backupSceneMatrices, 0.0f, 1.0f);
-
-    renderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA);
-    //renderer->SetCullMode( R_CULL_NONE );
-
-    float uvs[4], uvt[4];
-    uvs[0] = 0;
-    uvt[0] = 1;
-    uvs[1] = 1;
-    uvt[1] = 1;
-    uvs[2] = 1;
-    uvt[2] = 0;
-    uvs[3] = 0;
-    uvt[3] = 0;
-
-    const size_t nLabels = m_textureLabels.size();
-    for (size_t i = 0; i < nLabels; i++)
-    {
-        STextureLabel& t = m_textureLabels[i];
-        float w2 = t.w * 0.5f;
-        float h2 = t.h * 0.5f;
-        if (t.flags & TEXICON_ADDITIVE)
-        {
-            renderer->SetState(GS_BLSRC_ONE | GS_BLDST_ONE);
-        }
-        else if (t.flags & TEXICON_ON_TOP)
-        {
-            renderer->SetState(GS_NODEPTHTEST | GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA);
-        }
-
-        renderer->DrawImageWithUV(t.x - w2, t.y + h2, t.z, t.w, -t.h, t.nTexId, uvs, uvt, t.color[0], t.color[1], t.color[2], t.color[3]);
-
-        if (t.flags & (TEXICON_ADDITIVE | TEXICON_ON_TOP)) // Restore state.
-        {
-            renderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA);
-        }
-    }
-
-    renderer->Unset2DMode(backupSceneMatrices);
-#endif
-
-    m_textureLabels.clear();
-}

+ 0 - 203
Code/Editor/Objects/EntityObject.cpp

@@ -28,66 +28,9 @@
 
 static constexpr int VIEW_DISTANCE_MULTIPLIER_MAX = 100;
 
-//////////////////////////////////////////////////////////////////////////
-//! Undo object for attach/detach changes
-class CUndoAttachEntity
-    : public IUndoObject
-{
-public:
-    CUndoAttachEntity(CEntityObject* pAttachedObject, bool bAttach)
-        : m_attachedEntityGUID(pAttachedObject->GetId())
-        , m_attachmentTarget(pAttachedObject->GetAttachTarget())
-        , m_attachmentType(pAttachedObject->GetAttachType())
-        , m_bAttach(bAttach)
-    {}
-
-    void Undo([[maybe_unused]] bool bUndo) override
-    {
-        if (!m_bAttach)
-        {
-            SetAttachmentTypeAndTarget();
-        }
-    }
-
-    void Redo() override
-    {
-        if (m_bAttach)
-        {
-            SetAttachmentTypeAndTarget();
-        }
-    }
-
-private:
-    void SetAttachmentTypeAndTarget()
-    {
-        CObjectManager* pObjectManager = static_cast<CObjectManager*>(GetIEditor()->GetObjectManager());
-        CEntityObject* pEntity = static_cast<CEntityObject*>(pObjectManager->FindObject(m_attachedEntityGUID));
-
-        if (pEntity)
-        {
-            pEntity->SetAttachType(m_attachmentType);
-            pEntity->SetAttachTarget(m_attachmentTarget.toUtf8().data());
-        }
-    }
-
-    int GetSize() override { return sizeof(CUndoAttachEntity); }
-
-    GUID m_attachedEntityGUID;
-    CEntityObject::EAttachmentType m_attachmentType;
-    QString m_attachmentTarget;
-    bool m_bAttach;
-};
-
-//////////////////////////////////////////////////////////////////////////
-// CBase implementation.
-//////////////////////////////////////////////////////////////////////////
-
 namespace
 {
     CEntityObject* s_pPropertyPanelEntityObject = nullptr;
-
-    // Prevent OnPropertyChange to be executed when loading many properties at one time.
-    static bool s_ignorePropertiesUpdate = false;
 };
 
 //////////////////////////////////////////////////////////////////////////
@@ -270,9 +213,7 @@ void CEntityObject::SetTransformDelegate(ITransformDelegate* pTransformDelegate)
         return;
     }
 
-    s_ignorePropertiesUpdate = true;
     ForceVariableUpdate();
-    s_ignorePropertiesUpdate = false;
     ResetCallbacks();
 }
 
@@ -564,150 +505,6 @@ struct IVariableType<Vec3>
     };
 };
 
-void CEntityObject::DrawExtraLightInfo(DisplayContext& dc)
-{
-    IObjectManager* objMan = GetIEditor()->GetObjectManager();
-
-    if (objMan)
-    {
-        if (objMan->IsLightClass(this) && GetProperties())
-        {
-            QString csText("");
-
-            if (GetEntityPropertyBool("bAmbient"))
-            {
-                csText += "A";
-            }
-
-            if (!GetEntityPropertyString("texture_Texture").isEmpty())
-            {
-                csText += "P";
-            }
-
-            int nLightType = GetEntityPropertyInteger("nCastShadows");
-            if (nLightType > 0)
-            {
-                csText += "S";
-            }
-
-            float fScale = GetIEditor()->GetViewManager()->GetView(ET_ViewportUnknown)->GetScreenScaleFactor(GetWorldPos());
-            Vec3 vDrawPos(GetWorldPos());
-            vDrawPos.z += fScale / 25;
-
-            ColorB col(255, 255, 255);
-            dc.SetColor(col);
-            dc.DrawTextLabel(vDrawPos, 1.3f, csText.toUtf8().data());
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void CEntityObject::DrawProjectorPyramid(DisplayContext& dc, float dist)
-{
-    const int numPoints = 16; // per one arc
-    const int numArcs = 6;
-
-    if (m_projectorFOV < FLT_EPSILON)
-    {
-        return;
-    }
-
-    Vec3 points[numPoints * numArcs];
-    {
-        // generate 4 arcs on intersection of sphere with pyramid
-        const float fov = DEG2RAD(m_projectorFOV);
-
-        const Vec3 lightAxis(dist, 0.0f, 0.0f);
-        const float tanA = tan(fov * 0.5f);
-        const float fovProj = asinf(1.0f / sqrtf(2.0f + 1.0f / (tanA * tanA))) * 2.0f;
-
-        const float halfFov = 0.5f * fov;
-        const float halfFovProj = fovProj * 0.5f;
-        const float anglePerSegmentOfFovProj = 1.0f / (numPoints - 1) * fovProj;
-
-        const Quat yRot = Quat::CreateRotationY(halfFov);
-        Vec3* arcPoints = points;
-        for (int i = 0; i < numPoints; ++i)
-        {
-            float angle = i * anglePerSegmentOfFovProj - halfFovProj;
-            arcPoints[i] = lightAxis * Quat::CreateRotationZ(angle) * yRot;
-        }
-
-        const Quat zRot = Quat::CreateRotationZ(halfFov);
-        arcPoints += numPoints;
-        for (int i = 0; i < numPoints; ++i)
-        {
-            float angle = (numPoints - i - 1) * anglePerSegmentOfFovProj - halfFovProj;
-            arcPoints[i] = lightAxis * Quat::CreateRotationY(angle) * zRot;
-        }
-
-        const Quat nyRot = Quat::CreateRotationY(-halfFov);
-        arcPoints += numPoints;
-        for (int i = 0; i < numPoints; ++i)
-        {
-            float angle = (numPoints - i - 1) * anglePerSegmentOfFovProj - halfFovProj;
-            arcPoints[i] = lightAxis * Quat::CreateRotationZ(angle) * nyRot;
-        }
-
-        const Quat nzRot = Quat::CreateRotationZ(-halfFov);
-        arcPoints += numPoints;
-        for (int i = 0; i < numPoints; ++i)
-        {
-            float angle = i * anglePerSegmentOfFovProj - halfFovProj;
-            arcPoints[i] = lightAxis * Quat::CreateRotationY(angle) * nzRot;
-        }
-
-        // generate cross
-        arcPoints += numPoints;
-        const float anglePerSegmentOfFov = 1.0f / (numPoints - 1) * fov;
-        for (int i = 0; i < numPoints; ++i)
-        {
-            float angle = i * anglePerSegmentOfFov - halfFov;
-            arcPoints[i] = lightAxis * Quat::CreateRotationY(angle);
-        }
-
-        arcPoints += numPoints;
-        for (int i = 0; i < numPoints; ++i)
-        {
-            float angle = i * anglePerSegmentOfFov - halfFov;
-            arcPoints[i] = lightAxis * Quat::CreateRotationZ(angle);
-        }
-    }
-    // draw pyramid and sphere intersection
-    dc.DrawPolyLine(points, numPoints * 4, false);
-
-    // draw cross
-    dc.DrawPolyLine(points + numPoints * 4, numPoints, false);
-    dc.DrawPolyLine(points + numPoints * 5, numPoints, false);
-
-    Vec3 org(0.0f, 0.0f, 0.0f);
-    dc.DrawLine(org, points[numPoints * 0]);
-    dc.DrawLine(org, points[numPoints * 1]);
-    dc.DrawLine(org, points[numPoints * 2]);
-    dc.DrawLine(org, points[numPoints * 3]);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void CEntityObject::DrawProjectorFrustum(DisplayContext& dc, Vec2 size, float dist)
-{
-    static const Vec3 org(0.0f, 0.0f, 0.0f);
-    const Vec3 corners[4] =
-    {
-        Vec3(dist, -size.x, -size.y),
-        Vec3(dist, size.x, -size.y),
-        Vec3(dist, -size.x, size.y),
-        Vec3(dist, size.x, size.y)
-    };
-
-    dc.DrawLine(org, corners[0]);
-    dc.DrawLine(org, corners[1]);
-    dc.DrawLine(org, corners[2]);
-    dc.DrawLine(org, corners[3]);
-
-    dc.DrawWireBox(Vec3(dist, -size.x, -size.y), Vec3(dist, size.x, size.y));
-}
-
 //////////////////////////////////////////////////////////////////////////
 void CEntityObject::Serialize(CObjectArchive& ar)
 {

+ 0 - 8
Code/Editor/Objects/EntityObject.h

@@ -20,10 +20,6 @@
 #include <QObject>
 #endif
 
-#define CLASS_LIGHT "Light"
-#define CLASS_DESTROYABLE_LIGHT "DestroyableLight"
-#define CLASS_RIGIDBODY_LIGHT "RigidBodyLight"
-
 class CEntityObject;
 class QMenu;
 
@@ -79,7 +75,6 @@ public:
     void InitVariables() override;
     void Done() override;
 
-    void DrawExtraLightInfo (DisplayContext& disp);
 
     bool GetEntityPropertyBool(const char* name) const;
     int GetEntityPropertyInteger(const char* name) const;
@@ -202,9 +197,6 @@ protected:
     T GetEntityProperty(const char* name, T defaultvalue) const;
 
     //! Draw default object items.
-    void DrawProjectorPyramid(DisplayContext& dc, float dist);
-    void DrawProjectorFrustum(DisplayContext& dc, Vec2 size, float dist);
-
     void OnLoadFailed();
 
     CVarBlock* CloneProperties(CVarBlock* srcProperties);

+ 0 - 26
Code/Editor/Objects/ObjectManager.cpp

@@ -790,32 +790,6 @@ void CObjectManager::GatherUsedResources(CUsedResources& resources)
     }
 }
 
-//////////////////////////////////////////////////////////////////////////
-bool CObjectManager::IsLightClass(CBaseObject* pObject)
-{
-    if (qobject_cast<CEntityObject*>(pObject))
-    {
-        CEntityObject* pEntity = (CEntityObject*)pObject;
-        if (pEntity)
-        {
-            if (pEntity->GetEntityClass().compare(CLASS_LIGHT) == 0)
-            {
-                return true;
-            }
-            if (pEntity->GetEntityClass().compare(CLASS_RIGIDBODY_LIGHT) == 0)
-            {
-                return true;
-            }
-            if (pEntity->GetEntityClass().compare(CLASS_DESTROYABLE_LIGHT) == 0)
-            {
-                return true;
-            }
-        }
-    }
-
-    return false;
-}
-
 //////////////////////////////////////////////////////////////////////////
 namespace
 {

+ 0 - 2
Code/Editor/Objects/ObjectManager.h

@@ -106,8 +106,6 @@ public:
     // Gathers all resources used by all objects.
     void GatherUsedResources(CUsedResources& resources) override;
 
-    bool IsLightClass(CBaseObject* pObject) override;
-
     int GetAxisHelperHitRadius() const override { return m_axisHelperHitRadius; }
 
 private:

+ 0 - 1
Code/Editor/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp

@@ -23,7 +23,6 @@
 
 #include <AzToolsFramework/API/EntityCompositionRequestBus.h>
 #include <AzToolsFramework/API/ToolsApplicationAPI.h>
-#include <AzToolsFramework/UI/Slice/SliceRelationshipWidget.hxx>
 
 #include "SandboxIntegration.h"
 

+ 0 - 32
Code/Editor/Plugins/ComponentEntityEditorPlugin/ContextMenuHandlers.cpp

@@ -22,44 +22,12 @@
 
 void EditorContextMenuHandler::Setup()
 {
-    AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
     AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusConnect();
 }
 
 void EditorContextMenuHandler::Teardown()
 {
     AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusDisconnect();
-    AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
-}
-
-int EditorContextMenuHandler::GetMenuPosition() const
-{
-    return aznumeric_cast<int>(AzToolsFramework::EditorContextMenuOrdering::BOTTOM);
-}
-
-void EditorContextMenuHandler::PopulateEditorGlobalContextMenu(
-    QMenu* menu, [[maybe_unused]] const AZStd::optional<AzFramework::ScreenPoint>& point, [[maybe_unused]] int flags)
-{
-    AzToolsFramework::EntityIdList selected;
-    AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-        selected, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
-
-    QAction* action = nullptr;
-
-    if (selected.size() > 0)
-    {
-        action = menu->addAction(QObject::tr("Open pinned Inspector"));
-        QObject::connect(
-            action, &QAction::triggered, action,
-            [selected]
-            {
-                AzToolsFramework::EntityIdSet pinnedEntities(selected.begin(), selected.end());
-                AzToolsFramework::EditorRequestBus::Broadcast(&AzToolsFramework::EditorRequests::OpenPinnedInspector, pinnedEntities);
-            }
-        );
-
-        menu->addSeparator();
-    }
 }
 
 void EditorContextMenuHandler::OnMenuBindingHook()

+ 2 - 7
Code/Editor/Plugins/ComponentEntityEditorPlugin/ContextMenuHandlers.h

@@ -9,21 +9,16 @@
 #pragma once
 
 #include <AzToolsFramework/ActionManager/ActionManagerRegistrationNotificationBus.h>
-#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
 
 //! Provides additional functionality for the editor's context menu.
-class EditorContextMenuHandler
-    : private AzToolsFramework::EditorContextMenuBus::Handler
-    , private AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler
+class EditorContextMenuHandler:
+    private AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler
 {
 public:
     void Setup();
     void Teardown();
 
 private:
-    // EditorContextMenu overrides ...
-    void PopulateEditorGlobalContextMenu(QMenu* menu, const AZStd::optional<AzFramework::ScreenPoint>& point, int flags) override;
-    int GetMenuPosition() const override;
 
     // ActionManagerRegistrationNotificationBus overrides ...
     void OnMenuBindingHook() override;

+ 0 - 114
Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp

@@ -35,14 +35,12 @@
 #include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
 #include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
 #include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
 #include <AzToolsFramework/Commands/SelectionCommand.h>
 #include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
 #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorContextIdentifiers.h>
 #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorMenuIdentifiers.h>
 #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorActionUpdaterIdentifiers.h>
 #include <AzToolsFramework/Editor/ActionManagerUtils.h>
-#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
 #include <AzToolsFramework/Entity/EditorEntityHelpers.h>
 #include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
 #include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
@@ -140,7 +138,6 @@ void GetSelectedEntitiesSetWithFlattenedHierarchy(AzToolsFramework::EntityIdSet&
 
 SandboxIntegrationManager::SandboxIntegrationManager()
     : m_startedUndoRecordingNestingLevel(0)
-    , m_dc(nullptr)
 {
     // Required to receive events from the Cry Engine undo system.
     GetIEditor()->GetUndoManager()->AddListener(this);
@@ -167,11 +164,8 @@ void SandboxIntegrationManager::Setup()
     AzToolsFramework::ToolsApplicationEvents::Bus::Handler::BusConnect();
     AzToolsFramework::EditorRequests::Bus::Handler::BusConnect();
     AzToolsFramework::EditorWindowRequests::Bus::Handler::BusConnect();
-    AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
     AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
 
-    AzFramework::DisplayContextRequestBus::Handler::BusConnect();
-
     m_prefabIntegrationInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabIntegrationInterface>::Get();
     AZ_Assert(
         (m_prefabIntegrationInterface != nullptr),
@@ -189,25 +183,12 @@ void SandboxIntegrationManager::Setup()
 void SandboxIntegrationManager::Teardown()
 {
     m_contextMenuBottomHandler.Teardown();
-
-    AzFramework::DisplayContextRequestBus::Handler::BusDisconnect();
     AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
-    AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
     AzToolsFramework::EditorWindowRequests::Bus::Handler::BusDisconnect();
     AzToolsFramework::EditorRequests::Bus::Handler::BusDisconnect();
     AzToolsFramework::ToolsApplicationEvents::Bus::Handler::BusDisconnect();
 }
 
-void SandboxIntegrationManager::SetDC(DisplayContext* dc)
-{
-    m_dc = dc;
-}
-
-DisplayContext* SandboxIntegrationManager::GetDC()
-{
-    return m_dc;
-}
-
 void SandboxIntegrationManager::OnBeginUndo([[maybe_unused]] const char* label)
 {
     AzToolsFramework::UndoSystem::URSequencePoint* currentBatch = nullptr;
@@ -264,101 +245,6 @@ void SandboxIntegrationManager::OnEndUndo(const char* label, bool changed)
     }
 }
 
-int SandboxIntegrationManager::GetMenuPosition() const
-{
-    return aznumeric_cast<int>(AzToolsFramework::EditorContextMenuOrdering::TOP);
-}
-
-void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(
-    QMenu* menu, const AZStd::optional<AzFramework::ScreenPoint>& point, int flags)
-{
-    if (!IsLevelDocumentOpen())
-    {
-        return;
-    }
-
-    if (flags & AzToolsFramework::EditorEvents::eECMF_USE_VIEWPORT_CENTER)
-    {
-        int width = 0;
-        int height = 0;
-        // If there is no 3D Viewport active to aid in the positioning of context menu
-        // operations, we don't need to store anything but default values here. Any code
-        // using these numbers for placement should default to the origin when there's
-        // no 3D viewport to raycast into.
-        if (const CViewport* view = GetIEditor()->GetViewManager()->GetGameViewport())
-        {
-            view->GetDimensions(&width, &height);
-        }
-
-        m_contextMenuViewPoint = AzFramework::ScreenPoint{ width / 2, height / 2 };
-    }
-    else
-    {
-        m_contextMenuViewPoint = point;
-    }
-
-    CGameEngine* gameEngine = GetIEditor()->GetGameEngine();
-    if (!gameEngine || !gameEngine->IsLevelLoaded())
-    {
-        return;
-    }
-
-    menu->setToolTipsVisible(true);
-
-    AzToolsFramework::EntityIdList selected;
-    GetSelectedOrHighlightedEntities(selected);
-
-    QAction* action = nullptr;
-
-    // when nothing is selected, entity is created at root level
-    if (selected.size() == 0)
-    {
-        action = menu->addAction(QObject::tr("Create entity"));
-        action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_N));
-        QObject::connect(
-            action, &QAction::triggered, action,
-            [this]
-            {
-                ContextMenu_NewEntity();
-            }
-        );
-    }
-    // when a single entity is selected, entity is created as its child
-    else if (selected.size() == 1)
-    {
-        AZ::EntityId selectedEntityId = selected.front();
-        bool selectedEntityIsReadOnly = m_readOnlyEntityPublicInterface->IsReadOnly(selectedEntityId);
-        auto containerEntityInterface = AZ::Interface<AzToolsFramework::ContainerEntityInterface>::Get();
-        if (containerEntityInterface && containerEntityInterface->IsContainerOpen(selectedEntityId) && !selectedEntityIsReadOnly)
-        {
-            action = menu->addAction(QObject::tr("Create entity"));
-            action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_N));
-            QObject::connect(
-                action, &QAction::triggered, action,
-                [selectedEntityId]
-                {
-                    AzToolsFramework::EditorRequestBus::Broadcast(&AzToolsFramework::EditorRequestBus::Handler::CreateNewEntityAsChild, selectedEntityId);
-                }
-            );
-        }
-    }
-
-    menu->addSeparator();
-
-    if (selected.size() > 0)
-    {
-        action = menu->addAction(QObject::tr("Find in Entity Outliner"));
-        QObject::connect(
-            action, &QAction::triggered,
-            [selected]
-            {
-                AzToolsFramework::EditorEntityContextNotificationBus::Broadcast(
-                    &EditorEntityContextNotification::OnFocusInEntityOutliner, selected);
-            });
-        menu->addSeparator();
-    }
-}
-
 void SandboxIntegrationManager::OpenPinnedInspector(const AzToolsFramework::EntityIdSet& entities)
 {
     QDockWidget* dockWidget = InstanceViewPane(LyViewPane::EntityInspectorPinned);

+ 0 - 17
Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h

@@ -15,11 +15,9 @@
 #include <AzCore/Math/Uuid.h>
 #include <AzCore/std/string/conversions.h>
 #include <AzFramework/Entity/EntityDebugDisplayBus.h>
-#include <AzFramework/Viewport/DisplayContextRequestBus.h>
 #include <AzToolsFramework/ActionManager/ActionManagerRegistrationNotificationBus.h>
 #include <AzToolsFramework/API/EditorWindowRequestBus.h>
 #include <AzToolsFramework/API/ToolsApplicationAPI.h>
-#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
 #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
 #include <AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h>
 #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
@@ -86,9 +84,7 @@ namespace AzToolsFramework
 class SandboxIntegrationManager
     : private AzToolsFramework::ToolsApplicationEvents::Bus::Handler
     , private AzToolsFramework::EditorRequests::Bus::Handler
-    , private AzToolsFramework::EditorContextMenuBus::Handler
     , private AzToolsFramework::EditorWindowRequests::Bus::Handler
-    , private AzFramework::DisplayContextRequestBus::Handler
     , private AzToolsFramework::EditorEntityContextNotificationBus::Handler
     , private IUndoManagerListener
     , private AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler
@@ -146,22 +142,11 @@ private:
     QWidget* GetAppMainWindow() override;
     //////////////////////////////////////////////////////////////////////////
 
-    //////////////////////////////////////////////////////////////////////////
-    // AzToolsFramework::EditorContextMenu::Bus::Handler overrides
-    void PopulateEditorGlobalContextMenu(QMenu* menu, const AZStd::optional<AzFramework::ScreenPoint>& point, int flags) override;
-    int GetMenuPosition() const override;
-    //////////////////////////////////////////////////////////////////////////
-
     //////////////////////////////////////////////////////////////////////////
     // AzToolsFramework::EditorEntityContextNotificationBus::Handler
     void OnPrepareForContextReset() override;
     //////////////////////////////////////////////////////////////////////////
 
-    // AzFramework::DisplayContextRequestBus (and @deprecated EntityDebugDisplayRequestBus)
-    // AzFramework::DisplayContextRequestBus
-    void SetDC(DisplayContext* dc) override;
-    DisplayContext* GetDC() override;
-
     // ActionManagerRegistrationNotificationBus overrides ...
     void OnActionRegistrationHook() override;
     void OnMenuBindingHook() override;
@@ -211,8 +196,6 @@ private:
 
     short m_startedUndoRecordingNestingLevel; //!< Used in OnBegin/EndUndo to ensure we only accept undos we started recording
 
-    DisplayContext* m_dc;
-
     const AZStd::string m_defaultComponentIconLocation = "Icons/Components/Component_Placeholder.svg";
     const AZStd::string m_defaultComponentViewportIconLocation = "Icons/Components/Viewport/Component_Placeholder.svg";
     const AZStd::string m_defaultEntityIconLocation = "Icons/Components/Viewport/Transform.svg";

+ 0 - 2
Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/AssetCatalogModel.cpp

@@ -20,7 +20,6 @@
 #include <AzCore/Component/ComponentApplicationBus.h>
 #include <AzCore/Serialization/SerializeContext.h>
 #include <AzCore/Settings/SettingsRegistryMergeUtils.h>
-#include <AzCore/Slice/SliceAsset.h>
 #include <AzCore/Asset/AssetManager.h>
 #include <AzCore/Asset/AssetManagerBus.h>
 #include <AzCore/Asset/AssetTypeInfoBus.h>
@@ -33,7 +32,6 @@
 #include <AzToolsFramework/ToolsComponents/ComponentAssetMimeDataContainer.h>
 #include <AzToolsFramework/ToolsComponents/ScriptEditorComponent.h>
 #include <AzToolsFramework/ToolsComponents/TransformComponent.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
 
 #include <QTimer>
 

+ 0 - 7
Code/Editor/Resource.h

@@ -236,13 +236,7 @@
 #define ID_FILE_SAVE_LEVEL                         34197
 #define ID_TV_SYNC_TO_BASE                         34199
 #define ID_TV_SYNC_FROM_BASE                       34200
-#ifdef ENABLE_SLICE_EDITOR
-#define ID_FILE_NEW_SLICE                          34201
-#define ID_FILE_OPEN_SLICE                         34202
-#endif
-#define ID_FILE_SAVE_SELECTED_SLICE                34203
 #define ID_FILE_SAVESETTINGS                       34204
-#define ID_FILE_SAVE_SLICE_TO_ROOT                 34205
 #define ID_SET_TIME_TO_KEY                         34206
 #define ID_TOGGLE_SCRUB_UNITS                      34207
 #define ID_TOGGLE_PREVIEW_UNITS                    34208
@@ -285,7 +279,6 @@
 #define ID_DOCUMENTATION_FEEDBACK                    36043
 #define ID_OPEN_SUBSTANCE_EDITOR                     36060
 #define ID_IMPORT_ASSET                              36069
-#define ID_FILE_RESAVESLICES                        36210
 #define FIRST_QT_ACTION                      50000
 #define ID_VIEW_CONSOLEWINDOW                50001
 #define ID_TOOLBAR_SEPARATOR                 50002

+ 0 - 1
Code/Editor/TrackView/TrackViewDialog.cpp

@@ -2213,7 +2213,6 @@ void CTrackViewDialog::OnEntityDestruction(const AZ::EntityId& entityId)
     if (m_currentSequenceEntityId == entityId)
     {
         // The currently selected sequence is about to be deleted, make sure to clear the selection right now.
-        // Clearing it here will make sure it is clear in slice work flow edge cases.
         GetIEditor()->GetAnimation()->SetSequence(nullptr, false, false);
 
         // Refresh the records in m_wndNodesCtrl, the sequence will not be selected in Track View

+ 3 - 4
Code/Editor/TrackView/TrackViewNodes.cpp

@@ -2264,10 +2264,9 @@ void CTrackViewNodesCtrl::ShowNextResult()
 void CTrackViewNodesCtrl::Update()
 {
     // Update the Track UI elements with the latest names of the Tracks.
-    // In some cases (save slice overrides) the Track names (param names)
-    // may not be available at the time of the Sequence activation because
-    // they come from the animated entities (which may not be active). So
-    // just update them once a frame to make sure they are the latest.
+    // In some cases the Track names (param names) may not be available at the time
+    // of the Sequence activation because they come from the animated entities (which may not be active).
+    // So just update them once a frame to make sure they are the latest.
     for (auto iter = m_nodeToRecordMap.begin(); iter != m_nodeToRecordMap.end(); ++iter)
     {
         const CTrackViewNode* node = iter->first;

+ 6 - 6
Code/Editor/TrackView/TrackViewSplineCtrl.cpp

@@ -759,8 +759,8 @@ void CTrackViewSplineCtrl::mouseMoveEvent(QMouseEvent* event)
     case ScrollMode:
     {
         // Set the new scrolled coordinates
-        float ofsx = m_grid.origin.x - (point.x() - m_cMouseDownPos.x()) / m_grid.zoom.x;
-        float ofsy = m_grid.origin.y + (point.y() - m_cMouseDownPos.y()) / m_grid.zoom.y;
+        const float ofsx = m_grid.origin.GetX() - (point.x() - m_cMouseDownPos.x()) / m_grid.zoom.GetX();
+        const float ofsy = m_grid.origin.GetY() + (point.y() - m_cMouseDownPos.y()) / m_grid.zoom.GetY();
         SetScrollOffset(Vec2(ofsx, ofsy));
         m_cMouseDownPos = point;
     }
@@ -771,16 +771,16 @@ void CTrackViewSplineCtrl::mouseMoveEvent(QMouseEvent* event)
         float ofsx = (point.x() - m_cMouseDownPos.x()) * 0.01f;
         float ofsy = (point.y() - m_cMouseDownPos.y()) * 0.01f;
 
-        Vec2 z = m_grid.zoom;
+        AZ::Vector2 z = m_grid.zoom;
         if (ofsx != 0)
         {
-            z.x = max(z.x * (1.0f + ofsx), 0.001f);
+            z.SetX(max(z.GetX() * (1.0f + ofsx), 0.001f));
         }
         if (ofsy != 0)
         {
-            z.y = max(z.y * (1.0f + ofsy), 0.001f);
+            z.SetY(max(z.GetY() * (1.0f + ofsy), 0.001f));
         }
-        SetZoom(z, m_cMouseDownPos);
+        SetZoom(Vec2(z.GetX(), z.GetY()), m_cMouseDownPos);
         m_cMouseDownPos = point;
     }
     break;

+ 0 - 5
Code/Editor/Viewport.h

@@ -37,7 +37,6 @@ namespace AzQtComponents
 
 // forward declarations.
 class CBaseObject;
-struct DisplayContext;
 class CCryEditDoc;
 class CLayoutViewPane;
 class CViewManager;
@@ -207,8 +206,6 @@ public:
     virtual void CenterOnSelection() = 0;
     virtual void CenterOnAABB(const AABB& aabb) = 0;
 
-    virtual void CenterOnSliceInstance() = 0;
-
     /** Set ID of this viewport
     */
     virtual void SetViewportId(int id) { m_nCurViewportID = id; };
@@ -417,8 +414,6 @@ public:
     void CenterOnSelection() override {}
     void CenterOnAABB([[maybe_unused]] const AABB& aabb) override {}
 
-    void CenterOnSliceInstance() override {}
-
     //! Performs hit testing of 2d point in view to find which object hit.
     bool HitTest(const QPoint& point, HitContext& hitInfo) override;
 

+ 2 - 3
Code/Editor/editor_lib_files.cmake

@@ -222,6 +222,7 @@ set(FILES
     res/veed_tree.bmp
     res/vegetati.bmp
     res/vegtree.bmp
+    res/Prefab_80.svg
     res/video_record.ico
     res/warning16x16.ico
     res/water.bmp
@@ -382,6 +383,7 @@ set(FILES
     NewLevelDialog.cpp
     NewLevelDialog.h
     NewLevelDialog.ui
+    NewLevelDialog.qrc
     Dialogs/PythonScriptsDialog.cpp
     Dialogs/PythonScriptsDialog.h
     Dialogs/PythonScriptsDialog.ui
@@ -407,15 +409,12 @@ set(FILES
     LogFileImpl.cpp
     LogFileImpl.h
     Objects/ClassDesc.h
-    Objects/DisplayContextShared.inl
     Objects/ObjectLoader.cpp
     Objects/ObjectLoader.h
     Objects/ObjectManager.cpp
     Objects/ObjectManager.h
     Objects/ObjectManagerLegacyUndo.cpp
     Objects/ObjectManagerLegacyUndo.h
-    Objects/DisplayContext.cpp
-    Objects/DisplayContext.h
     Objects/EntityObject.cpp
     Objects/EntityObject.h
     PythonEditorFuncs.cpp

+ 3 - 0
Code/Editor/res/Prefab_80.svg

@@ -0,0 +1,3 @@
+<svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M66.5521 56.4173C67.6477 55.8373 68.3333 54.7018 68.3333 53.4673V26.7354C68.3333 25.5349 67.6845 24.4298 66.6354 23.8436L43.3726 10.8459C41.3553 9.71877 38.8921 9.71625 36.864 10.8393L13.3922 23.8368C12.3277 24.4263 11.6667 25.5448 11.6667 26.7566L11.6667 53.4761C11.6667 54.7059 12.3472 55.833 13.4365 56.4069L38.5039 69.6154C39.4808 70.1301 40.6518 70.128 41.6307 69.6099L66.5521 56.4173ZM41.6732 24.9691V15.5861L63.1725 27.4054V50.7711L54.6523 46.3625V33.5544L41.6732 40.9791V54.6525L53.2689 48.8595L62.0294 53.1073L40.06 64.8887L17.9082 53.1073L26.7317 48.8595L38.7801 54.6525V40.9791L25.3812 33.5544V46.3625L16.9475 50.7711V27.4054L38.7801 15.5861V24.9691L26.7317 31.6915L40.4377 38.4731L53.2689 31.6915L41.6732 24.9691Z" fill="white"/>
+</svg>

+ 2 - 2
Code/Editor/splashscreen_background.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:746adf79fe5d0b1cc99e529f9280b79bf9de4d3a2b99f42c6b30ca55f46a35cd
-size 3390470
+oid sha256:079c6d28fab15dfe624307d2be81d7008cc582de496f486a604186404ca818ab
+size 903037

+ 6 - 3
Code/Framework/AzFramework/AzFramework/DocumentPropertyEditor/AggregateAdapter.cpp

@@ -370,9 +370,12 @@ namespace AZ::DocumentPropertyEditor
                     // either a column or an attribute was added, update the nearest row as necessary
                     if (rowIsDirectParent)
                     {
-                        // the added child was not a full row, but it was the immediate child of a row
-                        // this addition shifts subsequent entries, so account for that in the parent
-                        rowNode->ShiftChildIndices(adapterIndex, patchPath.Back().GetIndex(), 1);
+                        if (auto backIndex = patchPath.Back(); backIndex.IsIndex())
+                        {
+                            // the added child was not a full row, but it was the immediate child of a row
+                            // this addition shifts subsequent entries, so account for that in the parent
+                            rowNode->ShiftChildIndices(adapterIndex, backIndex.GetIndex(), 1);
+                        }
                     }
                     UpdateAndPatchNode(rowNode, adapterIndex, patchOperation, leftoverPath, outgoingPatch);
                 }

+ 1 - 2
Code/Framework/AzFramework/AzFramework/Entity/EntityDebugDisplayBus.h

@@ -27,7 +27,6 @@ namespace AZ
     class Entity;
 }
 
-struct DisplayContext;
 class ITexture;
 
 namespace AzFramework
@@ -52,7 +51,7 @@ namespace AzFramework
         virtual void DrawWireQuad(float width, float height) { (void)width; (void)height; }
         virtual void DrawQuadGradient(const AZ::Vector3& p1, const AZ::Vector3& p2, const AZ::Vector3& p3, const AZ::Vector3& p4, const AZ::Vector4& firstColor, const AZ::Vector4& secondColor) { (void)p1; (void)p2; (void)p3; (void)p4; (void)firstColor; (void)secondColor; }
 
-        /// Draws a 2D quad with gradient to the viewport. 
+        /// Draws a 2D quad with gradient to the viewport.
         /// @param p1 p2 p3 p4 Normalized screen coordinates of the 4 points on the quad. <0, 0> is the upper-left corner of the viewport, <1,1> is the lower-right corner of the viewport.
         /// @param z Depth value. Useful when rendering multiple 2d quads on screen and you want them to stack in a particular order.
         /// @param firstColor. Vertex color applied to p1 p2.

+ 0 - 84
Code/Framework/AzFramework/AzFramework/Viewport/DisplayContextRequestBus.h

@@ -1,84 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#pragma once
-
-#include <AzCore/EBus/EBus.h>
-
-struct DisplayContext;
-
-namespace AzFramework
-{
-    /// Requests to be made of the DisplayContext (predominantly to Set/Clear the
-    /// bound DisplayContext). Prefer to use DisplayContextRequestGuard as opposed
-    /// to Set(displayContext)/Set(nullptr) directly.
-    class DisplayContextRequests
-        : public AZ::EBusTraits
-    {
-    public:
-        // EBusTraits overrides
-        static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
-
-        virtual void SetDC(DisplayContext* displayContext) = 0;
-        virtual DisplayContext* GetDC() = 0;
-
-    protected:
-        ~DisplayContextRequests() = default;
-    };
-
-    /// Inherit from DisplayContextRequestBus::Handler to implement the DisplayContextRequests interface.
-    using DisplayContextRequestBus = AZ::EBus<DisplayContextRequests>;
-
-    /// A helper to wrap DisplayContext set EBus calls.
-    /// Usage:
-    /// // enter scope
-    /// {
-    ///     AzFramework::DisplayContextRequestGuard displayContextGuard(displayContext);
-    ///     ...
-    /// } // exit scope, clean up
-    /// \attention This is used to bind/unbind DisplayContext for the implementation of
-    /// DebugDisplayRequestBus before commands to draw can be used.
-    class DisplayContextRequestGuard
-    {
-    public:
-        explicit DisplayContextRequestGuard(DisplayContext& displayContext)
-        {
-            // store previously bound display context (may be null - not have been bound)
-            DisplayContextRequestBus::BroadcastResult(
-                m_prevSetDisplayContext, &DisplayContextRequestBus::Events::GetDC);
-
-            // keep track of the display context we are about to set
-            m_currSetDisplayContext = &displayContext;
-
-            // set the new display context
-            DisplayContextRequestBus::Broadcast(
-                &DisplayContextRequestBus::Events::SetDC, &displayContext);
-        }
-
-        ~DisplayContextRequestGuard()
-        {
-            // check what the currently bound display context is
-            DisplayContext* currentDisplayContext = nullptr;
-            DisplayContextRequestBus::BroadcastResult(
-                currentDisplayContext, &DisplayContextRequestBus::Events::GetDC);
-
-            // ensure the current display context has not been changed out from under us
-            AZ_Assert(currentDisplayContext == m_currSetDisplayContext,
-                "DisplayContext was changed during lifetime of DisplayRequestDCGuard - "
-                "This indicates a logical error.")
-
-            // set previous display context
-            DisplayContextRequestBus::Broadcast(
-                &DisplayContextRequestBus::Events::SetDC, m_prevSetDisplayContext);
-        }
-
-    private:
-        DisplayContext* m_prevSetDisplayContext = nullptr;
-        DisplayContext* m_currSetDisplayContext = nullptr;
-    };
-} // namespace AzFramework

+ 0 - 1
Code/Framework/AzFramework/AzFramework/azframework_files.cmake

@@ -112,7 +112,6 @@ set(FILES
     Viewport/ClickDetector.h
     Viewport/ClickDetector.cpp
     Viewport/CursorState.h
-    Viewport/DisplayContextRequestBus.h
     Entity/BehaviorEntity.cpp
     Entity/BehaviorEntity.h
     Entity/GameEntityContextComponent.cpp

+ 3 - 1
Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp

@@ -75,6 +75,7 @@ AZ_POP_DISABLE_WARNING
 #include <QtWidgets/private/qstylehelper_p.h>
 
 #include <limits>
+#include <QListWidget>
 
 namespace AzQtComponents
 {
@@ -789,7 +790,8 @@ namespace AzQtComponents
 
     QPixmap Style::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap, const QStyleOption* option) const
     {
-        if (qobject_cast<const TableView*>(m_drawControlWidget) && iconMode == QIcon::Mode::Selected)
+        if ((qobject_cast<const TableView*>(m_drawControlWidget) ||
+            qobject_cast<const QListWidget*>(m_drawControlWidget)) && iconMode == QIcon::Mode::Selected)
         {
             return QProxyStyle::generatedIconPixmap(QIcon::Mode::Active, pixmap, option);
         }

+ 0 - 3
Code/Framework/AzToolsFramework/AzToolsFramework/API/ComponentEntityObjectBus.h

@@ -64,9 +64,6 @@ namespace AzToolsFramework
 
         /// Retrieve AZ Entity Id associated with this sandbox object.
         virtual AZ::EntityId GetAssociatedEntityId() = 0;
-
-        /// Updates the undo cache for this sandbox object
-        virtual void UpdatePreemptiveUndoCache() = 0;
     };
 
     using ComponentEntityObjectRequestBus = AZ::EBus < ComponentEntityObjectRequests >;

+ 36 - 0
Code/Framework/AzToolsFramework/AzToolsFramework/API/EntityPropertyEditorNotificationBus.h

@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+
+#pragma once
+
+#include <AzCore/Component/ComponentBus.h>
+#include <AzCore/EBus/EBus.h>
+#include <AzToolsFramework/API/ToolsApplicationAPI.h>
+
+namespace AzToolsFramework
+{
+    //! Provides a bus to notify when EntityPropertyEditor is interacted with.
+    class EntityPropertyEditorNotifications
+        : public AZ::EBusTraits
+    {
+    public:
+        //////////////////////////////////////////////////////////////////////////
+        // EBusTraits overrides
+        static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
+        static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
+        //////////////////////////////////////////////////////////////////////////
+
+        //! Notifies whenever component selection changes on an EntityPropertyEditor
+        virtual void OnComponentSelectionChanged(
+            [[maybe_unused]] EntityPropertyEditor* entityPropertyEditor,
+            [[maybe_unused]] const AZStd::unordered_set<AZ::EntityComponentIdPair>& selectedEntityComponentIds)
+        {}
+    };
+
+    using EntityPropertyEditorNotificationBus = AZ::EBus<EntityPropertyEditorNotifications>;
+} // namespace AzToolsFramework

+ 6 - 2
Code/Framework/AzToolsFramework/AzToolsFramework/API/EntityPropertyEditorRequestsBus.h

@@ -24,14 +24,18 @@ namespace AzToolsFramework
     public:
         using VisitComponentEditorsCallback = AZStd::function<bool(const ComponentEditor*)>;
 
-        //! Allows a component to get the list of selected entities or if in a pinned window, the list of entities in that window
+        //! Returns the list of selected entities or if in a pinned window, the list of entities in that window
         //! \param selectedEntityIds the return vector holding the entities required
         virtual void GetSelectedAndPinnedEntities(EntityIdList& selectedEntityIds) = 0;
 
-        //! Allows a component to get the list of selected entities
+        //! Returns the list of selected entities
         //! \param selectedEntityIds the return vector holding the entities required
         virtual void GetSelectedEntities(EntityIdList& selectedEntityIds) = 0;
 
+        //! Returns the list of selected components
+        //! \param selectedEntityIds the return vector holding the entities required
+        virtual void GetSelectedComponents(AZStd::unordered_set<AZ::EntityComponentIdPair>& selectedComponentEntityIds) = 0;
+
         //! Explicitly sets a component as having been the most recently added.
         //! This means that the next time the UI refreshes, that component will be ensured to be visible.
         virtual void SetNewComponentId(AZ::ComponentId componentId) = 0;

+ 2 - 2
Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.cpp

@@ -48,7 +48,7 @@ namespace AzToolsFramework::EmbeddedPython
         if (!isSdkEngine)
         {
             m_embeddedLibPythonModuleHandle = AZ::DynamicModuleHandle::Create(IMPLICIT_LOAD_PYTHON_SHARED_LIBRARY, false);
-            bool loadResult = m_embeddedLibPythonModuleHandle->Load(AZ::DynamicModuleHandle::LoadFlags::GlobalSymbols);
+            [[maybe_unused]] bool loadResult = m_embeddedLibPythonModuleHandle->Load(AZ::DynamicModuleHandle::LoadFlags::GlobalSymbols);
             AZ_Error("PythonLoader", loadResult, "Failed to load " IMPLICIT_LOAD_PYTHON_SHARED_LIBRARY "\n");
         }
         #endif // IMPLICIT_LOAD_PYTHON_SHARED_LIBRARY
@@ -122,7 +122,7 @@ namespace AzToolsFramework::EmbeddedPython
             }
             return true;
         };
-        const auto parseOutcome = AZ::Settings::ParseConfigFile(systemFileStream, parserSettings);
+        [[maybe_unused]] const auto parseOutcome = AZ::Settings::ParseConfigFile(systemFileStream, parserSettings);
         AZ_Error("python", parseOutcome, "Python venv file at %s missing home key. Make sure to run python/get_python.", pythonVenvConfig.c_str());
 
         return AZ::IO::FixedMaxPath(pythonHome);

+ 55 - 0
Code/Framework/AzToolsFramework/AzToolsFramework/API/SettingsRegistryUtils.h

@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+
+#pragma once
+
+#include <AzCore/Settings/SettingsRegistry.h>
+
+//! @file - contains a few utility functions for dealing with the settings registry.
+
+namespace AzToolsFramework
+{
+    //! Set a value in the Settings Registry.
+    //! setting needs to be a fully formed path, like "O3DE/Editor/General/Something"
+    template<typename T>
+    void SetRegistry(const AZStd::string_view setting, T&& value)
+    {
+        if (auto* registry = AZ::SettingsRegistry::Get())
+        {
+            registry->Set(setting, AZStd::forward<T>(value));
+        }
+    }
+
+    //! Get a value from the Settings Registry.
+    //! setting needs to be a fully formed path, like "O3DE/Editor/General/Something"
+    //! defaultValue is returned if the setting is not found.
+    template<typename T>
+    AZStd::remove_cvref_t<T> GetRegistry(const AZStd::string_view setting, T&& defaultValue)
+    {
+        AZStd::remove_cvref_t<T> value = AZStd::forward<T>(defaultValue);
+        if (const auto* registry = AZ::SettingsRegistry::Get())
+        {
+            AZStd::remove_cvref_t<T> potentialValue;
+            if (registry->Get(potentialValue, setting))
+            {
+                value = AZStd::move(potentialValue);
+            }
+        }
+        return value;
+    }
+
+    //! Clear a value from the Settings Registry.
+    //! setting needs to be a fully formed path, like "O3DE/Editor/General/Something"
+    inline void ClearRegistry(const AZStd::string_view setting)
+    {
+        if (auto* registry = AZ::SettingsRegistry::Get())
+        {
+            registry->Remove(setting);
+        }
+    }
+}

+ 0 - 20
Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h

@@ -43,7 +43,6 @@ namespace AzToolsFramework
 {
     struct ViewPaneOptions;
     class EntityPropertyEditor;
-    class PreemptiveUndoCache;
 
     namespace UndoSystem
     {
@@ -330,11 +329,6 @@ namespace AzToolsFramework
          */
         virtual void EndUndoBatch() = 0;
 
-        /*!
-         * Retrieves the preemptive undo cache for the application.
-         */
-        virtual PreemptiveUndoCache* GetUndoCache() = 0;
-
         /*!
          * \return true if the entity (or entities) can be edited/modified.
          */
@@ -454,18 +448,6 @@ namespace AzToolsFramework
         */
         virtual void DeleteEntitiesAndAllDescendants(const EntityIdList& entities) = 0;
 
-        virtual bool DetachEntities(const AZStd::vector<AZ::EntityId>& entitiesToDetach, AZStd::vector<AZStd::pair<AZ::EntityId, AZ::SliceComponent::EntityRestoreInfo>>& restoreInfos) = 0;
-
-        /*!
-        * \brief Detaches the supplied subslices from their owning slice instance
-        * \param subsliceRootList A list of SliceInstanceAddresses paired with a mapping from the sub slices asset entityId's to the owing slice instance's live entityIds
-                                  See SliceComponent::GetMappingBetweenSubsliceAndSourceInstanceEntityIds for a helper to acquire this mapping
-        * \param restoreInfos A list of EntityRestoreInfo's to be filled with information on how to restore the entities in the subslices back to their original state before this operation
-        * \return Returns true on operation success, false otherwise
-        */
-        virtual bool DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList,
-            AZStd::vector<AZStd::pair<AZ::EntityId, AZ::SliceComponent::EntityRestoreInfo>>& restoreInfos) = 0;
-
         /*!
         * \brief Finds the Common root of an entity list; Also finds the top level entities in a given list of active entities (who share the common root)
         * Example : A(B[D,E{F}],C),G (Letter is entity name, braces hold children)
@@ -881,8 +863,6 @@ namespace AzToolsFramework
         /// Returns the world-space position under the center of the render viewport.
         virtual AZ::Vector3 GetWorldPositionAtViewportCenter() { return AZ::Vector3::CreateZero(); }
 
-        virtual void InstantiateSliceFromAssetId(const AZ::Data::AssetId& /*assetId*/) {}
-
         /// Clears current redo stack
         virtual void ClearRedoStack() {}
     };

+ 0 - 228
Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp

@@ -32,7 +32,6 @@
 #include <AzToolsFramework/AssetBundle/AssetBundleComponent.h>
 #include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
 #include <AzToolsFramework/AssetEditor/AssetEditorWidget.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
 #include <AzToolsFramework/Commands/SelectionCommand.h>
 #include <AzToolsFramework/Component/EditorComponentAPIComponent.h>
 #include <AzToolsFramework/Component/EditorLevelComponentAPIComponent.h>
@@ -110,85 +109,6 @@ namespace AzToolsFramework
 {
     namespace Internal
     {
-        template<typename IdContainerType>
-        void DeleteEntities(const IdContainerType& entityIds)
-        {
-            AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-            if (entityIds.empty())
-            {
-                return;
-            }
-
-            UndoSystem::URSequencePoint* currentUndoBatch = nullptr;
-            ToolsApplicationRequests::Bus::BroadcastResult(
-                currentUndoBatch, &ToolsApplicationRequests::Bus::Events::GetCurrentUndoBatch);
-
-            bool createdUndo = false;
-            if (!currentUndoBatch)
-            {
-                createdUndo = true;
-                ToolsApplicationRequests::Bus::BroadcastResult(
-                    currentUndoBatch, &ToolsApplicationRequests::Bus::Events::BeginUndoBatch, "Delete Selected");
-                AZ_Assert(currentUndoBatch, "Failed to create new undo batch.");
-            }
-
-            UndoSystem::UndoStack* undoStack = nullptr;
-            PreemptiveUndoCache* preemptiveUndoCache = nullptr;
-            ToolsApplicationRequests::Bus::BroadcastResult(undoStack, &ToolsApplicationRequests::Bus::Events::GetUndoStack);
-            ToolsApplicationRequests::Bus::BroadcastResult(preemptiveUndoCache, &ToolsApplicationRequests::Bus::Events::GetUndoCache);
-            AZ_Assert(undoStack, "Failed to retrieve undo stack.");
-            AZ_Assert(preemptiveUndoCache, "Failed to retrieve preemptive undo cache.");
-            if (undoStack && preemptiveUndoCache)
-            {
-                // In order to undo DeleteSelected, we have to create a selection command which selects the current selection
-                // and then add the deletion as children.
-                // Commands always execute themselves first and then their children (when going forwards)
-                // and do the opposite when going backwards.
-                AzToolsFramework::EntityIdList selection;
-                ToolsApplicationRequests::Bus::BroadcastResult(selection, &ToolsApplicationRequests::Bus::Events::GetSelectedEntities);
-                AzToolsFramework::SelectionCommand* selCommand = aznew AzToolsFramework::SelectionCommand(selection, "Delete Entities");
-
-                // We insert a "deselect all" command before we delete the entities. This ensures the delete operations aren't changing
-                // selection state, which triggers expensive UI updates. By deselecting up front, we are able to do those expensive
-                // UI updates once at the start instead of once for each entity.
-                {
-                    AzToolsFramework::EntityIdList deselection;
-                    AzToolsFramework::SelectionCommand* deselectAllCommand = aznew AzToolsFramework::SelectionCommand(deselection, "Deselect Entities");
-                    deselectAllCommand->SetParent(selCommand);
-                }
-
-                {
-                    AZ_PROFILE_SCOPE(AzToolsFramework, "Internal::DeleteEntities:UndoCaptureAndPurgeEntities");
-                    for (const auto& entityId : entityIds)
-                    {
-                        AZ::Entity* entity = nullptr;
-                        AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationBus::Events::FindEntity, entityId);
-
-                        if (entity)
-                        {
-                            EntityDeleteCommand* command = aznew EntityDeleteCommand(static_cast<AZ::u64>(entityId));
-                            command->Capture(entity);
-                            command->SetParent(selCommand);
-                        }
-
-                        preemptiveUndoCache->PurgeCache(entityId);
-                    }
-                }
-
-                selCommand->SetParent(currentUndoBatch);
-                {
-                    AZ_PROFILE_SCOPE(AzToolsFramework, "Internal::DeleteEntities:RunRedo");
-                    selCommand->RunRedo();
-                }
-            }
-
-            if (createdUndo)
-            {
-                ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::EndUndoBatch);
-            }
-        }
-
         struct ToolsApplicationNotificationBusHandler final
             : public ToolsApplicationNotificationBus::Handler
             , public AZ::BehaviorEBusHandler
@@ -266,8 +186,6 @@ namespace AzToolsFramework
     {
         ToolsApplicationRequests::Bus::Handler::BusConnect();
         AzToolsFramework::Prefab::PrefabPublicNotificationBus::Handler::BusConnect();
-
-        m_undoCache.RegisterToUndoCacheInterface();
     }
 
     ToolsApplication::~ToolsApplication()
@@ -906,150 +824,6 @@ namespace AzToolsFramework
         m_editorEntityAPI->DeleteEntitiesAndAllDescendants(entities);
     }
 
-    bool ToolsApplication::DetachEntities(const AZStd::vector<AZ::EntityId>& entitiesToDetach, AZStd::vector<AZStd::pair<AZ::EntityId, AZ::SliceComponent::EntityRestoreInfo>>& restoreInfos)
-    {
-        AZStd::vector<AZStd::pair<AZ::Entity*, AZ::SliceComponent::SliceReference*>> pendingSliceChanges;
-
-        AZ::SliceComponent* editorRootSlice = nullptr;
-        AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(editorRootSlice,
-            &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
-        AZ_Assert(editorRootSlice, "Failed to retrieve editor root slice.");
-
-        // Gather desired changes without modifying slices or entities
-        for (const AZ::EntityId& entityId : entitiesToDetach)
-        {
-            AZ::SliceComponent::SliceInstanceAddress sliceAddress(nullptr, nullptr);
-            AzFramework::SliceEntityRequestBus::EventResult(sliceAddress, entityId,
-                &AzFramework::SliceEntityRequestBus::Events::GetOwningSlice);
-
-            AZ::SliceComponent::SliceReference* sliceReference = sliceAddress.first;
-            AZ::SliceComponent::SliceInstance* sliceInstance = sliceAddress.second;
-            if (!sliceReference || !sliceInstance)
-            {
-                AZ_Error("DetachSliceEntity", false, "Entity with Id %s is not part of a slice. \"Detach\" action cancelled. No slices or entities were modified.", entityId.ToString().c_str());
-                return false;
-            }
-
-            AZ::Entity* entity = nullptr;
-            AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationRequests::FindEntity, entityId);
-            AZ_Error("DetachSliceEntity", entity, "Unable to find entity for Entity Id %s. \"Detach\" action cancelled. No slices or entities were modified.", entityId.ToString().c_str());
-            if (!entity)
-            {
-                return false;
-            }
-
-            AZ::SliceComponent::EntityRestoreInfo restoreInfo;
-            if (editorRootSlice->GetEntityRestoreInfo(entityId, restoreInfo))
-            {
-                restoreInfos.emplace_back(entityId, restoreInfo);
-                pendingSliceChanges.emplace_back(entity, sliceReference);
-            }
-            else
-            {
-                AZ_Error("DetachSliceEntity", entity, "Failed to prepare restore information for entity of Id %s. \"Detach\" action cancelled. No slices or entities were modified.", entityId.ToString().c_str());
-                return false;
-            }
-        }
-
-        // Apply pending changes
-        for (AZStd::pair<AZ::Entity*, AZ::SliceComponent::SliceReference*>& pendingSliceChange : pendingSliceChanges)
-        {
-            // Remove entity from current slice instance without deleting the entity. Delete slice instance if the detached entity is the last one
-            // in the slice instance. The slice instance will be reconstructed upon undo.
-            bool success = pendingSliceChange.second->GetSliceComponent()->RemoveEntity(pendingSliceChange.first->GetId(), false, true);
-            if (success)
-            {
-                editorRootSlice->AddEntity(pendingSliceChange.first); // Add back as loose entity
-            }
-            else
-            {
-                AZ_Error("DetachSliceEntity", success, "Entity with Id %s could not be removed from the slice. The Slice Instance is now in an unknown state, and saving it may result in data loss.", pendingSliceChange.first->GetId().ToString().c_str());
-            }
-        }
-
-        SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-            &SliceEditorEntityOwnershipServiceNotifications::OnEditorEntitiesSliceOwnershipChanged, entitiesToDetach);
-        return true;
-    }
-
-    bool ToolsApplication::DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList, AZStd::vector<AZStd::pair<AZ::EntityId, AZ::SliceComponent::EntityRestoreInfo>>& restoreInfos)
-    {
-        AZ::SliceComponent* editorRootSlice = nullptr;
-        AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(editorRootSlice,
-            &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
-
-        if (!editorRootSlice)
-        {
-            AZ_Assert(false,
-                "ToolsApplication::DetachSubsliceInstances: Failed to retrieve editor root slice");
-
-            return false;
-        }
-
-        AZStd::vector<AZ::EntityId> entitiesToUpdate;
-        for (const auto& subsliceRoot : subsliceRootList)
-        {
-            if (!subsliceRoot.first.IsValid())
-            {
-                AZ_Assert(false,
-                    "ToolsApplication::DetachSubsliceInstances: Invalid subslice root was passed in. Unable to proceed");
-
-                return false;
-            }
-
-            // Gather EntityRestoreInfo for all entities in the subslice about to be detached
-            for (const AZStd::pair<AZ::EntityId, AZ::EntityId>& liveToSubsliceEntityIdMapping : subsliceRoot.second)
-            {
-                const AZ::EntityId& liveEntityId = liveToSubsliceEntityIdMapping.first;
-
-                bool isMetaDataEntity = false;
-                AzToolsFramework::SliceMetadataEntityContextRequestBus::BroadcastResult(isMetaDataEntity, &AzToolsFramework::SliceMetadataEntityContextRequestBus::Events::IsSliceMetadataEntity, liveEntityId);
-
-                // Skip gathering restore info for meta data entities
-                if (isMetaDataEntity)
-                {
-                    continue;
-                }
-
-                AZ::SliceComponent::EntityRestoreInfo restoreInfo;
-                if (editorRootSlice->GetEntityRestoreInfo(liveEntityId, restoreInfo))
-                {
-                    restoreInfos.emplace_back(liveEntityId, restoreInfo);
-                    entitiesToUpdate.emplace_back(liveEntityId);
-                }
-                else
-                {
-                    AZ_Error("ToolsApplication::DetachSubsliceInstances",
-                        false,
-                        "Failed to prepare restore information for entity of Id %s. \"DetachSubsliceInstance\" action cancelled. No slices or entities were modified.",
-                        liveEntityId.ToString().c_str());
-
-                    return false;
-                }
-            }
-        }
-
-        // Perform the detach operation by extracting each subslice from its current slice and adding it as a standalone instance owned by the root slice
-        for (const auto& subsliceRoot : subsliceRootList)
-        {
-            const AZ::Data::Asset<AZ::SliceAsset>& subsliceAsset = subsliceRoot.first.GetReference()->GetSliceAsset();
-
-            if (!editorRootSlice->AddSliceUsingExistingEntities(subsliceAsset, subsliceRoot.second).IsValid())
-            {
-                AZ_Error("ToolsApplication::DetachSubsliceInstances",
-                    false,
-                    "Subslice Instance of Asset with Id %s could not be detached from source slice. The Slice instance is now in an unknown state, and saving it may result in data loss.",
-                    subsliceAsset.ToString<AZStd::string>().c_str());
-
-                return false;
-            }
-        }
-
-        SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-            &SliceEditorEntityOwnershipServiceNotificationBus::Events::OnEditorEntitiesSliceOwnershipChanged, entitiesToUpdate);
-        return true;
-    }
-
     bool ToolsApplication::FindCommonRoot(const AzToolsFramework::EntityIdSet& entitiesToBeChecked, AZ::EntityId& commonRootEntityId
         , AzToolsFramework::EntityIdList* topLevelEntities)
     {
@@ -1599,8 +1373,6 @@ namespace AzToolsFramework
         auto prefabPublicInterface = AZ::Interface<Prefab::PrefabPublicInterface>::Get();
         if (prefabPublicInterface)
         {
-            // Compared to the preemptive undo cache, we can avoid the duplicate check.
-            // Multiple changes to the same entity are just split between different undo nodes.
             for (AZ::EntityId entityId : m_dirtyEntities)
             {
                 auto outcome = prefabPublicInterface->GenerateUndoNodesForEntityChangeAndUpdateCache(entityId, m_currentBatchUndo);

+ 0 - 15
Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.h

@@ -15,7 +15,6 @@
 #include <AzToolsFramework/API/ToolsApplicationAPI.h>
 #include <AzToolsFramework/API/EditorEntityAPI.h>
 #include <AzToolsFramework/Application/EditorEntityManager.h>
-#include <AzToolsFramework/Commands/PreemptiveUndoCache.h>
 #include <AzToolsFramework/Prefab/PrefabPublicNotificationBus.h>
 
 #pragma once
@@ -112,7 +111,6 @@ namespace AzToolsFramework
 
         UndoSystem::UndoStack* GetUndoStack() override { return m_undoStack; }
         UndoSystem::URSequencePoint* GetCurrentUndoBatch() override { return m_currentBatchUndo; }
-        PreemptiveUndoCache* GetUndoCache() override { return &m_undoCache; }
 
         EntityIdSet GatherEntitiesAndAllDescendents(const EntityIdList& inputEntities) override;
 
@@ -126,18 +124,6 @@ namespace AzToolsFramework
         void DeleteEntityAndAllDescendants(AZ::EntityId entityId) override;
         void DeleteEntitiesAndAllDescendants(const EntityIdList& entities) override;
 
-        bool DetachEntities(const AZStd::vector<AZ::EntityId>& entitiesToDetach, AZStd::vector<AZStd::pair<AZ::EntityId, AZ::SliceComponent::EntityRestoreInfo>>& restoreInfos) override;
-
-        /**
-        * Detaches the supplied subslices from their owning slice instance
-        * @param subsliceRootList A list of SliceInstanceAddresses paired with a mapping from the sub slices asset entityId's to the owing slice instance's live entityIds
-                                  See SliceComponent::GetMappingBetweenSubsliceAndSourceInstanceEntityIds for a helper to acquire this mapping
-        * @param restoreInfos A list of EntityRestoreInfo's to be filled with information on how to restore the entities in the subslices back to their original state before this operation
-        * @return Returns true on operation success, false otherwise
-        */
-        bool DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList,
-            AZStd::vector<AZStd::pair<AZ::EntityId, AZ::SliceComponent::EntityRestoreInfo>>& restoreInfos) override;
-
         bool FindCommonRoot(const EntityIdSet& entitiesToBeChecked, AZ::EntityId& commonRootEntityId, EntityIdList* topLevelEntities = nullptr) override;
         bool FindCommonRootInactive(const EntityList& entitiesToBeChecked, AZ::EntityId& commonRootEntityId, EntityList* topLevelEntities = nullptr) override;
         void FindTopLevelEntityIdsInactive(const EntityIdList& entityIdsToCheck, EntityIdList& topLevelEntityIds) override;
@@ -189,7 +175,6 @@ namespace AzToolsFramework
         UndoSystem::UndoStack*              m_undoStack;
         UndoSystem::URSequencePoint*        m_currentBatchUndo;
         AZStd::unordered_set<AZ::EntityId>  m_dirtyEntities;
-        PreemptiveUndoCache                 m_undoCache;
         bool                                m_isDuringUndoRedo;
         bool                                m_isInIsolationMode;
         EntityIdSet                         m_isolatedEntityIdSet;

+ 2 - 2
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp

@@ -264,7 +264,7 @@ namespace AzToolsFramework
             const AssetBrowserEntry* item = static_cast<const AssetBrowserEntry*>(parent.internalPointer());
 
             // We should only have an item as a folder but will check
-            if (item && (item->RTTI_IsTypeOf(FolderAssetBrowserEntry::RTTI_Type())))
+            if (item && (item->GetEntryType() == AssetBrowserEntry::AssetEntryType::Folder))
             {
                 AZStd::vector<const AssetBrowserEntry*> entries;
 
@@ -581,7 +581,7 @@ namespace AzToolsFramework
                 return false;
             }
 
-            if (azrtti_istypeof<RootAssetBrowserEntry*>(entry))
+            if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Root)
             {
                 index = QModelIndex();
                 return true;

+ 44 - 7
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTreeToTableProxyModel.cpp

@@ -14,6 +14,10 @@ namespace AzToolsFramework
 {
     namespace AssetBrowser
     {
+        // the table is a hash and needs to eventually store the entire asset tree
+        // start with a good amount reserved so it doesn't incur crazy re-hashing as it grows.
+        static constexpr const int INITIAL_TABLE_RESERVE_SIZE = 1024 * 8; 
+
         ConstTableIterator IndexToMap::TableConstBegin() const
         {
             return m_tableToTree.constBegin();
@@ -71,19 +75,50 @@ namespace AzToolsFramework
             return m_tableToTree.remove(row) != 0;
         }
 
-        TreeIterator IndexToMap::Insert(TableType map, TreeType row)
+        void IndexToMap::Reserve(TableMap::size_type size)
         {
-            if (m_treeToTable.contains(map))
+            m_treeToTable.reserve(size);
+        }
+
+        void IndexToMap::Insert(TableType map, TreeType row)
+        {
+            // m_treeToTable maps from ModelIndex to int
+            // m_tableToTree maps from int to ModelIndex
+
+            // we have to erase from both maps before we update them.
+            // avoid using "Remove" on the hash, as that causes a re-hash.  Strategy here
+            // will be to update the value if we find it, and erase the value in the other container.
+            // this will yield the minimum amount of re-hashing and memory clearing.
+            bool insertIntoTableToTree = true;
+            bool insertIntoTreeToTable = true;
+            if (auto it = m_treeToTable.find(map); it != m_treeToTable.end())
             {
-                m_tableToTree.remove(m_treeToTable.take(map));
+                int& currentValue = it.value();
+                auto elementInOtherMap = m_tableToTree.find(currentValue);
+                m_tableToTree.erase(elementInOtherMap);
+                currentValue = row;
+                insertIntoTreeToTable = false;
             }
-            if (m_tableToTree.contains(row))
+
+            if (auto it = m_tableToTree.find(row); it != m_tableToTree.end())
+            {
+                QPersistentModelIndex& currentValue = it.value();
+                auto elementInOtherMap = m_treeToTable.find(currentValue);
+                m_treeToTable.erase(elementInOtherMap);
+                currentValue = map;
+                insertIntoTableToTree = false;
+            }
+            
+            if (insertIntoTableToTree)
             {
-                m_treeToTable.remove(m_tableToTree.take(row));
+                m_tableToTree.insert(row, map);
             }
 
-            m_tableToTree.insert(row, map);
-            return m_treeToTable.insert(map, row);
+            if (insertIntoTreeToTable)
+            {
+                m_treeToTable.insert(map, row);
+            }
+            
         }
 
         TableIterator IndexToMap::TableBegin()
@@ -100,6 +135,7 @@ namespace AzToolsFramework
         AssetBrowserTreeToTableProxyModel::AssetBrowserTreeToTableProxyModel(QObject* parent)
             : QAbstractProxyModel(parent)
         {
+            m_map.Reserve(INITIAL_TABLE_RESERVE_SIZE);
         }
 
         void AssetBrowserTreeToTableProxyModel::setSourceModel(QAbstractItemModel* model)
@@ -907,6 +943,7 @@ namespace AzToolsFramework
 
         void AssetBrowserTreeToTableProxyModel::ProcessParents()
         {
+            m_map.Reserve(m_parents.size());
             auto sourceModelPtr = sourceModel();
             while (!m_parents.isEmpty())
             {

+ 2 - 1
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTreeToTableProxyModel.h

@@ -39,10 +39,11 @@ namespace AzToolsFramework
             TableIterator TableBegin();
             TableIterator TableEnd();
             bool Empty() const;
+            void Reserve(TableMap::size_type size);
             bool TreeContains(TableType map) const;
             TreeType TreeToTable(TableType map) const;
             bool RemoveFromTree(TableType map);
-            TreeIterator Insert(TableType tmap, TreeType row);
+            void Insert(TableType tmap, TreeType row);
             void Clear();
 
         protected:

+ 20 - 2
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetEntryChangeset.cpp

@@ -17,6 +17,15 @@ namespace AzToolsFramework
 {
     namespace AssetBrowser
     {
+        // The number of changes to apply per tick when the system is
+        // up and running.  (For example, when changes happen due ot the user
+        // modifying files once the Editor has already started).
+        // This is a balance between responsiveness and performance.
+        // The higher the number,the faster the Asset Browser will populate
+        // itself when new assets appear (this is a per-tick limit, at a target
+        // of 60fps).
+        static const int s_BatchSize = 2;
+
         AssetEntryChangeset::AssetEntryChangeset(
             AZStd::shared_ptr<AssetDatabase::AssetDatabaseConnection> databaseConnection,
             AZStd::shared_ptr<RootAssetBrowserEntry> rootEntry)
@@ -60,21 +69,30 @@ namespace AzToolsFramework
 
             AZStd::lock_guard<AZStd::mutex> locker(m_mutex);
 
+            int changesToApplyThisBatch = s_BatchSize;
             if (m_updated)
             {
                 m_rootEntry->SetInitialUpdate(true);
                 m_rootEntry->Update(m_relativePath.c_str());
                 m_updated = false;
+                // during startup, do a big chunk of work for free before going into incremental mode.
+                changesToApplyThisBatch = 0;
             }
 
             // iterate through new changes and try to apply them
             // if application of change fails, try them again next tick
             AZStd::vector<AZStd::shared_ptr<AssetEntryChange>> changesFailed;
             changesFailed.reserve(m_changes.size());
-
+            int changesAppliedThisBatch = 0;
             for (auto& change : m_changes)
             {
-                if (!change->Apply(m_rootEntry))
+                // maintainer note, this is intentionally >, not >= so that if you set it to 1
+                // it moves 1, since we pre-increment it
+                if ( (changesToApplyThisBatch > 0) && (++changesAppliedThisBatch > changesToApplyThisBatch))
+                {
+                    changesFailed.emplace_back(AZStd::move(change));
+                }
+                else if (!change->Apply(m_rootEntry))
                 {
                     changesFailed.emplace_back(AZStd::move(change));
                 }

+ 5 - 4
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp

@@ -438,13 +438,14 @@ namespace AzToolsFramework
         bool AssetBrowserEntry::lessThan(const AssetBrowserEntry* other, const AssetEntrySortMode sortMode, const QCollator& collator) const
         {
             // folders should always come first
-            if (azrtti_istypeof<const FolderAssetBrowserEntry*>(this) && azrtti_istypeof<const SourceAssetBrowserEntry*>(other))
+            if (GetEntryType() == AssetEntryType::Folder && other->GetEntryType() != AssetEntryType::Folder)
             {
-                return false;
+                return true;
             }
-            if (azrtti_istypeof<const SourceAssetBrowserEntry*>(this) && azrtti_istypeof<const FolderAssetBrowserEntry*>(other))
+
+            if (GetEntryType() != AssetEntryType::Folder && other->GetEntryType() == AssetEntryType::Folder)
             {
-                return true;
+                return false;
             }
 
             switch (sortMode)

+ 4 - 3
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp

@@ -241,7 +241,7 @@ namespace AzToolsFramework
                 return false;
             }
 
-            auto source = azrtti_cast<SourceAssetBrowserEntry*>(itFile->second);
+            auto source = static_cast<SourceAssetBrowserEntry*>(itFile->second); // it MUST be a source to get here.
             source->m_sourceId = sourceWithFileIdEntry.second.m_sourceID;
             source->m_sourceUuid = sourceWithFileIdEntry.second.m_sourceGuid;
             source->PathsUpdated(); // update thumbnailkey to valid uuid
@@ -424,11 +424,12 @@ namespace AzToolsFramework
         {
             auto it = AZStd::find_if(parent->m_children.begin(), parent->m_children.end(), [folderName](AssetBrowserEntry* entry)
             {
-                return azrtti_istypeof<FolderAssetBrowserEntry*>(entry) && AZ::IO::PathView(entry->m_name) == AZ::IO::PathView(folderName);
+                return (entry->GetEntryType() == AssetEntryType::Folder) && AZ::IO::PathView(entry->m_name) == AZ::IO::PathView(folderName);
             });
+            
             if (it != parent->m_children.end())
             {
-                return azrtti_cast<FolderAssetBrowserEntry*>(*it);
+                return static_cast<FolderAssetBrowserEntry*>(*it); // RTTI Cast is not necessary since find_if only returns folders.
             }
 
             auto folder = aznew FolderAssetBrowserEntry();

+ 0 - 117
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/BaseSliceCommand.cpp

@@ -1,117 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#include "BaseSliceCommand.h"
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-
-namespace AzToolsFramework
-{
-    BaseSliceCommand::BaseSliceCommand(const AZStd::string& friendlyName)
-        : UndoSystem::URSequencePoint(friendlyName)
-        , m_changed(true)
-    {
-    }
-
-    bool BaseSliceCommand::CaptureRestoreInfoForUndo(const AZ::EntityId& entityId)
-    {
-        AZ::SliceComponent* editorRootSlice = nullptr;
-        AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(editorRootSlice,
-            &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
-
-        AZ::SliceComponent::EntityRestoreInfo restoreInfo;
-        AZ::SliceComponent::SliceInstanceAddress owningSlice = editorRootSlice->FindSlice(entityId);
-
-        // If no owning slice then store with an empty restore info
-        // We'll only need to detach the entity on undo
-        if (!owningSlice.IsValid())
-        {
-            m_entityUndoRestoreInfoArray.emplace_back(entityId, restoreInfo);
-
-            return true;
-        }
-
-        // Gather restore info so that on undo we can return this entity
-        // to its original owning slice instance
-        if (editorRootSlice->GetEntityRestoreInfo(entityId, restoreInfo))
-        {
-            m_entityUndoRestoreInfoArray.emplace_back(entityId, restoreInfo);
-        }
-        else
-        {
-            AZ_Error("CreateSliceCommand::Capture",
-                false,
-                "Failed to capture RestoreInfo for entity with Id: %s owned by sliceInstance with asset Id: %s. Unable to capture undo/redo state",
-                entityId.ToString().c_str(),
-                owningSlice.GetReference()->GetSliceAsset().GetId().ToString<AZStd::string>().c_str());
-
-            return false;
-        }
-
-        return true;
-    }
-
-    void BaseSliceCommand::RestoreEntities(AZ::SliceComponent::EntityRestoreInfoList& entitiesToRestore,
-        bool clearRestoreList /*=false*/,
-        SliceEntityRestoreType restoreType /*=SliceEntityRestoreType::Detached*/)
-    {
-        AZ::SliceComponent* editorRootSlice = nullptr;
-        AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(editorRootSlice,
-            &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
-
-        if (!editorRootSlice)
-        {
-            AZ_Assert(false,
-                "BaseSliceCommand::RestoreEntities: GetEditorRootSlice returned nullptr. Unable to proceed.");
-
-            return;
-        }
-
-        AzToolsFramework::EntityIdList detachedEntities;
-        for (const auto& restoreInfoPair : entitiesToRestore)
-        {
-            const AZ::EntityId& entityId = restoreInfoPair.first;
-            const AZ::SliceComponent::EntityRestoreInfo& restoreInfo = restoreInfoPair.second;
-
-            AZ::Entity* entity = editorRootSlice->FindEntity(entityId);
-
-            if (!entity)
-            {
-                AZ_Error("BaseSliceCommand::RestoreEntities",
-                    false,
-                    "Unable to find entity with Id: %s in the EditorEntityContext. Cannot complete operation and restore entity",
-                    entityId.ToString().c_str());
-
-                return;
-            }
-
-            // Detach the entity from whatever slice instance owned it before and place it directly in the root slice
-            editorRootSlice->RemoveEntity(entity, false);
-            editorRootSlice->AddEntity(entity);
-
-            if (restoreInfo)
-            {
-                SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
-                    &SliceEditorEntityOwnershipServiceRequestBus::Events::RestoreSliceEntity, entity, restoreInfo, restoreType);
-            }
-            else
-            {
-                // An invalid restoreInfo implies no slice to restore to
-                // Detaching the entity is all that's needed
-                detachedEntities.emplace_back(entity->GetId());
-            }
-        }
-
-        // RestoreSliceEntity will update slice info for the entities passed in. Only need to handle entities that weren't restored that way.
-        SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-            &SliceEditorEntityOwnershipServiceNotificationBus::Events::OnEditorEntitiesSliceOwnershipChanged, detachedEntities);
-
-        if (clearRestoreList)
-        {
-            entitiesToRestore.clear();
-        }
-    }
-}

+ 0 - 46
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/BaseSliceCommand.h

@@ -1,46 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#pragma once
-
-#include <AzCore/Slice/SliceAsset.h>
-#include <AzCore/Slice/SliceComponent.h>
-
-#include <AzToolsFramework/Undo/UndoSystem.h>
-#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-namespace AzToolsFramework
-{
-    class BaseSliceCommand
-        : public UndoSystem::URSequencePoint
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(BaseSliceCommand, AZ::SystemAllocator);
-        AZ_RTTI(BaseSliceCommand, "{87CB1C80-7D75-423B-964A-CF1964A9AB26}");
-
-        BaseSliceCommand(const AZStd::string& friendlyName);
-
-        ~BaseSliceCommand() {};
-
-        void Undo() override = 0;
-        void Redo() override = 0;
-
-        bool Changed() const override { return m_changed; }
-
-    protected:
-
-        bool CaptureRestoreInfoForUndo(const AZ::EntityId& entityId);
-
-        void RestoreEntities(AZ::SliceComponent::EntityRestoreInfoList& entitiesToRestore,
-            bool clearRestoreList = false,
-            SliceEntityRestoreType restoreType = SliceEntityRestoreType::Detached);
-
-        AZ::SliceComponent::EntityRestoreInfoList m_entityRedoRestoreInfoArray;
-        AZ::SliceComponent::EntityRestoreInfoList m_entityUndoRestoreInfoArray;
-        bool                                      m_changed;
-    };
-}

+ 0 - 218
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/CreateSliceCommand.cpp

@@ -1,218 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#include "CreateSliceCommand.h"
-
-#include <AzCore/Asset/AssetManager.h>
-#include <AzCore/Serialization/Utils.h>
-
-#include <AzToolsFramework/Slice/SliceUtilities.h>
-#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-namespace AzToolsFramework
-{
-    CreateSliceCommand::CreateSliceCommand(const AZStd::string& friendlyName)
-        : BaseSliceCommand(friendlyName)
-    {
-    }
-
-    void CreateSliceCommand::Capture(const AZ::Data::Asset<AZ::SliceAsset>& tempSliceAsset,
-        const AZStd::string& fullSliceAssetPath,
-        const AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetMap)
-    {
-        if (!tempSliceAsset.Get())
-        {
-            AZ_Error("CreateSliceCommand::Capture",
-                false,
-                "Invalid SliceAsset passed in. Unable to capture undo/redo state");
-
-            return;
-        }
-
-        if (liveToAssetMap.empty())
-        {
-            AZ_Warning("CreateSliceCommand::Capture",
-                false,
-                "Empty liveToAsset EntityId map passed in. Nothing to undo/redo");
-
-            return;
-        }
-
-        m_fullSliceAssetPath = fullSliceAssetPath;
-        m_liveToAssetMap = liveToAssetMap;
-
-        // Get the sourceUUID of our newly created slice so that we can build its asset ID without having to wait for it to be processed
-        AZ::Data::AssetInfo assetInfo;
-        AZStd::string watchFolder;
-        bool foundSourceInfo = false;
-
-        AzToolsFramework::AssetSystemRequestBus::BroadcastResult(foundSourceInfo,
-            &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath,
-            m_fullSliceAssetPath.c_str(), assetInfo, watchFolder);
-
-        if (!foundSourceInfo)
-        {
-            AZ_Error("CreateSliceCommand::Capture",
-                false,
-                "Failed to acquire asset source info for asset located at local path: %s. Unable to capture undo/redo state",
-                m_fullSliceAssetPath.c_str());
-
-            m_liveToAssetMap.clear();
-            return;
-        }
-
-        // Convert retrieved assetId to have the appropriate subID for a static (non-dynamic) slice asset
-        m_sliceAssetId = AZ::Data::AssetId(assetInfo.m_assetId.m_guid, AZ::SliceAsset::GetAssetSubId());
-
-        // Save a copy of our tempSliceAsset
-        AZ::SliceAsset* tempSliceAssetData = tempSliceAsset.Get();
-        AZ::Entity* tempSliceAssetEntity = tempSliceAssetData->GetEntity();
-        AZ::IO::ByteContainerStream<AZStd::vector<AZ::u8>> assetStream(&m_sliceAssetBuffer);
-        bool saveSuccess = AZ::Utils::SaveObjectToStream(assetStream, AZ::DataStream::ST_BINARY, tempSliceAssetEntity);
-
-        if (!saveSuccess)
-        {
-            AZ_Error("CreateSliceCommand::Capture",
-                false,
-                "Failed to cache provided slice asset specified at local path: %s. Unable to capture undo/redo state",
-                m_fullSliceAssetPath.c_str());
-
-            m_liveToAssetMap.clear();
-            return;
-        }
-
-        // Capture restore info for all the live entities in our map
-        for (const AZStd::pair<AZ::EntityId, AZ::EntityId>& liveToAssetIdPair : m_liveToAssetMap)
-        {
-            const AZ::EntityId& liveEntityId = liveToAssetIdPair.first;
-
-            bool restoreCaptured = BaseSliceCommand::CaptureRestoreInfoForUndo(liveEntityId);
-
-            if(!restoreCaptured)
-            {
-                m_liveToAssetMap.clear();
-                m_entityUndoRestoreInfoArray.clear();
-
-                return;
-            }
-        }
-
-        // Remove the dirty flag on these entities
-        // Otherwise an additional entity restore will be scheduled on these entities
-        for (const AZStd::pair<AZ::EntityId, AZ::EntityId>& liveToAssetId : m_liveToAssetMap)
-        {
-            AzToolsFramework::ToolsApplicationRequestBus::Broadcast(&AzToolsFramework::ToolsApplicationRequestBus::Events::RemoveDirtyEntity, liveToAssetId.first);
-        }
-    }
-
-    void CreateSliceCommand::Undo()
-    {
-        BaseSliceCommand::RestoreEntities(m_entityUndoRestoreInfoArray);
-    }
-
-    void CreateSliceCommand::Redo()
-    {
-        // Load our slice asset in memory
-        AZ::Data::Asset<AZ::SliceAsset> sliceAsset = PreloadSliceAsset();
-
-        // Move all entities marked in m_liveToAssetMap into a new instance of our sliceAsset
-        AZ::SliceComponent::SliceInstanceAddress sliceInstanceResult;
-        AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(sliceInstanceResult,
-            &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::PromoteEditorEntitiesIntoSlice,
-            sliceAsset, m_liveToAssetMap);
-    }
-
-    AZ::Data::Asset<AZ::SliceAsset> CreateSliceCommand::PreloadSliceAsset()
-    {
-        AZ::SerializeContext* serializeContext = nullptr;
-        AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
-        if (!serializeContext)
-        {
-            AZ_Error("CreateSliceCommand::PreloadSliceAsset",
-                false,
-                "Failed to retrieve serialize context. Unable to proceed with loading cached slice asset for redo");
-
-            return AZ::Data::Asset<AZ::SliceAsset>();
-        }
-
-        // Load our sliceAsset back in
-        AZ::IO::ByteContainerStream<AZStd::vector<AZ::u8>> sliceAssetStream(&m_sliceAssetBuffer);
-
-        // Load our cached Asset Entity from stream and store it in a unique_ptr. If we early out due to an error it will clean up the loose entity
-        AZStd::unique_ptr<AZ::Entity> sliceAssetEntity(AZ::Utils::LoadObjectFromStream<AZ::Entity>(sliceAssetStream, serializeContext));
-
-        if (!sliceAssetEntity)
-        {
-            AZ_Assert(false,
-                "CreateSliceCommand::PreloadSliceAsset could not load cached slice asset from stream. Unable to proceed with loading cached asset for redo");
-
-            return AZ::Data::Asset<AZ::SliceAsset>();
-        }
-
-        AZ::Data::Asset<AZ::SliceAsset> sliceAsset = AZ::Data::AssetManager::Instance().FindOrCreateAsset<AZ::SliceAsset>(m_sliceAssetId, AZ::Data::AssetLoadBehavior::Default);
-
-        // No Asset should exist under this AssetID. If one does we cannot continue
-        if (sliceAsset.GetStatus() != AZ::Data::AssetData::AssetStatus::NotLoaded)
-        {
-            AZ_Error("CreateSliceCommand::PreloadSliceAsset",
-                false,
-                "Asset already registered with AssetID: %s. Unable to proceed with loading cached asset for redo",
-                m_sliceAssetId.ToString<AZStd::string>().c_str());
-
-            return AZ::Data::Asset<AZ::SliceAsset>();
-        }
-
-        AZ::SliceAsset* sliceAssetData = sliceAsset.Get();
-
-        // Confirm GetAsset was successful
-        if (!sliceAssetData)
-        {
-            AZ_Error("CreateSliceCommand::PreloadSliceAsset",
-                false,
-                "Failed to get slice asset from Asset ID: %s via the AssetManager. Unable to generate initial slice instance during Create Slice",
-                m_sliceAssetId.ToString<AZStd::string>().c_str());
-
-            return AZ::Data::Asset<AZ::SliceAsset>();
-        }
-
-        // Set the new asset's data to be the data we cached in m_sliceAssetBuffer
-        sliceAssetData->SetData(sliceAssetEntity.get(), sliceAssetEntity->FindComponent<AZ::SliceComponent>());
-
-        // Validate that the entity and component of sliceAssetData were successfully set
-        if (sliceAssetData->GetStatus() != AZ::Data::AssetData::AssetStatus::Ready)
-        {
-            AZ_Error("CreateSliceCommand::PreloadSliceAsset",
-                false,
-                "Failed to load valid slice data during initial creation of slice asset with AssetID: %s. Unable to generate initial slice instance during Create Slice",
-                m_sliceAssetId.ToString<AZStd::string>().c_str());
-
-            return AZ::Data::Asset<AZ::SliceAsset>();
-        }
-
-        // Safe to release our Entity to the asset
-        sliceAssetEntity.release();
-
-        // Finalize configuring the slice asset
-        sliceAssetData->GetComponent()->SetMyAsset(sliceAssetData);
-        sliceAssetData->GetComponent()->ListenForAssetChanges();
-
-        // Update the asset's hint to be its relative asset path
-        bool relativePathFound = false;
-        AZStd::string assetPathRelative;
-        AssetSystemRequestBus::BroadcastResult(relativePathFound, &AssetSystemRequestBus::Events::GetRelativeProductPathFromFullSourceOrProductPath, m_fullSliceAssetPath, assetPathRelative);
-        AZStd::to_lower(assetPathRelative.begin(), assetPathRelative.end());
-
-        sliceAsset.SetHint(assetPathRelative);
-
-        // We've finalized loading this asset from memory
-        // Ignore the following reload from AssetCatalog since it will attempt to overwrite our asset with what's on disk
-        // Which is an unnecessary operation as SliceTransaction serialized the contents of transactionAsset to disk
-        sliceAssetData->SetIgnoreNextAutoReload(true);
-
-        return sliceAsset;
-    }
-}

+ 0 - 42
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/CreateSliceCommand.h

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#pragma once
-
-#include <AzCore/Slice/SliceAsset.h>
-#include <AzCore/Slice/SliceComponent.h>
-
-#include <AzToolsFramework/Commands/BaseSliceCommand.h>
-namespace AzToolsFramework
-{
-    class CreateSliceCommand
-        : public BaseSliceCommand
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(CreateSliceCommand, AZ::SystemAllocator);
-        AZ_RTTI(CreateSliceCommand, "{295F0D67-18F4-4C4E-937B-66398258A472}");
-
-        CreateSliceCommand(const AZStd::string& friendlyName);
-
-        ~CreateSliceCommand() {}
-
-        void Capture(const AZ::Data::Asset<AZ::SliceAsset>& tempSliceAsset,
-            const AZStd::string& fullSliceAssetPath,
-            const AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetMap);
-
-        void Undo() override;
-        void Redo() override;
-
-    protected:
-        AZ::Data::Asset<AZ::SliceAsset> PreloadSliceAsset();
-
-        AZStd::vector<AZ::u8> m_sliceAssetBuffer;
-        AZStd::string m_fullSliceAssetPath;
-        AZ::SliceComponent::EntityIdToEntityIdMap m_liveToAssetMap;
-        AZ::Data::AssetId m_sliceAssetId;
-    };
-}

+ 0 - 31
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/DetachSubSliceInstanceCommand.cpp

@@ -1,31 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#include "DetachSubSliceInstanceCommand.h"
-
-#include <AzToolsFramework/API/ToolsApplicationAPI.h>
-
-namespace AzToolsFramework
-{
-    DetachSubsliceInstanceCommand::DetachSubsliceInstanceCommand(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList, const AZStd::string& friendlyName)
-        : BaseSliceCommand(friendlyName)
-        , m_subslices(subsliceRootList)
-    {
-    }
-
-    void DetachSubsliceInstanceCommand::Undo()
-    {
-        RestoreEntities(m_entityUndoRestoreInfoArray, true);
-    }
-
-    void DetachSubsliceInstanceCommand::Redo()
-    {
-        AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-            m_changed, &AzToolsFramework::ToolsApplicationRequestBus::Events::DetachSubsliceInstances, m_subslices, m_entityUndoRestoreInfoArray);
-    }
-}

+ 0 - 32
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/DetachSubSliceInstanceCommand.h

@@ -1,32 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#pragma once
-
-#include <AzCore/Slice/SliceComponent.h>
-
-#include <AzToolsFramework/Commands/BaseSliceCommand.h>
-namespace AzToolsFramework
-{
-    class DetachSubsliceInstanceCommand
-        : public BaseSliceCommand
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(DetachSubsliceInstanceCommand, AZ::SystemAllocator);
-        AZ_RTTI(DetachSubsliceInstanceCommand, "{FCDE52C0-F334-4701-9CA6-43FA089007EE}");
-
-        DetachSubsliceInstanceCommand(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList, const AZStd::string& friendlyName);
-
-        ~DetachSubsliceInstanceCommand() {}
-
-        void Undo() override;
-        void Redo() override;
-
-    protected:
-        AZ::SliceComponent::SliceInstanceEntityIdRemapList m_subslices;
-    };
-} // namespace AzToolsFramework

+ 0 - 292
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/EntityStateCommand.cpp

@@ -1,292 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#include "EntityStateCommand.h"
-#include <AzCore/Component/Entity.h>
-#include <AzCore/Component/ComponentApplicationBus.h>
-#include <AzCore/Debug/Profiler.h>
-#include <AzCore/Serialization/SerializeContext.h>
-#include <AzCore/Serialization/ObjectStream.h>
-#include <AzCore/Serialization/Utils.h>
-#include <AzCore/IO/GenericStreams.h>
-#include <AzCore/IO/ByteContainerStream.h>
-#include <AzCore/Slice/SliceComponent.h>
-#include <AzCore/Asset/AssetManager.h>
-#include <AzFramework/Slice/SliceEntityBus.h>
-#include <AzToolsFramework/API/ToolsApplicationAPI.h>
-#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-#include <AzToolsFramework/Slice/SliceMetadataEntityContextBus.h>
-#include "PreemptiveUndoCache.h"
-
-#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
-
-// until we have some growing memory array:
-#define STATIC_BUFFERSIZE (1024 * 64)
-
-namespace AzToolsFramework
-{
-    namespace
-    {
-        void LoadEntity(void* pClassPtr, const AZ::Uuid& uuidValue, const AZ::SerializeContext* sc, AZ::Entity** destPtr)
-        {
-            // entity is loaded.
-            *destPtr = sc->Cast<AZ::Entity*>(pClassPtr, uuidValue);
-            AZ_Assert(*destPtr, "Could not cast object to entity!");
-        }
-    }
-
-    EntityStateCommand::EntityStateCommand(UndoSystem::URCommandID ID, const char* friendlyName)
-        : UndoSystem::URSequencePoint(friendlyName ? friendlyName : "Entity Change", ID)
-    {
-        m_entityID = AZ::EntityId(0);
-        m_entityContextId = AzFramework::EntityContextId::CreateNull();
-        m_entityState = AZ::Entity::State::Constructed;
-        m_isSelected = false;
-    }
-    EntityStateCommand::~EntityStateCommand()
-    {
-    }
-
-    void EntityStateCommand::Capture(AZ::Entity* pSourceEntity, bool captureUndo)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        m_entityID = pSourceEntity->GetId();
-        AzFramework::EntityIdContextQueryBus::EventResult(
-            m_entityContextId, m_entityID, &AzFramework::EntityIdContextQueryBus::Events::GetOwningContextId);
-        AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(m_isSelected,
-            &AzToolsFramework::ToolsApplicationRequests::Bus::Events::IsSelected, m_entityID);
-
-        AZ::SliceComponent::EntityRestoreInfo& sliceRestoreInfo = captureUndo ? m_undoSliceRestoreInfo : m_redoSliceRestoreInfo;
-        sliceRestoreInfo = AZ::SliceComponent::EntityRestoreInfo();
-
-        AZ_Assert(pSourceEntity, "Null entity for undo");
-        AZ_Assert(PreemptiveUndoCache::Get(), "You need a pre-emptive undo cache instance to exist for this to work.");
-        AZ_Assert((!captureUndo) || (m_undoState.empty()), "You can't capture undo more than once");
-        AZ::SerializeContext* sc = nullptr;
-        AZ::ComponentApplicationBus::BroadcastResult(sc, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
-        AZ_Assert(sc, "Serialization context not found!");
-
-        m_entityState = pSourceEntity->GetState();
-
-        // The entity is loose, so we capture it directly.
-        if (captureUndo)
-        {
-            m_undoState = PreemptiveUndoCache::Get()->Retrieve(m_entityID);
-            if (m_undoState.empty())
-            {
-                PreemptiveUndoCache::Get()->UpdateCache(m_entityID);
-                m_undoState = PreemptiveUndoCache::Get()->Retrieve(m_entityID);
-            }
-            AZ_Assert(!m_undoState.empty(), "Invalid empty size for the undo state of an entity.");
-        }
-        else
-        {
-            m_redoState.clear();
-            AZ::IO::ByteContainerStream<AZStd::vector<AZ::u8> > ms(&m_redoState);
-            AZ::ObjectStream* objStream = AZ::ObjectStream::Create(&ms, *sc, AZ::ObjectStream::ST_BINARY);
-            if (!objStream->WriteClass(pSourceEntity))
-            {
-                AZ_Assert(false, "Unable to serialize entity for undo/redo. ObjectStream::WriteClass() returned an error.");
-            }
-            if (!objStream->Finalize())
-            {
-                AZ_Assert(false, "Unable to serialize entity for undo/redo. ObjectStream::Finalize() returned an error.");
-            }
-        }
-
-        // If slice-owned, extract the data we need to restore it.
-        AZ::SliceComponent::SliceInstanceAddress sliceInstanceAddr;
-        AzFramework::SliceEntityRequestBus::EventResult(sliceInstanceAddr, m_entityID,
-            &AzFramework::SliceEntityRequestBus::Events::GetOwningSlice);
-        if (sliceInstanceAddr.IsValid())
-        {
-            AZ::SliceComponent* rootSlice = nullptr;
-            AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(rootSlice,
-                &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
-            AZ_Assert(rootSlice, "Failed to retrieve editor root slice.");
-            rootSlice->GetEntityRestoreInfo(m_entityID, sliceRestoreInfo);
-        }
-    }
-
-    void EntityStateCommand::RestoreEntity(const AZ::u8* buffer, AZStd::size_t bufferSizeBytes, const AZ::SliceComponent::EntityRestoreInfo& sliceRestoreInfo) const
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        AZ_Assert(buffer, "No data to undo!");
-        AZ_Assert(bufferSizeBytes, "Undo data is empty.");
-
-        AZ::SerializeContext* serializeContext = nullptr;
-        AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
-        AZ_Assert(serializeContext, "Serialization context not found!");
-        AZ::IO::MemoryStream memoryStream(reinterpret_cast<const char*>(buffer), bufferSizeBytes);
-
-        // If restoring to a slice, keep a reference to the slice asset so it isn't released when the entity
-        // is deleted, only to immediately reload upon restoring.
-        AZ::Data::Asset<AZ::SliceAsset> asset;
-        if (sliceRestoreInfo)
-        {
-            asset = AZ::Data::AssetManager::Instance().FindAsset(sliceRestoreInfo.m_assetId, AZ::Data::AssetLoadBehavior::Default);
-        }
-
-        // We have to delete the entity. If it's currently selected, make sure we re-select after re-creating.
-        AzToolsFramework::EntityIdList selectedEntities;
-        ToolsApplicationRequests::Bus::BroadcastResult(selectedEntities, &ToolsApplicationRequests::Bus::Events::GetSelectedEntities);
-
-        AZ::Entity* entity = nullptr;
-
-        AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationBus::Events::FindEntity, m_entityID);
-        EntityStateCommandNotificationBus::Event(m_entityID, &EntityStateCommandNotificationBus::Events::PreRestore);
-
-        bool isSliceMetadataEntity = false;
-        SliceMetadataEntityContextRequestBus::BroadcastResult(isSliceMetadataEntity, &SliceMetadataEntityContextRequestBus::Events::IsSliceMetadataEntity, m_entityID);
-        AZ::ObjectStream::InplaceLoadRootInfoCB inplaceLoadRootInfoCB;
-        if (isSliceMetadataEntity)
-        {
-            // Instead of deleting the entity, dtor it which will remove and disconnect it entirely
-            entity->~Entity();
-            
-            // placement new to default the entity
-            entity = new(entity) AZ::Entity();
-
-            // Set up a callback so we in-place load over this entity instead of creating it new
-            inplaceLoadRootInfoCB = [entity](void** rootAddress, const AZ::SerializeContext::ClassData** /*classData*/, const AZ::Uuid& /*classId*/, AZ::SerializeContext* /*context*/)
-            {
-                *rootAddress = entity;
-            };
-        }
-        else
-        {
-            // Normal entities will be deleted and loaded anew
-            //AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::DeleteEntity, m_entityID);
-            AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::DeleteEntity, m_entityID);
-        }
-
-        bool success = AZ::ObjectStream::LoadBlocking(&memoryStream, *serializeContext,
-            AZStd::bind(&LoadEntity, AZStd::placeholders::_1, AZStd::placeholders::_2, AZStd::placeholders::_3, &entity),
-            AZ::ObjectStream::FilterDescriptor(AZ::Data::AssetFilterNoAssetLoading),
-            inplaceLoadRootInfoCB);
-        (void)success;
-        AZ_Assert(success, "Unable to serialize entity for undo/redo");
-        AZ_Assert(entity, "Unable to create entity");
-
-        if (entity)
-        {
-            if (sliceRestoreInfo)
-            {
-                AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
-                    &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::RestoreSliceEntity,
-                    entity, sliceRestoreInfo, AzToolsFramework::SliceEntityRestoreType::Deleted);
-            }
-            else
-            {
-                if (!m_entityContextId.IsNull() && !isSliceMetadataEntity)
-                {
-                    AzFramework::EntityContextRequestBus::Event(
-                        m_entityContextId, &AzFramework::EntityContextRequestBus::Events::AddEntity, entity);
-                }
-
-                if (m_entityState == AZ::Entity::State::Init || m_entityState == AZ::Entity::State::Active)
-                {
-                    if (entity->GetState() == AZ::Entity::State::Constructed)
-                    {
-                        entity->Init();
-                    }
-                }
-                if (m_entityState == AZ::Entity::State::Active)
-                {
-                    if (entity->GetState() == AZ::Entity::State::Init)
-                    {
-                        entity->Activate();
-                    }
-                }
-            }
-
-            PreemptiveUndoCache::Get()->UpdateCache(m_entityID);
-
-            if (m_isSelected)
-            {
-                if (AZStd::find(selectedEntities.begin(), selectedEntities.end(), m_entityID) == selectedEntities.end())
-                {
-                    selectedEntities.push_back(m_entityID);
-                }
-            }
-
-            // Signal that an Entity was created since ComponentApplicationBus::Events::DeleteEntity causes
-            // EditorEntityContextNotification::OnEditorEntityDeleted to be fired, we need to have parity
-            // However, we don't send the notification here if we are restoring a slice, because the RestoreSliceEntity
-            // action gets queued so the Entity won't be in a good state yet until the restoration is complete.
-            AzFramework::EntityContextId editorEntityContextId = AzFramework::EntityContextId::CreateNull();
-            EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
-            if (editorEntityContextId == m_entityContextId && !sliceRestoreInfo)
-            {
-                EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
-            }
-
-            EntityStateCommandNotificationBus::Event(m_entityID, &EntityStateCommandNotificationBus::Events::PostRestore, entity);
-        }
-
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::SetSelectedEntities, selectedEntities);
-    }
-
-    void EntityStateCommand::Undo()
-    {
-        RestoreEntity(m_undoState.data(), m_undoState.size(), m_undoSliceRestoreInfo);
-    }
-
-    void EntityStateCommand::Redo()
-    {
-        RestoreEntity(m_redoState.data(), m_redoState.size(), m_redoSliceRestoreInfo);
-    }
-
-    EntityDeleteCommand::EntityDeleteCommand(UndoSystem::URCommandID ID)
-        : EntityStateCommand(ID, "Delete Entity")
-    {
-    }
-
-    void EntityDeleteCommand::Capture(AZ::Entity* pSourceEntity)
-    {
-        PreemptiveUndoCache::Get()->UpdateCache(pSourceEntity->GetId());
-        EntityStateCommand::Capture(pSourceEntity, true);
-    }
-
-    void EntityDeleteCommand::Undo()
-    {
-        RestoreEntity(m_undoState.data(), m_undoState.size(), m_undoSliceRestoreInfo);
-    }
-
-    void EntityDeleteCommand::Redo()
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-        AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::DeleteEntity, m_entityID);
-        PreemptiveUndoCache::Get()->PurgeCache(m_entityID);
-    }
-
-    EntityCreateCommand::EntityCreateCommand(UndoSystem::URCommandID ID)
-        : EntityStateCommand(ID, "Create Entity")
-    {
-    }
-
-    void EntityCreateCommand::Capture(AZ::Entity* pSourceEntity)
-    {
-        EntityStateCommand::Capture(pSourceEntity, false);
-        m_isSelected = true;
-    }
-
-    void EntityCreateCommand::Undo()
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-        AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::DeleteEntity, m_entityID);
-        PreemptiveUndoCache::Get()->PurgeCache(m_entityID);
-    }
-
-    void EntityCreateCommand::Redo()
-    {
-        RestoreEntity(m_redoState.data(), m_redoState.size(), m_redoSliceRestoreInfo);
-    }
-} // namespace AzToolsFramework

+ 0 - 115
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/EntityStateCommand.h

@@ -1,115 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#ifndef AZTOOLSFRAMEWORK_ENTITYSTATECOMMAND_H
-#define AZTOOLSFRAMEWORK_ENTITYSTATECOMMAND_H
-
-#include <AzCore/base.h>
-#include <AzCore/std/containers/vector.h>
-#include <AzCore/Component/EntityId.h>
-
-#include <AzCore/Memory/SystemAllocator.h>
-#include <AzCore/Slice/SliceComponent.h>
-#include <AzFramework/Entity/EntityContextBus.h>
-#include <AzToolsFramework/Undo/UndoSystem.h>
-
-#pragma once
-
-namespace AZ
-{
-    class Entity;
-}
-
-namespace AzToolsFramework
-{
-    class EntityStateCommandNotifications
-        : public AZ::EBusTraits
-    {
-    public:
-        static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
-        using BusIdType = AZ::EntityId;
-
-        virtual void PreRestore() {}
-        virtual void PostRestore(AZ::Entity* /*restoredEntity*/) {}
-    };
-
-    using EntityStateCommandNotificationBus = AZ::EBus<EntityStateCommandNotifications>;
-
-    // The entity State URSequencePoint stores the state of an entity before and after some change to it.
-    // it does so by serializing the entire entity, so its a good "default behavior" that cannot miss any particular change.
-    // we can specialize undos (such as the Entity Transform command) to be more specific and narrower in scope
-    // but at least an Entity State Command should be able to capture everything in its entirety.
-    class EntityStateCommand
-        : public UndoSystem::URSequencePoint
-    {
-    public:
-        AZ_RTTI(EntityStateCommand, "{4461579F-9D39-4954-B5D4-0F9388C8D15D}", UndoSystem::URSequencePoint);
-        AZ_CLASS_ALLOCATOR(EntityStateCommand, AZ::SystemAllocator);
-
-        EntityStateCommand(UndoSystem::URCommandID ID, const char* friendlyName = nullptr);
-        virtual ~EntityStateCommand();
-
-        void Undo() override;
-        void Redo() override;
-
-        // capture the initial state - this fills the undo with the initial data if captureUndo is true
-        // otherwise is captures the final state.
-        void Capture(AZ::Entity* pSourceEntity, bool captureUndo);
-        AZ::EntityId GetEntityID() const { return m_entityID; }
-
-        bool Changed() const override { return m_undoState != m_redoState; }
-
-    protected:
-
-        void RestoreEntity(const AZ::u8* buffer, AZStd::size_t bufferSizeBytes, const AZ::SliceComponent::EntityRestoreInfo& sliceRestoreInfo) const;
-
-        AZ::EntityId m_entityID;                            ///< The Id of the captured entity.
-        AzFramework::EntityContextId m_entityContextId;     ///< The entity context to which the entity belongs (if any).
-        AZ::Entity::State m_entityState;                    ///< The entity state at time of capture (active, constructed, etc).
-        bool m_isSelected;                                  ///< Whether the entity was selected at time of capture.
-
-        AZ::SliceComponent::EntityRestoreInfo m_undoSliceRestoreInfo;
-        AZ::SliceComponent::EntityRestoreInfo m_redoSliceRestoreInfo;
-
-        AZStd::vector<AZ::u8> m_undoState;
-        AZStd::vector<AZ::u8> m_redoState;
-
-        // DISABLE COPY
-        EntityStateCommand(const EntityStateCommand& other) = delete;
-        const EntityStateCommand& operator= (const EntityStateCommand& other) = delete;
-    };
-
-    class EntityDeleteCommand
-        : public EntityStateCommand
-    {
-    public:
-        AZ_RTTI(EntityDeleteCommand, "{2877DC4C-3F09-4E1A-BE3D-921A021DAB80}", EntityStateCommand);
-        AZ_CLASS_ALLOCATOR(EntityDeleteCommand, AZ::SystemAllocator);
-
-        explicit EntityDeleteCommand(UndoSystem::URCommandID ID);
-        void Capture(AZ::Entity* pSourceEntity);
-
-        void Undo() override;
-        void Redo() override;
-    };
-
-    class EntityCreateCommand
-        : public EntityStateCommand
-    {
-    public:
-        AZ_RTTI(EntityCreateCommand, "{C1AA9763-9EC8-4F7B-803E-C04EE3DB3DA9}", EntityStateCommand);
-        AZ_CLASS_ALLOCATOR(EntityCreateCommand, AZ::SystemAllocator);
-
-        explicit EntityCreateCommand(UndoSystem::URCommandID ID);
-        void Capture(AZ::Entity* pSourceEntity);
-
-        void Undo() override;
-        void Redo() override;
-    };
-} // namespace AzToolsFramework
-
-#endif // AZTOOLSFRAMEWORK_ENTITYSTATECOMMAND_H

+ 0 - 181
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PreemptiveUndoCache.cpp

@@ -1,181 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#include <AzCore/Component/ComponentApplicationBus.h>
-#include <AzCore/Debug/Profiler.h>
-#include <AzCore/Serialization/ObjectStream.h>
-#include <AzCore/Serialization/Utils.h>
-#include <AzCore/IO/GenericStreams.h>
-#include <AzCore/IO/ByteContainerStream.h>
-#include <AzCore/Component/Entity.h>
-#include <AzCore/Module/Environment.h>
-#include <AzCore/Slice/SliceComponent.h>
-#include <AzFramework/Entity/EntityContextBus.h>
-
-#include "PreemptiveUndoCache.h"
-
-namespace AzToolsFramework
-{
-    namespace
-    {
-        // configuration options here.
-        const AZ::DataStream::StreamType s_streamType = AZ::DataStream::ST_BINARY;
-
-        struct PreemptiveUndoCacheInstance
-        {
-            PreemptiveUndoCacheInstance()
-                : m_instance(nullptr) {}
-            AzToolsFramework::PreemptiveUndoCache* m_instance;
-        };
-        AZ::EnvironmentVariable<PreemptiveUndoCacheInstance> s_cache;
-    }
-
-    static const char* s_environmentVarName = "PreemptiveUndoCache";
-
-    PreemptiveUndoCache::PreemptiveUndoCache()
-    {
-        if (!AZ::Environment::FindVariable<PreemptiveUndoCacheInstance>(s_environmentVarName))
-        {
-            s_cache = AZ::Environment::CreateVariable<PreemptiveUndoCacheInstance>(s_environmentVarName);
-        }
-
-        AZ_Assert(s_cache, "Failed to create environment variable for PreemptiveUndoCache singleton.");
-        s_cache->m_instance = this;
-    }
-
-    void PreemptiveUndoCache::RegisterToUndoCacheInterface()
-    {
-        AZ::Interface<UndoSystem::UndoCacheInterface>::Register(this);
-    }
-
-    PreemptiveUndoCache::~PreemptiveUndoCache()
-    {
-        if (s_cache)
-        {
-            s_cache->m_instance = nullptr;
-            s_cache.Reset();
-        }
-
-        if (AZ::Interface<UndoSystem::UndoCacheInterface>::Get() == this)
-        {
-            AZ::Interface<UndoSystem::UndoCacheInterface>::Unregister(this);
-        }
-    }
-
-    PreemptiveUndoCache* PreemptiveUndoCache::Get()
-    {
-        auto var = AZ::Environment::FindVariable<PreemptiveUndoCacheInstance>(s_environmentVarName);
-        AZ_Assert(var, "Attempt to get PreemptiveUndoCache when an instance has not been created.");
-        return var->m_instance;
-    }
-
-    void PreemptiveUndoCache::Clear()
-    {
-        m_EntityStateMap.clear();
-    }
-
-    void PreemptiveUndoCache::PurgeCache(const AZ::EntityId& entityId)
-    {
-        m_EntityStateMap.erase(entityId);
-    }
-
-    void PreemptiveUndoCache::UpdateCache(const AZ::EntityId& entityId)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        // capture it
-
-        AZ::Entity* pEnt = nullptr;
-        AZ::ComponentApplicationBus::BroadcastResult(pEnt, &AZ::ComponentApplicationBus::Events::FindEntity, entityId);
-        if (!pEnt)
-        {
-            AZ_Warning("Undo", false, "Preemptive Undo Cache was told to update the cache for a particular entity, but that entity is not available in FindEntity");
-            return;
-        }
-
-        // entity found, snap it!
-        CacheLineType& newData = m_EntityStateMap[entityId];
-        newData.clear();
-        AZ::IO::ByteContainerStream<CacheLineType> ms(&newData);
-
-        AZ::SerializeContext* sc = nullptr;
-        AZ::ComponentApplicationBus::BroadcastResult(sc, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
-        AZ_Assert(sc, "Serialization context not found!");
-
-        // capture state.
-        AZ::ObjectStream* objStream = AZ::ObjectStream::Create(&ms, *sc, s_streamType);
-        if (!objStream->WriteClass(pEnt))
-        {
-            AZ_Assert(false, "Unable to serialize entity for undo/redo. ObjectStream::WriteClass() returned an error.");
-            return;
-        }
-
-        if (!objStream->Finalize())
-        {
-            AZ_Assert(false, "Unable to serialize entity for undo/redo. ObjectStream::Finalize() returned an error.");
-            return;
-        }
-    }
-
-    void PreemptiveUndoCache::Validate(const AZ::EntityId& entityId)
-    {
-        (void)entityId;
-
-#if defined(ENABLE_UNDOCACHE_CONSISTENCY_CHECKS)
-        if (entityId == AZ::SystemEntityId)
-        {
-            return;
-        }
-
-        CacheLineType oldData = Retrieve(entityId);
-
-        if (oldData.empty())
-        {
-            // this is ok.  It means the entity is not being tracked in the cache.
-            // for example, its not an actual undoable entity.
-            return;
-        }
-
-        UpdateCache(entityId);
-        const CacheLineType& newData = Retrieve(entityId);
-        if (newData != oldData)
-        {
-            // display a useful message
-            AZ::Entity* pEnt = nullptr;
-            AZ::ComponentApplicationBus::BroadcastResult(pEnt, &AZ::ComponentApplicationBus::Events::FindEntity, entityId);
-            if (!pEnt)
-            {
-                AZ_Warning("Undo", false, "Undo system wasn't informed about the deletion of entity %p - make sure you call DeleteEntity, instead of directly deleting it.\n", entityId);
-                return;
-            }
-
-            AZ_Warning("Undo", false, "Undo system has inconsistent data for entity %p (%s) - Old Size: %llu - New Size: %llu\n  Ensure that SetDirty is being called (or WorldEditor::WorldEditorMessages::Bus, AddDirtyEntity...) for modified entities.",
-                entityId, pEnt->GetName().c_str(),
-                oldData.size(), newData.size());
-        }
-
-        // Clear out newly generated data and
-        // replace with original data to ensure debug mode has the same data as profile/release in the event of the consistency check failing.
-        m_EntityStateMap[entityId].clear();
-        m_EntityStateMap[entityId] = oldData;
-#endif // ENABLE_UNDOCACHE_CONSISTENCY_CHECKS
-    }
-
-    const PreemptiveUndoCache::CacheLineType& PreemptiveUndoCache::Retrieve(const AZ::EntityId& entityId)
-    {
-        auto it = m_EntityStateMap.find(entityId);
-
-        if (it == m_EntityStateMap.end())
-        {
-            return m_Empty;
-        }
-
-        return it->second;
-    }
-
-} // namespace AzToolsFramework

+ 0 - 65
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PreemptiveUndoCache.h

@@ -1,65 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#ifndef PREEMPTIVE_UNDO_CACHE_H
-#define PREEMPTIVE_UNDO_CACHE_H
-
-#include <AzCore/base.h>
-#include <AzCore/Memory/SystemAllocator.h>
-#include <AzCore/Component/EntityId.h>
-#include <AzCore/Asset/AssetCommon.h>
-#include <AzCore/std/containers/unordered_map.h>
-
-#include <AzToolsFramework/Undo/UndoCacheInterface.h>
-
-// Enable to generate warnings for entity data changes not caught by undo batches.
-#if defined(AZ_DEBUG_BUILD) && !defined(ENABLE_UNDOCACHE_CONSISTENCY_CHECKS)
-#   define ENABLE_UNDOCACHE_CONSISTENCY_CHECKS
-#endif
-
-namespace AzToolsFramework
-{
-    // The purpose of the pre-emptive Undo Cache is to keep a snapshot of the last known state of any undoable objects
-    // so that the user does not have to inform us before they make a change, only after they make a change
-    // it also allows us to detect errors with change notification and not have to do multiple snapshots (before and after)
-    class PreemptiveUndoCache
-        : UndoSystem::UndoCacheInterface
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(PreemptiveUndoCache, AZ::SystemAllocator);
-
-        static PreemptiveUndoCache* Get();
-        PreemptiveUndoCache();
-        virtual ~PreemptiveUndoCache();
-
-        void RegisterToUndoCacheInterface();
-
-        // UndoCacheInterface...
-        void UpdateCache(const AZ::EntityId& entityId) override;
-        void PurgeCache(const AZ::EntityId& entityId) override;
-        void Clear() override;
-        void Validate(const AZ::EntityId& entityId) override;
-
-        // whenever an entity appears in the world, as an atomic operation (ie, after all of its loading is complete, and the entity is active)
-        // we snapshot it here. then, whenever an entity changes, we have what it used to be.
-        typedef AZStd::vector<AZ::u8> CacheLineType;
-
-        // retrieve the last known state for an entity
-        const CacheLineType& Retrieve(const AZ::EntityId& entityId);
-
-    protected:
-        typedef AZStd::unordered_map<AZ::EntityId, CacheLineType> EntityStateMap;
-
-        EntityStateMap m_EntityStateMap;
-
-        CacheLineType m_Empty;
-    };
-} // namespace AzToolsFramework
-
-#pragma once
-
-#endif

+ 0 - 95
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PushToSliceCommand.cpp

@@ -1,95 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#include "PushToSliceCommand.h"
-
-#include <AzCore/Component/TransformBus.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-#include <AzToolsFramework/Slice/SliceUtilities.h>
-namespace AzToolsFramework
-{
-    PushToSliceCommand::PushToSliceCommand(const AZStd::string& friendlyName)
-        : BaseSliceCommand(friendlyName)
-    {
-    }
-
-    void PushToSliceCommand::Capture(const AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const AZStd::unordered_map<AZ::EntityId, AZ::EntityId>& addedEntityIdRemaps)
-    {
-        if (!sliceAsset.Get())
-        {
-            AZ_Error("PushToSliceCommand::Capture",
-                false,
-                "Invalid SliceAsset passed in. Unable to capture undo/redo state");
-
-            return;
-        }
-
-        // Nothing to do if no remaps
-        if (addedEntityIdRemaps.empty())
-        {
-            AZ_Warning("PushToSliceCommand::Capture",
-                false,
-                "Emtpty addedEntityIdRemaps passed in. Nothing to undo/redo");
-
-            return;
-        }
-
-        AZ::SliceComponent* editorRootSlice = nullptr;
-        SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(editorRootSlice,
-            &SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
-
-        // Find the parent EntityID highest up in the slice hierarchy
-        AZ::EntityId parentId;
-        AZ::TransformBus::EventResult(parentId, addedEntityIdRemaps.begin()->first, &AZ::TransformBus::Events::GetParentId);
-
-        while (parentId.IsValid() && !SliceUtilities::IsSliceOrSubsliceRootEntity(parentId))
-        {
-            AZ::EntityId currentParentId = parentId;
-            AZ::TransformBus::EventResult(parentId, currentParentId, &AZ::TransformBus::Events::GetParentId);
-        }
-
-        if (!parentId.IsValid())
-        {
-            AZ_Error("SliceUtilities::SlicePostPushCallback", false, "Unable to find Slice Parent Entity cannot proceed with callback");
-            return;
-        }
-
-        // Acquire the highest level owning slice of this hierarchy
-        AZ::SliceComponent::SliceInstanceAddress targetSliceAddress = editorRootSlice->FindSlice(parentId);
-
-        // Capture undo state for each entity
-        for (auto addedIdRemapPair : addedEntityIdRemaps)
-        {
-            const AZ::EntityId& liveEntityId = addedIdRemapPair.first;
-            const AZ::EntityId& assetEntityId = addedIdRemapPair.second;
-
-            // Manufacture restoreInfo for the redo to add the entity back into targetSliceAddress
-            AZ::SliceComponent::EntityRestoreInfo redoRestoreInfo(sliceAsset, targetSliceAddress.GetInstance()->GetId(), assetEntityId, AZ::DataPatch::FlagsMap());
-            m_entityRedoRestoreInfoArray.emplace_back(liveEntityId, redoRestoreInfo);
-
-            bool restoreCaptured = BaseSliceCommand::CaptureRestoreInfoForUndo(liveEntityId);
-
-            if (!restoreCaptured)
-            {
-                m_entityRedoRestoreInfoArray.clear();
-                m_entityUndoRestoreInfoArray.clear();
-
-                return;
-            }
-        }
-    }
-
-    void PushToSliceCommand::Undo()
-    {
-        BaseSliceCommand::RestoreEntities(m_entityUndoRestoreInfoArray);
-    }
-
-    void PushToSliceCommand::Redo()
-    {
-        BaseSliceCommand::RestoreEntities(m_entityRedoRestoreInfoArray, false, AzToolsFramework::SliceEntityRestoreType::Added);
-    }
-}

+ 0 - 31
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/PushToSliceCommand.h

@@ -1,31 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#pragma once
-
-#include <AzCore/Slice/SliceComponent.h>
-
-#include <AzToolsFramework/Commands/BaseSliceCommand.h>
-namespace AzToolsFramework
-{
-    class PushToSliceCommand
-        : public BaseSliceCommand
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(PushToSliceCommand, AZ::SystemAllocator);
-        AZ_RTTI(PushToSliceCommand, "{3FDCD751-EB10-40C0-857C-F5038E592E1E}");
-
-        PushToSliceCommand(const AZStd::string& friendlyName);
-
-        ~PushToSliceCommand() {}
-
-        void Capture(const AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const AZStd::unordered_map<AZ::EntityId, AZ::EntityId>& addedEntityIdRemaps);
-
-        void Undo() override;
-        void Redo() override;
-    };
-}

+ 0 - 28
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/SliceDetachEntityCommand.cpp

@@ -1,28 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#include "SliceDetachEntityCommand.h"
-
-namespace AzToolsFramework
-{
-    SliceDetachEntityCommand::SliceDetachEntityCommand(const AzToolsFramework::EntityIdList& entityIds, const AZStd::string& friendlyName)
-        : BaseSliceCommand(friendlyName)
-        , m_entityIds(entityIds)
-    {}
-
-    void SliceDetachEntityCommand::Undo()
-    {
-        RestoreEntities(m_entityUndoRestoreInfoArray, true);
-    }
-
-    void SliceDetachEntityCommand::Redo()
-    {
-        AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-            m_changed, &AzToolsFramework::ToolsApplicationRequestBus::Events::DetachEntities, m_entityIds, m_entityUndoRestoreInfoArray);
-    }
-}

+ 0 - 40
Code/Framework/AzToolsFramework/AzToolsFramework/Commands/SliceDetachEntityCommand.h

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#pragma once
-
-#include <AzCore/base.h>
-#include <AzCore/Memory/SystemAllocator.h>
-#include <AzCore/RTTI/RTTI.h>
-#include <AzCore/Component/ComponentBus.h>
-
-#include <AzToolsFramework/API/ToolsApplicationAPI.h>
-#include <AzToolsFramework/Commands/BaseSliceCommand.h>
-
-namespace AzToolsFramework
-{
-    /**
-    * Stores information about Entities that are being detached from their slice
-    */
-    class SliceDetachEntityCommand
-        : public BaseSliceCommand
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(SliceDetachEntityCommand, AZ::SystemAllocator);
-        AZ_RTTI(SliceDetachEntityCommand, "{FD26D09E-FD95-4D8C-8575-E01DA7100240}");
-
-        SliceDetachEntityCommand(const AzToolsFramework::EntityIdList& entityIds, const AZStd::string& friendlyName);
-
-        ~SliceDetachEntityCommand() {}
-
-        void Undo() override;
-        void Redo() override;
-
-    protected:
-        AzToolsFramework::EntityIdList m_entityIds; // Used for redo when no information is known other than a selected entity list
-    };
-} // namespace AzToolsFramework

+ 20 - 2
Code/Framework/AzToolsFramework/AzToolsFramework/ContainerEntity/ContainerEntitySystemComponent.cpp

@@ -10,6 +10,7 @@
 
 #include <AzCore/Component/TransformBus.h>
 #include <AzToolsFramework/API/ToolsApplicationAPI.h>
+#include <AzToolsFramework/API/ViewportEditorModeTrackerInterface.h>
 #include <AzToolsFramework/ContainerEntity/ContainerEntityNotificationBus.h>
 #include <AzToolsFramework/Prefab/PrefabEditorPreferences.h>
 #include <AzToolsFramework/Prefab/PrefabFocusPublicInterface.h>
@@ -113,6 +114,16 @@ namespace AzToolsFramework
             return entityId;
         }
 
+        // is entity pick mode enabled?
+        bool isEntityPickModeEnabled = false;
+        if (auto viewportEditorModeTracker = AZ::Interface<AzToolsFramework::ViewportEditorModeTrackerInterface>::Get())
+        {
+            auto entityContextId = AzFramework::EntityContextId::CreateNull();
+            EditorEntityContextRequestBus::BroadcastResult(entityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
+            isEntityPickModeEnabled = viewportEditorModeTracker->GetViewportEditorModes({ entityContextId })
+                                          ->IsModeActive(AzToolsFramework::ViewportEditorMode::Pick);
+        }
+
         auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
         EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
 
@@ -141,12 +152,19 @@ namespace AzToolsFramework
                 {
                     if (AZStd::find(selectedEntities.begin(), selectedEntities.end(), entityId) != selectedEntities.end())
                     {
-                        // Found a selected container
+                        if (!IsContainerOpen(entityId))
+                        {
+                            // If the selected container is closed, keep selecting it.
+                            highestUnselectedAncestorContainer = entityId;
+                        }
                         break;
                     }
                     else
                     {
-                        highestUnselectedAncestorContainer = entityId;
+                        if (!isEntityPickModeEnabled || !IsContainerOpen(entityId))
+                        {
+                            highestUnselectedAncestorContainer = entityId;
+                        }
                     }
                 }
 

+ 1 - 0
Code/Framework/AzToolsFramework/AzToolsFramework/Editor/ActionManagerIdentifiers/EditorActionUpdaterIdentifiers.h

@@ -14,6 +14,7 @@ namespace EditorIdentifiers
 {
     inline constexpr AZStd::string_view AngleSnappingStateChangedUpdaterIdentifier = "o3de.updater.onAngleSnappingStateChanged";
     inline constexpr AZStd::string_view ComponentModeChangedUpdaterIdentifier = "o3de.updater.onComponentModeChanged";
+    inline constexpr AZStd::string_view ComponentSelectionChangedUpdaterIdentifier = "o3de.updater.onComponentSelectionChanged";
     inline constexpr AZStd::string_view ContainerEntityStatesChangedUpdaterIdentifier = "o3de.updater.onContainerEntityStatesChanged";
     inline constexpr AZStd::string_view DrawHelpersStateChangedUpdaterIdentifier = "o3de.updater.onViewportDrawHelpersStateChanged";
     inline constexpr AZStd::string_view EntityPickingModeChangedUpdaterIdentifier = "o3de.updater.onEntityPickingModeChanged";

+ 2 - 0
Code/Framework/AzToolsFramework/AzToolsFramework/Editor/ActionManagerIdentifiers/EditorMenuIdentifiers.h

@@ -51,6 +51,8 @@ namespace EditorIdentifiers
 
     // Editor Widget Menus
     inline constexpr AZStd::string_view EntityOutlinerContextMenuIdentifier = "o3de.menu.editor.entityOutliner.context";
+    inline constexpr AZStd::string_view InspectorEntityComponentContextMenuIdentifier = "o3de.menu.editor.inspector.component.context";
+    inline constexpr AZStd::string_view InspectorEntityPropertyContextMenuIdentifier = "o3de.menu.editor.inspector.property.context";
 
     // Entity creation menu
     inline constexpr AZStd::string_view EntityCreationMenuIdentifier = "o3de.menu.entity.create";

+ 0 - 92
Code/Framework/AzToolsFramework/AzToolsFramework/Editor/EditorContextMenuBus.h

@@ -1,92 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-#pragma once
-
-#include <AzCore/EBus/EBus.h>
-#include <AzCore/Math/Vector2.h>
-#include <AzCore/Outcome/Outcome.h>
-#include <AzCore/std/any.h>
-#include <AzCore/std/string/string.h>
-
-class QMenu;
-
-namespace AzFramework
-{
-    struct ScreenPoint;
-}
-
-namespace AzToolsFramework
-{
-    enum class EditorContextMenuOrdering
-    {
-        TOP = 0,
-        MIDDLE = 500,
-        BOTTOM = 1000
-    };
-
-    //! Editor Settings API Bus
-    class EditorContextMenuEvents
-        : public AZ::EBusTraits
-    {
-    public:
-        virtual ~EditorContextMenuEvents() = default;
-
-        static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::MultipleAndOrdered;
-        static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
-        
-        /**
-         * Determines the order in which handlers populate the context menus.
-         */
-        struct BusHandlerOrderCompare
-        {
-            AZ_FORCE_INLINE bool operator()(EditorContextMenuEvents* left, EditorContextMenuEvents* right) const
-            {
-                if (left->GetMenuPosition() == right->GetMenuPosition())
-                {
-                    return left->GetMenuIdentifier() < right->GetMenuIdentifier();
-                }
-
-                return left->GetMenuPosition() < right->GetMenuPosition();
-            }
-        };
-
-        /**
-         * Specifies the order in which a handler receives context menu events relative to other handlers.
-         * This value should not be changed while the handler is connected.
-         * Use the EditorContextMenuOrdering enum values as a baseline.
-         * @return A value specifying this handler's relative order.
-         */
-        virtual int GetMenuPosition() const
-        {
-            return aznumeric_cast<int>(EditorContextMenuOrdering::BOTTOM);
-        }
-
-        /**
-         * Returns the identifier for this handler.
-         * Used to break ties in the order comparison.
-         * @return A string containing the identifier for this handler.
-         */
-        virtual AZStd::string GetMenuIdentifier() const
-        {
-            return "";
-        }
-
-        /**
-         * Appends menu items to the global editor context menu.
-         * This is the menu that appears when right clicking the main editor window,
-         * including the Entity Outliner and the Viewport.
-         * @param menu The QMenu to append menu items to.
-         * @param point An optional screen point indicating where the user clicked in the 3d viewport for entity placement.
-         *              note: AZStd::nullopt may be passed when the context menu is created outside of the 3d viewport.
-         * @param flags See EditorEvents::EditorContextMenuFlags for available flags to pass.
-         */
-        virtual void PopulateEditorGlobalContextMenu(QMenu* menu, const AZStd::optional<AzFramework::ScreenPoint>& point, int flags) = 0;
-    };
-
-    using EditorContextMenuBus = AZ::EBus<EditorContextMenuEvents>;
-}

+ 0 - 27
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.cpp

@@ -31,8 +31,6 @@
 #include <AzFramework/StringFunc/StringFunc.h>
 
 #include <AzToolsFramework/API/EntityCompositionRequestBus.h>
-#include <AzToolsFramework/Commands/PreemptiveUndoCache.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
 #include <AzToolsFramework/Commands/SelectionCommand.h>
 
 #include <AzToolsFramework/ToolsComponents/EditorEntityIconComponent.h>
@@ -162,11 +160,7 @@ namespace AzToolsFramework
         m_entityOwnershipService->InstantiateAllPrefabs();
 
         EditorEntityContextRequestBus::Handler::BusConnect();
-
         EditorEntityContextPickingRequestBus::Handler::BusConnect(GetContextId());
-
-        SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
-
         EditorLegacyGameModeNotificationBus::Handler::BusConnect();
     }
 
@@ -176,11 +170,7 @@ namespace AzToolsFramework
     void EditorEntityContextComponent::Deactivate()
     {
         EditorLegacyGameModeNotificationBus::Handler::BusDisconnect();
-
-        SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
-
         EditorEntityContextRequestBus::Handler::BusDisconnect();
-
         EditorEntityContextPickingRequestBus::Handler::BusDisconnect();
 
         DestroyContext();
@@ -685,23 +675,6 @@ namespace AzToolsFramework
         AZ::Data::AssetManager::Instance().ResumeAssetRelease();
     }
 
-    void EditorEntityContextComponent::OnSaveStreamForGameBegin(AZ::IO::GenericStream& gameStream, AZ::DataStream::StreamType streamType,
-        AZStd::vector<AZStd::unique_ptr<AZ::Entity>>& levelEntities)
-    {
-        EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnSaveStreamForGameBegin,
-            gameStream, streamType, levelEntities);
-    }
-
-    void EditorEntityContextComponent::OnSaveStreamForGameSuccess(AZ::IO::GenericStream& gameStream)
-    {
-        EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnSaveStreamForGameSuccess, gameStream);
-    }
-
-    void EditorEntityContextComponent::OnSaveStreamForGameFailure(AZStd::string_view failureString)
-    {
-        EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnSaveStreamForGameFailure, failureString);
-    }
-    
     void EditorEntityContextComponent::OnStartGameModeRequest()
     {
         m_isRequestingGame = true;

+ 2 - 11
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityContextComponent.h

@@ -20,8 +20,6 @@
 #include <AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.h>
 
 #include <AzToolsFramework/Entity/EditorEntityContextPickingBus.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipService.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
 
 #include "EditorEntityContextBus.h"
 
@@ -54,7 +52,6 @@ namespace AzToolsFramework
         , private EditorEntityContextRequestBus::Handler
         , private EditorEntityContextPickingRequestBus::Handler
         , private EditorLegacyGameModeNotificationBus::Handler
-        , private SliceEditorEntityOwnershipServiceNotificationBus::Handler
     {
     public:
 
@@ -153,14 +150,6 @@ namespace AzToolsFramework
 
     private:
         EditorEntityContextComponent(const EditorEntityContextComponent&) = delete;
-
-        //////////////////////////////////////////////////////////////////////////
-        // SliceEditorEntityOwnershipServiceNotificationBus
-        void OnSaveStreamForGameBegin(AZ::IO::GenericStream& gameStream, AZ::DataStream::StreamType streamType,
-            AZStd::vector<AZStd::unique_ptr<AZ::Entity>>& levelEntities) override;
-        void OnSaveStreamForGameSuccess(AZ::IO::GenericStream& gameStream) override;
-        void OnSaveStreamForGameFailure(AZStd::string_view failureString) override;
-        //////////////////////////////////////////////////////////////////////////
         
         // EditorLegacyGameModeNotificationBus ...
         void OnStartGameModeRequest() override;
@@ -175,6 +164,8 @@ namespace AzToolsFramework
         EntityIdList m_selectedBeforeStartingGame;
 
         //! Bidirectional mapping of runtime entity Ids to their editor counterparts (relevant during in-editor simulation).
+        using EntityIdToEntityIdMap = AZStd::unordered_map<AZ::EntityId, AZ::EntityId>;
+
         EntityIdToEntityIdMap m_editorToRuntimeIdMap;
         EntityIdToEntityIdMap m_runtimeToEditorIdMap;
 

+ 0 - 274
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp

@@ -16,11 +16,9 @@
 #include <AzCore/RTTI/AttributeReader.h>
 #include <AzCore/Serialization/SerializeContext.h>
 #include <AzFramework/API/ApplicationAPI.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
 #include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
 #include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
 #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
 #include <AzToolsFramework/FocusMode/FocusModeInterface.h>
 #include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
 #include <AzToolsFramework/Slice/SliceMetadataEntityContextBus.h>
@@ -59,37 +57,6 @@ namespace AzToolsFramework
             AZ::SliceComponent::InstantiatedContainer& inout_allEntityClones,
             const AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap);
 
-        /// Internal helper function for CloneInstantiatedEntities. Selects all cloned entities, and updates the undo stack with
-        /// information on all cloned entities.
-        /// @param allEntityClones The collection of all entities that were cloned.
-        /// @param undoBatch The undo batch used for tracking the cloning operation.
-        void UpdateUndoStackAndSelectClonedEntities(
-            const EntityList& allEntityClones,
-            ScopedUndoBatch& undoBatch);
-
-        /// Internal helper function for CloneInstantiatedEntities. If the given entity identified by the ancestor list is a slice root, clone it.
-        /// @param ancestors The entity to clone if it is a slice root entity, tracked through its ancestry.
-        /// @param out_allEntityClones Output parameter populated with all cloned entities.
-        /// @param out_sourceToCloneEntityIdMap Output parameter populated with a map from all source entities to cloned entities.
-        /// @return True if the passed in entity was cloned, false if not.
-        bool CloneIfSliceRoot(
-            const AZ::SliceComponent::EntityAncestorList& ancestors,
-            EntityList& out_allEntityClones,
-            AZ::SliceComponent::EntityIdToEntityIdMap& out_sourceToCloneEntityIdMap);
-
-        /// Internal helper function for CloneInstantiatedEntities. If the given entity identified by the slice address and
-        /// ancestor list is a subslice root, clone it.
-        /// @param owningSliceAddress The slice address that owns this entity. This is necessary to clone the subslice.
-        /// @param ancestors The entity to clone if it is a subslice root entity, tracked through its ancestry.
-        /// @param out_allEntityClones Output parameter populated with all cloned entities.
-        /// @param out_sourceToCloneEntityIdMap Output parameter populated with a map from all source entities to cloned entities.
-        /// @return True if the passed in entity was cloned, false if not.
-        bool CloneIfSubsliceRoot(
-            const AZ::SliceComponent::SliceInstanceAddress& owningSliceAddress,
-            const AZ::SliceComponent::EntityAncestorList& ancestors,
-            EntityList& out_allEntityClones,
-            AZ::SliceComponent::EntityIdToEntityIdMap& out_sourceToCloneEntityIdMap);
-
         /// Internal helper function for CloneInstantiatedEntities. Clones the given entity collection as loose entities.
         /// @param duplicationList The collection of entities to clone.
         /// @param out_allEntityClones Output parameter populated with all cloned entities.
@@ -960,60 +927,6 @@ namespace AzToolsFramework
             &AzToolsFramework::ToolsApplicationRequestBus::Events::SetSelectedEntities, entities);
     }
 
-    bool CloneInstantiatedEntities(const EntityIdSet& entitiesToClone, EntityIdSet& clonedEntities)
-    {
-        EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::SetForceAddEntitiesToBackFlag, true);
-        ScopedUndoBatch undoBatch("Clone Selection");
-
-        // Track the mapping of source to cloned entity. This both helps make sure that an entity is not accidentally
-        // cloned twice, as well as provides the information needed to remap entity references.
-        AZ::SliceComponent::EntityIdToEntityIdMap sourceToCloneEntityIdMap;
-        // Track every entity that has been cloned in the container type that AZ::EntityUtils::ReplaceEntityRefs uses.
-        AZ::SliceComponent::InstantiatedContainer allEntityClonesContainer(false);
-        // Loose entities can all be cloned at once, so track each one found while looking for slice instances to clone.
-        EntityIdList looseEntitiesToClone;
-
-        // Clone the entities.
-        Internal::CloneSliceEntitiesAndChildren(
-            entitiesToClone,
-            allEntityClonesContainer.m_entities,
-            sourceToCloneEntityIdMap,
-            looseEntitiesToClone);
-        // All entities cloned so far are slice entities, so store those in a container to use for adding to the editor.
-        EntityList clonedSliceEntities(allEntityClonesContainer.m_entities.begin(), allEntityClonesContainer.m_entities.end());
-        // Capture all cloned loose entities, so they can be added to the editor.
-        EntityList clonedLooseEntities;
-
-        Internal::CloneLooseEntities(
-            looseEntitiesToClone,
-            allEntityClonesContainer.m_entities,
-            sourceToCloneEntityIdMap,
-            clonedLooseEntities);
-
-        // Update any references cloned entities have to each other.
-        Internal::UpdateClonedEntityReferences(allEntityClonesContainer, sourceToCloneEntityIdMap);
-
-        // Add the cloned entities to the editor, which will also activate them.
-        EditorEntityContextRequestBus::Broadcast(
-            &EditorEntityContextRequests::AddEditorEntities,
-            clonedLooseEntities);
-        EditorEntityContextRequestBus::Broadcast(
-            &EditorEntityContextRequests::HandleEntitiesAdded, clonedSliceEntities);
-
-        // Make sure an undo operation will delete all of these cloned entities.
-        // Also replace the selection with the entities that have been cloned.
-        Internal::UpdateUndoStackAndSelectClonedEntities(allEntityClonesContainer.m_entities, undoBatch);
-
-        EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::SetForceAddEntitiesToBackFlag, false);
-
-        for (const AZ::Entity* entity : allEntityClonesContainer.m_entities)
-        {
-            clonedEntities.insert(entity->GetId());
-        }
-
-        return !allEntityClonesContainer.m_entities.empty();
-    }
-
     EntityIdSet GetCulledEntityHierarchy(const EntityIdList& entities)
     {
         EntityIdSet culledEntities;
@@ -1090,76 +1003,6 @@ namespace AzToolsFramework
 
     namespace Internal
     {
-        void CloneSliceEntitiesAndChildren(
-            const EntityIdSet& duplicationSet,
-            EntityList& out_allEntityClones,
-            AZ::SliceComponent::EntityIdToEntityIdMap& out_sourceToCloneEntityIdMap,
-            EntityIdList& out_looseEntitiesToClone)
-        {
-            for (const AZ::EntityId& entityId : duplicationSet)
-            {
-                AZ::SliceComponent::SliceInstanceAddress owningSliceAddress;
-                AzFramework::SliceEntityRequestBus::EventResult(owningSliceAddress, entityId,
-                    &AzFramework::SliceEntityRequestBus::Events::GetOwningSlice);
-                AZ::SliceComponent::EntityAncestorList ancestors;
-                bool hasInstanceEntityAncestors = false;
-                if (owningSliceAddress.IsValid())
-                {
-                    hasInstanceEntityAncestors = owningSliceAddress.GetReference()->GetInstanceEntityAncestry(entityId, ancestors);
-                }
-                AZ::SliceComponent::SliceInstanceAddress sourceSliceInstance;
-
-                // Don't clone if this entity has already been cloned.
-                if (out_sourceToCloneEntityIdMap.find(entityId) != out_sourceToCloneEntityIdMap.end())
-                {
-                }
-                // Slice roots take first priority when cloning.
-                else if (hasInstanceEntityAncestors &&
-                    CloneIfSliceRoot(
-                        ancestors,
-                        out_allEntityClones,
-                        out_sourceToCloneEntityIdMap))
-                {
-                }
-                // Subslice roots take second priority.
-                else if (hasInstanceEntityAncestors &&
-                    CloneIfSubsliceRoot(
-                        owningSliceAddress,
-                        ancestors,
-                        out_allEntityClones,
-                        out_sourceToCloneEntityIdMap))
-                {
-                }
-                else
-                {
-                    // If this wasn't a slice root or subslice root, clone it as a loose entity.
-                    out_looseEntitiesToClone.push_back(entityId);
-                }
-
-                // Search through all the children of this entity for anything that needs to be cloned.
-                // Slice instance entities that are not subslice roots will have been cloned already
-                // when the slice root was cloned or the subslice root was cloned. Entities may exist
-                // in the hierarchy that weren't cloned if they are entities that have a slice instance entity
-                // as a parent, but the entity itself is not part of that slice instance.
-                EntityIdList children;
-                AZ::TransformBus::EventResult(
-                    /*result*/ children,
-                    /*address*/ entityId,
-                    &AZ::TransformBus::Events::GetChildren);
-
-                EntityIdSet childrenSet;
-                for (const AZ::EntityId& child : children)
-                {
-                    childrenSet.insert(child);
-                }
-                CloneSliceEntitiesAndChildren(
-                    childrenSet,
-                    out_allEntityClones,
-                    out_sourceToCloneEntityIdMap,
-                    out_looseEntitiesToClone);
-            }
-        }
-
         void UpdateClonedEntityReferences(
             AZ::SliceComponent::InstantiatedContainer& inout_allEntityClones,
             const AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap)
@@ -1185,123 +1028,6 @@ namespace AzToolsFramework
             });
         }
 
-        void UpdateUndoStackAndSelectClonedEntities(
-            const EntityList& allEntityClones,
-            ScopedUndoBatch &undoBatch)
-        {
-            EntityIdList selectEntities;
-            selectEntities.reserve(allEntityClones.size());
-            for (AZ::Entity* newEntity : allEntityClones)
-            {
-                AZ::EntityId entityId = newEntity->GetId();
-                selectEntities.push_back(entityId);
-
-                // Make sure all cloned entities are contained within the currently active undo batch command.
-                EntityCreateCommand* command = aznew EntityCreateCommand(
-                    static_cast<UndoSystem::URCommandID>(entityId));
-                command->Capture(newEntity);
-                command->SetParent(undoBatch.GetUndoBatch());
-            }
-            // Clear selection and select everything we cloned.
-            ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, selectEntities);
-        }
-
-        bool CloneIfSliceRoot(
-            const AZ::SliceComponent::EntityAncestorList& ancestors,
-            EntityList& out_allEntityClones,
-            AZ::SliceComponent::EntityIdToEntityIdMap& out_sourceToCloneEntityIdMap)
-        {
-            // This entity can't be a slice root if it has no ancestors.
-            if (ancestors.size() <= 0)
-            {
-                return false;
-            }
-            // This entity is a slice root if it is the root entity of the first ancestor.
-            if (!ancestors[0].m_entity || !SliceUtilities::IsRootEntity(*ancestors[0].m_entity))
-            {
-                return false;
-            }
-
-            AZ::SliceComponent::EntityIdToEntityIdMap sourceToCloneSliceEntityIdMap;
-            AZ::SliceComponent::SliceInstanceAddress newInstance;
-            SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(newInstance,
-                &SliceEditorEntityOwnershipServiceRequests::CloneEditorSliceInstance,
-                ancestors[0].m_sliceAddress, sourceToCloneSliceEntityIdMap);
-
-            if (!newInstance.IsValid())
-            {
-                AZ_Warning(
-                    "Cloning",
-                    false,
-                    "Unable to clone slice instance, check your duplicated entity selection and verify it contains the entities you expect to see.");
-                return false;
-            }
-
-            for (AZ::Entity* clone : newInstance.GetInstance()->GetInstantiated()->m_entities)
-            {
-                out_allEntityClones.push_back(clone);
-            }
-            for (const AZStd::pair<AZ::EntityId, AZ::EntityId>& sourceIdToCloneId : sourceToCloneSliceEntityIdMap)
-            {
-                out_sourceToCloneEntityIdMap.insert(sourceIdToCloneId);
-            }
-            return true;
-        }
-
-        bool CloneIfSubsliceRoot(
-            const AZ::SliceComponent::SliceInstanceAddress& owningSliceAddress,
-            const AZ::SliceComponent::EntityAncestorList& ancestors,
-            EntityList& out_allEntityClones,
-            AZ::SliceComponent::EntityIdToEntityIdMap& out_sourceToCloneEntityIdMap)
-        {
-            bool result = false;
-            // This entity can't be a subslice root if there was only one ancestor.
-            if (ancestors.size() <= 1)
-            {
-                return result;
-            }
-
-            AZStd::vector<AZ::SliceComponent::SliceInstanceAddress> sourceSubSliceAncestry;
-
-
-            AZ::SliceComponent::EntityAncestorList::const_iterator ancestorIter = ancestors.begin();
-            // Skip the first, that would be a regular slice root and not a subslice root, which was already checked.
-            ++ancestorIter;
-            for (; ancestorIter != ancestors.end(); ++ancestorIter)
-            {
-                const AZ::SliceComponent::Ancestor& ancestor = *ancestorIter;
-                if (!ancestor.m_entity || !SliceUtilities::IsRootEntity(*ancestor.m_entity))
-                {
-                    // This entity was not the root entity of this slice, so add the slice to the ancestor
-                    // list and move on to the next ancestor.
-                    sourceSubSliceAncestry.push_back(ancestor.m_sliceAddress);
-                    continue;
-                }
-
-                // This entity has been verified to be a subslice root at this point, so clone the entity's subslice instance.
-                AZ::SliceComponent::SliceInstanceAddress clonedAddress;
-                AZ::SliceComponent::EntityIdToEntityIdMap sourceToCloneSliceEntityIdMap;
-                SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(clonedAddress,
-                    &SliceEditorEntityOwnershipServiceRequests::CloneSubSliceInstance, owningSliceAddress, sourceSubSliceAncestry,
-                    ancestor.m_sliceAddress, &sourceToCloneSliceEntityIdMap);
-
-                for (AZ::Entity* instanceEntity : clonedAddress.GetInstance()->GetInstantiated()->m_entities)
-                {
-                    out_allEntityClones.push_back(instanceEntity);
-                }
-                for (const AZStd::pair<AZ::EntityId, AZ::EntityId>& sourceIdToCloneId : sourceToCloneSliceEntityIdMap)
-                {
-                    out_sourceToCloneEntityIdMap.insert(sourceIdToCloneId);
-                }
-
-                // Only perform one clone, and prioritize the first found ancestor, which will track against
-                // the rest of the ancestors automatically.
-                result = true;
-                break;
-            }
-            return result;
-        }
-
         void CloneLooseEntities(
             const EntityIdList& duplicationList,
             EntityList& out_allEntityClones,

+ 0 - 38
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.cpp

@@ -119,7 +119,6 @@ namespace AzToolsFramework
         EditorTransformChangeNotificationBus::Handler::BusConnect();
         ToolsApplicationEvents::Bus::Handler::BusConnect();
         EditorEntityContextNotificationBus::Handler::BusConnect();
-        SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
         EditorEntityModelRequestBus::Handler::BusConnect();
 
         AzFramework::EntityContextId editorEntityContextId = AzFramework::EntityContextId::CreateNull();
@@ -137,7 +136,6 @@ namespace AzToolsFramework
     {
         AzToolsFramework::Prefab::PrefabPublicNotificationBus::Handler::BusDisconnect();
         AzFramework::EntityContextEventBus::Handler::BusDisconnect();
-        SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
         EditorEntityContextNotificationBus::Handler::BusDisconnect();
         ToolsApplicationEvents::Bus::Handler::BusDisconnect();
         EditorTransformChangeNotificationBus::Handler::BusDisconnect();
@@ -649,43 +647,12 @@ namespace AzToolsFramework
         }
     }
 
-    void EditorEntityModel::OnEditorEntitiesPromotedToSlicedEntities(const AzToolsFramework::EntityIdList& promotedEntities)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        OnEditorEntitiesSliceOwnershipChanged(promotedEntities);
-    }
-
-    void EditorEntityModel::OnEditorEntitiesSliceOwnershipChanged(const AzToolsFramework::EntityIdList& entityIdList)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        // Need to update slice info from top of hierarchy down
-        // as parent entity slice status will be querried and needs to be correct
-        AzToolsFramework::EntityIdList sortedEntityList(entityIdList);
-        AzToolsFramework::SortEntitiesByLocationInHierarchy(sortedEntityList);
-        for (const auto& entityId : sortedEntityList)
-        {
-            UpdateSliceInfoHierarchy(entityId);
-            EditorEntityInfoNotificationBus::Broadcast(&EditorEntityInfoNotificationBus::Events::OnEntityInfoUpdateSliceOwnership, entityId);
-        }
-    }
-
     void EditorEntityModel::OnPrepareForContextReset()
     {
         m_preparingForContextReset = true;
         Reset();
     }
 
-    void EditorEntityModel::OnSliceInstantiationFailed(const AZ::Data::AssetId&, const AzFramework::SliceInstantiationTicket&)
-    {
-        QMessageBox::warning(AzToolsFramework::GetActiveWindow(),
-            QStringLiteral("Can't instantiate the selected slice"),
-            QString("The slice may contain UI elements that can't be instantiated in the main Open 3D Engine editor. "
-                "Use the UI Editor to instantiate this slice or select another one."),
-            QMessageBox::Ok);
-    }
-
     void EditorEntityModel::OnEntityStreamLoadBegin()
     {
         Reset();
@@ -1101,11 +1068,6 @@ namespace AzToolsFramework
         // The re-parented entity is dirty due to parent change
         undo.MarkEntityDirty(m_entityId);
 
-        if (AzToolsFramework::SliceUtilities::IsReparentNonTrivial(m_entityId, parentId))
-        {
-            AzToolsFramework::SliceUtilities::ReparentNonTrivialSliceInstanceHierarchy(m_entityId, parentId);
-        }
-
         // Guarding this to prevent the entity from being marked dirty when the parent doesn't change.
         AZ::TransformBus::Event(m_entityId, &AZ::TransformBus::Events::SetParent, parentId);
 

+ 0 - 10
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityModel.h

@@ -27,7 +27,6 @@
 #include <AzToolsFramework/Entity/EditorEntitySortBus.h>
 #include <AzToolsFramework/Entity/EditorEntityTransformBus.h>
 #include <AzToolsFramework/Entity/EditorEntityModelBus.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
 #include <AzToolsFramework/Prefab/PrefabPublicNotificationBus.h>
 #include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
 #include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
@@ -41,7 +40,6 @@ namespace AzToolsFramework
     class EditorEntityModel
         : public AzFramework::EntityContextEventBus::Handler
         , public EditorEntityContextNotificationBus::Handler
-        , public SliceEditorEntityOwnershipServiceNotificationBus::Handler
         , public EditorEntitySortNotificationBus::MultiHandler
         , public ToolsApplicationEvents::Bus::Handler
         , public EditorOnlyEntityComponentNotificationBus::Handler
@@ -80,14 +78,6 @@ namespace AzToolsFramework
         ///////////////////////////////////
         void ChildEntityOrderArrayUpdated() override;
 
-        //////////////////////////////////////////////////////////////////////////
-        // AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler
-        //////////////////////////////////////////////////////////////////////////
-        void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId,
-            const AzFramework::SliceInstantiationTicket& ticket) override;
-        void OnEditorEntitiesPromotedToSlicedEntities(const AzToolsFramework::EntityIdList& promotedEntities) override;
-        void OnEditorEntitiesSliceOwnershipChanged(const AzToolsFramework::EntityIdList& entityIdList) override;
-
         //////////////////////////////////////////////////////////////////////////
         // AzToolsFramework::EditorEntityContextNotificationBus::Handler
         //////////////////////////////////////////////////////////////////////////

+ 0 - 67
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp

@@ -67,8 +67,6 @@ namespace AzToolsFramework
             AZStd::unique_ptr<Prefab::Instance>(m_prefabSystemComponent->CreatePrefab(AzToolsFramework::EntityList{}, {}, "newLevel.prefab"));
         m_sliceOwnershipService.BusConnect(m_entityContextId);
         m_sliceOwnershipService.m_shouldAssertForLegacySlicesUsage = m_shouldAssertForLegacySlicesUsage;
-        m_editorSliceOwnershipService.BusConnect();
-        m_editorSliceOwnershipService.m_shouldAssertForLegacySlicesUsage = m_shouldAssertForLegacySlicesUsage;
     }
 
     bool PrefabEditorEntityOwnershipService::IsInitialized()
@@ -79,8 +77,6 @@ namespace AzToolsFramework
     void PrefabEditorEntityOwnershipService::Destroy()
     {
         StopPlayInEditor();
-        m_editorSliceOwnershipService.BusDisconnect();
-        m_sliceOwnershipService.BusDisconnect();
 
         if (m_rootInstance != nullptr)
         {
@@ -771,67 +767,4 @@ namespace AzToolsFramework
         AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
         return dummy;
     }
-
-    //////////////////////////////////////////////////////////////////////////
-
-    AzFramework::SliceInstantiationTicket UnimplementedSliceEditorEntityOwnershipService::InstantiateEditorSlice(
-        const AZ::Data::Asset<AZ::Data::AssetData>&, const AZ::Transform&)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-        return AzFramework::SliceInstantiationTicket();
-    }
-
-    AZ::SliceComponent::SliceInstanceAddress UnimplementedSliceEditorEntityOwnershipService::CloneEditorSliceInstance(
-        AZ::SliceComponent::SliceInstanceAddress, AZ::SliceComponent::EntityIdToEntityIdMap&)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-        return {};
-    }
-
-    AZ::SliceComponent::SliceInstanceAddress UnimplementedSliceEditorEntityOwnershipService::CloneSubSliceInstance(
-        const AZ::SliceComponent::SliceInstanceAddress&, const AZStd::vector<AZ::SliceComponent::SliceInstanceAddress>&,
-        const AZ::SliceComponent::SliceInstanceAddress&, AZ::SliceComponent::EntityIdToEntityIdMap*)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-        return {};
-    }
-
-    AZ::SliceComponent::SliceInstanceAddress UnimplementedSliceEditorEntityOwnershipService::PromoteEditorEntitiesIntoSlice(
-        const AZ::Data::Asset<AZ::SliceAsset>&, const AZ::SliceComponent::EntityIdToEntityIdMap&)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-        return {};
-    }
-
-    void UnimplementedSliceEditorEntityOwnershipService::DetachSliceEntities(const EntityIdList&)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-    }
-
-    void UnimplementedSliceEditorEntityOwnershipService::DetachSliceInstances(const AZ::SliceComponent::SliceInstanceAddressSet&)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-    }
-
-    void UnimplementedSliceEditorEntityOwnershipService::DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList&)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-    }
-
-    void UnimplementedSliceEditorEntityOwnershipService::RestoreSliceEntity(
-        AZ::Entity*, const AZ::SliceComponent::EntityRestoreInfo&, SliceEntityRestoreType)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-    }
-
-    void UnimplementedSliceEditorEntityOwnershipService::ResetEntitiesToSliceDefaults(EntityIdList)
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-    }
-
-    AZ::SliceComponent* UnimplementedSliceEditorEntityOwnershipService::GetEditorRootSlice()
-    {
-        AZ_Assert(!m_shouldAssertForLegacySlicesUsage, "Slice usage with Prefab code enabled");
-        return nullptr;
-    }
 }

+ 0 - 33
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h

@@ -14,7 +14,6 @@
 #include <AzFramework/Spawnable/SpawnableEntitiesContainer.h>
 #include <AzToolsFramework/Entity/EntityTypes.h>
 #include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
 #include <AzToolsFramework/Prefab/Overrides/PrefabOverridePublicHandler.h>
 #include <AzToolsFramework/Prefab/Spawnable/PrefabInMemorySpawnableConverter.h>
 
@@ -62,37 +61,6 @@ namespace AzToolsFramework
         void SetIsDynamic(bool isDynamic) override;
         const AzFramework::RootSliceAsset& GetRootAsset() const override;
     };
-
-    class UnimplementedSliceEditorEntityOwnershipService
-        : public AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Handler
-    {
-    public:
-        bool m_shouldAssertForLegacySlicesUsage = false;
-    private:
-        AzFramework::SliceInstantiationTicket InstantiateEditorSlice(
-            const AZ::Data::Asset<AZ::Data::AssetData>& sliceAsset, const AZ::Transform& worldTransform) override;
-
-        AZ::SliceComponent::SliceInstanceAddress CloneEditorSliceInstance(
-            AZ::SliceComponent::SliceInstanceAddress sourceInstance,
-            AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap) override;
-
-        AZ::SliceComponent::SliceInstanceAddress CloneSubSliceInstance(
-            const AZ::SliceComponent::SliceInstanceAddress& sourceSliceInstanceAddress,
-            const AZStd::vector<AZ::SliceComponent::SliceInstanceAddress>& sourceSubSliceInstanceAncestry,
-            const AZ::SliceComponent::SliceInstanceAddress& sourceSubSliceInstanceAddress,
-            AZ::SliceComponent::EntityIdToEntityIdMap* out_sourceToCloneEntityIdMap) override;
-
-        AZ::SliceComponent::SliceInstanceAddress PromoteEditorEntitiesIntoSlice(
-            const AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetMap) override;
-
-        void DetachSliceEntities(const EntityIdList& entities) override;
-        void DetachSliceInstances(const AZ::SliceComponent::SliceInstanceAddressSet& instances) override;
-        void DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList) override;
-        void RestoreSliceEntity(
-            AZ::Entity* entity, const AZ::SliceComponent::EntityRestoreInfo& info, SliceEntityRestoreType restoreType) override;
-        void ResetEntitiesToSliceDefaults(EntityIdList entities) override;
-        AZ::SliceComponent* GetEditorRootSlice() override;
-    };
     //////////////////////////////////////////////////////////////////////////
 
     class PrefabEditorEntityOwnershipService
@@ -219,7 +187,6 @@ namespace AzToolsFramework
         ValidateEntitiesCallback m_validateEntitiesCallback;
 
         UnimplementedSliceEntityOwnershipService m_sliceOwnershipService;
-        UnimplementedSliceEditorEntityOwnershipService m_editorSliceOwnershipService;
 
         AZStd::string m_rootPath;
         AZStd::unique_ptr<Prefab::Instance> m_rootInstance;

+ 0 - 941
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.cpp

@@ -1,941 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#include <AzCore/Script/ScriptSystemBus.h>
-
-#include <AzFramework/Entity/GameEntityContextBus.h>
-
-#include <AzToolsFramework/API/ToolsApplicationAPI.h>
-#include <AzToolsFramework/Commands/DetachSubSliceInstanceCommand.h>
-#include <AzToolsFramework/Commands/EntityStateCommand.h>
-#include <AzToolsFramework/Commands/SliceDetachEntityCommand.h>
-#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipService.h>
-#include <AzToolsFramework/Slice/SliceCompilation.h>
-#include <AzToolsFramework/Slice/SliceDataFlagsCommand.h>
-#include <AzToolsFramework/Slice/SliceMetadataEntityContextBus.h>
-#include <AzToolsFramework/Slice/SliceUtilities.h>
-#include <AzToolsFramework/ToolsComponents/EditorLockComponent.h>
-#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
-
-namespace AzToolsFramework
-{
-    namespace Internal
-    {
-        struct SliceEditorEntityOwnershipServiceNotificationBusHandler final
-            : public SliceEditorEntityOwnershipServiceNotificationBus::Handler
-            , public AZ::BehaviorEBusHandler
-        {
-            AZ_EBUS_BEHAVIOR_BINDER(SliceEditorEntityOwnershipServiceNotificationBusHandler, "{159C07A6-BCB6-432E-BEBB-6AABF6C76989}", AZ::SystemAllocator,
-                OnSliceInstantiated, OnSliceInstantiationFailed);
-
-            void OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& ticket) override
-            {
-                Call(FN_OnSliceInstantiated, sliceAssetId, sliceAddress, ticket);
-            }
-
-            void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& ticket) override
-            {
-                Call(FN_OnSliceInstantiationFailed, sliceAssetId, ticket);
-            }
-        };
-    }
-
-    SliceEditorEntityOwnershipService::SliceEditorEntityOwnershipService(const AzFramework::EntityContextId& entityContextId,
-        AZ::SerializeContext* serializeContext)
-        : SliceEntityOwnershipService(entityContextId, serializeContext)
-    {
-        SliceEditorEntityOwnershipServiceRequestBus::Handler::BusConnect();
-    }
-
-    SliceEditorEntityOwnershipService::~SliceEditorEntityOwnershipService()
-    {
-        SliceEditorEntityOwnershipServiceRequestBus::Handler::BusDisconnect();
-    }
-
-    void SliceEditorEntityOwnershipService::Reflect(AZ::ReflectContext* context)
-    {
-        if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
-        {
-            behaviorContext->EBus<SliceEditorEntityOwnershipServiceNotificationBus>("SliceEditorEntityOwnershipServiceNotificationBus")
-                ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
-                ->Attribute(AZ::Script::Attributes::Category, "Editor")
-                ->Attribute(AZ::Script::Attributes::Module, "editor")
-                ->Handler<Internal::SliceEditorEntityOwnershipServiceNotificationBusHandler>()
-                ->Event("OnSliceInstantiated", &SliceEditorEntityOwnershipServiceNotifications::OnSliceInstantiated)
-                ->Event("OnSliceInstantiationFailed", &SliceEditorEntityOwnershipServiceNotifications::OnSliceInstantiationFailed)
-                ;
-        }
-    }
-
-    AzFramework::SliceInstantiationTicket SliceEditorEntityOwnershipService::InstantiateEditorSlice(
-        const AZ::Data::Asset<AZ::Data::AssetData>& sliceAsset, const AZ::Transform& worldTransform)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        if (sliceAsset.GetId().IsValid())
-        {
-            m_instantiatingSlices.push_back(AZStd::make_pair(sliceAsset, worldTransform));
-
-            const AzFramework::SliceInstantiationTicket ticket = InstantiateSlice(sliceAsset);
-            if (ticket.IsValid())
-            {
-                AzFramework::SliceInstantiationResultBus::MultiHandler::BusConnect(ticket);
-            }
-
-            return ticket;
-        }
-
-        return AzFramework::SliceInstantiationTicket();
-    }
-
-    void SliceEditorEntityOwnershipService::OnSlicePreInstantiate(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& sliceAddress)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        // Start an undo that will wrap the entire slice instantiation event (unable to do this at a higher level since this is queued up by AzFramework and there's no undo concept at that level)
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::BeginUndoBatch, "Slice Instantiation");
-
-        // Find the next ticket corresponding to this asset.
-        // Given the desired world root, position entities in the instance.
-        for (auto instantiatingIter = m_instantiatingSlices.begin(); instantiatingIter != m_instantiatingSlices.end(); ++instantiatingIter)
-        {
-            if (instantiatingIter->first.GetId() == sliceAssetId)
-            {
-                const AZ::Transform& worldTransform = instantiatingIter->second;
-
-                const AZ::SliceComponent::EntityList& entities = sliceAddress.GetInstance()->GetInstantiated()->m_entities;
-
-                for (AZ::Entity* entity : entities)
-                {
-                    auto* transformComponent = entity->FindComponent<Components::TransformComponent>();
-                    if (transformComponent)
-                    {
-                        // Non-root entities will be positioned relative to their parents.
-                        if (!transformComponent->GetParentId().IsValid())
-                        {
-                            // Note: Root slice entity always has translation at origin, so this maintains scale & rotation.
-                            transformComponent->SetWorldTM(worldTransform * transformComponent->GetWorldTM());
-                        }
-                    }
-                }
-
-                break;
-            }
-        }
-    }
-
-    void SliceEditorEntityOwnershipService::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& sliceAddress)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        const AzFramework::SliceInstantiationTicket ticket = *AzFramework::SliceInstantiationResultBus::GetCurrentBusId();
-
-        AzFramework::SliceInstantiationResultBus::MultiHandler::BusDisconnect(ticket);
-
-        // Make a copy of sliceAddress because a handler of EditorEntityContextNotification::OnSliceInstantiated (CCryEditDoc::OnSliceInstantiated)
-        // can end up destroying the slice instance which invalidates the values stored in sliceAddress for the following handlers. 
-        // If CCryEditDoc::OnSliceInstantiated destroys the slice instance, it will set SliceInstanceAddress::m_instance and SliceInstanceAddress::m_reference 
-        // to nullptr making the sliceAddressCopy invalid for the following handlers.
-        AZ::SliceComponent::SliceInstanceAddress sliceAddressCopy = sliceAddress;
-
-        // Close out the next ticket corresponding to this asset.
-        for (auto instantiatingIter = m_instantiatingSlices.begin(); instantiatingIter != m_instantiatingSlices.end(); ++instantiatingIter)
-        {
-            AZ_PROFILE_SCOPE(AzToolsFramework, "EditorEntityContextComponent::OnSliceInstantiated:CloseTicket");
-            if (instantiatingIter->first.GetId() == sliceAssetId)
-            {
-                const AZ::SliceComponent::EntityList& entities = sliceAddressCopy.GetInstance()->GetInstantiated()->m_entities;
-
-                // Select slice roots when found, otherwise default to selecting all entities in slice
-                EntityIdSet setOfEntityIds;
-                for (const AZ::Entity* const entity : entities)
-                {
-                    setOfEntityIds.insert(entity->GetId());
-                }
-
-                UpdateSelectedEntitiesInHierarchy(setOfEntityIds);
-
-                // Create a slice instantiation undo command.
-                {
-                    AZ_PROFILE_SCOPE(AzToolsFramework, "EditorEntityContextComponent::OnSliceInstantiated:CloseTicket:CreateInstantiateUndo");
-                    ScopedUndoBatch undoBatch("Instantiate Slice");
-                    for (AZ::Entity* entity : entities)
-                    {
-
-                        EntityCreateCommand* command = aznew EntityCreateCommand(
-                            reinterpret_cast<UndoSystem::URCommandID>(sliceAddressCopy.GetInstance()));
-                        command->Capture(entity);
-                        command->SetParent(undoBatch.GetUndoBatch());
-                    }
-                }
-
-                SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-                    &SliceEditorEntityOwnershipServiceNotifications::OnSliceInstantiated, sliceAssetId, sliceAddressCopy, ticket);
-
-                m_instantiatingSlices.erase(instantiatingIter);
-
-                break;
-            }
-        }
-
-        // End the slice instantiation undo batch started in OnSlicePreInstantiate
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::EndUndoBatch);
-    }
-
-    void SliceEditorEntityOwnershipService::OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        const AzFramework::SliceInstantiationTicket ticket = *AzFramework::SliceInstantiationResultBus::GetCurrentBusId();
-
-        AzFramework::SliceInstantiationResultBus::MultiHandler::BusDisconnect(ticket);
-
-        for (auto instantiatingIter = m_instantiatingSlices.begin(); instantiatingIter != m_instantiatingSlices.end(); ++instantiatingIter)
-        {
-            if (instantiatingIter->first.GetId() == sliceAssetId)
-            {
-                SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-                    &SliceEditorEntityOwnershipServiceNotifications::OnSliceInstantiationFailed, sliceAssetId, ticket);
-
-                m_instantiatingSlices.erase(instantiatingIter);
-                break;
-            }
-        }
-    }
-
-    AZ::SliceComponent::SliceInstanceAddress SliceEditorEntityOwnershipService::CloneEditorSliceInstance(
-        AZ::SliceComponent::SliceInstanceAddress sourceInstance, AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        if (sourceInstance.IsValid())
-        {
-            AZ::SliceComponent::SliceInstanceAddress address = CloneSliceInstance(sourceInstance, sourceToCloneEntityIdMap);
-            return address;
-        }
-        else
-        {
-            AZ_Error("EditorEntityContext", false, "Invalid slice source instance. Unable to clone.");
-        }
-
-        return AZ::SliceComponent::SliceInstanceAddress();
-    }
-
-    AZ::SliceComponent::SliceInstanceAddress SliceEditorEntityOwnershipService::CloneSubSliceInstance(
-        const AZ::SliceComponent::SliceInstanceAddress& sourceSliceInstanceAddress,
-        const AZStd::vector<AZ::SliceComponent::SliceInstanceAddress>& sourceSubSliceInstanceAncestry,
-        const AZ::SliceComponent::SliceInstanceAddress& sourceSubSliceInstanceAddress,
-        AZ::SliceComponent::EntityIdToEntityIdMap* out_sourceToCloneEntityIdMap)
-    {
-        AZ::SliceComponent::SliceInstanceAddress subsliceInstanceCloneAddress =
-            GetRootSlice()->CloneAndAddSubSliceInstance(sourceSliceInstanceAddress.GetInstance(),
-            sourceSubSliceInstanceAncestry, sourceSubSliceInstanceAddress, out_sourceToCloneEntityIdMap);
-
-        if (!subsliceInstanceCloneAddress.IsValid())
-        {
-            AZ_Assert(false, "Clone sub-slice instance failed.");
-            return AZ::SliceComponent::SliceInstanceAddress();
-        }
-
-        return subsliceInstanceCloneAddress;
-    }
-
-    AZ::SliceComponent::SliceInstanceAddress SliceEditorEntityOwnershipService::PromoteEditorEntitiesIntoSlice(const AZ::Data::Asset<AZ::SliceAsset>& sliceAsset, const AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetMap)
-    {
-        AZ::SliceComponent* editorRootSlice = GetRootSlice();
-
-        if (!sliceAsset.GetId().IsValid())
-        {
-            AZ_Error("SliceEditorEntityOwnershipService::PromoteEditorEntitiesIntoSlice", false, "SliceAsset with Invalid Asset ID passed in. Unable to promote entities into slice");
-            return AZ::SliceComponent::SliceInstanceAddress();
-        }
-
-        if (!editorRootSlice)
-        {
-            AZ_Assert(editorRootSlice, "SliceEditorEntityOwnershipService::PromoteEditorEntitiesIntoSlice: Editor root slice not found! Unable to promote entities into slice");
-            return AZ::SliceComponent::SliceInstanceAddress();
-        }
-
-        AzFramework::SliceInstantiationTicket ticket = GenerateSliceInstantiationTicket();
-
-        AzFramework::SliceInstantiationResultBus::Event(ticket, &AzFramework::SliceInstantiationResultBus::Events::OnSlicePreInstantiate,
-            sliceAsset.GetId(), AZ::SliceComponent::SliceInstanceAddress());
-
-        AZ::SliceComponent::SliceInstanceAddress instanceAddress = editorRootSlice->
-            AddSliceUsingExistingEntities(sliceAsset, liveToAssetMap);
-
-        if (!instanceAddress.IsValid())
-        {
-            AzFramework::SliceInstantiationResultBus::Event(ticket,
-                &AzFramework::SliceInstantiationResultBus::Events::OnSliceInstantiationFailed, sliceAsset.GetId());
-            AzFramework::SliceInstantiationResultBus::Event(ticket,
-                &AzFramework::SliceInstantiationResultBus::Events::OnSliceInstantiationFailedOrCanceled, sliceAsset.GetId(), false);
-            return AZ::SliceComponent::SliceInstanceAddress();
-        }
-
-        AzFramework::SliceInstantiationResultBus::Event(ticket, &AzFramework::SliceInstantiationResultBus::Events::OnSliceInstantiated,
-            sliceAsset.GetId(), instanceAddress);
-
-        SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-            &SliceEditorEntityOwnershipServiceNotificationBus::Events::OnSliceInstantiated,
-            sliceAsset.GetId(), instanceAddress, ticket);
-
-        const EntityList& instanceEntities = instanceAddress.GetInstance()->GetInstantiated()->m_entities;
-
-        EntityIdSet instantiatedIdSet;
-        AzToolsFramework::EntityIdList instantiatedIds;
-        for (const AZ::Entity* instanceEntity : instanceEntities)
-        {
-            instantiatedIdSet.emplace(instanceEntity->GetId());
-            instantiatedIds.emplace_back(instanceEntity->GetId());
-        }
-
-        UpdateSelectedEntitiesInHierarchy(instantiatedIdSet);
-
-        SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-            &SliceEditorEntityOwnershipServiceNotificationBus::Events::OnEditorEntitiesPromotedToSlicedEntities, instantiatedIds);
-
-        return instanceAddress;
-    }
-
-    void SliceEditorEntityOwnershipService::UpdateSelectedEntitiesInHierarchy(const EntityIdSet& entityIdSet)
-    {
-        // Use a lambda to call multiple requests via one Broadcast
-        ToolsApplicationRequestBus::Broadcast([&entityIdSet](ToolsApplicationRequests* toolsApplicationRequest)
-        {
-            EntityIdList selectedEntities;
-            AZ::EntityId commonRoot;
-            if (toolsApplicationRequest->FindCommonRoot(entityIdSet, commonRoot, &selectedEntities) || selectedEntities.empty())
-            {
-                selectedEntities.insert(selectedEntities.end(), entityIdSet.begin(), entityIdSet.end());
-            }
-
-            toolsApplicationRequest->SetSelectedEntities(selectedEntities);
-        });
-    }
-
-    void SliceEditorEntityOwnershipService::DetachSliceEntities(const AzToolsFramework::EntityIdList& entities)
-    {
-        const char* undoMsg = entities.size() == 1 ? "Detach Entity from Slice" : "Detach Entities from Slice";
-        DetachFromSlice(entities, undoMsg);
-    }
-
-    void SliceEditorEntityOwnershipService::DetachSliceInstances(const AZ::SliceComponent::SliceInstanceAddressSet& instances)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        const char* undoMsg = instances.size() == 1 ? "Detach Instance from Slice" : "Detach Instances from Slice";
-
-        // Get all entities in the input instance(s)
-        AzToolsFramework::EntityIdList entities;
-        for (const AZ::SliceComponent::SliceInstanceAddress& sliceInstanceAddress : instances)
-
-        {
-            if (!sliceInstanceAddress.IsValid())
-            {
-                continue;
-            }
-
-            const AZ::SliceComponent::InstantiatedContainer* instantiated = sliceInstanceAddress.GetInstance()->GetInstantiated();
-            if (instantiated)
-            {
-                for (const AZ::Entity* entityInSlice : instantiated->m_entities)
-                {
-                    entities.push_back(entityInSlice->GetId());
-                }
-            }
-        }
-
-        DetachFromSlice(entities, undoMsg);
-    }
-
-    void SliceEditorEntityOwnershipService::DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        if (subsliceRootList.empty())
-        {
-            return;
-        }
-
-        const char* undoMsg = subsliceRootList.size() == 1 ? "Detach Subslice Instance from owning Slice Instance" : "Detach Subslice Instances from owning Slice Instance";
-
-        ScopedUndoBatch undoBatch(undoMsg);
-
-        AzToolsFramework::DetachSubsliceInstanceCommand* detachCommand = aznew AzToolsFramework::DetachSubsliceInstanceCommand(subsliceRootList, undoMsg);
-        detachCommand->SetParent(undoBatch.GetUndoBatch());
-
-        // Running Redo on the DetachSubsliceInstanceCommand will perform the Detach command
-        ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequestBus::Events::RunRedoSeparately, undoBatch.GetUndoBatch());
-    }
-
-    void SliceEditorEntityOwnershipService::DetachFromSlice(const AzToolsFramework::EntityIdList& entities, const char* undoMessage)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        if (entities.empty())
-        {
-            return;
-        }
-
-        ScopedUndoBatch undoBatch(undoMessage);
-
-        AzToolsFramework::SliceDetachEntityCommand* detachCommand = aznew AzToolsFramework::SliceDetachEntityCommand(entities, undoMessage);
-        detachCommand->SetParent(undoBatch.GetUndoBatch());
-
-        // Running Redo on the SliceDetachEntityCommand will perform the Detach command
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::RunRedoSeparately, undoBatch.GetUndoBatch());
-    }
-
-    void SliceEditorEntityOwnershipService::RestoreSliceEntity(AZ::Entity* entity,
-        const AZ::SliceComponent::EntityRestoreInfo& info, SliceEntityRestoreType restoreType)
-    {
-        AZ_Error("EditorEntityContext", info.m_assetId.IsValid(), "Invalid asset Id for entity restore.");
-
-        // If asset isn't loaded when this request is made, we need to queue the load and process the request
-        // when the asset is ready. Otherwise we'll immediately process the request when OnAssetReady is invoked
-        // by the AssetBus connection policy.
-
-        // Hold a reference to the slice asset so the underlying AssetData won't be ref-counted away when re-adding slice instance.
-        AZ::Data::Asset<AZ::Data::AssetData> asset =
-            AZ::Data::AssetManager::Instance().GetAsset<AZ::SliceAsset>(info.m_assetId, AZ::Data::AssetLoadBehavior::Default);
-
-        SliceEntityRestoreRequest request = { entity, info, asset, restoreType };
-
-        // Remove all previous queued states of the same entity, only restore to the most recent state.
-        AZ::EntityId entityId = entity->GetId();
-        m_queuedSliceEntityRestores.erase(
-            AZStd::remove_if(m_queuedSliceEntityRestores.begin(), m_queuedSliceEntityRestores.end(),
-                [entityId](const SliceEntityRestoreRequest& request) { return request.m_entity->GetId() == entityId; }),
-            m_queuedSliceEntityRestores.end());
-
-        m_queuedSliceEntityRestores.emplace_back(request);
-
-        AZ::Data::AssetBus::MultiHandler::BusConnect(asset.GetId());
-    }
-
-    void SliceEditorEntityOwnershipService::OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        AZ::Data::AssetBus::MultiHandler::BusDisconnect(asset.GetId());
-
-        AzFramework::EntityList deletedEntitiesRestored;
-        AzFramework::EntityIdList detachedEntitiesRestored;
-
-        AZ::SliceComponent* rootSlice = GetRootSlice();
-        AZ_Assert(rootSlice, "Failed to retrieve editor root slice.");
-
-        for (auto iter = m_queuedSliceEntityRestores.begin(); iter != m_queuedSliceEntityRestores.end(); )
-        {
-            SliceEntityRestoreRequest& request = *iter;
-            if (asset.GetId() == request.m_asset.GetId())
-            {
-                AZ::SliceComponent::SliceInstanceAddress address =
-                    rootSlice->RestoreEntity(request.m_entity, request.m_restoreInfo,
-                        request.m_restoreType == SliceEntityRestoreType::Added);
-
-                if (address.IsValid())
-                {
-                    switch (request.m_restoreType)
-                    {
-                    case SliceEntityRestoreType::Deleted:
-                    {
-                        deletedEntitiesRestored.push_back(request.m_entity);
-                    } break;
-
-                    case SliceEntityRestoreType::Added:
-                    {
-                        // Fall through and perform same operations as Detached
-                    }
-                    case SliceEntityRestoreType::Detached:
-                    {
-                        detachedEntitiesRestored.push_back(request.m_entity->GetId());
-                        rootSlice->RemoveLooseEntity(request.m_entity->GetId());
-                    } break;
-
-                    default:
-                    {
-                        AZ_Error("EditorEntityContext", false, "Invalid slice entity restore type (%d). Entity: \"%s\" [%llu]",
-                            request.m_restoreType, request.m_entity->GetName().c_str(), request.m_entity->GetId());
-                    } break;
-                    }
-                }
-                else
-                {
-                    AZ_Error("EditorEntityContext", false, "Failed to restore entity \"%s\" [%llu]",
-                        request.m_entity->GetName().c_str(), request.m_entity->GetId());
-
-                    if (request.m_restoreType == SliceEntityRestoreType::Deleted)
-                    {
-                        delete request.m_entity;
-                    }
-                }
-
-                iter = m_queuedSliceEntityRestores.erase(iter);
-            }
-            else
-            {
-                ++iter;
-            }
-        }
-
-        HandleEntitiesAdded(deletedEntitiesRestored);
-
-        // Broadcast the created entity notification now after the restore is complete.
-        for (auto deletedEntity : deletedEntitiesRestored)
-        {
-            EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, deletedEntity->GetId());
-        }
-
-        if (!detachedEntitiesRestored.empty())
-        {
-            SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-                &SliceEditorEntityOwnershipServiceNotifications::OnEditorEntitiesSliceOwnershipChanged, detachedEntitiesRestored);
-        }
-
-        // Pass on to base EntityOwnershipService.
-        SliceEntityOwnershipService::OnAssetReady(asset);
-    }
-
-    //=========================================================================
-    // OnAssetReloaded - Root slice (or its dependents) has been reloaded.
-    //=========================================================================
-    void SliceEditorEntityOwnershipService::OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        EntityIdList selectedEntities;
-        ToolsApplicationRequests::Bus::BroadcastResult(selectedEntities, &ToolsApplicationRequests::GetSelectedEntities);
-
-        SliceEntityOwnershipService::OnAssetReloaded(asset);
-
-        // Ensure selection set is preserved after applying the new level slice.
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, selectedEntities);
-    }
-
-    void SliceEditorEntityOwnershipService::ResetEntitiesToSliceDefaults(EntityIdList entities)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-        ScopedUndoBatch undoBatch("Resetting entities to slice defaults.");
-
-        PreemptiveUndoCache* preemptiveUndoCache = nullptr;
-        ToolsApplicationRequests::Bus::BroadcastResult(preemptiveUndoCache, &ToolsApplicationRequests::GetUndoCache);
-
-        EntityIdList selectedEntities;
-        ToolsApplicationRequestBus::BroadcastResult(selectedEntities, &ToolsApplicationRequests::GetSelectedEntities);
-
-        SelectionCommand* selCommand = aznew SelectionCommand(
-            selectedEntities, "Reset Entity to Slice Defaults");
-        selCommand->SetParent(undoBatch.GetUndoBatch());
-
-        SelectionCommand* newSelCommand = aznew SelectionCommand(
-            selectedEntities, "Reset Entity to Slice Defaults");
-
-        for (AZ::EntityId id : entities)
-        {
-            AZ::SliceComponent::SliceInstanceAddress sliceAddress = GetOwningSlice(id);
-
-            AZ::SliceComponent::SliceReference* sliceReference = sliceAddress.GetReference();
-            AZ::SliceComponent::SliceInstance* sliceInstance = sliceAddress.GetInstance();
-
-            AZ::EntityId sliceRootEntityId;
-            ToolsApplicationRequestBus::BroadcastResult(sliceRootEntityId,
-                &ToolsApplicationRequestBus::Events::GetRootEntityIdOfSliceInstance, sliceAddress);
-
-            bool isSliceRootEntity = (id == sliceRootEntityId);
-
-            if (sliceReference)
-            {
-                // Clear any data flags for entity
-                auto clearDataFlagsCommand = aznew ClearSliceDataFlagsBelowAddressCommand(id, AZ::DataPatch::AddressType(), "Clear data flags");
-                clearDataFlagsCommand->SetParent(undoBatch.GetUndoBatch());
-
-                AZ::Entity* oldEntity = nullptr;
-                AZ::ComponentApplicationBus::BroadcastResult(oldEntity, &AZ::ComponentApplicationBus::Events::FindEntity, id);
-                AZ_Assert(oldEntity, "Couldn't find the entity we were looking for!");
-                if (!oldEntity)
-                {
-                    continue;
-                }
-
-                // Clone the entity from the slice source (clean)
-                auto sourceEntityIterator = sliceInstance->GetEntityIdToBaseMap().find(id);
-                AZ_Assert(sourceEntityIterator != sliceInstance->GetEntityIdToBaseMap().end(), "Attempting to clone an invalid instance entity id for this slice instance!");
-                if (sourceEntityIterator != sliceInstance->GetEntityIdToBaseMap().end())
-                {
-                    AZ::SliceComponent* dependentSlice = sliceReference->GetSliceAsset().Get()->GetComponent();
-                    AZ::Entity* sourceEntity = dependentSlice->FindEntity(sourceEntityIterator->second);
-
-                    AZ_Assert(sourceEntity, "Couldn't find source entity from sourceEntityId in slice reference!");
-                    if (sourceEntity)
-                    {
-                        AZ::Entity* entityClone = dependentSlice->GetSerializeContext()->CloneObject(sourceEntity);
-                        if (entityClone)
-                        {
-                            AZ::IdUtils::Remapper<AZ::EntityId>::ReplaceIdsAndIdRefs(
-                                entityClone,
-                                [sliceInstance](const AZ::EntityId& originalId, bool /*isEntityId*/, const AZStd::function<AZ::EntityId()>& /*idGenerator*/) -> AZ::EntityId
-                            {
-                                auto findIt = sliceInstance->GetEntityIdMap().find(originalId);
-                                if (findIt == sliceInstance->GetEntityIdMap().end())
-                                {
-                                    return originalId; // entityId is not being remapped
-                                }
-                                else
-                                {
-                                    return findIt->second; // return the remapped id
-                                }
-                            }, dependentSlice->GetSerializeContext());
-
-                            // Only restore world position and rotation for the slice root entity.
-                            if (isSliceRootEntity)
-                            {
-                                // Get the transform component on the cloned entity.  We cannot use the bus since it isn't activated.
-                                Components::TransformComponent* transformComponent = entityClone->FindComponent<Components::TransformComponent>();
-                                AZ_Assert(transformComponent, "Entity doesn't have a transform component!");
-                                if (transformComponent)
-                                {
-                                    AZ::Vector3 oldEntityWorldPosition;
-                                    AZ::TransformBus::EventResult(oldEntityWorldPosition, id, &AZ::TransformBus::Events::GetWorldTranslation);
-                                    transformComponent->SetWorldTranslation(oldEntityWorldPosition);
-
-                                    AZ::Quaternion oldEntityRotation;
-                                    AZ::TransformBus::EventResult(oldEntityRotation, id, &AZ::TransformBus::Events::GetWorldRotationQuaternion);
-                                    transformComponent->SetWorldRotationQuaternion(oldEntityRotation);
-
-                                    // Ensure the existing hierarchy is maintained
-                                    AZ::EntityId oldParentEntityId;
-                                    AZ::TransformBus::EventResult(oldParentEntityId, id, &AZ::TransformBus::Events::GetParentId);
-                                    transformComponent->SetParent(oldParentEntityId);
-                                }
-                            }
-
-                            // Create a state command and capture both the undo and redo data
-                            EntityStateCommand* stateCommand = aznew EntityStateCommand(
-                                static_cast<UndoSystem::URCommandID>(id));
-                            stateCommand->Capture(oldEntity, true);
-                            stateCommand->Capture(entityClone, false);
-                            stateCommand->SetParent(undoBatch.GetUndoBatch());
-
-                            // Delete our temporary entity clone
-                            delete entityClone;
-                        }
-                    }
-                }
-            }
-        }
-
-        newSelCommand->SetParent(undoBatch.GetUndoBatch());
-
-        // Run the redo in order to do the initial swap of entity data
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::RunRedoSeparately, undoBatch.GetUndoBatch());
-
-        // Make sure to set selection to newly cloned entities
-        ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::SetSelectedEntities, selectedEntities);
-    }
-
-    bool SliceEditorEntityOwnershipService::SaveToStreamForEditor(AZ::IO::GenericStream& stream, const EntityList& entitiesInLayers,
-        AZ::SliceComponent::SliceReferenceToInstancePtrs& instancesInLayers)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        AZ_Assert(stream.IsOpen(), "Invalid target stream.");
-        AzFramework::RootSliceAsset rootSliceAsset = GetRootAsset();
-        AZ_Assert(rootSliceAsset && rootSliceAsset->GetComponent(), "The entity ownership service is not initialized.");
-
-        // Grab the entire entity list to make sure saving layers doesn't cause entity order to shuffle.
-        EntityList entities = rootSliceAsset->GetComponent()->GetNewEntities();
-
-        if (!instancesInLayers.empty())
-        {
-            rootSliceAsset->GetComponent()->RemoveAndCacheInstances(instancesInLayers);
-        }
-
-        if (!entitiesInLayers.empty())
-        {
-            // These entities were already saved out to individual layer files, so do not save them to the level file.
-            rootSliceAsset->GetComponent()->EraseEntities(entitiesInLayers);
-        }
-
-        bool saveResult = AZ::Utils::SaveObjectToStream<AZ::Entity>(stream,
-            SliceUtilities::GetSliceStreamFormat(), GetRootAsset()->GetEntity());
-
-        // Restore the level slice's entities.
-        if (!entities.empty())
-        {
-            rootSliceAsset->GetComponent()->ReplaceEntities(entities);
-        }
-
-        if (!instancesInLayers.empty())
-        {
-            rootSliceAsset->GetComponent()->RestoreCachedInstances();
-        }
-
-        return saveResult;
-    }
-
-    bool SliceEditorEntityOwnershipService::SaveToStreamForGame(AZ::IO::GenericStream& stream, AZ::DataStream::StreamType streamType)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        AZ::SliceComponent::EntityList sourceEntities;
-        GetRootSlice()->GetEntities(sourceEntities);
-
-        AZStd::vector<AZStd::unique_ptr<AZ::Entity>> tempEntities;
-        SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-            &SliceEditorEntityOwnershipServiceNotifications::OnSaveStreamForGameBegin, stream, streamType, tempEntities);
-
-        sourceEntities.reserve(sourceEntities.size() + tempEntities.size());
-        for (AZStd::unique_ptr<AZ::Entity>& tempEntity : tempEntities)
-        {
-            sourceEntities.emplace_back(tempEntity.release());
-        }
-        tempEntities = {};
-        // Add the root slice metadata entity so that we export any level components
-        sourceEntities.push_back(GetRootSlice()->GetMetadataEntity());
-
-        // Create a source slice from our editor components.
-        AZ::Entity* sourceSliceEntity = aznew AZ::Entity();
-        AZ::SliceComponent* sourceSliceData = sourceSliceEntity->CreateComponent<AZ::SliceComponent>();
-        AZ::Data::Asset<AZ::SliceAsset> sourceSliceAsset(aznew AZ::SliceAsset(), AZ::Data::AssetLoadBehavior::Default);
-        sourceSliceAsset.Get()->SetData(sourceSliceEntity, sourceSliceData);
-
-        for (AZ::Entity* sourceEntity : sourceEntities)
-        {
-            // This is a sanity check that the editor source entity was created and validated before starting export to game target entity
-            // Note - this assert should *not* live directly in PreExportEntity implementation, because of the case where we are modifying
-            // system entities we do not want system components active, ticking tick buses, running simulations, etc.
-            AZ_Assert(sourceEntity->GetState() == AZ::Entity::State::Active, "Source entity must be active.");
-
-            sourceSliceData->AddEntity(sourceEntity);
-        }
-
-        // Emulate client flags.
-        AZ::PlatformTagSet platformTags = { AZ_CRC("renderer", 0xf199a19c) };
-
-        // Compile the source slice into the runtime slice (with runtime components).
-        WorldEditorOnlyEntityHandler worldEditorOnlyEntityHandler;
-        EditorOnlyEntityHandlers handlers =
-        {
-            &worldEditorOnlyEntityHandler
-        };
-        AZ::SerializeContext* serializeContext = GetSerializeContext();
-        SliceCompilationResult sliceCompilationResult = CompileEditorSlice(sourceSliceAsset, platformTags, *serializeContext, handlers);
-
-        // This is a sanity check that the editor source entity was created and validated and didn't suddenly
-        // get out of an active state during export.
-        // Note - this assert should *not* live directly in PostExportEntity implementation, because of the case where we are
-        // modifying system entities we do not want system components active, ticking tick buses, running simulations, etc.
-        for (AZ::Entity* sourceEntity : sourceEntities)
-        {
-            AZ_UNUSED(sourceEntity);
-            AZ_Assert(sourceEntity->GetState() == AZ::Entity::State::Active, "Source entity must be active.");
-        }
-
-        // Reclaim entities from the temporary source asset. We now have ownership of the entities.
-        sourceSliceData->RemoveAllEntities(false);
-
-
-        if (!sliceCompilationResult)
-        {
-            AZ_Error("Save Runtime Stream", false, "Failed to export entities for runtime:\n%s",
-                sliceCompilationResult.GetError().c_str());
-            SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-                &SliceEditorEntityOwnershipServiceNotifications::OnSaveStreamForGameFailure, sliceCompilationResult.GetError());
-            return false;
-        }
-
-        // Export runtime slice representing the level, which is a completely flat list of entities.
-        AZ::Data::Asset<AZ::SliceAsset> exportSliceAsset = sliceCompilationResult.GetValue();
-        bool saveResult = AZ::Utils::SaveObjectToStream<AZ::Entity>(stream, streamType, exportSliceAsset.Get()->GetEntity());
-        if (saveResult)
-        {
-            SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-                &SliceEditorEntityOwnershipServiceNotifications::OnSaveStreamForGameSuccess, stream);
-        }
-        else
-        {
-            SliceEditorEntityOwnershipServiceNotificationBus::Broadcast(
-                &SliceEditorEntityOwnershipServiceNotifications::OnSaveStreamForGameFailure,
-                AZStd::string::format("Unable to save slice asset %s to stream",
-                exportSliceAsset.GetId().ToString<AZStd::string>().data()));
-        }
-
-        return saveResult;
-    }
-
-    void SliceEditorEntityOwnershipService::StartPlayInEditor(EntityIdToEntityIdMap& m_editorToRuntimeIdMap,
-        EntityIdToEntityIdMap& m_runtimeToEditorIdMap)
-    {
-        // Save the editor context to a memory stream.
-        AZStd::vector<char> entityBuffer;
-        AZ::IO::ByteContainerStream<AZStd::vector<char> > stream(&entityBuffer);
-        const bool isRuntimeStreamValid = SaveToStreamForGame(stream, AZ::DataStream::ST_BINARY);
-
-        if (!isRuntimeStreamValid)
-        {
-            AZ_Error("EditorEntityContext", false,
-                "Failed to create runtime entity context for play-in-editor mode. Entities will not be created.");
-        }
-
-        // Deactivate the editor context.
-        AZ::SliceComponent* rootSlice = GetRootSlice();
-        if (rootSlice)
-        {
-            AZ::SliceComponent::EntityList entities;
-            rootSlice->GetEntities(entities);
-
-            AZ::Entity* rootMetaDataEntity = rootSlice->GetMetadataEntity();
-            if (rootMetaDataEntity)
-            {
-                entities.push_back(rootMetaDataEntity);
-            }
-
-            for (AZ::Entity* entity : entities)
-            {
-                if (entity->GetState() == AZ::Entity::State::Active)
-                {
-                    entity->Deactivate();
-                }
-            }
-        }
-
-        m_runtimeToEditorIdMap.clear();
-
-        if (isRuntimeStreamValid)
-        {
-            // Load the exported stream into the game context.
-            stream.Seek(0, AZ::IO::GenericStream::ST_SEEK_BEGIN);
-            AzFramework::GameEntityContextRequestBus::Broadcast(&AzFramework::GameEntityContextRequests::LoadFromStream, stream, true);
-
-            // Retrieve Id map from game entity context (editor->runtime).
-            AzFramework::EntityContextId gameContextId = AzFramework::EntityContextId::CreateNull();
-            AzFramework::GameEntityContextRequestBus::BroadcastResult(
-                gameContextId, &AzFramework::GameEntityContextRequests::GetGameEntityContextId);
-            AzFramework::SliceEntityOwnershipServiceRequestBus::EventResult(
-                m_editorToRuntimeIdMap, gameContextId, &AzFramework::SliceEntityOwnershipServiceRequests::GetLoadedEntityIdMap);
-
-            // Generate reverse lookup (runtime->editor).
-            for (const auto& idMapping : m_editorToRuntimeIdMap)
-            {
-                m_runtimeToEditorIdMap.insert(AZStd::make_pair(idMapping.second, idMapping.first));
-            }
-        }
-    }
-
-    void SliceEditorEntityOwnershipService::StopPlayInEditor(EntityIdToEntityIdMap& m_editorToRuntimeIdMap,
-        EntityIdToEntityIdMap& m_runtimeToEditorIdMap)
-    {
-        m_editorToRuntimeIdMap.clear();
-        m_runtimeToEditorIdMap.clear();
-
-        // Reset the runtime context.
-        AzFramework::GameEntityContextRequestBus::Broadcast(
-            &AzFramework::GameEntityContextRequests::ResetGameContext);
-
-        // Do a full lua GC.
-        AZ::ScriptSystemRequestBus::Broadcast(&AZ::ScriptSystemRequests::GarbageCollect);
-
-        // Re-activate the editor context.
-        AZ::SliceComponent* rootSlice = GetRootSlice();
-        if (rootSlice)
-        {
-            AZ::SliceComponent::EntityList entities;
-            rootSlice->GetEntities(entities);
-
-            AZ::Entity* rootMetaDataEntity = rootSlice->GetMetadataEntity();
-            if (rootMetaDataEntity)
-            {
-                entities.push_back(rootMetaDataEntity);
-            }
-
-            for (AZ::Entity* entity : entities)
-            {
-                if (entity->GetState() == AZ::Entity::State::Constructed)
-                {
-                    entity->Init();
-                }
-
-                if (entity->GetState() == AZ::Entity::State::Init)
-                {
-                    entity->Activate();
-                }
-            }
-        }
-    }
-
-    void SliceEditorEntityOwnershipService::HandleNewMetadataEntitiesCreated(AZ::SliceComponent& slice)
-    {
-        AZ::SliceComponent::EntityList metadataEntityIds;
-        slice.GetAllMetadataEntities(metadataEntityIds);
-
-        const auto& slices = slice.GetSlices();
-
-        // Add the metadata entity from the root slice to the appropriate context
-        // For now, the instance address of the root slice is <nullptr,nullptr>
-        SliceMetadataEntityContextRequestBus::Broadcast(&SliceMetadataEntityContextRequestBus::Events::AddMetadataEntityToContext, AZ::SliceComponent::SliceInstanceAddress(), *slice.GetMetadataEntity());
-
-        // Add the metadata entities from every slice instance streamed in as well. We need to grab them directly
-        // from their slices so we have the appropriate instance address for each one.
-        for (auto& subSlice : slices)
-        {
-            for (const auto& instance : subSlice.GetInstances())
-            {
-                if (auto instantiated = instance.GetInstantiated())
-                {
-                    for (auto* metadataEntity : instantiated->m_metadataEntities)
-                    {
-                        SliceMetadataEntityContextRequestBus::Broadcast(&SliceMetadataEntityContextRequestBus::Events::AddMetadataEntityToContext, AZ::SliceComponent::SliceInstanceAddress(const_cast<AZ::SliceComponent::SliceReference*>(&subSlice), const_cast<AZ::SliceComponent::SliceInstance*>(&instance)), *metadataEntity);
-                    }
-                }
-            }
-        }
-    }
-
-    void SliceEditorEntityOwnershipService::AssociateToRootMetadataEntity(const EntityList& entities)
-    {
-        for (const auto* entity : entities)
-        {
-            AZ::SliceComponent* rootSliceComponent = GetRootSlice();
-            auto sliceAddress = rootSliceComponent->FindSlice(entity->GetId());
-            if (!sliceAddress.IsValid())
-            {
-                AZ::SliceMetadataInfoManipulationBus::Event(rootSliceComponent->GetMetadataEntity()->GetId(), &AZ::SliceMetadataInfoManipulationBus::Events::AddAssociatedEntity, entity->GetId());
-            }
-        }
-    }
-
-    bool SliceEditorEntityOwnershipService::LoadFromStreamWithLayers(AZ::IO::GenericStream& stream, QString levelPakFile)
-    {
-        AZ_PROFILE_FUNCTION(AzToolsFramework);
-
-        AZ::ObjectStream::FilterDescriptor filterDesc = AZ::ObjectStream::FilterDescriptor(&AZ::Data::AssetFilterSourceSlicesOnly);
-
-        AZ::Entity* newRootEntity = AZ::Utils::LoadObjectFromStream<AZ::Entity>(stream, GetSerializeContext(), filterDesc);
-
-        AZ::SliceComponent* newRootSlice = newRootEntity->FindComponent<AZ::SliceComponent>();
-        EntityList entities = newRootSlice->GetNewEntities();
-        AZ::SliceComponent::SliceAssetToSliceInstancePtrs layerSliceInstances;
-
-        // make sure that PRE_NOTIFY assets get their notify before we activate, so that we can preserve the order of 
-        // (load asset) -> (notify) -> (init) -> (activate)
-        AZ::Data::AssetManager::Instance().DispatchEvents();
-
-        // for other kinds of instantiations, like slice instantiations, because they use the queued slice instantiation mechanism, they will always
-        // be instantiated after their asset is already ready.
-
-        return HandleRootEntityReloadedFromStream(newRootEntity, false, nullptr);
-    }
-
-    AZ::SliceComponent* SliceEditorEntityOwnershipService::GetEditorRootSlice()
-    {
-        return GetRootSlice();
-    }
-}

+ 0 - 149
Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.h

@@ -1,149 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#pragma once
-
-#include <AzFramework/Entity/SliceEntityOwnershipService.h>
-#include <AzToolsFramework/Entity/EntityTypes.h>
-#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
-
-#include <QString>
-
-namespace AzToolsFramework
-{
-    using EntityIdToEntityIdMap = AZStd::unordered_map<AZ::EntityId, AZ::EntityId>;
-
-    class SliceEditorEntityOwnershipService
-        : public AzFramework::SliceEntityOwnershipService
-        , private SliceEditorEntityOwnershipServiceRequestBus::Handler
-        , private AzFramework::SliceInstantiationResultBus::MultiHandler
-    {
-    public:
-        AZ_CLASS_ALLOCATOR(SliceEditorEntityOwnershipService, AZ::SystemAllocator);
-        explicit SliceEditorEntityOwnershipService(const AzFramework::EntityContextId& entityContextId,
-            AZ::SerializeContext* serializeContext);
-
-        virtual ~SliceEditorEntityOwnershipService();
-
-        /**
-         * Switches to game mode in the editor.
-         * 
-         * \param m_editorToRuntimeIdMap The entityId map of editor entities to game entities.
-         * \param m_runtimeToEditorIdMap The entityId map of game entities to editor entities.
-         */
-        void StartPlayInEditor(EntityIdToEntityIdMap& m_editorToRuntimeIdMap, EntityIdToEntityIdMap& m_runtimeToEditorIdMap);
-
-        /**
-         * Stops the game mode in the editor.
-         * 
-         * \param m_editorToRuntimeIdMap The entityId map of editor entities to game entities.
-         * \param m_runtimeToEditorIdMap The entityId map of game entities to editor entities.
-         */
-        void StopPlayInEditor(EntityIdToEntityIdMap& m_editorToRuntimeIdMap, EntityIdToEntityIdMap& m_runtimeToEditorIdMap);
-
-        /**
-         * Saves the root slice of the entity ownership service to the specified buffer. Entities are saved as-is (with editor components).
-         *
-         * \param stream The stream to save the editor entity ownership service to.
-         * \param entitiesInLayers A list of entities that were saved into layers.
-         *        These won't be saved to the editor entity ownership service stream.
-         * \param instancesInLayers The map of slice references to their instances that were saved into layers.
-         *        These won't be saved to the editor entity ownership service stream.
-         * \return true if successfully saved. Failure is only possible if serialization data is corrupt.
-         */
-        bool SaveToStreamForEditor(AZ::IO::GenericStream& stream, const EntityList& entitiesInLayers,
-            AZ::SliceComponent::SliceReferenceToInstancePtrs& instancesInLayers);
-
-        /**
-         * Saves the root slice of entity ownership serive to the specified buffer.
-         * Entities undergo conversion for game: editor -> game components.
-         *
-         * \param stream The stream to save the entity ownership service to.
-         * \param streamType
-         * \return true if successfully saved. Failure is only possible if serialization data is corrupt.
-         */
-        bool SaveToStreamForGame(AZ::IO::GenericStream& stream, AZ::DataStream::StreamType streamType);
-
-        /**
-         * If the entities do not belong to a slice, associate them to the root slice metdata info component.
-         * 
-         * \param entities
-         */
-        void AssociateToRootMetadataEntity(const EntityList& entities);
-
-        /**
-         * Loads the root slice of EntityOwnershipService from the specified stream, and loads any layers referenced in the level.
-         * 
-         * \param stream The stream to load from.
-         * \param levelPakFile The path to the level's pak file, which is used to find the layers.
-         * \return true if successfully loaded.
-         */
-        bool LoadFromStreamWithLayers(AZ::IO::GenericStream& stream, QString levelPakFile);
-
-        //////////////////////////////////////////////////////////////////////////
-        // AssetBus
-        void OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
-        void OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
-        //////////////////////////////////////////////////////////////////////////
-
-        static void Reflect(AZ::ReflectContext* context);
-
-        using InstantiatingSlicePair = AZStd::pair<AZ::Data::Asset<AZ::Data::AssetData>, AZ::Transform>;
-    protected:
-        void HandleNewMetadataEntitiesCreated(AZ::SliceComponent& slice) override;
-
-    private:
-        //////////////////////////////////////////////////////////////////////////
-        // AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus
-        AzFramework::SliceInstantiationTicket InstantiateEditorSlice(const AZ::Data::Asset<AZ::Data::AssetData>& sliceAsset,
-            const AZ::Transform& worldTransform) override;
-        AZ::SliceComponent::SliceInstanceAddress CloneEditorSliceInstance(AZ::SliceComponent::SliceInstanceAddress sourceInstance,
-            AZ::SliceComponent::EntityIdToEntityIdMap& sourceToCloneEntityIdMap) override;
-        AZ::SliceComponent::SliceInstanceAddress CloneSubSliceInstance(
-            const AZ::SliceComponent::SliceInstanceAddress& sourceSliceInstanceAddress,
-            const AZStd::vector<AZ::SliceComponent::SliceInstanceAddress>& sourceSubSliceInstanceAncestry,
-            const AZ::SliceComponent::SliceInstanceAddress& sourceSubSliceInstanceAddress,
-            AZ::SliceComponent::EntityIdToEntityIdMap* out_sourceToCloneEntityIdMap) override;
-        AZ::SliceComponent::SliceInstanceAddress PromoteEditorEntitiesIntoSlice(const AZ::Data::Asset<AZ::SliceAsset>& sliceAsset,
-            const AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetMap) override;
-        void DetachSliceEntities(const EntityIdList& entities) override;
-        void DetachSliceInstances(const AZ::SliceComponent::SliceInstanceAddressSet& instances) override;
-        void DetachSubsliceInstances(const AZ::SliceComponent::SliceInstanceEntityIdRemapList& subsliceRootList) override;
-        void RestoreSliceEntity(AZ::Entity* entity, const AZ::SliceComponent::EntityRestoreInfo& info,
-            SliceEntityRestoreType restoreType) override;
-        void ResetEntitiesToSliceDefaults(EntityIdList entities) override;
-        AZ::SliceComponent* GetEditorRootSlice() override;
-        //////////////////////////////////////////////////////////////////////////
-
-        //////////////////////////////////////////////////////////////////////////
-        // AzFramework::SliceInstantiationResultBus
-        void OnSlicePreInstantiate(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& sliceAddress) override;
-        void OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& sliceAddress) override;
-        void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId) override;
-        //////////////////////////////////////////////////////////////////////////
-
-        void UpdateSelectedEntitiesInHierarchy(const EntityIdSet& entityIdSet);
-        void DetachFromSlice(const EntityIdList& entities, const char* undoMessage);
-
-        /**
-         * Slice entity restore requests, which can be deferred if asset wasn't loaded at request time.
-         */
-        struct SliceEntityRestoreRequest
-        {
-            AZ::Entity* m_entity;
-            AZ::SliceComponent::EntityRestoreInfo m_restoreInfo;
-            AZ::Data::Asset<AZ::Data::AssetData> m_asset;
-            SliceEntityRestoreType m_restoreType;
-        };
-
-        AZStd::vector<SliceEntityRestoreRequest> m_queuedSliceEntityRestores;
-
-        AZStd::vector<InstantiatingSlicePair> m_instantiatingSlices;
-    };
-}
-

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