//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #include "Mesh/BsTransientMesh.h" #include "RenderAPI/BsVertexData.h" #include "Math/BsBounds.h" #include "Mesh/BsMeshHeap.h" #include "Allocators/BsFrameAlloc.h" namespace bs { TransientMesh::TransientMesh(const SPtr& parentHeap, UINT32 id, UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp) :MeshBase(numVertices, numIndices, drawOp), mIsDestroyed(false), mParentHeap(parentHeap), mId(id) { } TransientMesh::~TransientMesh() { if (!mIsDestroyed) { SPtr meshPtr = std::static_pointer_cast(getThisPtr()); mParentHeap->dealloc(meshPtr); } } SPtr TransientMesh::getCore() const { return std::static_pointer_cast(mCoreSpecific); } SPtr TransientMesh::createCore() const { ct::TransientMesh* core = new (bs_alloc()) ct::TransientMesh( mParentHeap->getCore(), mId, mProperties.mNumVertices, mProperties.mNumIndices, mProperties.mSubMeshes); SPtr meshCore = bs_shared_ptr(core); meshCore->_setThisPtr(meshCore); return meshCore; } namespace ct { TransientMesh::TransientMesh(const SPtr& parentHeap, UINT32 id, UINT32 numVertices, UINT32 numIndices, const Vector& subMeshes) :MeshBase(numVertices, numIndices, subMeshes), mParentHeap(parentHeap), mId(id) { } SPtr TransientMesh::getVertexData() const { return mParentHeap->getVertexData(); } SPtr TransientMesh::getIndexBuffer() const { return mParentHeap->getIndexBuffer(); } UINT32 TransientMesh::getVertexOffset() const { return mParentHeap->getVertexOffset(mId); } UINT32 TransientMesh::getIndexOffset() const { return mParentHeap->getIndexOffset(mId); } SPtr TransientMesh::getVertexDesc() const { return mParentHeap->getVertexDesc(); } void TransientMesh::_notifyUsedOnGPU() { mParentHeap->notifyUsedOnGPU(mId); } } }