Marko Pintera 12 лет назад
Родитель
Сommit
1eafbaa11b
35 измененных файлов с 88 добавлено и 109 удалено
  1. 2 2
      CamelotClient/CamelotClient.cpp
  2. 2 2
      CamelotCore/Include/CmDeferredRenderContext.h
  3. 1 2
      CamelotCore/Include/CmFontImportOptionsRTTI.h
  4. 3 4
      CamelotCore/Include/CmFontRTTI.h
  5. 2 4
      CamelotCore/Include/CmGameObjectHandle.h
  6. 1 2
      CamelotCore/Include/CmGpuProgramImportOptionsRTTI.h
  7. 1 2
      CamelotCore/Include/CmImportOptionsRTTI.h
  8. 2 2
      CamelotCore/Include/CmMaterialManager.cpp
  9. 1 2
      CamelotCore/Include/CmPassRTTI.h
  10. 1 2
      CamelotCore/Include/CmPixelDataRTTI.h
  11. 1 2
      CamelotCore/Include/CmResourceHandle.h
  12. 2 2
      CamelotCore/Include/CmSceneObject.h
  13. 1 2
      CamelotCore/Include/CmTechniqueRTTI.h
  14. 13 13
      CamelotCore/Source/CmApplication.cpp
  15. 4 4
      CamelotCore/Source/CmCgProgramFactory.cpp
  16. 4 4
      CamelotCore/Source/CmCommandQueue.cpp
  17. 1 1
      CamelotCore/Source/CmGpuBuffer.cpp
  18. 6 6
      CamelotCore/Source/CmGpuParams.cpp
  19. 2 2
      CamelotCore/Source/CmGpuProgInclude.cpp
  20. 1 2
      CamelotCore/Source/CmGpuProgram.cpp
  21. 1 2
      CamelotCore/Source/CmGpuProgramImporter.cpp
  22. 1 1
      CamelotCore/Source/CmHardwareBufferManager.cpp
  23. 2 2
      CamelotCore/Source/CmImporter.cpp
  24. 1 2
      CamelotCore/Source/CmMaterialRTTI.cpp
  25. 3 4
      CamelotCore/Source/CmMesh.cpp
  26. 1 2
      CamelotCore/Source/CmMeshData.cpp
  27. 3 3
      CamelotCore/Source/CmMeshManager.cpp
  28. 4 4
      CamelotCore/Source/CmRenderStateManager.cpp
  29. 5 6
      CamelotCore/Source/CmRenderSystem.cpp
  30. 1 2
      CamelotCore/Source/CmResourceHandle.cpp
  31. 7 10
      CamelotCore/Source/CmResources.cpp
  32. 3 2
      CamelotCore/Source/CmSceneObject.cpp
  33. 1 2
      CamelotCore/Source/CmSpecificImporter.cpp
  34. 1 1
      CamelotCore/Source/CmTextUtility.cpp
  35. 3 4
      CamelotCore/Source/CmTexture.cpp

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -30,9 +30,9 @@
 #include "CmRTTIType.h"
 #include "CmCursor.h"
 
-//#define DX11
+#define DX11
 //#define DX9
-#define GL
+//#define GL
 
 using namespace CamelotFramework;
 using namespace BansheeEditor;

+ 2 - 2
CamelotCore/Include/CmDeferredRenderContext.h

@@ -35,12 +35,12 @@ namespace CamelotFramework
 		{
 			assert(mRenderSystem != nullptr);
 
-			mCommandQueue = CM_NEW(CommandQueue<CommandQueueSyncPolicy>, GenAlloc) CommandQueue<CommandQueueSyncPolicy>(threadId);
+			mCommandQueue = cm_new<CommandQueue<CommandQueueSyncPolicy>>(threadId);
 		}
 
 		~DeferredRenderContext()
 		{
-			CM_DELETE(mCommandQueue, CommandQueue<CommandQueueSyncPolicy>, GenAlloc);
+			cm_delete(mCommandQueue);
 		}
 
 		/** @copydoc RenderSystem::disableTextureUnit() */

+ 1 - 2
CamelotCore/Include/CmFontImportOptionsRTTI.h

@@ -30,8 +30,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			return ImportOptionsPtr(CM_NEW(FontImportOptions, PoolAlloc) FontImportOptions(),
-				&MemAllocDeleter<FontImportOptions, PoolAlloc>::deleter);
+			return cm_shared_ptr<FontImportOptions, PoolAlloc>();
 		}
 	};
 }

+ 3 - 4
CamelotCore/Include/CmFontRTTI.h

@@ -72,8 +72,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			return std::shared_ptr<FontData>(CM_NEW(FontData, PoolAlloc) FontData(),
-				&MemAllocDeleter<FontData, PoolAlloc>::deleter);
+			return cm_shared_ptr<FontData, PoolAlloc>();
 		}
 	};
 
@@ -141,7 +140,7 @@ namespace CamelotFramework
 	protected:
 		virtual void onDeserializationStarted(IReflectable* obj)
 		{
-			FontInitData* initData = CM_NEW(FontInitData, PoolAlloc) FontInitData();
+			FontInitData* initData = cm_new<FontInitData, PoolAlloc>();
 
 			Font* font = static_cast<Font*>(obj);
 			font->mRTTIData = initData;
@@ -154,7 +153,7 @@ namespace CamelotFramework
 
 			font->initialize(initData->fontDataPerSize);
 
-			CM_DELETE(initData, FontInitData, PoolAlloc);
+			cm_delete<PoolAlloc>(initData);
 		}
 	};
 }

+ 2 - 4
CamelotCore/Include/CmGameObjectHandle.h

@@ -75,8 +75,7 @@ namespace CamelotFramework
 		GameObjectHandle()
 			:GameObjectHandleBase()
 		{	
-			mData = std::shared_ptr<GameObjectHandleData>(CM_NEW(GameObjectHandleData, PoolAlloc) GameObjectHandleData(),
-				&MemAllocDeleter<GameObjectHandleData, PoolAlloc>::deleter);
+			mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>();
 		}
 
 		template <typename T1>
@@ -114,8 +113,7 @@ namespace CamelotFramework
 		explicit GameObjectHandle(T* ptr, void(*deleter)(GameObject*) = nullptr)
 			:GameObjectHandleBase()
 		{
-			mData = std::shared_ptr<GameObjectHandleData>(CM_NEW(GameObjectHandleData, PoolAlloc) GameObjectHandleData((GameObject*)ptr, deleter),
-				&MemAllocDeleter<GameObjectHandleData, PoolAlloc>::deleter);
+			mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>((GameObject*)ptr, deleter);
 		}
 	};
 

+ 1 - 2
CamelotCore/Include/CmGpuProgramImportOptionsRTTI.h

@@ -50,8 +50,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			return ImportOptionsPtr(CM_NEW(GpuProgramImportOptions, PoolAlloc) GpuProgramImportOptions(),
-				&MemAllocDeleter<GpuProgramImportOptions, PoolAlloc>::deleter);
+			return cm_shared_ptr<GpuProgramImportOptions, PoolAlloc>();
 		}
 	};
 }

+ 1 - 2
CamelotCore/Include/CmImportOptionsRTTI.h

@@ -26,8 +26,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			return ImportOptionsPtr(CM_NEW(ImportOptions, PoolAlloc) ImportOptions(),
-				&MemAllocDeleter<ImportOptions, PoolAlloc>::deleter);
+			return cm_shared_ptr<ImportOptions, PoolAlloc>();
 		}
 	};
 }

+ 2 - 2
CamelotCore/Include/CmMaterialManager.cpp

@@ -5,7 +5,7 @@ namespace CamelotFramework
 {
 	MaterialPtr MaterialManager::create() const
 	{
-		MaterialPtr newMat(CM_NEW(Material, PoolAlloc) Material(), &CoreObject::_deleteDelayed<Material, PoolAlloc>);
+		MaterialPtr newMat = cm_core_ptr<Material, PoolAlloc>(new (cm_alloc<Material, PoolAlloc>()) Material());
 		newMat->setThisPtr(newMat);
 		newMat->initialize();
 
@@ -14,7 +14,7 @@ namespace CamelotFramework
 
 	MaterialPtr MaterialManager::create(ShaderPtr shader) const
 	{
-		MaterialPtr newMat(CM_NEW(Material, PoolAlloc) Material(), &CoreObject::_deleteDelayed<Material, PoolAlloc>);
+		MaterialPtr newMat = cm_core_ptr<Material, PoolAlloc>(new (cm_alloc<Material, PoolAlloc>()) Material());
 		newMat->setThisPtr(newMat);
 		newMat->initialize();
 		newMat->setShader(shader);

+ 1 - 2
CamelotCore/Include/CmPassRTTI.h

@@ -63,8 +63,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			return std::shared_ptr<Pass>(CM_NEW(Pass, PoolAlloc) Pass(),
-				&MemAllocDeleter<Pass, PoolAlloc>::deleter);
+			return cm_shared_ptr<Pass, PoolAlloc>();
 		}
 	};
 }

+ 1 - 2
CamelotCore/Include/CmPixelDataRTTI.h

@@ -84,8 +84,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			PixelDataPtr newPixelData(CM_NEW(PixelData, PoolAlloc) PixelData(),
-				&MemAllocDeleter<PixelData, PoolAlloc>::deleter);
+			PixelDataPtr newPixelData = cm_shared_ptr<PixelData, PoolAlloc>();
 
 			return newPixelData;
 		}

+ 1 - 2
CamelotCore/Include/CmResourceHandle.h

@@ -128,8 +128,7 @@ namespace CamelotFramework
 		 */
 		void reset()
 		{
-			mData = std::shared_ptr<ResourceHandleData>(CM_NEW(ResourceHandleData, ScratchAlloc) ResourceHandleData(),
-				&MemAllocDeleter<ResourceHandleData, ScratchAlloc>::deleter);
+			mData = cm_shared_ptr<ResourceHandleData, ScratchAlloc>();
 		}
 
 		template<class _Ty>

+ 2 - 2
CamelotCore/Include/CmSceneObject.h

@@ -216,8 +216,8 @@ namespace CamelotFramework
 			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<CamelotFramework::Component, T>::value), 
 				"Specified type is not a valid Component.");
 
-			GameObjectHandle<T> newComponent = GameObjectHandle<T>(CM_NEW(T, PoolAlloc) T(mThisHandle),
-				&MemAllocDeleter<GameObject, PoolAlloc>::deleter);
+			GameObjectHandle<T> newComponent = GameObjectHandle<T>(
+				new (cm_alloc<T, PoolAlloc>()) T(mThisHandle), &cm_delete<PoolAlloc, GameObject>);
 			mComponents.push_back(newComponent);
 
 			gSceneManager().notifyComponentAdded(newComponent);

+ 1 - 2
CamelotCore/Include/CmTechniqueRTTI.h

@@ -57,8 +57,7 @@ namespace CamelotFramework
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
-			return std::shared_ptr<Technique>(CM_NEW(Technique, PoolAlloc) Technique(),
-				&MemAllocDeleter<Technique, PoolAlloc>::deleter);
+			return cm_shared_ptr<Technique, PoolAlloc>(new (cm_alloc<Technique, PoolAlloc>()) Technique());
 		}
 	};
 }

+ 13 - 13
CamelotCore/Source/CmApplication.cpp

@@ -46,17 +46,17 @@ namespace CamelotFramework
 	{
 		MemStack::setupHeap(HID_Main);
 
-		Time::startUp(CM_NEW(Time, GenAlloc) Time());
-		Input::startUp(CM_NEW(Input, GenAlloc) Input());
-		DynLibManager::startUp(CM_NEW(DynLibManager, GenAlloc) DynLibManager());
-		CoreGpuObjectManager::startUp(CM_NEW(CoreGpuObjectManager, GenAlloc) CoreGpuObjectManager());
-		Resources::startUp(CM_NEW(Resources, GenAlloc) Resources(desc.resourceCacheDirectory));
-		HighLevelGpuProgramManager::startUp(CM_NEW(HighLevelGpuProgramManager, GenAlloc) HighLevelGpuProgramManager());
-
-		RenderSystemManager::startUp(CM_NEW(RenderSystemManager, GenAlloc) RenderSystemManager());
+		Time::startUp(cm_new<Time>());
+		Input::startUp(cm_new<Input>());
+		DynLibManager::startUp(cm_new<DynLibManager>());
+		CoreGpuObjectManager::startUp(cm_new<CoreGpuObjectManager>());
+		Resources::startUp(cm_new<Resources>(desc.resourceCacheDirectory));
+		HighLevelGpuProgramManager::startUp(cm_new<HighLevelGpuProgramManager>());
+
+		RenderSystemManager::startUp(cm_new<RenderSystemManager>());
 		mPrimaryWindow = RenderSystemManager::instance().initialize(desc.renderSystem, desc.primaryWindowDesc);
 
-		RendererManager::startUp(CM_NEW(RendererManager, GenAlloc) RendererManager());
+		RendererManager::startUp(cm_new<RendererManager>());
 
 		loadPlugin(desc.renderer);
 		RendererManager::instance().setActive(desc.renderer);
@@ -68,11 +68,11 @@ namespace CamelotFramework
 
 		SceneManager::startUp((SceneManager*)loadPlugin(desc.sceneManager));
 
-		MeshManager::startUp(CM_NEW(MeshManager, GenAlloc) MeshManager());
-		MaterialManager::startUp(CM_NEW(MaterialManager, GenAlloc) MaterialManager());
-		FontManager::startUp(CM_NEW(FontManager, GenAlloc) FontManager());
+		MeshManager::startUp(cm_new<MeshManager>());
+		MaterialManager::startUp(cm_new<MaterialManager>());
+		FontManager::startUp(cm_new<FontManager>());
 
-		Importer::startUp(CM_NEW(Importer, GenAlloc) Importer());
+		Importer::startUp(cm_new<Importer>());
 
 		for(auto& importerName : desc.importers)
 			loadPlugin(importerName);

+ 4 - 4
CamelotCore/Source/CmCgProgramFactory.cpp

@@ -57,16 +57,16 @@ namespace CamelotFramework {
     HighLevelGpuProgramPtr CgProgramFactory::create(const String& source, const String& entryPoint, 
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<HGpuProgInclude>::type* includes)
     {
-		CgProgram* prog = CM_NEW(CgProgram, PoolAlloc) CgProgram(mCgContext, source, entryPoint, sLanguageName, gptype, profile, includes);
+		CgProgram* prog = new (cm_alloc<CgProgram, PoolAlloc>()) CgProgram(mCgContext, source, entryPoint, sLanguageName, gptype, profile, includes);
 
-		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<CgProgram, PoolAlloc>);
+		return cm_core_ptr<CgProgram, PoolAlloc>(prog);
     }
 	//----------------------------------------------------------------------
 	HighLevelGpuProgramPtr CgProgramFactory::create()
 	{
-		CgProgram* prog = CM_NEW(CgProgram, PoolAlloc) CgProgram(mCgContext, "", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
+		CgProgram* prog = new (cm_alloc<CgProgram, PoolAlloc>()) CgProgram(mCgContext, "", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
 
-		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<CgProgram, PoolAlloc>);
+		return cm_core_ptr<CgProgram, PoolAlloc>(prog);
 	}
     //-----------------------------------------------------------------------
 }

+ 4 - 4
CamelotCore/Source/CmCommandQueue.cpp

@@ -10,7 +10,7 @@ namespace CamelotFramework
 	CommandQueueBase::CommandQueueBase(CM_THREAD_ID_TYPE threadId, bool allowAllThreads)
 		:mMyThreadId(threadId), mAllowAllThreads(allowAllThreads), mMaxDebugIdx(0)
 	{
-		mCommands = CM_NEW(std::queue<QueuedCommand>, PoolAlloc) std::queue<QueuedCommand>();
+		mCommands = cm_new<std::queue<QueuedCommand>, PoolAlloc>();
 
 		{
 			CM_LOCK_MUTEX(CommandQueueBreakpointMutex);
@@ -22,14 +22,14 @@ namespace CamelotFramework
 	CommandQueueBase::CommandQueueBase(CM_THREAD_ID_TYPE threadId, bool allowAllThreads)
 		:mMyThreadId(threadId), mAllowAllThreads(allowAllThreads)
 	{
-		mCommands = CM_NEW(std::queue<QueuedCommand>, PoolAlloc) std::queue<QueuedCommand>();
+		mCommands = cm_new<std::queue<QueuedCommand>, PoolAlloc>();
 	}
 #endif
 
 	CommandQueueBase::~CommandQueueBase()
 	{
 		if(mCommands != nullptr)
-			CM_DELETE(mCommands, queue<QueuedCommand>, PoolAlloc);
+			cm_delete(mCommands);
 	}
 
 	AsyncOp CommandQueueBase::queueReturn(boost::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete, UINT32 _callbackId)
@@ -73,7 +73,7 @@ namespace CamelotFramework
 	std::queue<QueuedCommand>* CommandQueueBase::flush()
 	{
 		std::queue<QueuedCommand>* oldCommands = mCommands;
-		mCommands = CM_NEW(std::queue<QueuedCommand>, PoolAlloc) std::queue<QueuedCommand>();
+		mCommands = cm_new<std::queue<QueuedCommand>, PoolAlloc>();
 
 		return oldCommands;
 	}

+ 1 - 1
CamelotCore/Source/CmGpuBuffer.cpp

@@ -47,7 +47,7 @@ namespace CamelotFramework
 		{
 			GpuBufferView* newView = buffer->createView();
 			newView->initialize(buffer, key);
-			buffer->mBufferViews[key] = CM_NEW(GpuBufferReference, PoolAlloc) GpuBufferReference(newView);
+			buffer->mBufferViews[key] = cm_new<GpuBufferReference, PoolAlloc>(newView);
 
 			iterFind = buffer->mBufferViews.find(key);
 		}

+ 6 - 6
CamelotCore/Source/CmGpuParams.cpp

@@ -44,7 +44,7 @@ namespace CamelotFramework
 	{
 		for(auto& paramBlock : mParamBlocks)
 		{
-			CM_DELETE(paramBlock, GpuParamBlock, PoolAlloc);
+			cm_delete<PoolAlloc>(paramBlock);
 		}
 	}
 
@@ -81,9 +81,9 @@ namespace CamelotFramework
 		}
 
 		if(mParamBlocks[slot] != nullptr)
-			CM_DELETE(mParamBlocks[slot], GpuParamBlock, PoolAlloc);
+			cm_delete<PoolAlloc>(mParamBlocks[slot]);
 
-		mParamBlocks[slot] = CM_NEW(GpuParamBlock, PoolAlloc) GpuParamBlock(paramBlockBuffer->getSize());
+		mParamBlocks[slot] = cm_new<GpuParamBlock, PoolAlloc>(paramBlockBuffer->getSize());
 		mParamBlockBuffers[slot] = paramBlockBuffer;
 	}
 
@@ -100,7 +100,7 @@ namespace CamelotFramework
 		if(mParamBlocks[iterFind->second.slot] != nullptr)
 			CM_DELETE(mParamBlocks[iterFind->second.slot], GpuParamBlock, PoolAlloc);
 
-		mParamBlocks[iterFind->second.slot] = CM_NEW(GpuParamBlock, PoolAlloc) GpuParamBlock(paramBlockBuffer->getSize());
+		mParamBlocks[iterFind->second.slot] = cm_new<GpuParamBlock, PoolAlloc>(paramBlockBuffer->getSize());
 		mParamBlockBuffers[iterFind->second.slot] = paramBlockBuffer;
 	}
 
@@ -304,7 +304,7 @@ namespace CamelotFramework
 
 	BindableGpuParams GpuParams::createBindableCopy(GpuParamsPtr params)
 	{
-		GpuParams* copy = CM_NEW(GpuParams, ScratchAlloc) GpuParams(params->mParamDesc);
+		GpuParams* copy = cm_new<GpuParams, ScratchAlloc>(std::ref(params->mParamDesc));
 
 		copy->mTransposeMatrices = params->mTransposeMatrices;
 		copy->mSamplerStates = params->mSamplerStates;
@@ -314,7 +314,7 @@ namespace CamelotFramework
 		copy->mParamBlocks.clear();
 		for(auto& paramBlock : params->mParamBlocks)
 		{
-			GpuParamBlock* blockCopy = CM_NEW(GpuParamBlock, ScratchAlloc) GpuParamBlock(paramBlock);
+			GpuParamBlock* blockCopy = cm_new<GpuParamBlock, ScratchAlloc>(paramBlock);
 
 			copy->mParamBlocks.push_back(blockCopy);
 		}

+ 2 - 2
CamelotCore/Source/CmGpuProgInclude.cpp

@@ -10,8 +10,8 @@ namespace CamelotFramework
 
 	HGpuProgInclude GpuProgInclude::create(const String& includeString)
 	{
-		GpuProgIncludePtr gpuProgIncludePtr = GpuProgIncludePtr(CM_NEW(GpuProgInclude, PoolAlloc) GpuProgInclude(includeString), 
-			&CoreObject::_deleteDelayed<GpuProgInclude, PoolAlloc>);
+		GpuProgIncludePtr gpuProgIncludePtr = cm_core_ptr<GpuProgInclude, PoolAlloc>(
+			new (cm_alloc<GpuProgInclude, PoolAlloc>()) GpuProgInclude(includeString));
 		gpuProgIncludePtr->setThisPtr(gpuProgIncludePtr);
 		gpuProgIncludePtr->initialize();
 

+ 1 - 2
CamelotCore/Source/CmGpuProgram.cpp

@@ -92,8 +92,7 @@ namespace CamelotFramework
 	//---------------------------------------------------------------------
 	GpuParamsPtr GpuProgram::createParameters(void)
 	{
-		return GpuParamsPtr(CM_NEW(GpuParams, PoolAlloc) GpuParams(mParametersDesc),
-			&MemAllocDeleter<GpuParams, PoolAlloc>::deleter);
+		return cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc));
 	}
     //-----------------------------------------------------------------------
     const String& GpuProgram::getLanguage(void) const

+ 1 - 2
CamelotCore/Source/CmGpuProgramImporter.cpp

@@ -45,7 +45,6 @@ namespace CamelotFramework
 
 	ImportOptionsPtr GpuProgramImporter::createImportOptions() const
 	{
-		return ImportOptionsPtr(CM_NEW(GpuProgramImportOptions, PoolAlloc) GpuProgramImportOptions(),
-			&MemAllocDeleter<GpuProgramImportOptions, PoolAlloc>::deleter);
+		return cm_shared_ptr<GpuProgramImportOptions, PoolAlloc>();
 	}
 }

+ 1 - 1
CamelotCore/Source/CmHardwareBufferManager.cpp

@@ -92,6 +92,6 @@ namespace CamelotFramework {
 	//-----------------------------------------------------------------------
 	VertexDeclarationPtr HardwareBufferManager::createVertexDeclarationImpl(void)
 	{
-		return VertexDeclarationPtr(CM_NEW(VertexDeclaration, PoolAlloc) VertexDeclaration(), &CoreObject::_deleteDelayed<VertexDeclaration, PoolAlloc>);
+		return cm_core_ptr<VertexDeclaration, PoolAlloc>(new (cm_alloc<VertexDeclaration, PoolAlloc>()) VertexDeclaration());
 	}
 }

+ 2 - 2
CamelotCore/Source/CmImporter.cpp

@@ -14,8 +14,8 @@ namespace CamelotFramework
 {
 	Importer::Importer()
 	{
-		registerAssetImporter(CM_NEW(GpuProgIncludeImporter, GenAlloc) GpuProgIncludeImporter());
-		registerAssetImporter(CM_NEW(GpuProgramImporter, GenAlloc) GpuProgramImporter());
+		registerAssetImporter(cm_new<GpuProgIncludeImporter>());
+		registerAssetImporter(cm_new<GpuProgramImporter>());
 	}
 
 	Importer::~Importer()

+ 1 - 2
CamelotCore/Source/CmMaterialRTTI.cpp

@@ -37,8 +37,7 @@ namespace CamelotFramework
 	void MaterialRTTI::onSerializationStarted(IReflectable* obj)
 	{
 		Material* material = static_cast<Material*>(obj);
-		std::shared_ptr<MaterialParams> params = std::shared_ptr<MaterialParams>(CM_NEW(MaterialParams, ScratchAlloc) MaterialParams(),
-			&MemAllocDeleter<MaterialParams, ScratchAlloc>::deleter);
+		std::shared_ptr<MaterialParams> params = cm_shared_ptr<MaterialParams, ScratchAlloc>();
 
 		ShaderPtr shader = material->getShader();
 		if(shader != nullptr)

+ 3 - 4
CamelotCore/Source/CmMesh.cpp

@@ -56,7 +56,7 @@ namespace CamelotFramework
 		}
 
 		// Indices
-		mIndexData = CM_NEW(IndexData, PoolAlloc) IndexData();
+		mIndexData = cm_new<IndexData, PoolAlloc>();
 
 		mIndexData->indexCount = meshData.getNumIndices();
 		mIndexData->indexBuffer = HardwareBufferManager::instance().createIndexBuffer(
@@ -75,7 +75,7 @@ namespace CamelotFramework
 		mIndexData->indexBuffer->unlock();
 
 		// Vertices
-		mVertexData = CM_NEW(VertexData, PoolAlloc) VertexData();
+		mVertexData = cm_new<VertexData, PoolAlloc>();
 
 		mVertexData->vertexCount = meshData.getNumVertices();
 		mVertexData->vertexDeclaration = meshData.createDeclaration();
@@ -165,8 +165,7 @@ namespace CamelotFramework
 		if(mIndexData)
 			indexType = mIndexData->indexBuffer->getType();
 
-		MeshDataPtr meshData(CM_NEW(MeshData, PoolAlloc) MeshData(mVertexData->vertexCount, indexType),
-			&MemAllocDeleter<MeshData, PoolAlloc>::deleter);
+		MeshDataPtr meshData = cm_shared_ptr<MeshData, PoolAlloc>(mVertexData->vertexCount, indexType);
 
 		meshData->beginDesc();
 		if(mIndexData)

+ 1 - 2
CamelotCore/Source/CmMeshData.cpp

@@ -184,8 +184,7 @@ namespace CamelotFramework
 			totalVertexCount += numVertices;
 		}
 
-		MeshDataPtr combinedMeshData(CM_NEW(MeshData, PoolAlloc) MeshData(totalVertexCount),
-			&MemAllocDeleter<MeshData, PoolAlloc>::deleter);
+		MeshDataPtr combinedMeshData = cm_shared_ptr<MeshData, PoolAlloc>(totalVertexCount);
 
 		combinedMeshData->beginDesc();
 

+ 3 - 3
CamelotCore/Source/CmMeshManager.cpp

@@ -18,7 +18,7 @@ namespace CamelotFramework
 
 	MeshPtr MeshManager::create()
 	{
-		MeshPtr mesh = MeshPtr(CM_NEW(Mesh, PoolAlloc) Mesh(), &CoreObject::_deleteDelayed<Mesh, PoolAlloc>);
+		MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh());
 		mesh->setThisPtr(mesh);
 		mesh->initialize();
 
@@ -27,7 +27,7 @@ namespace CamelotFramework
 
 	MeshPtr MeshManager::createEmpty()
 	{
-		MeshPtr mesh = MeshPtr(CM_NEW(Mesh, PoolAlloc) Mesh(), &CoreObject::_deleteDelayed<Mesh, PoolAlloc>);
+		MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh());
 		mesh->setThisPtr(mesh);
 
 		return mesh;
@@ -35,7 +35,7 @@ namespace CamelotFramework
 
 	void MeshManager::onStartUp()
 	{
-		mDummyMeshData = MeshDataPtr(CM_NEW(MeshData, GenAlloc) MeshData(1), &MemAllocDeleter<MeshData, GenAlloc>::deleter);
+		mDummyMeshData = cm_shared_ptr<MeshData>(1);
 
 		mDummyMeshData->beginDesc();
 		mDummyMeshData->addVertElem(VET_FLOAT3, VES_POSITION);

+ 4 - 4
CamelotCore/Source/CmRenderStateManager.cpp

@@ -108,21 +108,21 @@ namespace CamelotFramework
 
 	SamplerStatePtr RenderStateManager::createSamplerStateImpl() const
 	{
-		return SamplerStatePtr(CM_NEW(SamplerState, PoolAlloc) SamplerState(), &CoreObject::_deleteDelayed<SamplerState, PoolAlloc>);
+		return cm_core_ptr<SamplerState, PoolAlloc>();
 	}
 
 	BlendStatePtr RenderStateManager::createBlendStateImpl() const
 	{
-		return BlendStatePtr(CM_NEW(BlendState, PoolAlloc) BlendState(), &CoreObject::_deleteDelayed<BlendState, PoolAlloc>);
+		return cm_core_ptr<BlendState, PoolAlloc>();
 	}
 
 	RasterizerStatePtr RenderStateManager::createRasterizerStateImpl() const
 	{
-		return RasterizerStatePtr(CM_NEW(RasterizerState, PoolAlloc) RasterizerState(), &CoreObject::_deleteDelayed<RasterizerState, PoolAlloc>);
+		return cm_core_ptr<RasterizerState, PoolAlloc>();
 	}
 
 	DepthStencilStatePtr RenderStateManager::createDepthStencilStateImpl() const
 	{
-		return DepthStencilStatePtr(CM_NEW(DepthStencilState, PoolAlloc) DepthStencilState(), &CoreObject::_deleteDelayed<DepthStencilState, PoolAlloc>);
+		return cm_core_ptr<DepthStencilState, PoolAlloc>();
 	}
 }

+ 5 - 6
CamelotCore/Source/CmRenderSystem.cpp

@@ -91,7 +91,7 @@ namespace CamelotFramework {
 	RenderWindowPtr RenderSystem::initialize(const RENDER_WINDOW_DESC& primaryWindowDesc)
 	{
 		mRenderThreadId = CM_THREAD_CURRENT_ID;
-		mCommandQueue = CM_NEW(CommandQueue<CommandQueueSync>, GenAlloc) CommandQueue<CommandQueueSync>(CM_THREAD_CURRENT_ID, true);
+		mCommandQueue = cm_new<CommandQueue<CommandQueueSync>>(CM_THREAD_CURRENT_ID, true);
 		mPrimaryWindowDesc = primaryWindowDesc;
 
 		MemStack::setupHeap(HID_Render);
@@ -109,7 +109,7 @@ namespace CamelotFramework {
 		mGeometryProgramBound = false;
 		mFragmentProgramBound = false;
 
-		mSyncedRenderContext = CM_NEW(DeferredRenderContext<CommandQueueSync>, GenAlloc) DeferredRenderContext<CommandQueueSync>(this, CM_THREAD_CURRENT_ID);
+		mSyncedRenderContext = cm_new<DeferredRenderContext<CommandQueueSync>>(this, CM_THREAD_CURRENT_ID);
 	}
 
 	void RenderSystem::destroy_internal()
@@ -118,7 +118,7 @@ namespace CamelotFramework {
 
 		if(mSyncedRenderContext != nullptr)
 		{
-			CM_DELETE(mSyncedRenderContext, DeferredRenderContext<CommandQueueSync>, GenAlloc);
+			cm_delete(mSyncedRenderContext);
 		}
 	}
 
@@ -301,7 +301,7 @@ namespace CamelotFramework {
 	void RenderSystem::initRenderThread()
 	{
 #if !CM_FORCE_SINGLETHREADED_RENDERING
-		mRenderThreadFunc = CM_NEW(RenderWorkerFunc, GenAlloc) RenderWorkerFunc(this);
+		mRenderThreadFunc = cm_new<RenderWorkerFunc>(this);
 
 #if CM_THREAD_SUPPORT
 		CM_THREAD_CREATE(t, *mRenderThreadFunc);
@@ -385,8 +385,7 @@ namespace CamelotFramework {
 
 	RenderContextPtr RenderSystem::createDeferredContext()
 	{
-		return RenderContextPtr(CM_NEW(DeferredRenderContext<CommandQueueNoSync>, GenAlloc) DeferredRenderContext<CommandQueueNoSync>(this, CM_THREAD_CURRENT_ID), 
-			&MemAllocDeleter<DeferredRenderContext<CommandQueueNoSync>, GenAlloc>::deleter);
+		return cm_shared_ptr<DeferredRenderContext<CommandQueueNoSync>>(this, CM_THREAD_CURRENT_ID);
 	}
 
 	SyncedRenderContext& RenderSystem::getSyncedDeferredContext()

+ 1 - 2
CamelotCore/Source/CmResourceHandle.cpp

@@ -11,8 +11,7 @@ namespace CamelotFramework
 
 	ResourceHandleBase::ResourceHandleBase()
 	{
-		mData = std::shared_ptr<ResourceHandleData>(CM_NEW(ResourceHandleData, PoolAlloc) ResourceHandleData(),
-			&MemAllocDeleter<ResourceHandleData, PoolAlloc>::deleter);
+		mData = cm_shared_ptr<ResourceHandleData, PoolAlloc>();
 	}
 
 	bool ResourceHandleBase::isLoaded() const 

+ 7 - 10
CamelotCore/Source/CmResources.cpp

@@ -19,11 +19,10 @@ namespace CamelotFramework
 	{
 		ResourceLoadRequestPtr resRequest = boost::any_cast<ResourceLoadRequestPtr>(req->getData());
 
-		ResourceLoadResponsePtr resResponse = ResourceLoadResponsePtr(CM_NEW(Resources::ResourceLoadResponse, ScratchAlloc) Resources::ResourceLoadResponse(),
-			&MemAllocDeleter<Resources::ResourceLoadResponse, ScratchAlloc>::deleter);
+		ResourceLoadResponsePtr resResponse = cm_shared_ptr<Resources::ResourceLoadResponse, ScratchAlloc>();
 		resResponse->rawResource = gResources().loadFromDiskAndDeserialize(resRequest->filePath);
 
-		return CM_NEW(WorkQueue::Response, ScratchAlloc) WorkQueue::Response(req, true, resResponse);
+		return cm_new<WorkQueue::Response, ScratchAlloc>(req, true, resResponse);
 	}
 
 	bool Resources::ResourceResponseHandler::canHandleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ)
@@ -74,10 +73,10 @@ namespace CamelotFramework
 
 		loadMetaData();
 
-		mWorkQueue = CM_NEW(WorkQueue, GenAlloc) WorkQueue();
+		mWorkQueue = cm_new<WorkQueue>();
 		mWorkQueueChannel = mWorkQueue->getChannel("Resources");
-		mRequestHandler = CM_NEW(ResourceRequestHandler, GenAlloc) ResourceRequestHandler();
-		mResponseHandler = CM_NEW(ResourceResponseHandler, GenAlloc) ResourceResponseHandler();
+		mRequestHandler = cm_new<ResourceRequestHandler>();
+		mResponseHandler = cm_new<ResourceResponseHandler>();
 
 		mWorkQueue->addRequestHandler(mWorkQueueChannel, mRequestHandler);
 		mWorkQueue->addResponseHandler(mWorkQueueChannel, mResponseHandler);
@@ -205,8 +204,7 @@ namespace CamelotFramework
 		HResource newResource;
 		newResource.setUUID(uuid); // UUID needs to be set immediately if the resource gets loaded async
 
-		ResourceLoadRequestPtr resRequest = ResourceLoadRequestPtr(CM_NEW(Resources::ResourceLoadRequest, ScratchAlloc) Resources::ResourceLoadRequest(),
-			&MemAllocDeleter<Resources::ResourceLoadRequest, ScratchAlloc>::deleter);
+		ResourceLoadRequestPtr resRequest = cm_shared_ptr<Resources::ResourceLoadRequest, ScratchAlloc>();
 		resRequest->filePath = filePath;
 		resRequest->resource = newResource;
 
@@ -372,8 +370,7 @@ namespace CamelotFramework
 		if(metaExists_UUID(uuid))
 			CM_EXCEPT(InternalErrorException, "Resource with the same UUID already exists. UUID: " + uuid);
 
-		ResourceMetaDataPtr dbEntry(CM_NEW(ResourceMetaData, GenAlloc) ResourceMetaData(),
-			&MemAllocDeleter<ResourceMetaData, GenAlloc>::deleter);
+		ResourceMetaDataPtr dbEntry = cm_shared_ptr<ResourceMetaData>();
 		dbEntry->mPath = filePath;
 		dbEntry->mUUID = uuid;
 

+ 3 - 2
CamelotCore/Source/CmSceneObject.cpp

@@ -35,8 +35,9 @@ namespace CamelotFramework
 
 	HSceneObject SceneObject::createInternal(const String& name)
 	{
-		HSceneObject sceneObject = GameObjectHandle<SceneObject>(CM_NEW(SceneObject, PoolAlloc) SceneObject(name),
-			&MemAllocDeleter<GameObject, PoolAlloc>::deleter);
+		HSceneObject sceneObject = GameObjectHandle<SceneObject>(
+			new (cm_alloc<SceneObject, PoolAlloc>()) SceneObject(name),
+			&cm_delete<PoolAlloc, GameObject>);
 		sceneObject->mThisHandle = sceneObject;
 
 		return sceneObject;

+ 1 - 2
CamelotCore/Source/CmSpecificImporter.cpp

@@ -6,8 +6,7 @@ namespace CamelotFramework
 {
 	ImportOptionsPtr SpecificImporter::createImportOptions() const
 	{
-		return ImportOptionsPtr(CM_NEW(ImportOptions, PoolAlloc) ImportOptions(),
-			&MemAllocDeleter<ImportOptions, PoolAlloc>::deleter);
+		return cm_shared_ptr<ImportOptions, PoolAlloc>();
 	}
 
 	ConstImportOptionsPtr SpecificImporter::getDefaultImportOptions() const

+ 1 - 1
CamelotCore/Source/CmTextUtility.cpp

@@ -278,7 +278,7 @@ namespace CamelotFramework
 		bool heightIsLimited = height > 0;
 		bool widthIsLimited = width > 0;
 
-		std::shared_ptr<TextUtility::TextData> textData(CM_NEW(TextData, PoolAlloc) TextData(), &MemAllocDeleter<TextData, PoolAlloc>::deleter);
+		std::shared_ptr<TextUtility::TextData> textData = cm_shared_ptr<TextData, PoolAlloc>();
 		textData->mLines.push_back(TextLine(fontData->fontDesc.baselineOffset, fontData->fontDesc.lineHeight, fontData->fontDesc.spaceWidth));
 		TextLine* curLine = &textData->mLines.back();
 

+ 3 - 4
CamelotCore/Source/CmTexture.cpp

@@ -159,8 +159,7 @@ namespace CamelotFramework {
 			if(depth != 1) depth /= 2;
 		}
 
-		PixelDataPtr dst(CM_NEW(PixelData, PoolAlloc) PixelData(width, height, depth, getFormat()),
-			&MemAllocDeleter<PixelData, PoolAlloc>::deleter);
+		PixelDataPtr dst = cm_shared_ptr<PixelData, PoolAlloc>(width, height, depth, getFormat());
 
 		dst->allocateInternalBuffer();
 
@@ -242,7 +241,7 @@ namespace CamelotFramework {
 
 	TextureViewPtr Texture::createView()
 	{
-		TextureViewPtr viewPtr(CM_NEW(TextureView, PoolAlloc) TextureView(), &CoreObject::_deleteDelayed<TextureView, PoolAlloc>);
+		TextureViewPtr viewPtr = cm_core_ptr<TextureView, PoolAlloc>(new (cm_alloc<TextureView, PoolAlloc>()) TextureView());
 		viewPtr->setThisPtr(viewPtr);
 
 		return viewPtr;
@@ -269,7 +268,7 @@ namespace CamelotFramework {
 		{
 			TextureViewPtr newView = texture->createView();
 			newView->initialize(texture, key);
-			texture->mTextureViews[key] = CM_NEW(TextureViewReference, PoolAlloc) TextureViewReference(newView);
+			texture->mTextureViews[key] = new (cm_alloc<TextureViewReference, PoolAlloc>()) TextureViewReference(newView);
 
 			iterFind = texture->mTextureViews.find(key);
 		}