BsTransientMesh.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsMeshBase.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Represents a single mesh entry in the MeshHeap. This can be used as a normal mesh
  8. * but due to the nature of the mesh-heap it is not the type of mesh you should use
  9. * for storing static data.
  10. *
  11. * Transient meshes don't keep internal index/vertex buffers but instead use the ones
  12. * provided by their parent mesh heap.
  13. *
  14. * @see MeshHeap
  15. */
  16. class BS_CORE_EXPORT TransientMesh : public MeshBase
  17. {
  18. public:
  19. virtual ~TransientMesh();
  20. /**
  21. * @copydoc GpuResource::writeSubresource
  22. */
  23. virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer);
  24. /**
  25. * @copydoc GpuResource::readSubresource
  26. */
  27. virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data);
  28. /**
  29. * @copydoc MeshBase::getVertexData
  30. */
  31. std::shared_ptr<VertexData> _getVertexData() const;
  32. /**
  33. * @copydoc MeshBase::getIndexData
  34. */
  35. IndexBufferPtr _getIndexBuffer() const;
  36. /**
  37. * @brief Returns the ID that uniquely identifies this mesh in the parent heap.
  38. */
  39. UINT32 getMeshHeapId() const { return mId; }
  40. /**
  41. * @copydoc MeshBase::getVertexOffset
  42. */
  43. virtual UINT32 _getVertexOffset() const;
  44. /**
  45. * @copydoc MeshBase::getIndexOffset
  46. */
  47. virtual UINT32 _getIndexOffset() const;
  48. /**
  49. * @copydoc MeshBase::notifyUsedOnGPU
  50. */
  51. virtual void _notifyUsedOnGPU();
  52. /************************************************************************/
  53. /* CORE PROXY */
  54. /************************************************************************/
  55. /**
  56. * @copydoc MeshBase::_createProxy
  57. */
  58. MeshProxyPtr _createProxy(UINT32 subMeshIdx);
  59. protected:
  60. friend class MeshHeap;
  61. /**
  62. * @brief Constructs a new transient mesh.
  63. *
  64. * @see MeshHeap::alloc
  65. */
  66. TransientMesh(const MeshHeapPtr& parentHeap, UINT32 id, UINT32 numIndices,
  67. UINT32 numVertices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
  68. /**
  69. * @brief Marks the mesh as destroyed so we know that we don't need to destroy it ourselves.
  70. */
  71. void markAsDestroyed() { mIsDestroyed = true; }
  72. protected:
  73. bool mIsDestroyed;
  74. MeshHeapPtr mParentHeap;
  75. UINT32 mId;
  76. };
  77. }