Browse Source

Ensured meshes get properly released
Added Banshee version defines

Marko Pintera 11 years ago
parent
commit
2386b6c4cd

+ 2 - 1
BansheeCore/Include/BsMeshProxy.h

@@ -11,8 +11,9 @@ namespace BansheeEngine
 	 */
 	struct BS_CORE_EXPORT MeshProxy
 	{
-		MeshBasePtr mesh;
+		std::weak_ptr<MeshBase> mesh;
 		SubMesh subMesh;
 		Bounds bounds;
+		UINT32 submeshIdx;
 	};
 }

+ 2 - 2
BansheeCore/Source/BsCoreObjectManager.cpp

@@ -21,8 +21,8 @@ namespace BansheeEngine
 			// (Reason: This is called on application shutdown and at that point we also unload any dynamic libraries, 
 			// which will invalidate any pointers to objects created from those libraries. Therefore we require of the user to 
 			// clean up all objects manually before shutting down the application).
-			BS_EXCEPT(InternalErrorException, "Core object manager shut down, but not all objects were released. User must release ALL " \
-				"engine objects before application shutdown.");
+			BS_EXCEPT(InternalErrorException, "Core object manager shut down, but not all objects were released. Application must release ALL " \
+				"engine objects before shutdown.");
 		}
 #endif
 	}

+ 1 - 0
BansheeCore/Source/BsMesh.cpp

@@ -392,6 +392,7 @@ namespace BansheeEngine
 		coreProxy->mesh = std::static_pointer_cast<MeshBase>(getThisPtr());
 		coreProxy->bounds = mBounds;
 		coreProxy->subMesh = getSubMesh(subMeshIdx);
+		coreProxy->submeshIdx = subMeshIdx;
 
 		return coreProxy;
 	}

+ 2 - 1
BansheeCore/Source/BsTransientMesh.cpp

@@ -60,11 +60,12 @@ namespace BansheeEngine
 		MeshProxyPtr coreProxy = bs_shared_ptr<MeshProxy>();
 		coreProxy->mesh = std::static_pointer_cast<MeshBase>(getThisPtr());
 		coreProxy->subMesh = mSubMeshes[0];
+		coreProxy->submeshIdx = subMeshIdx;
 
 		// Note: Not calculating bounds for transient meshes yet
 		// (No particular reason, I just didn't bother)
 		coreProxy->bounds = Bounds(); 
-
+		
 		return coreProxy;
 	}
 }

+ 5 - 0
BansheeEngine/Source/BsApplication.cpp

@@ -54,15 +54,20 @@ namespace BansheeEngine
 		BuiltinResources::startUp();
 		Cursor::startUp();
 
+#if BS_VER == BS_VER_DEV
 		loadPlugin("BansheeMono", &mMonoPlugin);
 		loadPlugin("SBansheeEngine", &mSBansheeEnginePlugin); // Scripting interface
+#endif
 	}
 
 	Application::~Application()
 	{
 		ScriptManager::instance().destroy();
+
+#if BS_VER == BS_VER_DEV
 		unloadPlugin(mSBansheeEnginePlugin);
 		unloadPlugin(mMonoPlugin);
+#endif
 
 		Cursor::shutDown();
 		BuiltinResources::shutDown();

+ 0 - 3
BansheeEngine/Source/BsProfilerOverlay.cpp

@@ -291,9 +291,6 @@ namespace BansheeEngine
 
 	ProfilerOverlay::~ProfilerOverlay()
 	{
-		if(mIsShown)
-			hide();
-
 		if(mTarget != nullptr)
 			mTargetResizedConn.disconnect();
 

+ 7 - 1
BansheeRenderer/Source/BsBansheeRenderer.cpp

@@ -555,7 +555,13 @@ namespace BansheeEngine
 		THROW_IF_NOT_CORE_THREAD;
 
 		RenderSystem& rs = RenderSystem::instance();
-		MeshBasePtr mesh = meshProxy.mesh;
+		MeshBasePtr mesh;
+
+		if (!meshProxy.mesh.expired())
+			mesh = meshProxy.mesh.lock(); 
+		else
+			return;
+
 		std::shared_ptr<VertexData> vertexData = mesh->_getVertexData();
 
 		rs.setVertexDeclaration(vertexData->vertexDeclaration);

+ 7 - 0
BansheeUtility/Include/BsPrerequisitesUtil.h

@@ -9,6 +9,13 @@
 
 #define BS_PROFILING_ENABLED 1
 
+// Versions
+
+#define BS_VER_DEV 1
+#define BS_VER_PREVIEW 2
+
+#define BS_VER VS_VER_PREVIEW
+
 // Platform-specific stuff
 #include "BsPlatformDefines.h"
 

+ 3 - 0
Polish.txt

@@ -1,6 +1,7 @@
 Polish TODO:
  - Finalize example with resolution settings and proper GUI
   - Ensure that going fullscreen and windowed works fine
+ - Mouse movement is release build is too slow
  - Add an example model
  - Test if example shuts down fine
 
@@ -18,6 +19,8 @@ Polish TODO:
  - Test checking out source and extracting dependencies and see if it compiles
  - Test compiling on another PC
 
+Transient meshes never get released. I'm assuming its circular reference MeshBase and MeshProxy have to each-other. Figure out a way to resolve it properly.
+
 -----------------
 
 Not so critical