Просмотр исходного кода

DefaultMeshData is now RendererMeshData and can be overriden by Renderer implementation
FBX importer now generates RendererMeshData instead of the generic MeshData

Marko Pintera 10 лет назад
Родитель
Сommit
1076f0124b

+ 2 - 0
BansheeCore/BansheeCore.vcxproj

@@ -288,6 +288,7 @@
     <ClInclude Include="Include\BsPrefabDiffRTTI.h" />
     <ClInclude Include="Include\BsPrefabDiffRTTI.h" />
     <ClInclude Include="Include\BsPrefabRTTI.h" />
     <ClInclude Include="Include\BsPrefabRTTI.h" />
     <ClInclude Include="Include\BsPrefabUtility.h" />
     <ClInclude Include="Include\BsPrefabUtility.h" />
+    <ClInclude Include="Include\BsRendererMeshData.h" />
     <ClInclude Include="Include\BsShaderIncludeRTTI.h" />
     <ClInclude Include="Include\BsShaderIncludeRTTI.h" />
     <ClInclude Include="Include\BsIResourceListener.h" />
     <ClInclude Include="Include\BsIResourceListener.h" />
     <ClInclude Include="Include\BsMaterialParam.h" />
     <ClInclude Include="Include\BsMaterialParam.h" />
@@ -466,6 +467,7 @@
     <ClCompile Include="Source\BsGpuParamBlockBuffer.cpp" />
     <ClCompile Include="Source\BsGpuParamBlockBuffer.cpp" />
     <ClCompile Include="Source\BsGpuParams.cpp" />
     <ClCompile Include="Source\BsGpuParams.cpp" />
     <ClCompile Include="Source\BsProfilerGPU.cpp" />
     <ClCompile Include="Source\BsProfilerGPU.cpp" />
+    <ClCompile Include="Source\BsRendererMeshData.cpp" />
     <ClCompile Include="Source\BsShaderInclude.cpp" />
     <ClCompile Include="Source\BsShaderInclude.cpp" />
     <ClCompile Include="Source\BsGpuProgram.cpp" />
     <ClCompile Include="Source\BsGpuProgram.cpp" />
     <ClCompile Include="Source\BsGpuResourceData.cpp" />
     <ClCompile Include="Source\BsGpuResourceData.cpp" />

+ 6 - 0
BansheeCore/BansheeCore.vcxproj.filters

@@ -548,6 +548,9 @@
     <ClInclude Include="Include\BsPrefabUtility.h">
     <ClInclude Include="Include\BsPrefabUtility.h">
       <Filter>Header Files\Scene</Filter>
       <Filter>Header Files\Scene</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsRendererMeshData.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCoreApplication.cpp">
     <ClCompile Include="Source\BsCoreApplication.cpp">
@@ -868,5 +871,8 @@
     <ClCompile Include="Source\BsPrefabUtility.cpp">
     <ClCompile Include="Source\BsPrefabUtility.cpp">
       <Filter>Source Files\Scene</Filter>
       <Filter>Source Files\Scene</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsRendererMeshData.cpp">
+      <Filter>Source Files\Renderer</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 2 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -168,6 +168,7 @@ namespace BansheeEngine
 	class IShaderIncludeHandler;
 	class IShaderIncludeHandler;
 	class Prefab;
 	class Prefab;
 	class PrefabDiff;
 	class PrefabDiff;
+	class RendererMeshData;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;
 	class Importer;
 	class Importer;
@@ -266,6 +267,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<IShaderIncludeHandler> ShaderIncludeHandlerPtr;
 	typedef std::shared_ptr<IShaderIncludeHandler> ShaderIncludeHandlerPtr;
 	typedef std::shared_ptr<Prefab> PrefabPtr;
 	typedef std::shared_ptr<Prefab> PrefabPtr;
 	typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
 	typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
+	typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
 }
 }
 
 
 /************************************************************************/
 /************************************************************************/

+ 18 - 0
BansheeCore/Include/BsCoreRenderer.h

@@ -4,6 +4,7 @@
 #include "BsGameObject.h"
 #include "BsGameObject.h"
 #include "BsEvent.h"
 #include "BsEvent.h"
 #include "BsStringID.h"
 #include "BsStringID.h"
+#include "BsRendererMeshData.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -80,6 +81,23 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual void _notifyCameraRemoved(const CameraHandlerCore* camera) { }
 		virtual void _notifyCameraRemoved(const CameraHandlerCore* camera) { }
 
 
+		/**
+		 * @brief	Creates a new empty renderer mesh data.
+		 *
+		 * @note	Sim thread.
+		 *			Internal method.
+		 */
+		virtual RendererMeshDataPtr _createMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
+
+		/**
+		 * @brief	Creates a new renderer mesh data using an existing generic mesh data buffer.
+		 *
+		 * @note	Sim thread.
+		 *			Internal method.
+		 */
+		virtual RendererMeshDataPtr _createMeshData(const MeshDataPtr& meshData);
+
+
 		/**
 		/**
 		 * @brief	Activates the specified pass on the pipeline.
 		 * @brief	Activates the specified pass on the pipeline.
 		 *
 		 *

+ 2 - 0
BansheeCore/Include/BsRendererFactory.h

@@ -16,6 +16,8 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT RendererFactory
 	class BS_CORE_EXPORT RendererFactory
 	{
 	{
 	public:
 	public:
+		virtual ~RendererFactory() { }
+
 		/**
 		/**
 		 * @brief	Creates a new instance of the renderer.
 		 * @brief	Creates a new instance of the renderer.
 		 */
 		 */

+ 22 - 9
BansheeEngine/Include/BsDefaultMeshData.h → BansheeCore/Include/BsRendererMeshData.h

@@ -1,6 +1,6 @@
 #pragma once
 #pragma once
 
 
-#include "BsPrerequisites.h"
+#include "BsCorePrerequisites.h"
 #include "BsMeshData.h"
 #include "BsMeshData.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
@@ -30,19 +30,17 @@ namespace BansheeEngine
 		PNTU = Position | Normal | Tangent | UV0,
 		PNTU = Position | Normal | Tangent | UV0,
 	};
 	};
 
 
-
 	/**
 	/**
 	 * @brief	Wrapper around MeshData that constructs the default mesh data structure 
 	 * @brief	Wrapper around MeshData that constructs the default mesh data structure 
 	 *			expected by the renderer and other engine systems. Data will be compressed and
 	 *			expected by the renderer and other engine systems. Data will be compressed and
 	 *			uncompressed when written to and read to as needed to comply with wanted format.
 	 *			uncompressed when written to and read to as needed to comply with wanted format.
+	 *			
+	 * @note	This is the default implementation while the Renderer plugins can override it by overriding
+	 *			createMeshData method in their Renderer implementation.
 	 */
 	 */
-	// TODO: Allow the Renderer plugin to override how is data packed.
-	class BS_EXPORT DefaultMeshData
+	class BS_CORE_EXPORT RendererMeshData
 	{
 	{
 	public:
 	public:
-		DefaultMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
-		DefaultMeshData(const MeshDataPtr& meshData);
-
 		/**
 		/**
 		 * @brief	Reads the vertex positions into the provided output buffer.
 		 * @brief	Reads the vertex positions into the provided output buffer.
 		 *			Data will be copied and potentially uncompressed to fit the output
 		 *			Data will be copied and potentially uncompressed to fit the output
@@ -127,6 +125,16 @@ namespace BansheeEngine
 		 */
 		 */
 		void setColors(Color* buffer, UINT32 size);
 		void setColors(Color* buffer, UINT32 size);
 
 
+		/**
+		 * @brief	Writes the vertex colors from the provided output buffer.
+		 *			Data will be copied and potentially compressed to fit the internal 
+		 *			mesh data format as needed.
+		 *			
+		 * @param	buffer	Pre-allocated buffer to read the color data from. Colors should be in RGBA format.
+		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(UINT32)).
+		 */
+		void setColors(UINT32* buffer, UINT32 size);
+
 		/**
 		/**
 		 * @brief	Reads the first UV channel coordinates into the provided output buffer.
 		 * @brief	Reads the first UV channel coordinates into the provided output buffer.
 		 *			Data will be copied and potentially uncompressed to fit the output
 		 *			Data will be copied and potentially uncompressed to fit the output
@@ -219,12 +227,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Creates a new empty mesh data structure.
 		 * @brief	Creates a new empty mesh data structure.
 		 */
 		 */
-		static DefaultMeshDataPtr create(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
+		static RendererMeshDataPtr create(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
 
 
 		/**
 		/**
 		 * @brief	Creates a new mesh data structure using an existing mesh data buffer.
 		 * @brief	Creates a new mesh data structure using an existing mesh data buffer.
 		 */
 		 */
-		static DefaultMeshDataPtr create(const MeshDataPtr& meshData);
+		static RendererMeshDataPtr create(const MeshDataPtr& meshData);
 
 
 		/**
 		/**
 		 * @brief	Creates a vertex descriptor from a vertex layout enum.
 		 * @brief	Creates a vertex descriptor from a vertex layout enum.
@@ -232,6 +240,11 @@ namespace BansheeEngine
 		static VertexDataDescPtr vertexLayoutVertexDesc(VertexLayout type);
 		static VertexDataDescPtr vertexLayoutVertexDesc(VertexLayout type);
 
 
 	private:
 	private:
+		friend class CoreRenderer;
+
+		RendererMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
+		RendererMeshData(const MeshDataPtr& meshData);
+
 		MeshDataPtr mMeshData;
 		MeshDataPtr mMeshData;
 	};
 	};
 }
 }

+ 12 - 0
BansheeCore/Source/BsCoreRenderer.cpp

@@ -10,6 +10,18 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	RendererMeshDataPtr CoreRenderer::_createMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType)
+	{
+		return bs_shared_ptr<RendererMeshData, PoolAlloc>(new (bs_alloc<RendererMeshData, PoolAlloc>()) 
+			RendererMeshData(numVertices, numIndices, layout, indexType));
+	}
+
+	RendererMeshDataPtr CoreRenderer::_createMeshData(const MeshDataPtr& meshData)
+	{
+		return bs_shared_ptr<RendererMeshData, PoolAlloc>(new (bs_alloc<RendererMeshData, PoolAlloc>())
+			RendererMeshData(meshData));
+	}
+
 	void CoreRenderer::setPass(const SPtr<MaterialCore>& material, UINT32 passIdx)
 	void CoreRenderer::setPass(const SPtr<MaterialCore>& material, UINT32 passIdx)
 	{
 	{
 		THROW_IF_NOT_CORE_THREAD;
 		THROW_IF_NOT_CORE_THREAD;

+ 38 - 24
BansheeEngine/Source/BsDefaultMeshData.cpp → BansheeCore/Source/BsRendererMeshData.cpp

@@ -1,27 +1,29 @@
-#include "BsDefaultMeshData.h"
+#include "BsRendererMeshData.h"
 #include "BsVertexDataDesc.h"
 #include "BsVertexDataDesc.h"
 #include "BsVector2.h"
 #include "BsVector2.h"
 #include "BsVector3.h"
 #include "BsVector3.h"
 #include "BsVector4.h"
 #include "BsVector4.h"
 #include "BsColor.h"
 #include "BsColor.h"
 #include "BsPixelUtil.h"
 #include "BsPixelUtil.h"
+#include "BsRendererManager.h"
+#include "BsCoreRenderer.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	DefaultMeshData::DefaultMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType)
+	RendererMeshData::RendererMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType)
 	{
 	{
 		VertexDataDescPtr vertexDesc = vertexLayoutVertexDesc(layout);
 		VertexDataDescPtr vertexDesc = vertexLayoutVertexDesc(layout);
 
 
 		mMeshData = bs_shared_ptr<MeshData>(numVertices, numIndices, vertexDesc, indexType);
 		mMeshData = bs_shared_ptr<MeshData>(numVertices, numIndices, vertexDesc, indexType);
 	}
 	}
 
 
-	DefaultMeshData::DefaultMeshData(const MeshDataPtr& meshData)
+	RendererMeshData::RendererMeshData(const MeshDataPtr& meshData)
 		:mMeshData(meshData)
 		:mMeshData(meshData)
 	{
 	{
 
 
 	}
 	}
 
 
-	void DefaultMeshData::getPositions(Vector3* buffer, UINT32 size)
+	void RendererMeshData::getPositions(Vector3* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_POSITION))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_POSITION))
 			return;
 			return;
@@ -32,7 +34,7 @@ namespace BansheeEngine
 		mMeshData->getVertexData(VES_POSITION, (UINT8*)buffer, size);
 		mMeshData->getVertexData(VES_POSITION, (UINT8*)buffer, size);
 	}
 	}
 
 
-	void DefaultMeshData::setPositions(Vector3* buffer, UINT32 size)
+	void RendererMeshData::setPositions(Vector3* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_POSITION))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_POSITION))
 			return;
 			return;
@@ -43,7 +45,7 @@ namespace BansheeEngine
 		mMeshData->setVertexData(VES_POSITION, (UINT8*)buffer, size);
 		mMeshData->setVertexData(VES_POSITION, (UINT8*)buffer, size);
 	}
 	}
 
 
-	void DefaultMeshData::getNormals(Vector3* buffer, UINT32 size)
+	void RendererMeshData::getNormals(Vector3* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_NORMAL))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_NORMAL))
 			return;
 			return;
@@ -54,7 +56,7 @@ namespace BansheeEngine
 		mMeshData->getVertexData(VES_NORMAL, (UINT8*)buffer, size);
 		mMeshData->getVertexData(VES_NORMAL, (UINT8*)buffer, size);
 	}
 	}
 
 
-	void DefaultMeshData::setNormals(Vector3* buffer, UINT32 size)
+	void RendererMeshData::setNormals(Vector3* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_NORMAL))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_NORMAL))
 			return;
 			return;
@@ -65,7 +67,7 @@ namespace BansheeEngine
 		mMeshData->setVertexData(VES_NORMAL, (UINT8*)buffer, size);
 		mMeshData->setVertexData(VES_NORMAL, (UINT8*)buffer, size);
 	}
 	}
 
 
-	void DefaultMeshData::getTangents(Vector4* buffer, UINT32 size)
+	void RendererMeshData::getTangents(Vector4* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TANGENT))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TANGENT))
 			return;
 			return;
@@ -76,7 +78,7 @@ namespace BansheeEngine
 		mMeshData->getVertexData(VES_TANGENT, (UINT8*)buffer, size);
 		mMeshData->getVertexData(VES_TANGENT, (UINT8*)buffer, size);
 	}
 	}
 
 
-	void DefaultMeshData::setTangents(Vector4* buffer, UINT32 size)
+	void RendererMeshData::setTangents(Vector4* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TANGENT))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TANGENT))
 			return;
 			return;
@@ -87,7 +89,7 @@ namespace BansheeEngine
 		mMeshData->setVertexData(VES_TANGENT, (UINT8*)buffer, size);
 		mMeshData->setVertexData(VES_TANGENT, (UINT8*)buffer, size);
 	}
 	}
 
 
-	void DefaultMeshData::getColors(Color* buffer, UINT32 size)
+	void RendererMeshData::getColors(Color* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_COLOR))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_COLOR))
 			return;
 			return;
@@ -108,7 +110,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void DefaultMeshData::setColors(Color* buffer, UINT32 size)
+	void RendererMeshData::setColors(Color* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_COLOR))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_COLOR))
 			return;
 			return;
@@ -129,7 +131,19 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void DefaultMeshData::getUV0(Vector2* buffer, UINT32 size)
+	void RendererMeshData::setColors(UINT32* buffer, UINT32 size)
+	{
+		if (!mMeshData->getVertexDesc()->hasElement(VES_COLOR))
+			return;
+
+		UINT32 numElements = mMeshData->getNumVertices();
+		assert(numElements * sizeof(UINT32) == size);
+
+		UINT8* colorDst = mMeshData->getElementData(VES_COLOR);
+		memcpy(colorDst, buffer, size);
+	}
+
+	void RendererMeshData::getUV0(Vector2* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 0))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 0))
 			return;
 			return;
@@ -140,7 +154,7 @@ namespace BansheeEngine
 		mMeshData->getVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 0);
 		mMeshData->getVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 0);
 	}
 	}
 
 
-	void DefaultMeshData::setUV0(Vector2* buffer, UINT32 size)
+	void RendererMeshData::setUV0(Vector2* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 0))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 0))
 			return;
 			return;
@@ -151,7 +165,7 @@ namespace BansheeEngine
 		mMeshData->setVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 0);
 		mMeshData->setVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 0);
 	}
 	}
 
 
-	void DefaultMeshData::getUV1(Vector2* buffer, UINT32 size)
+	void RendererMeshData::getUV1(Vector2* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 1))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 1))
 			return;
 			return;
@@ -162,7 +176,7 @@ namespace BansheeEngine
 		mMeshData->getVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 1);
 		mMeshData->getVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 1);
 	}
 	}
 
 
-	void DefaultMeshData::setUV1(Vector2* buffer, UINT32 size)
+	void RendererMeshData::setUV1(Vector2* buffer, UINT32 size)
 	{
 	{
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 1))
 		if (!mMeshData->getVertexDesc()->hasElement(VES_TEXCOORD, 1))
 			return;
 			return;
@@ -173,7 +187,7 @@ namespace BansheeEngine
 		mMeshData->setVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 1);
 		mMeshData->setVertexData(VES_TEXCOORD, (UINT8*)buffer, size, 1);
 	}
 	}
 
 
-	void DefaultMeshData::getBoneWeights(BoneWeight* buffer, UINT32 size)
+	void RendererMeshData::getBoneWeights(BoneWeight* buffer, UINT32 size)
 	{
 	{
 		VertexDataDescPtr vertexDesc = mMeshData->getVertexDesc();
 		VertexDataDescPtr vertexDesc = mMeshData->getVertexDesc();
 
 
@@ -211,7 +225,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void DefaultMeshData::setBoneWeights(BoneWeight* buffer, UINT32 size)
+	void RendererMeshData::setBoneWeights(BoneWeight* buffer, UINT32 size)
 	{
 	{
 		VertexDataDescPtr vertexDesc = mMeshData->getVertexDesc();
 		VertexDataDescPtr vertexDesc = mMeshData->getVertexDesc();
 
 
@@ -249,7 +263,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void DefaultMeshData::getIndices(UINT32* buffer, UINT32 size)
+	void RendererMeshData::getIndices(UINT32* buffer, UINT32 size)
 	{
 	{
 		UINT32 indexSize = mMeshData->getIndexElementSize();
 		UINT32 indexSize = mMeshData->getIndexElementSize();
 		UINT32 numIndices = mMeshData->getNumIndices();
 		UINT32 numIndices = mMeshData->getNumIndices();
@@ -275,7 +289,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void DefaultMeshData::setIndices(UINT32* buffer, UINT32 size)
+	void RendererMeshData::setIndices(UINT32* buffer, UINT32 size)
 	{
 	{
 		UINT32 indexSize = mMeshData->getIndexElementSize();
 		UINT32 indexSize = mMeshData->getIndexElementSize();
 		UINT32 numIndices = mMeshData->getNumIndices();
 		UINT32 numIndices = mMeshData->getNumIndices();
@@ -301,17 +315,17 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	DefaultMeshDataPtr DefaultMeshData::create(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType)
+	RendererMeshDataPtr RendererMeshData::create(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType)
 	{
 	{
-		return bs_shared_ptr<DefaultMeshData>(numVertices, numIndices, layout, indexType);
+		return RendererManager::instance().getActive()->_createMeshData(numVertices, numIndices, layout, indexType);
 	}
 	}
 
 
-	DefaultMeshDataPtr DefaultMeshData::create(const MeshDataPtr& meshData)
+	RendererMeshDataPtr RendererMeshData::create(const MeshDataPtr& meshData)
 	{
 	{
-		return bs_shared_ptr<DefaultMeshData>(meshData);
+		return RendererManager::instance().getActive()->_createMeshData(meshData);
 	}
 	}
 
 
-	VertexDataDescPtr DefaultMeshData::vertexLayoutVertexDesc(VertexLayout type)
+	VertexDataDescPtr RendererMeshData::vertexLayoutVertexDesc(VertexLayout type)
 	{
 	{
 		VertexDataDescPtr vertexDesc = VertexDataDesc::create();
 		VertexDataDescPtr vertexDesc = VertexDataDesc::create();
 
 

+ 0 - 2
BansheeEngine/BansheeEngine.vcxproj

@@ -234,7 +234,6 @@
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCameraHandler.cpp" />
     <ClCompile Include="Source\BsCameraHandler.cpp" />
     <ClCompile Include="Source\BsCursor.cpp" />
     <ClCompile Include="Source\BsCursor.cpp" />
-    <ClCompile Include="Source\BsDefaultMeshData.cpp" />
     <ClCompile Include="Source\BsDrawHelper.cpp" />
     <ClCompile Include="Source\BsDrawHelper.cpp" />
     <ClCompile Include="Source\BsDropDownAreaPlacement.cpp" />
     <ClCompile Include="Source\BsDropDownAreaPlacement.cpp" />
     <ClCompile Include="Source\BsGUIDropDownContent.cpp" />
     <ClCompile Include="Source\BsGUIDropDownContent.cpp" />
@@ -262,7 +261,6 @@
     <ClInclude Include="Include\BsCameraHandler.h" />
     <ClInclude Include="Include\BsCameraHandler.h" />
     <ClInclude Include="Include\BsCameraHandlerRTTI.h" />
     <ClInclude Include="Include\BsCameraHandlerRTTI.h" />
     <ClInclude Include="Include\BsCursor.h" />
     <ClInclude Include="Include\BsCursor.h" />
-    <ClInclude Include="Include\BsDefaultMeshData.h" />
     <ClInclude Include="Include\BsDrawHelper.h" />
     <ClInclude Include="Include\BsDrawHelper.h" />
     <ClInclude Include="Include\BsDropDownAreaPlacement.h" />
     <ClInclude Include="Include\BsDropDownAreaPlacement.h" />
     <ClInclude Include="Include\BsGUIDropDownContent.h" />
     <ClInclude Include="Include\BsGUIDropDownContent.h" />

+ 0 - 6
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -329,9 +329,6 @@
     <ClInclude Include="Include\BsGUILayoutData.h">
     <ClInclude Include="Include\BsGUILayoutData.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\BsDefaultMeshData.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsGUIDropDownMenu.h">
     <ClInclude Include="Include\BsGUIDropDownMenu.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
@@ -577,9 +574,6 @@
     <ClCompile Include="Source\BsGUIPanel.cpp">
     <ClCompile Include="Source\BsGUIPanel.cpp">
       <Filter>Source Files\GUI</Filter>
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\BsDefaultMeshData.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsGUIDropDownMenu.cpp">
     <ClCompile Include="Source\BsGUIDropDownMenu.cpp">
       <Filter>Source Files\GUI</Filter>
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
     </ClCompile>

+ 1 - 2
BansheeEngine/Include/BsPrerequisites.h

@@ -92,7 +92,7 @@ namespace BansheeEngine
 	class PlainText;
 	class PlainText;
 	class ScriptCode;
 	class ScriptCode;
 	class ScriptCodeImportOptions;
 	class ScriptCodeImportOptions;
-	class DefaultMeshData;
+	class RendererMeshData;
 
 
 	// 2D
 	// 2D
 	class TextSprite;
 	class TextSprite;
@@ -118,7 +118,6 @@ namespace BansheeEngine
 	typedef std::shared_ptr<ScriptCode> ScriptCodePtr;
 	typedef std::shared_ptr<ScriptCode> ScriptCodePtr;
 	typedef std::shared_ptr<GUISkin> GUISkinPtr;
 	typedef std::shared_ptr<GUISkin> GUISkinPtr;
 	typedef std::shared_ptr<GUIContextMenu> GUIContextMenuPtr;
 	typedef std::shared_ptr<GUIContextMenu> GUIContextMenuPtr;
-	typedef std::shared_ptr<DefaultMeshData> DefaultMeshDataPtr;
 
 
 	typedef GameObjectHandle<GUIWidget> HGUIWidget;
 	typedef GameObjectHandle<GUIWidget> HGUIWidget;
 	typedef GameObjectHandle<Camera> HCamera;
 	typedef GameObjectHandle<Camera> HCamera;

+ 1 - 1
BansheeFBXImporter/Include/BsFBXImporter.h

@@ -135,7 +135,7 @@ namespace BansheeEngine
 		 * @brief	Converts the mesh data from the imported FBX scene into mesh data that can be used
 		 * @brief	Converts the mesh data from the imported FBX scene into mesh data that can be used
 		 *			for initializing a mesh.
 		 *			for initializing a mesh.
 		 */
 		 */
-		MeshDataPtr generateMeshData(const FBXImportScene& scene, const FBXImportOptions& options, Vector<SubMesh>& subMeshes);
+		RendererMeshDataPtr generateMeshData(const FBXImportScene& scene, const FBXImportOptions& options, Vector<SubMesh>& subMeshes);
 
 
 		/**
 		/**
 		 * @brief	Creates an internal representation of an FBX node from an FbxNode object.
 		 * @brief	Creates an internal representation of an FBX node from an FbxNode object.

+ 54 - 40
BansheeFBXImporter/Source/BsFBXImporter.cpp

@@ -12,7 +12,8 @@
 #include "BsVertexDataDesc.h"
 #include "BsVertexDataDesc.h"
 #include "BsFBXUtility.h"
 #include "BsFBXUtility.h"
 #include "BsMeshUtility.h"
 #include "BsMeshUtility.h"
-#include <BsMeshImportOptions.h>
+#include "BsRendererMeshData.h"
+#include "BsMeshImportOptions.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -140,7 +141,7 @@ namespace BansheeEngine
 		generateMissingTangentSpace(importedScene, fbxImportOptions);
 		generateMissingTangentSpace(importedScene, fbxImportOptions);
 		
 		
 		Vector<SubMesh> subMeshes;
 		Vector<SubMesh> subMeshes;
-		MeshDataPtr meshData = generateMeshData(importedScene, fbxImportOptions, subMeshes);
+		RendererMeshDataPtr rendererMeshData = generateMeshData(importedScene, fbxImportOptions, subMeshes);
 
 
 		// TODO - Later: Optimize mesh: Remove bad and degenerate polygons, weld nearby vertices, optimize for vertex cache
 		// TODO - Later: Optimize mesh: Remove bad and degenerate polygons, weld nearby vertices, optimize for vertex cache
 
 
@@ -150,7 +151,7 @@ namespace BansheeEngine
 		if (meshImportOptions->getCPUReadable())
 		if (meshImportOptions->getCPUReadable())
 			usage |= MU_CPUCACHED;
 			usage |= MU_CPUCACHED;
 
 
-		MeshPtr mesh = Mesh::_createPtr(meshData, subMeshes, usage);
+		MeshPtr mesh = Mesh::_createPtr(rendererMeshData->getData(), subMeshes, usage);
 
 
 		WString fileName = filePath.getWFilename(false);
 		WString fileName = filePath.getWFilename(false);
 		mesh->setName(fileName);
 		mesh->setName(fileName);
@@ -342,7 +343,7 @@ namespace BansheeEngine
 		scene.meshes = splitMeshes;
 		scene.meshes = splitMeshes;
 	}
 	}
 
 
-	MeshDataPtr FBXImporter::generateMeshData(const FBXImportScene& scene, const FBXImportOptions& options, Vector<SubMesh>& outputSubMeshes)
+	RendererMeshDataPtr FBXImporter::generateMeshData(const FBXImportScene& scene, const FBXImportOptions& options, Vector<SubMesh>& outputSubMeshes)
 	{
 	{
 		Matrix4 importScale = Matrix4::scaling(options.importScale);
 		Matrix4 importScale = Matrix4::scaling(options.importScale);
 
 
@@ -375,25 +376,24 @@ namespace BansheeEngine
 				currentIndex += indexCount;
 				currentIndex += indexCount;
 			}
 			}
 
 
-			VertexDataDescPtr vertexDesc = bs_shared_ptr<VertexDataDesc>();
-			vertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
+			UINT32 vertexLayout = (UINT32)VertexLayout::Position;
 
 
 			size_t numVertices = mesh->positions.size();
 			size_t numVertices = mesh->positions.size();
 			bool hasColors = mesh->colors.size() == numVertices;
 			bool hasColors = mesh->colors.size() == numVertices;
 			bool hasNormals = mesh->normals.size() == numVertices;
 			bool hasNormals = mesh->normals.size() == numVertices;
 
 
 			if (hasColors)
 			if (hasColors)
-				vertexDesc->addVertElem(VET_COLOR, VES_COLOR);
+				vertexLayout |= (UINT32)VertexLayout::Color;
 
 
 			bool hasTangents = false;
 			bool hasTangents = false;
 			if (hasNormals)
 			if (hasNormals)
 			{
 			{
-				vertexDesc->addVertElem(VET_FLOAT3, VES_NORMAL);
+				vertexLayout |= (UINT32)VertexLayout::Normal;
 
 
 				if (mesh->tangents.size() == numVertices &&
 				if (mesh->tangents.size() == numVertices &&
 					mesh->bitangents.size() == numVertices)
 					mesh->bitangents.size() == numVertices)
 				{
 				{
-					vertexDesc->addVertElem(VET_FLOAT4, VES_TANGENT);
+					vertexLayout |= (UINT32)VertexLayout::Tangent;
 					hasTangents = true;
 					hasTangents = true;
 				}
 				}
 			}
 			}
@@ -403,7 +403,10 @@ namespace BansheeEngine
 			{
 			{
 				if (mesh->UV[i].size() == numVertices)
 				if (mesh->UV[i].size() == numVertices)
 				{
 				{
-					vertexDesc->addVertElem(VET_FLOAT2, VES_TEXCOORD, UVIdx++);
+					if (i == 0)
+						vertexLayout |= (UINT32)VertexLayout::UV0;
+					else if (i == 1)
+						vertexLayout |= (UINT32)VertexLayout::UV1;
 				}
 				}
 			}
 			}
 
 
@@ -414,36 +417,37 @@ namespace BansheeEngine
 				Matrix4 worldTransformIT = worldTransform.transpose();
 				Matrix4 worldTransformIT = worldTransform.transpose();
 				worldTransformIT = worldTransformIT.inverse();
 				worldTransformIT = worldTransformIT.inverse();
 
 
-				MeshDataPtr meshData = bs_shared_ptr<MeshData>((UINT32)numVertices, numIndices, vertexDesc);
+				RendererMeshDataPtr meshData = RendererMeshData::create((UINT32)numVertices, numIndices, (VertexLayout)vertexLayout);
 
 
 				// Copy indices
 				// Copy indices
-				UINT32* indices = meshData->getIndices32();
-				memcpy(indices, mesh->indices.data(), numIndices * sizeof(UINT32));
+				meshData->setIndices((UINT32*)mesh->indices.data(), numIndices * sizeof(UINT32));
 
 
 				// Copy & transform positions
 				// Copy & transform positions
-				auto posIter = meshData->getVec3DataIter(VES_POSITION, 0);
+				UINT32 positionsSize = sizeof(Vector3) * (UINT32)numVertices;
+				Vector3* transformedPositions = (Vector3*)stackAlloc(positionsSize);
 
 
-				for (auto& position : mesh->positions)
-				{
-					Vector3 tfrmdValue = worldTransform.multiplyAffine((Vector3)position);
-					posIter.addValue(tfrmdValue);
-				}
+				for (UINT32 i = 0; i < (UINT32)numVertices; i++)
+					transformedPositions[i] = worldTransform.multiplyAffine((Vector3)mesh->positions[i]);
+
+				meshData->setPositions(transformedPositions, positionsSize);
+				stackDeallocLast(transformedPositions);
 
 
 				// Copy & transform normals
 				// Copy & transform normals
 				if (hasNormals)
 				if (hasNormals)
 				{
 				{
-					auto normalIter = meshData->getVec3DataIter(VES_NORMAL, 0);
+					UINT32 normalsSize = sizeof(Vector3) * (UINT32)numVertices;
+					Vector3* transformedNormals = (Vector3*)stackAlloc(normalsSize);
 
 
 					// Copy, convert & transform tangents & bitangents
 					// Copy, convert & transform tangents & bitangents
 					if (hasTangents)
 					if (hasTangents)
 					{
 					{
-						auto tangentIter = meshData->getVec4DataIter(VES_TANGENT, 0);
+						UINT32 tangentsSize = sizeof(Vector4) * (UINT32)numVertices;
+						Vector4* transformedTangents = (Vector4*)stackAlloc(tangentsSize);
 
 
 						for (UINT32 i = 0; i < (UINT32)numVertices; i++)
 						for (UINT32 i = 0; i < (UINT32)numVertices; i++)
 						{
 						{
 							Vector3 normal = (Vector3)mesh->normals[i];
 							Vector3 normal = (Vector3)mesh->normals[i];
-							normal = worldTransformIT.multiplyAffine(normal);
-							normalIter.addValue(normal);
+							transformedNormals[i] = worldTransformIT.multiplyAffine(normal);
 
 
 							Vector3 tangent = (Vector3)mesh->tangents[i];
 							Vector3 tangent = (Vector3)mesh->tangents[i];
 							tangent = worldTransformIT.multiplyAffine(tangent);
 							tangent = worldTransformIT.multiplyAffine(tangent);
@@ -454,27 +458,26 @@ namespace BansheeEngine
 							Vector3 engineBitangent = Vector3::cross(normal, tangent);
 							Vector3 engineBitangent = Vector3::cross(normal, tangent);
 							float sign = Vector3::dot(engineBitangent, bitangent);
 							float sign = Vector3::dot(engineBitangent, bitangent);
 
 
-							Vector4 combinedTangent(tangent.x, tangent.y, tangent.z, sign > 0 ? 1.0f : -1.0f);
-							tangentIter.addValue(combinedTangent);
+							transformedTangents[i] = Vector4(tangent.x, tangent.y, tangent.z, sign > 0 ? 1.0f : -1.0f);
 						}
 						}
+
+						meshData->setTangents(transformedTangents, tangentsSize);
+						stackDeallocLast(transformedTangents);
 					}
 					}
 					else // Just normals
 					else // Just normals
 					{
 					{
-						for (auto& normal : mesh->normals)
-						{
-							Vector3 tfrmdValue = worldTransformIT.multiplyAffine((Vector3)normal);
-							normalIter.addValue(tfrmdValue);
-						}
+						for (UINT32 i = 0; i < (UINT32)numVertices; i++)
+							transformedNormals[i] = worldTransformIT.multiplyAffine((Vector3)mesh->normals[i]);
 					}
 					}
+
+					meshData->setNormals(transformedNormals, normalsSize);
+					stackDeallocLast(transformedNormals);
 				}
 				}
 
 
 				// Copy colors
 				// Copy colors
 				if (hasColors)
 				if (hasColors)
 				{
 				{
-					auto colorIter = meshData->getDWORDDataIter(VES_COLOR, 0);
-
-					for (auto& color : mesh->colors)
-						colorIter.addValue(color);
+					meshData->setColors(mesh->colors.data(), sizeof(UINT32) * (UINT32)numVertices);
 				}
 				}
 
 
 				// Copy UV
 				// Copy UV
@@ -483,31 +486,42 @@ namespace BansheeEngine
 				{
 				{
 					if (uvLayer.size() == numVertices)
 					if (uvLayer.size() == numVertices)
 					{
 					{
-						auto uvIter = meshData->getVec2DataIter(VES_TEXCOORD, writeUVIDx);
+						UINT32 size = sizeof(Vector2) * (UINT32)numVertices;
+						Vector2* transformedUV = (Vector2*)stackAlloc(size);
 
 
+						UINT32 i = 0;
 						for (auto& uv : uvLayer)
 						for (auto& uv : uvLayer)
 						{
 						{
-							uv.y = 1.0f - uv.y;
-							uvIter.addValue(uv);
+							transformedUV[i] = uv;
+							transformedUV[i].y = 1.0f - uv.y;
+
+							i++;
 						}
 						}
 
 
+						if (writeUVIDx == 0)
+							meshData->setUV0(transformedUV, size);
+						else if (writeUVIDx == 1)
+							meshData->setUV1(transformedUV, size);
+
+						stackDeallocLast(transformedUV);
+
 						writeUVIDx++;
 						writeUVIDx++;
 					}
 					}
 				}
 				}
 
 
-				allMeshData.push_back(meshData);
+				allMeshData.push_back(meshData->getData());
 				allSubMeshes.push_back(subMeshes);
 				allSubMeshes.push_back(subMeshes);
 			}
 			}
 		}
 		}
 
 
 		if (allMeshData.size() > 1)
 		if (allMeshData.size() > 1)
 		{
 		{
-			return MeshData::combine(allMeshData, allSubMeshes, outputSubMeshes);
+			return RendererMeshData::create(MeshData::combine(allMeshData, allSubMeshes, outputSubMeshes));
 		}
 		}
 		else if (allMeshData.size() == 1)
 		else if (allMeshData.size() == 1)
 		{
 		{
 			outputSubMeshes = allSubMeshes[0];
 			outputSubMeshes = allSubMeshes[0];
-			return allMeshData[0];
+			return RendererMeshData::create(allMeshData[0]);
 		}
 		}
 
 
 		return nullptr;
 		return nullptr;

+ 5 - 5
SBansheeEngine/Include/BsScriptMeshData.h

@@ -2,7 +2,7 @@
 
 
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptObject.h"
 #include "BsScriptObject.h"
-#include "BsDefaultMeshData.h"
+#include "BsRendererMeshData.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -18,15 +18,15 @@ namespace BansheeEngine
 	public:
 	public:
 		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "MeshData")
 		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "MeshData")
 
 
-		DefaultMeshDataPtr getInternalValue() const { return mMeshData; }
+		RendererMeshDataPtr getInternalValue() const { return mMeshData; }
 
 
-		static MonoObject* create(const DefaultMeshDataPtr& meshData);
+		static MonoObject* create(const RendererMeshDataPtr& meshData);
 		static MonoObject* create(const MeshDataPtr& meshData);
 		static MonoObject* create(const MeshDataPtr& meshData);
 	private:
 	private:
 		ScriptMeshData(MonoObject* managedInstance);
 		ScriptMeshData(MonoObject* managedInstance);
 		~ScriptMeshData();
 		~ScriptMeshData();
 
 
-		void initialize(const DefaultMeshDataPtr& meshData);
+		void initialize(const RendererMeshDataPtr& meshData);
 
 
 		static void internal_CreateInstance(MonoObject* instance, int numVertices,
 		static void internal_CreateInstance(MonoObject* instance, int numVertices,
 			int numIndices, VertexLayout vertex, ScriptIndexType index);
 			int numIndices, VertexLayout vertex, ScriptIndexType index);
@@ -51,6 +51,6 @@ namespace BansheeEngine
 
 
 		static bool checkIsLocked(ScriptMeshData* thisPtr);
 		static bool checkIsLocked(ScriptMeshData* thisPtr);
 		
 		
-		DefaultMeshDataPtr mMeshData;
+		RendererMeshDataPtr mMeshData;
 	};
 	};
 }
 }

+ 1 - 1
SBansheeEngine/Source/BsScriptMesh.cpp

@@ -48,7 +48,7 @@ namespace BansheeEngine
 	void ScriptMesh::internal_CreateInstance(MonoObject* instance, int numVertices, int numIndices, 
 	void ScriptMesh::internal_CreateInstance(MonoObject* instance, int numVertices, int numIndices, 
 		MonoArray* subMeshes, MeshUsage usage, VertexLayout vertex, ScriptIndexType index)
 		MonoArray* subMeshes, MeshUsage usage, VertexLayout vertex, ScriptIndexType index)
 	{
 	{
-		VertexDataDescPtr vertexDesc = DefaultMeshData::vertexLayoutVertexDesc(vertex);
+		VertexDataDescPtr vertexDesc = RendererMeshData::vertexLayoutVertexDesc(vertex);
 
 
 		IndexType indexType = IT_16BIT;
 		IndexType indexType = IT_16BIT;
 		if (index == ScriptIndexType::Index32)
 		if (index == ScriptIndexType::Index32)

+ 26 - 26
SBansheeEngine/Source/BsScriptMeshData.cpp

@@ -15,84 +15,84 @@ namespace BansheeEngine
 	template<int Semantic>
 	template<int Semantic>
 	struct TVertexDataAccessor
 	struct TVertexDataAccessor
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size) { }
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size) { }
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size) { }
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size) { }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::Position >
 	struct TVertexDataAccessor < (int)VertexLayout::Position >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getPositions((Vector3*)buffer, size); }
 		{ meshData->getPositions((Vector3*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setPositions((Vector3*)buffer, size); }
 		{ meshData->setPositions((Vector3*)buffer, size); }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::Normal >
 	struct TVertexDataAccessor < (int)VertexLayout::Normal >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getNormals((Vector3*)buffer, size); }
 		{ meshData->getNormals((Vector3*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setNormals((Vector3*)buffer, size); }
 		{ meshData->setNormals((Vector3*)buffer, size); }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::Tangent >
 	struct TVertexDataAccessor < (int)VertexLayout::Tangent >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getTangents((Vector4*)buffer, size); }
 		{ meshData->getTangents((Vector4*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setTangents((Vector4*)buffer, size); }
 		{ meshData->setTangents((Vector4*)buffer, size); }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::Color >
 	struct TVertexDataAccessor < (int)VertexLayout::Color >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getColors((Color*)buffer, size); }
 		{ meshData->getColors((Color*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setColors((Color*)buffer, size); }
 		{ meshData->setColors((Color*)buffer, size); }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::UV0 >
 	struct TVertexDataAccessor < (int)VertexLayout::UV0 >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getUV0((Vector2*)buffer, size); }
 		{ meshData->getUV0((Vector2*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setUV0((Vector2*)buffer, size); }
 		{ meshData->setUV0((Vector2*)buffer, size); }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::UV1 >
 	struct TVertexDataAccessor < (int)VertexLayout::UV1 >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getUV1((Vector2*)buffer, size); }
 		{ meshData->getUV1((Vector2*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setUV1((Vector2*)buffer, size); }
 		{ meshData->setUV1((Vector2*)buffer, size); }
 	};
 	};
 
 
 	template<>
 	template<>
 	struct TVertexDataAccessor < (int)VertexLayout::BoneWeights >
 	struct TVertexDataAccessor < (int)VertexLayout::BoneWeights >
 	{
 	{
-		static void get(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void get(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->getBoneWeights((BoneWeight*)buffer, size); }
 		{ meshData->getBoneWeights((BoneWeight*)buffer, size); }
 
 
-		static void set(const DefaultMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
+		static void set(const RendererMeshDataPtr& meshData, UINT8* buffer, UINT32 size)
 		{ meshData->setBoneWeights((BoneWeight*)buffer, size); }
 		{ meshData->setBoneWeights((BoneWeight*)buffer, size); }
 	};
 	};
 
 
 	template<int Semantic, class TNative, class TScript>
 	template<int Semantic, class TNative, class TScript>
 	MonoArray* getVertexDataArray(ScriptMeshData* scriptMeshData)
 	MonoArray* getVertexDataArray(ScriptMeshData* scriptMeshData)
 	{
 	{
-		DefaultMeshDataPtr meshData = scriptMeshData->getInternalValue();
+		RendererMeshDataPtr meshData = scriptMeshData->getInternalValue();
 		UINT32 numElements = meshData->getData()->getNumVertices();
 		UINT32 numElements = meshData->getData()->getNumVertices();
 
 
 		ScriptArray outArray = ScriptArray::create<TScript>(numElements);
 		ScriptArray outArray = ScriptArray::create<TScript>(numElements);
@@ -107,7 +107,7 @@ namespace BansheeEngine
 		if (array == nullptr)
 		if (array == nullptr)
 			return;
 			return;
 
 
-		DefaultMeshDataPtr meshData = scriptMeshData->getInternalValue();
+		RendererMeshDataPtr meshData = scriptMeshData->getInternalValue();
 		UINT32 numElements = meshData->getData()->getNumVertices();
 		UINT32 numElements = meshData->getData()->getNumVertices();
 
 
 		ScriptArray inArray(array);
 		ScriptArray inArray(array);
@@ -148,12 +148,12 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_GetIndexCount", &ScriptMeshData::internal_GetIndexCount);
 		metaData.scriptClass->addInternalCall("Internal_GetIndexCount", &ScriptMeshData::internal_GetIndexCount);
 	}
 	}
 
 
-	void ScriptMeshData::initialize(const DefaultMeshDataPtr& meshData)
+	void ScriptMeshData::initialize(const RendererMeshDataPtr& meshData)
 	{
 	{
 		mMeshData = meshData;
 		mMeshData = meshData;
 	}
 	}
 
 
-	MonoObject* ScriptMeshData::create(const DefaultMeshDataPtr& meshData)
+	MonoObject* ScriptMeshData::create(const RendererMeshDataPtr& meshData)
 	{
 	{
 		MonoObject* meshDataObj = metaData.scriptClass->createInstance();
 		MonoObject* meshDataObj = metaData.scriptClass->createInstance();
 
 
@@ -167,7 +167,7 @@ namespace BansheeEngine
 	{
 	{
 		MonoObject* meshDataObj = metaData.scriptClass->createInstance();
 		MonoObject* meshDataObj = metaData.scriptClass->createInstance();
 
 
-		DefaultMeshDataPtr defaultMeshData = DefaultMeshData::create(meshData);
+		RendererMeshDataPtr defaultMeshData = RendererMeshData::create(meshData);
 		ScriptMeshData* scriptMeshData = ScriptMeshData::toNative(meshDataObj);
 		ScriptMeshData* scriptMeshData = ScriptMeshData::toNative(meshDataObj);
 		scriptMeshData->initialize(defaultMeshData);
 		scriptMeshData->initialize(defaultMeshData);
 
 
@@ -181,7 +181,7 @@ namespace BansheeEngine
 		if (index == ScriptIndexType::Index32)
 		if (index == ScriptIndexType::Index32)
 			indexType = IT_32BIT;
 			indexType = IT_32BIT;
 
 
-		DefaultMeshDataPtr meshData = DefaultMeshData::create(numVertices, numIndices, vertex, indexType);
+		RendererMeshDataPtr meshData = RendererMeshData::create(numVertices, numIndices, vertex, indexType);
 
 
 		ScriptMeshData* scriptMeshData = new (bs_alloc<ScriptMeshData>()) ScriptMeshData(instance);
 		ScriptMeshData* scriptMeshData = new (bs_alloc<ScriptMeshData>()) ScriptMeshData(instance);
 		scriptMeshData->initialize(meshData);
 		scriptMeshData->initialize(meshData);
@@ -259,7 +259,7 @@ namespace BansheeEngine
 
 
 	MonoArray* ScriptMeshData::internal_GetIndices(ScriptMeshData* thisPtr)
 	MonoArray* ScriptMeshData::internal_GetIndices(ScriptMeshData* thisPtr)
 	{
 	{
-		DefaultMeshDataPtr meshData = thisPtr->getInternalValue();
+		RendererMeshDataPtr meshData = thisPtr->getInternalValue();
 		UINT32 numElements = meshData->getData()->getNumIndices();
 		UINT32 numElements = meshData->getData()->getNumIndices();
 
 
 		ScriptArray outArray = ScriptArray::create<UINT32>(numElements);
 		ScriptArray outArray = ScriptArray::create<UINT32>(numElements);
@@ -273,7 +273,7 @@ namespace BansheeEngine
 		if (value == nullptr)
 		if (value == nullptr)
 			return;
 			return;
 
 
-		DefaultMeshDataPtr meshData = thisPtr->getInternalValue();
+		RendererMeshDataPtr meshData = thisPtr->getInternalValue();
 		UINT32 numElements = meshData->getData()->getNumIndices();
 		UINT32 numElements = meshData->getData()->getNumIndices();
 
 
 		ScriptArray inArray(value);
 		ScriptArray inArray(value);
@@ -282,14 +282,14 @@ namespace BansheeEngine
 
 
 	int ScriptMeshData::internal_GetVertexCount(ScriptMeshData* thisPtr)
 	int ScriptMeshData::internal_GetVertexCount(ScriptMeshData* thisPtr)
 	{
 	{
-		DefaultMeshDataPtr meshData = thisPtr->getInternalValue();
+		RendererMeshDataPtr meshData = thisPtr->getInternalValue();
 
 
 		return (int)meshData->getData()->getNumVertices();
 		return (int)meshData->getData()->getNumVertices();
 	}
 	}
 
 
 	int ScriptMeshData::internal_GetIndexCount(ScriptMeshData* thisPtr)
 	int ScriptMeshData::internal_GetIndexCount(ScriptMeshData* thisPtr)
 	{
 	{
-		DefaultMeshDataPtr meshData = thisPtr->getInternalValue();
+		RendererMeshDataPtr meshData = thisPtr->getInternalValue();
 
 
 		return (int)meshData->getData()->getNumIndices();
 		return (int)meshData->getData()->getNumIndices();
 	}
 	}

+ 61 - 5
TODOExperimentation.txt

@@ -1,6 +1,62 @@
 -------------------------
 -------------------------
-FBX
-Next:
- - DefaultMeshData is defined in BansheeEngine but FBXImporter only includes Banshee Core
-  - Therefore I am not using it in FBXImporter but I should
- 
+Study shadow rendering implementations
+
+Add basic light type components and their core thread representations
+ - Directional, Point, Spot light
+ - Luminous flux - intensity
+ - Color
+ - Directional - direction
+ - Spot - angle, direction, position
+ - Point - range (or derive that from flux?), position
+
+Load up and set up a test-bed with Ribek's scene
+
+Create a basic GBuffer - albedo, normal, depth
+ - Using HDR formats where needed
+
+Implement deferred rendering (just basic lambert shading for now, only point light)
+ - Then convert to tiled rendering
+
+-------------
+
+Implement gamma correct rendering, HDR, tone mapping
+ - Will likely need a simple framework for rendering full-screen effects
+   (e.g. I will need to downsample scene to determine brightness here, but will
+    also need that framework for all post-processing)
+
+-------------
+
+Implement shadows
+ - Start with hard shadows
+ - Move to PCF soft shadows (see if there's anything better)
+ - Then cascaded maps
+
+-------------
+
+Later: 
+ - Finish up all light types
+ - Reflection probes
+ - Proper PBR materials with reflection
+ - Post-processing system - FXAA, SSAO, Color correction, Depth of field (Bokeh)
+ - Forward rendering for transparent objects
+
+-----------------
+
+SECOND STAGE(S)
+ - Occlusion
+ - GI
+ - Volumetric lighting
+ - SSR
+ - Depth pre-pass
+ - HDR skybox, skylight stuff
+
+-----------------
+
+THIRD STAGE(S)
+ - Skin & vegetation shaders
+ - Tesselation/displacement/parallax
+ - Water
+ - Fog
+ - Motion blur
+ - Per object shadows
+ - Extend camera with shutter speed (motion blur), aperture size and focal distance (depth of field), exposure (HDR)