Marko Pintera 13 лет назад
Родитель
Сommit
288f2f37e7
28 измененных файлов с 195 добавлено и 53 удалено
  1. 2 2
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  2. 1 1
      CamelotFBXImporter/Include/CmFBXImporter.h
  3. 3 3
      CamelotFBXImporter/Source/CmFBXImporter.cpp
  4. 1 1
      CamelotFreeImgImporter/Include/CmFreeImgImporter.h
  5. 3 3
      CamelotFreeImgImporter/Source/CmFreeImgImporter.cpp
  6. 2 2
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  7. 2 0
      CamelotRenderer/CamelotRenderer.vcxproj
  8. 6 0
      CamelotRenderer/CamelotRenderer.vcxproj.filters
  9. 2 2
      CamelotRenderer/Include/CmApplication.h
  10. 3 3
      CamelotRenderer/Include/CmGpuProgramParams.h
  11. 1 1
      CamelotRenderer/Include/CmImporter.h
  12. 1 0
      CamelotRenderer/Include/CmMaterial.h
  13. 4 4
      CamelotRenderer/Include/CmPass.h
  14. 13 0
      CamelotRenderer/Include/CmPrerequisites.h
  15. 5 3
      CamelotRenderer/Include/CmResource.h
  16. 2 2
      CamelotRenderer/Include/CmResourceRTTI.h
  17. 77 0
      CamelotRenderer/Include/CmResourceRef.h
  18. 1 1
      CamelotRenderer/Include/CmShader.h
  19. 1 1
      CamelotRenderer/Include/CmSpecificImporter.h
  20. 2 2
      CamelotRenderer/Include/CmTechnique.h
  21. 2 2
      CamelotRenderer/Include/CmTextureRTTI.h
  22. 23 6
      CamelotRenderer/Source/CmApplication.cpp
  23. 1 1
      CamelotRenderer/Source/CmGpuProgramParams.cpp
  24. 2 2
      CamelotRenderer/Source/CmImporter.cpp
  25. 2 2
      CamelotRenderer/Source/CmPass.cpp
  26. 22 0
      CamelotRenderer/Source/CmResourceRef.cpp
  27. 4 6
      CamelotRenderer/Source/CmShader.cpp
  28. 7 3
      CamelotRenderer/Source/CmTechnique.cpp

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -2773,9 +2773,9 @@ namespace CamelotEngine
 				if (i->second.variability & variability)
 				{
 					size_t logicalIndex = i->first;
-					TexturePtr texture = params->getTexture(i->second.physicalIndex);
+					TextureRef texture = params->getTexture(i->second.physicalIndex);
 
-					_setTexture(logicalIndex, true, texture);
+					_setTexture(logicalIndex, true, texture.getInternalPtr());
 				}
 			}
 		}

+ 1 - 1
CamelotFBXImporter/Include/CmFBXImporter.h

@@ -35,7 +35,7 @@ namespace CamelotEngine
 		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
 
 		/** Inherited from SpecificImporter */
-		virtual ResourcePtr import(const String& filePath);
+		virtual BaseResourceRef import(const String& filePath);
 	private:
 		vector<String>::type mExtensions;
 

+ 3 - 3
CamelotFBXImporter/Source/CmFBXImporter.cpp

@@ -35,7 +35,7 @@ namespace CamelotEngine
 		return true; // FBX files can be plain-text so I don't even check for magic number
 	}
 
-	ResourcePtr FBXImporter::import(const String& filePath)
+	BaseResourceRef FBXImporter::import(const String& filePath)
 	{
 		FbxManager* fbxManager = nullptr;
 		FbxScene* fbxScene = nullptr;
@@ -47,7 +47,7 @@ namespace CamelotEngine
 
 		shutDownSdk(fbxManager);
 
-		MeshPtr mesh(new Mesh());
+		MeshRef mesh(new Mesh());
 		mesh->setMeshData(meshData);
 
 		return mesh;
@@ -785,7 +785,7 @@ namespace CamelotEngine
 		{
 			UINT32 subMeshCount = (*iter)->subMeshes.size();
 
-			for(int i = 0; i < subMeshCount; i++)
+			for(UINT32 i = 0; i < subMeshCount; i++)
 			{
 				MeshData::SubMeshData newSubMesh;
 				newSubMesh.indexCount = (*iter)->subMeshes[i].indexCount;

+ 1 - 1
CamelotFreeImgImporter/Include/CmFreeImgImporter.h

@@ -32,7 +32,7 @@ namespace CamelotEngine
 		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
 
 		/** Inherited from SpecificImporter */
-		virtual ResourcePtr import(const String& filePath);
+		virtual BaseResourceRef import(const String& filePath);
 	private:
 		vector<String>::type mExtensions;
 		std::unordered_map<String, int> mExtensionToFID;

+ 3 - 3
CamelotFreeImgImporter/Source/CmFreeImgImporter.cpp

@@ -127,7 +127,7 @@ namespace CamelotEngine
 		}
 	}
 
-	ResourcePtr FreeImgImporter::import(const String& filePath)
+	BaseResourceRef FreeImgImporter::import(const String& filePath)
 	{
 		DataStreamPtr fileData = FileSystem::open(filePath, true);
 
@@ -135,8 +135,8 @@ namespace CamelotEngine
 		if(imgData == nullptr || imgData->getData() == nullptr)
 			return nullptr;
 
-		TexturePtr newTexture = TextureManager::instance().create(TEX_TYPE_2D, 
-			imgData->getWidth(), imgData->getHeight(), imgData->getNumMipmaps(), imgData->getFormat());
+		TextureRef newTexture(TextureManager::instance().create(TEX_TYPE_2D, 
+			imgData->getWidth(), imgData->getHeight(), imgData->getNumMipmaps(), imgData->getFormat()));
 
 		newTexture->setTextureData(0, imgData);
 

+ 2 - 2
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -2529,8 +2529,8 @@ namespace CamelotEngine {
 				if(def.constType == GCT_SAMPLER2D || def.constType == GCT_SAMPLERCUBE || def.constType == GCT_SAMPLER1D 
 					|| def.constType == GCT_SAMPLER2DSHADOW || def.constType == GCT_SAMPLER3D || def.constType == GCT_SAMPLER1DSHADOW)
 				{
-					TexturePtr curTexture = params->getTexture(def.physicalIndex);
-					_setTexture(def.physicalIndex, true, curTexture);
+					TextureRef curTexture = params->getTexture(def.physicalIndex);
+					_setTexture(def.physicalIndex, true, curTexture.getInternalPtr());
 				}
 			}
 		}

+ 2 - 0
CamelotRenderer/CamelotRenderer.vcxproj

@@ -138,6 +138,7 @@
     <ClInclude Include="Include\CmRenderTexture.h" />
     <ClInclude Include="Include\CmRenderWindow.h" />
     <ClInclude Include="Include\CmResource.h" />
+    <ClInclude Include="Include\CmResourceRef.h" />
     <ClInclude Include="Include\CmResources.h" />
     <ClInclude Include="Include\CmSceneManager.h" />
     <ClInclude Include="Include\CmSpecificImporter.h" />
@@ -191,6 +192,7 @@
     <ClCompile Include="Source\CmRenderTexture.cpp" />
     <ClCompile Include="Source\CmRenderWindow.cpp" />
     <ClCompile Include="Source\CmResource.cpp" />
+    <ClCompile Include="Source\CmResourceRef.cpp" />
     <ClCompile Include="Source\CmResources.cpp" />
     <ClCompile Include="Source\CmSceneManager.cpp" />
     <ClCompile Include="Source\CmShader.cpp" />

+ 6 - 0
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -268,6 +268,9 @@
     <ClInclude Include="Include\CmRendererFactory.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmResourceRef.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -405,5 +408,8 @@
     <ClCompile Include="Source\CmRendererManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmResourceRef.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 2
CamelotRenderer/Include/CmApplication.h

@@ -38,8 +38,8 @@ namespace CamelotEngine
 			std::shared_ptr<Camera> mCamera;
 			HighLevelGpuProgramPtr mFragProg;
 			HighLevelGpuProgramPtr mVertProg;
-			TexturePtr mDbgTexture;
-			MeshPtr mDbgMesh;
+			TextureRef mDbgTexture;
+			MeshRef mDbgMesh;
 			GameObjectPtr mCameraGO;
 	};
 

+ 3 - 3
CamelotRenderer/Include/CmGpuProgramParams.h

@@ -350,7 +350,7 @@ namespace CamelotEngine {
 	@note Not necessarily in direct index order to constant indexes, logical
 	to physical index map is derived from GpuProgram
 	*/
-	typedef vector<TexturePtr>::type TextureList;
+	typedef vector<TextureRef>::type TextureList;
 
 	/** Collects together the program parameters used for a GpuProgram.
 	@remarks
@@ -715,7 +715,7 @@ namespace CamelotEngine {
 		/// Get a pointer to the 'nth' item in the int buffer
 		const int* getIntPointer(size_t pos) const { return &mIntConstants[pos]; }
 		const GpuLogicalBufferStructPtr& getSamplerLogicalBufferStruct() const { return mSamplerLogicalToPhysical; }
-		TexturePtr getTexture(size_t pos) const { return mTextures[pos];}
+		TextureRef getTexture(size_t pos) const { return mTextures[pos];}
 		/// Get a reference to the list of textures
 		const TextureList& getTextureList() const { return mTextures; }
 
@@ -742,7 +742,7 @@ namespace CamelotEngine {
 		@param name The name of the parameter
 		@param val The value to set
 		*/
-		void setNamedConstant(const String& name, TexturePtr val);
+		void setNamedConstant(const String& name, TextureRef val);
 
 		/** Sets a single value constant floating-point parameter to the program.
 		@remarks

+ 1 - 1
CamelotRenderer/Include/CmImporter.h

@@ -23,7 +23,7 @@ namespace CamelotEngine
 		 *
 		 * @param	inputFilePath 	Pathname of the input file.
 		 */
-		ResourcePtr import(const String& inputFilePath);
+		BaseResourceRef import(const String& inputFilePath);
 
 
 		/**

+ 1 - 0
CamelotRenderer/Include/CmMaterial.h

@@ -13,6 +13,7 @@ namespace CamelotEngine
 			GpuProgramParametersPtr mGeomParams;
 		};
 
+	public:
 		/**
 		 * @brief	Sets a shader that will be used by the material. 
 		 * 			Shaders best technique will be retrieved and used in all subsequent Material

+ 4 - 4
CamelotRenderer/Include/CmPass.h

@@ -16,7 +16,7 @@ namespace CamelotEngine
 	class CM_EXPORT Pass
     {
     protected:
-        Technique* mParent;
+        const Technique* mParent;
         unsigned short mIndex; // pass index
         String mName; // optional name for the pass
         //-------------------------------------------------------------------------
@@ -87,9 +87,9 @@ namespace CamelotEngine
     public:
 		CM_MUTEX(mGpuProgramChangeMutex)
         /// Default constructor
-		Pass(Technique* parent, unsigned short index);
+		Pass(const Technique* parent, unsigned short index);
         /// Copy constructor
-        Pass(Technique* parent, unsigned short index, const Pass& oth );
+        Pass(const Technique* parent, unsigned short index, const Pass& oth );
         /// Operator = overload
         Pass& operator=(const Pass& oth);
         virtual ~Pass();
@@ -464,7 +464,7 @@ namespace CamelotEngine
 		bool getTransparentSortingForced(void) const;
 
 		/// Gets the parent Technique
-        Technique* getParent(void) const { return mParent; }
+        const Technique* getParent(void) const { return mParent; }
 
 		/** Sets the details of the vertex program to use.
 		*/

+ 13 - 0
CamelotRenderer/Include/CmPrerequisites.h

@@ -157,6 +157,19 @@ namespace CamelotEngine
 	};
 }
 
+/************************************************************************/
+/* 							Resource references                   		*/
+/************************************************************************/
+
+#include "CmResourceRef.h"
+
+namespace CamelotEngine
+{
+	typedef ResourceRef<Resource> BaseResourceRef;
+	typedef ResourceRef<Texture> TextureRef;
+	typedef ResourceRef<Mesh> MeshRef;
+}
+
 #endif // __OgrePrerequisites_H__
 
 

+ 5 - 3
CamelotRenderer/Include/CmResource.h

@@ -18,14 +18,16 @@ namespace CamelotEngine
 	class CM_EXPORT Resource : public IReflectable
 	{
 	public:
-		Resource(/*const UUID& sourceUUID*/) // TODO - Temporarily don't initialize UUID, because I want texture to inherit from resource and UUIDs arent set up yet
-			:mSize(0), mLoadState(RS_Unloaded) /*mSourceUUID(sourceUUID),*/
+		Resource(/*UUID& _UUID*/) // TODO - Temporarily don't initialize UUID, because I want texture to inherit from resource and UUIDs arent set up yet
+			:mSize(0), mLoadState(RS_Unloaded) /*mUUID(_UUID),*/
 		{}
 		virtual ~Resource() {};
 
 		void load();
 		virtual void loadImpl() = 0;
 
+		const String& getUUID() const { return mUUID; }
+
 	protected:
 		friend class Resources;
 		//virtual void unload() = 0;
@@ -33,7 +35,7 @@ namespace CamelotEngine
 		//virtual void calculateSize() = 0;
 		//virtual void reload();
 
-		UUID mSourceUUID; 
+		String mUUID; 
 		UINT32 mSize;
 
 		// Transient

+ 2 - 2
CamelotRenderer/Include/CmResourceRTTI.h

@@ -11,8 +11,8 @@ namespace CamelotEngine
 	private:
 		UINT32& getSize(Resource* obj) { return obj->mSize; }
 		void setSize(Resource* obj, UINT32& size) { obj->mSize = size; } 
-		UUID& getUUID(Resource* obj) { return obj->mSourceUUID; }
-		void setUUID(Resource* obj, UUID& uuid) { obj->mSourceUUID = uuid; }
+		String& getUUID(Resource* obj) { return obj->mUUID; }
+		void setUUID(Resource* obj, String& uuid) { obj->mUUID = uuid; }
 
 	public:
 		ResourceRTTI()

+ 77 - 0
CamelotRenderer/Include/CmResourceRef.h

@@ -0,0 +1,77 @@
+#pragma once
+
+namespace CamelotEngine
+{
+	template <typename T>
+	class ResourceRef;
+
+	class CM_EXPORT ResourceRefBase
+	{
+	protected:
+		ResourceRefBase()
+			:mUUIDSet(false)
+		{ }
+
+		std::shared_ptr<Resource> mPtr;
+		String mUUID;
+		bool mUUIDSet;
+
+		void init(Resource* ptr);
+		void init(std::shared_ptr<Resource> ptr);
+
+		template <typename T1>
+		void init(const ResourceRef<T1>& ptr)
+		{
+			init(std::static_pointer_cast<Resource>(ptr.mPtr));
+		}
+	};
+
+	template <typename T>
+	class ResourceRef : public ResourceRefBase
+	{
+	public:
+		ResourceRef()
+			:ResourceRefBase()
+		{	}
+
+		ResourceRef(T* ptr)
+			:ResourceRefBase()
+		{
+			init(ptr);
+		}
+
+		ResourceRef(std::shared_ptr<T> ptr)
+			:ResourceRefBase()
+		{
+			init(ptr);
+		}
+
+		template <typename T1>
+		ResourceRef(const ResourceRef<T1>& ptr)
+			:ResourceRefBase()
+		{
+			init(ptr);
+		}
+
+		operator ResourceRef<Resource>&() 
+		{
+			return *this; 
+		}
+
+		const T* get() const { return static_cast<T*>(mPtr.get()); }
+		const T* operator-> () const { return get(); }
+		const T& operator* () const { return *get(); }
+
+		T* get() { return static_cast<T*>(mPtr.get()); }
+		T* operator-> () { return get(); }
+		T& operator* () { return *get(); }
+
+		std::shared_ptr<T> getInternalPtr() { return std::static_pointer_cast<T>(mPtr); }
+	};
+
+	template<class _Ty1, class _Ty2>
+		ResourceRef<_Ty1> static_resource_cast(const ResourceRef<_Ty2>& other)
+	{	
+		return ResourceRef<_Ty1>(other);
+	}
+}

+ 1 - 1
CamelotRenderer/Include/CmShader.h

@@ -18,7 +18,7 @@ namespace CamelotEngine
 	public:
 		Shader(const String& name);
 
-		void addTechnique(TechniquePtr technique);
+		TechniquePtr addTechnique(const String& renderSystem, const String& renderer);
 		
 		void removeTechnique(UINT32 idx);
 		void removeTechnique(TechniquePtr technique);

+ 1 - 1
CamelotRenderer/Include/CmSpecificImporter.h

@@ -28,6 +28,6 @@ namespace CamelotEngine
 		 *
 		 * @return	null if it fails, otherwise the loaded object.
 		 */
-		virtual ResourcePtr import(const String& filePath) = 0;
+		virtual BaseResourceRef import(const String& filePath) = 0;
 	};
 }

+ 2 - 2
CamelotRenderer/Include/CmTechnique.h

@@ -9,9 +9,9 @@ namespace CamelotEngine
 	public:
 		Technique(const String& renderSystem, const String& renderer);
 
-		void addPass(PassPtr pass);
+		PassPtr addPass();
 		void removePass(UINT32 idx);
-		PassPtr getPass(UINT32 idx);
+		PassPtr getPass(UINT32 idx) const;
 
 		UINT32 getNumPasses() const { return mPasses.size(); }
 

+ 2 - 2
CamelotRenderer/Include/CmTextureRTTI.h

@@ -15,7 +15,7 @@ namespace CamelotEngine
 	{
 	private:
 		CM_SETGET_MEMBER(mSize, UINT32, Texture)
-		CM_SETGET_MEMBER(mSourceUUID, UUID, Texture);
+		CM_SETGET_MEMBER(mUUID, String, Texture);
 		CM_SETGET_MEMBER(mHeight, UINT32, Texture)
 		CM_SETGET_MEMBER(mWidth, UINT32, Texture)
 		CM_SETGET_MEMBER(mDepth, UINT32, Texture)
@@ -57,7 +57,7 @@ namespace CamelotEngine
 		TextureRTTI()
 		{
 			CM_ADD_PLAINFIELD(mSize, 0, TextureRTTI)
-			CM_ADD_PLAINFIELD(mSourceUUID, 1, TextureRTTI)
+			CM_ADD_PLAINFIELD(mUUID, 1, TextureRTTI)
 			CM_ADD_PLAINFIELD(mHeight, 2, TextureRTTI)
 			CM_ADD_PLAINFIELD(mWidth, 3, TextureRTTI)
 			CM_ADD_PLAINFIELD(mDepth, 4, TextureRTTI)

+ 23 - 6
CamelotRenderer/Source/CmApplication.cpp

@@ -21,6 +21,11 @@
 #include "CmTime.h"
 #include "CmInput.h"
 
+#include "CmMaterial.h"
+#include "CmShader.h"
+#include "CmTechnique.h"
+#include "CmPass.h"
+
 namespace CamelotEngine
 {
 	Application::Application()
@@ -132,6 +137,18 @@ namespace CamelotEngine
 		//mVertProg = HighLevelGpuProgramManager::instance().createProgram(vertShaderCode, "main", "glsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
 		//mVertProg->load();
 
+		//ShaderPtr newShader(new Shader("TestShader"));
+		//TechniquePtr newTechnique = newShader->addTechnique("GLRenderSystem", "ForwardRenderer");
+		//PassPtr newPass = newTechnique->addPass();
+		//newPass->setVertexProgram(mVertProg);
+		//newPass->setFragmentProgram(mFragProg);
+
+		//Material newMat;
+		//newMat.setShader(newShader);
+		
+		//newShader.
+		
+
 
 		// IMPORTER TEST
 		Importer::startUp(new Importer());
@@ -139,17 +156,17 @@ namespace CamelotEngine
 		loadPlugin("CamelotFBXImporter"); // TODO - Load this automatically somehow
 
 		//mDbgTexture = std::static_pointer_cast<Texture>(Importer::instance().import("C:\\ImportTest.tga"));
-		TexturePtr testTex = std::static_pointer_cast<Texture>(Importer::instance().import("C:\\ImportTest.tga"));
-		mDbgMesh = std::static_pointer_cast<Mesh>(Importer::instance().import("C:\\X_Arena_Tower.FBX"));
+		TextureRef testTex = static_resource_cast<Texture>(Importer::instance().import("C:\\ImportTest.tga"));
+		mDbgMesh = static_resource_cast<Mesh>(Importer::instance().import("C:\\X_Arena_Tower.FBX"));
 		//mDbgMesh = std::static_pointer_cast<Mesh>(Importer::instance().import("C:\\BarrelMesh.fbx"));
 
 		Resources::startUp(new Resources());
 
-		gResources().save(testTex, "C:\\ExportTest.tex");
-		gResources().save(mDbgMesh, "C:\\ExportMesh.mesh");
+		//gResources().save(testTex, "C:\\ExportTest.tex");
+		//gResources().save(mDbgMesh, "C:\\ExportMesh.mesh");
 
-		mDbgTexture = std::static_pointer_cast<Texture>(gResources().load("C:\\ExportTest.tex"));
-		mDbgMesh = std::static_pointer_cast<Mesh>(gResources().load("C:\\ExportMesh.mesh"));
+		//mDbgTexture = std::static_pointer_cast<Texture>(gResources().load("C:\\ExportTest.tex"));
+		//mDbgMesh = std::static_pointer_cast<Mesh>(gResources().load("C:\\ExportMesh.mesh"));
 
 		mDbgTexture = testTex;
 

+ 1 - 1
CamelotRenderer/Source/CmGpuProgramParams.cpp

@@ -704,7 +704,7 @@ namespace CamelotEngine
 		}
 	}
 	//----------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, TexturePtr val)
+	void GpuProgramParameters::setNamedConstant(const String& name, TextureRef val)
 	{
 		// look up, and throw an exception if we're not ignoring missing
 		const GpuConstantDefinition* def = 

+ 2 - 2
CamelotRenderer/Source/CmImporter.cpp

@@ -45,7 +45,7 @@ namespace CamelotEngine
 		return false;
 	}
 
-	ResourcePtr Importer::import(const String& inputFilePath)
+	BaseResourceRef Importer::import(const String& inputFilePath)
 	{
 		if(!Path::exists(inputFilePath))
 		{
@@ -70,7 +70,7 @@ namespace CamelotEngine
 			}
 		}
 
-		ResourcePtr importedResource = importer->import(inputFilePath);
+		BaseResourceRef importedResource = importer->import(inputFilePath);
 		importedResource->load();
 
 		return importedResource;

+ 2 - 2
CamelotRenderer/Source/CmPass.cpp

@@ -4,7 +4,7 @@
 namespace CamelotEngine
 {
     //-----------------------------------------------------------------------------
-	Pass::Pass(Technique* parent, unsigned short index)
+	Pass::Pass(const Technique* parent, unsigned short index)
         : mParent(parent)
 		, mIndex(index)
 		, mSourceBlendFactor(SBF_ONE)
@@ -39,7 +39,7 @@ namespace CamelotEngine
    }
 
     //-----------------------------------------------------------------------------
-	Pass::Pass(Technique *parent, unsigned short index, const Pass& oth)
+	Pass::Pass(const Technique *parent, unsigned short index, const Pass& oth)
         :mParent(parent), mIndex(index), mPassIterationCount(1)
     {
         *this = oth;

+ 22 - 0
CamelotRenderer/Source/CmResourceRef.cpp

@@ -0,0 +1,22 @@
+#include "CmPrerequisites.h"
+#include "CmResourceRef.h"
+#include "CmResource.h"
+
+namespace CamelotEngine
+{
+	void ResourceRefBase::init(Resource* ptr)
+	{
+		init(std::shared_ptr<Resource>(ptr));
+	}
+
+	void ResourceRefBase::init(std::shared_ptr<Resource> ptr)
+	{
+		mPtr = ptr;
+
+		if(mPtr)
+		{
+			mUUID = mPtr->getUUID();
+			mUUIDSet = true;
+		}
+	}
+}

+ 4 - 6
CamelotRenderer/Source/CmShader.cpp

@@ -11,14 +11,12 @@ namespace CamelotEngine
 
 	}
 
-	void Shader::addTechnique(TechniquePtr technique)
+	TechniquePtr Shader::addTechnique(const String& renderSystem, const String& renderer)
 	{
-		auto iterFind = std::find(mTechniques.begin(), mTechniques.end(), technique);
-
-		if(iterFind != mTechniques.end())
-			CM_EXCEPT(InvalidParametersException, "Identical technique already exists in this shader.");
-
+		TechniquePtr technique = TechniquePtr(new Technique(renderSystem, renderer));
 		mTechniques.push_back(technique);
+
+		return technique;
 	}
 
 	void Shader::removeTechnique(UINT32 idx)

+ 7 - 3
CamelotRenderer/Source/CmTechnique.cpp

@@ -3,6 +3,7 @@
 #include "CmRenderSystemManager.h"
 #include "CmRenderSystem.h"
 #include "CmRendererManager.h"
+#include "CmPass.h"
 #include "CmRenderer.h"
 
 namespace CamelotEngine
@@ -13,9 +14,12 @@ namespace CamelotEngine
 
 	}
 
-	void Technique::addPass(PassPtr pass)
+	PassPtr Technique::addPass()
 	{
-		mPasses.push_back(pass);
+		PassPtr newPass(new Pass(this, mPasses.size()));
+
+		mPasses.push_back(newPass);
+		return newPass;
 	}
 
 	void Technique::removePass(UINT32 idx)
@@ -34,7 +38,7 @@ namespace CamelotEngine
 		mPasses.erase(iter);
 	}
 
-	PassPtr Technique::getPass(UINT32 idx)
+	PassPtr Technique::getPass(UINT32 idx) const
 	{
 		if(idx < 0 || idx >= mPasses.size())
 			CM_EXCEPT(InvalidParametersException, "Index out of range: " + toString(idx));