2
0
Marko Pintera 12 жил өмнө
parent
commit
3d4e7b34b4

+ 3 - 3
BansheeEngine/Source/BsGUIManager.cpp

@@ -514,7 +514,7 @@ namespace BansheeEngine
 				{
 					UINT32 bufferNumQuads = group->numQuads + MESH_BUFFER_SIZE_INCREMENT;
 
-					renderData.cachedMeshes.push_back(Mesh::create(bufferNumQuads * 4, bufferNumQuads * 6, mVertexDesc, MeshBufferType::Dynamic));
+					renderData.cachedMeshes.push_back(Mesh::create(bufferNumQuads * 4, bufferNumQuads * 6, mVertexDesc, meshData, MeshBufferType::Dynamic));
 					renderData.meshBufferSizes.push_back(bufferNumQuads);
 				}
 				else
@@ -527,9 +527,9 @@ namespace BansheeEngine
 						renderData.cachedMeshes[groupIdx] = Mesh::create(bufferNumQuads * 4, bufferNumQuads * 6, mVertexDesc, MeshBufferType::Dynamic);
 						renderData.meshBufferSizes[groupIdx] = bufferNumQuads;
 					}
-				}
 
-				gMainCA().writeSubresource(renderData.cachedMeshes[groupIdx].getInternalPtr(), 0, meshData, true);
+					gMainCA().writeSubresource(renderData.cachedMeshes[groupIdx].getInternalPtr(), 0, meshData, true);
+				}
 
 				groupIdx++;
 			}

+ 6 - 0
CamelotCore/Include/CmMesh.h

@@ -90,6 +90,9 @@ namespace CamelotFramework
 		Mesh(UINT32 numVertices, UINT32 numIndices, 
 			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
 
+		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
+			MeshBufferType bufferType = MeshBufferType::Static, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
 		Mesh(const MeshDataPtr& initialMeshData, MeshBufferType bufferType = MeshBufferType::Static);
 
 		std::shared_ptr<VertexData> mVertexData;
@@ -134,6 +137,9 @@ namespace CamelotFramework
 		static HMesh create(UINT32 numVertices, UINT32 numIndices, 
 			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
 
+		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
+			MeshBufferType bufferType = MeshBufferType::Static, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
 		static HMesh create(const MeshDataPtr& initialMeshData, MeshBufferType bufferType = MeshBufferType::Static);
 	};
 }

+ 2 - 0
CamelotCore/Include/CmMeshManager.h

@@ -14,6 +14,8 @@ namespace CamelotFramework
 
 		MeshPtr create(UINT32 numVertices, UINT32 numIndices, 
 			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialData, 
+			MeshBufferType bufferType = MeshBufferType::Static, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
 		MeshPtr create(const MeshDataPtr& initialData, MeshBufferType bufferType = MeshBufferType::Static);
 		MeshPtr createEmpty();
 

+ 13 - 0
CamelotCore/Source/CmMesh.cpp

@@ -21,6 +21,12 @@ namespace CamelotFramework
 		mVertexDesc(vertexDesc), mBufferType(bufferType), mIndexType(indexType)
 	{ }
 
+	Mesh::Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, 
+		const MeshDataPtr& initialMeshData, MeshBufferType bufferType, IndexBuffer::IndexType indexType)
+		:mVertexData(nullptr), mIndexData(nullptr), mNumVertices(numVertices), mNumIndices(numIndices), 
+		mVertexDesc(vertexDesc), mBufferType(bufferType), mIndexType(indexType), mTempInitialMeshData(initialMeshData)
+	{ }
+
 	Mesh::Mesh(const MeshDataPtr& initialMeshData, MeshBufferType bufferType)
 		:mVertexData(nullptr), mIndexData(nullptr), mNumVertices(initialMeshData->getNumVertices()), 
 		mNumIndices(initialMeshData->getNumIndices()), mBufferType(bufferType), mIndexType(initialMeshData->getIndexType()),
@@ -347,6 +353,13 @@ namespace CamelotFramework
 		return static_resource_cast<Mesh>(Resource::_createResourceHandle(meshPtr));
 	}
 
+	HMesh Mesh::create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, MeshBufferType bufferType, IndexBuffer::IndexType indexType)
+	{
+		MeshPtr meshPtr = MeshManager::instance().create(numVertices, numIndices, vertexDesc, initialMeshData, bufferType, indexType);
+
+		return static_resource_cast<Mesh>(Resource::_createResourceHandle(meshPtr));
+	}
+
 	HMesh Mesh::create(const MeshDataPtr& initialMeshData, MeshBufferType bufferType)
 	{
 		MeshPtr meshPtr = MeshManager::instance().create(initialMeshData, bufferType);

+ 10 - 0
CamelotCore/Source/CmMeshManager.cpp

@@ -26,6 +26,16 @@ namespace CamelotFramework
 		return mesh;
 	}
 
+	MeshPtr MeshManager::create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialData, 
+		MeshBufferType bufferType, IndexBuffer::IndexType indexType)
+	{
+		MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh(numVertices, numIndices, vertexDesc, initialData, bufferType, indexType));
+		mesh->setThisPtr(mesh);
+		mesh->initialize();
+
+		return mesh;
+	}
+
 	MeshPtr MeshManager::create(const MeshDataPtr& initialData, MeshBufferType bufferType)
 	{
 		MeshPtr mesh = cm_core_ptr<Mesh, PoolAlloc>(new (cm_alloc<Mesh, PoolAlloc>()) Mesh(initialData, bufferType));