Browse Source

Properly cleaning up scene on shutdown
Properly cleaning up finalized script objects on shutdown
Properly releasing the active render target before the render window manager is shut down

Marko Pintera 10 years ago
parent
commit
d8f42b37eb

+ 3 - 1
BansheeCore/Include/BsCoreSceneManager.h

@@ -24,8 +24,10 @@ namespace BansheeEngine
 
 		/**
 		 * @brief	Destroys all scene objects in the scene.
+		 *
+		 * @param	forceAll	If true, then even the persistent objects will be unloaded.
 		 */
-		void clearScene();
+		void clearScene(bool forceAll = false);
 
 		/**
 		 * @brief	Called every frame.

+ 3 - 4
BansheeCore/Source/BsCoreSceneManager.cpp

@@ -18,7 +18,7 @@ namespace BansheeEngine
 			mRootNode->destroy(true);
 	}
 
-	void CoreSceneManager::clearScene()
+	void CoreSceneManager::clearScene(bool forceAll)
 	{
 		UINT32 numChildren = mRootNode->getNumChildren();
 
@@ -27,11 +27,10 @@ namespace BansheeEngine
 		{
 			HSceneObject child = mRootNode->getChild(curIdx);
 
-			if (!child->hasFlag(SOF_Persistent))
-			{
+			if (forceAll || !child->hasFlag(SOF_Persistent))
 				child->destroy();
+			else
 				curIdx++;
-			}
 		}
 
 		GameObjectManager::instance().destroyQueuedObjects();

+ 1 - 0
BansheeD3D11RenderSystem/Source/BsD3D11RenderAPI.cpp

@@ -169,6 +169,7 @@ namespace BansheeEngine
 
 		mActiveVertexDeclaration = nullptr;
 		mActiveVertexShader = nullptr;
+		mActiveRenderTarget = nullptr;
 
 		RenderStateCoreManager::shutDown();
 		RenderWindowCoreManager::shutDown();

+ 1 - 1
BansheeEngine/Source/BsApplication.cpp

@@ -90,7 +90,7 @@ namespace BansheeEngine
 	{
 		// Need to clear all objects before I unload any plugins, as they
 		// could have allocated parts or all of those objects.
-		SceneManager::instance().clearScene();
+		SceneManager::instance().clearScene(true);
 
 		// These plugins must be unloaded before any other script plugins, because
 		// they will cause finalizers to trigger and various modules those finalizers

+ 0 - 6
MBansheeEditor/EditorApplication.cs

@@ -99,10 +99,6 @@ namespace BansheeEditor
             inputConfig.RegisterAxis(SceneCamera.HorizontalAxisBinding, InputAxis.MouseX);
             inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
 
-            // Open windows
-            InspectorWindow inspector = EditorWindow.OpenWindow<InspectorWindow>();
-            EditorWindow.OpenWindow<SceneWindow>();
-
             ProjectLibrary.Refresh();
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
             monitor.OnAdded += OnAssetModified;
@@ -115,8 +111,6 @@ namespace BansheeEditor
             dbgComponent = newDbgObject.AddComponent<Debug_Component1>();
             newDbgObject.AddComponent<Debug_Component2>();
 
-            inspector.SetObjectToInspect(newDbgObject);
-
             SceneObject gizmoDbgObject = new SceneObject("GizmoDebug");
             gizmoDbgObject.AddComponent<DbgGizmoComponent>();
 

+ 1 - 0
SBansheeEngine/Include/BsScriptObjectManager.h

@@ -9,6 +9,7 @@ namespace BansheeEngine
 	{
 	public:
 		ScriptObjectManager();
+		~ScriptObjectManager();
 
 		void registerScriptObject(ScriptObjectBase* instance);
 		void unregisterScriptObject(ScriptObjectBase* instance);

+ 2 - 0
SBansheeEngine/Source/BsScriptEnginePlugin.cpp

@@ -54,6 +54,8 @@ namespace BansheeEngine
 		ScriptInput::shutDown();
 		ManagedResourceManager::shutDown();
 		ScriptManager::instance().destroy();
+		ScriptObjectManager::instance().processFinalizedObjects();
+
 		ScriptGameObjectManager::shutDown();
 		ScriptResourceManager::shutDown();
 		ScriptAssemblyManager::shutDown();

+ 5 - 0
SBansheeEngine/Source/BsScriptObjectManager.cpp

@@ -11,6 +11,11 @@ namespace BansheeEngine
 
 	}
 
+	ScriptObjectManager::~ScriptObjectManager()
+	{
+		processFinalizedObjects();
+	}
+
 	void ScriptObjectManager::registerScriptObject(ScriptObjectBase* instance)
 	{
 		mScriptObjects.insert(instance);

+ 0 - 1
TODO.txt

@@ -56,7 +56,6 @@ Code quality improvements:
 ----------------------------------------------------------------------
 Polish stage 1
 
-After undocking ProjectWindow the auto-scroll seems to be stuck in up position
 When selecting an gizmo icon the selection seems delayed and its gizmos flash for a frame before hiding (Can't reproduce atm but I saw it)
 Decent looking default layout