BsTransientMesh.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #pragma once
  5. #include "BsCorePrerequisites.h"
  6. #include "BsMeshBase.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Represents a single mesh entry in the MeshHeap. This can be used as a normal mesh
  11. * but due to the nature of the mesh-heap it is not the type of mesh you should use
  12. * for storing static data.
  13. *
  14. * Transient meshes don't keep internal index/vertex buffers but instead use the ones
  15. * provided by their parent mesh heap.
  16. *
  17. * @see MeshHeap
  18. */
  19. class BS_CORE_EXPORT TransientMesh : public MeshBase
  20. {
  21. public:
  22. virtual ~TransientMesh();
  23. /**
  24. * @copydoc GpuResource::writeSubresource
  25. */
  26. virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer);
  27. /**
  28. * @copydoc GpuResource::readSubresource
  29. */
  30. virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data);
  31. /**
  32. * @copydoc MeshBase::getVertexData
  33. */
  34. std::shared_ptr<VertexData> _getVertexData() const;
  35. /**
  36. * @copydoc MeshBase::getIndexData
  37. */
  38. IndexBufferPtr _getIndexBuffer() const;
  39. /**
  40. * @brief Returns the ID that uniquely identifies this mesh in the parent heap.
  41. */
  42. UINT32 getMeshHeapId() const { return mId; }
  43. /**
  44. * @copydoc MeshBase::getVertexOffset
  45. */
  46. virtual UINT32 _getVertexOffset() const;
  47. /**
  48. * @copydoc MeshBase::getIndexOffset
  49. */
  50. virtual UINT32 _getIndexOffset() const;
  51. /**
  52. * @copydoc MeshBase::notifyUsedOnGPU
  53. */
  54. virtual void _notifyUsedOnGPU();
  55. /************************************************************************/
  56. /* CORE PROXY */
  57. /************************************************************************/
  58. /**
  59. * @copydoc MeshBase::_createProxy
  60. */
  61. MeshProxyPtr _createProxy(UINT32 subMeshIdx);
  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. };
  80. }