BsTransientMesh.h 2.3 KB

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