Revamped AzFramework::Scene (#332)
Updated AzFramework::Scene to allow it to serve as the one-stop location for localized singletons. Localized singletons in this case are instance that can only occur once in an environment but multiple times within an application. As an example, this allows settings up a single camera per viewport for instance. Highlights of changes: Replaced the original ebuses with interfaces and events for easy of use and performance. Removed the Entity Context specific code and moved that to new locations within the Entity Context itself. Allowed basic inheritance. If a subsystem isn't found in a scene the parent can optionally be searched. Scenes can enter a zombie state and avoid immediately being deleted. This is needed for situations where subsystems can't be destroyed until async calls have been completed.
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzFramework/Entity/EntityContext.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzFramework/Entity/EntityContext.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include <AzFramework/Entity/EntityContextBus.h>
|
||||
#include <AzFramework/Entity/EntityContext.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include <SkinnedMesh/SkinnedMeshDebugDisplay.h>
|
||||
#include <Atom/Feature/SkinnedMesh/SkinnedMeshStatsBus.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ namespace AZ
|
||||
RPI::ScenePtr m_scene;
|
||||
AZStd::string m_sceneName = "Material Thumbnail Scene";
|
||||
AZStd::string m_pipelineName = "Material Thumbnail Pipeline";
|
||||
AzFramework::Scene* m_frameworkScene = nullptr;
|
||||
AZStd::shared_ptr<AzFramework::Scene> m_frameworkScene;
|
||||
RPI::RenderPipelinePtr m_renderPipeline;
|
||||
AZStd::unique_ptr<AzFramework::EntityContext> m_entityContext;
|
||||
AZStd::vector<AZStd::string> m_passHierarchy;
|
||||
|
||||
+7
-16
@@ -100,24 +100,15 @@ namespace AZ
|
||||
data->m_scene->SetShaderResourceGroupCallback(callback);
|
||||
|
||||
// Bind m_defaultScene to the GameEntityContext's AzFramework::Scene
|
||||
Outcome<AzFramework::Scene*, AZStd::string> createSceneOutcome;
|
||||
AzFramework::SceneSystemRequestBus::BroadcastResult(
|
||||
createSceneOutcome,
|
||||
&AzFramework::SceneSystemRequests::CreateScene,
|
||||
data->m_sceneName);
|
||||
auto* sceneSystem = AzFramework::SceneSystemInterface::Get();
|
||||
AZ_Assert(sceneSystem, "Thumbnail system failed to get scene system implementation.");
|
||||
Outcome<AZStd::shared_ptr<AzFramework::Scene>, AZStd::string> createSceneOutcome =
|
||||
sceneSystem->CreateScene(data->m_sceneName);
|
||||
AZ_Assert(createSceneOutcome, createSceneOutcome.GetError().c_str()); // This should never happen unless scene creation has changed.
|
||||
createSceneOutcome.GetValue()->SetSubsystem(data->m_scene.get());
|
||||
data->m_frameworkScene = createSceneOutcome.GetValue();
|
||||
data->m_frameworkScene->SetSubsystem(data->m_scene.get());
|
||||
|
||||
bool success = false;
|
||||
AzFramework::SceneSystemRequestBus::BroadcastResult(
|
||||
success,
|
||||
&AzFramework::SceneSystemRequests::SetSceneForEntityContextId,
|
||||
data->m_entityContext->GetContextId(),
|
||||
data->m_frameworkScene);
|
||||
AZ_Assert(success, "Unable to set entity context on AzFramework::Scene: %s", data->m_sceneName.c_str());
|
||||
data->m_frameworkScene = createSceneOutcome.TakeValue();
|
||||
data->m_frameworkScene->SetSubsystem(data->m_scene);
|
||||
|
||||
data->m_frameworkScene->SetSubsystem(data->m_entityContext.get());
|
||||
// Create a render pipeline from the specified asset for the window context and add the pipeline to the scene
|
||||
RPI::RenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.m_mainViewTagName = "MainCamera";
|
||||
|
||||
+8
-6
@@ -14,7 +14,7 @@
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
#include <Thumbnails/Rendering/ThumbnailRendererContext.h>
|
||||
#include <Thumbnails/Rendering/ThumbnailRendererData.h>
|
||||
#include <Thumbnails/Rendering/ThumbnailRendererSteps/ReleaseResourcesStep.h>
|
||||
@@ -49,11 +49,13 @@ namespace AZ
|
||||
m_context->GetData()->m_scene->Deactivate();
|
||||
m_context->GetData()->m_scene->RemoveRenderPipeline(m_context->GetData()->m_renderPipeline->GetId());
|
||||
RPI::RPISystemInterface::Get()->UnregisterScene(m_context->GetData()->m_scene);
|
||||
bool sceneRemovedSuccessfully = false;
|
||||
AzFramework::SceneSystemRequestBus::BroadcastResult(
|
||||
sceneRemovedSuccessfully,
|
||||
&AzFramework::SceneSystemRequests::RemoveScene,
|
||||
m_context->GetData()->m_sceneName);
|
||||
|
||||
auto sceneSystem = AzFramework::SceneSystemInterface::Get();
|
||||
AZ_Assert(sceneSystem, "Thumbnail system failed to get scene system implementation.");
|
||||
[[maybe_unused]] bool sceneRemovedSuccessfully = sceneSystem->RemoveScene(m_context->GetData()->m_sceneName);
|
||||
AZ_Assert(
|
||||
sceneRemovedSuccessfully, "Thumbnail system was unable to remove scene '%s' from the scene system.",
|
||||
m_context->GetData()->m_sceneName.c_str());
|
||||
m_context->GetData()->m_scene = nullptr;
|
||||
m_context->GetData()->m_renderPipeline = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user