BsTransientMesh.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsMeshBase.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Core thread portion of a transient mesh.
  8. *
  9. * @see Transient mesh
  10. *
  11. * @note Core thread.
  12. */
  13. class BS_CORE_EXPORT TransientMeshCore : public MeshCoreBase
  14. {
  15. public:
  16. TransientMeshCore(const SPtr<MeshHeapCore>& parentHeap, UINT32 id, UINT32 numVertices,
  17. UINT32 numIndices, const Vector<SubMesh>& subMeshes);
  18. /**
  19. * @copydoc MeshCoreBase::getVertexData
  20. */
  21. SPtr<VertexData> getVertexData() const override;
  22. /**
  23. * @copydoc MeshCoreBase::getIndexData
  24. */
  25. SPtr<IndexBufferCore> getIndexBuffer() const override;
  26. /**
  27. * @copydoc MeshCoreBase::getVertexDesc
  28. */
  29. SPtr<VertexDataDesc> getVertexDesc() const override;
  30. /**
  31. * @brief Returns the ID that uniquely identifies this mesh in the parent heap.
  32. */
  33. UINT32 getMeshHeapId() const { return mId; }
  34. /**
  35. * @copydoc MeshCoreBase::getVertexOffset
  36. */
  37. virtual UINT32 getVertexOffset() const override;
  38. /**
  39. * @copydoc MeshCoreBase::getIndexOffset
  40. */
  41. virtual UINT32 getIndexOffset() const override;
  42. /**
  43. * @copydoc MeshCoreBase::notifyUsedOnGPU
  44. */
  45. virtual void _notifyUsedOnGPU() override;
  46. protected:
  47. friend class TransientMesh;
  48. SPtr<MeshHeapCore> mParentHeap;
  49. UINT32 mId;
  50. };
  51. /**
  52. * @brief Represents a single mesh entry in the MeshHeap. This can be used as a normal mesh
  53. * but due to the nature of the mesh-heap it is not the type of mesh you should use
  54. * for storing static data.
  55. *
  56. * Transient meshes don't keep internal index/vertex buffers but instead use the ones
  57. * provided by their parent mesh heap.
  58. *
  59. * @see MeshHeap
  60. *
  61. * @note Sim thread.
  62. */
  63. class BS_CORE_EXPORT TransientMesh : public MeshBase
  64. {
  65. public:
  66. virtual ~TransientMesh();
  67. /**
  68. * @brief Retrieves a core implementation of a mesh usable only from the
  69. * core thread.
  70. */
  71. SPtr<TransientMeshCore> getCore() const;
  72. protected:
  73. friend class MeshHeap;
  74. /**
  75. * @brief Constructs a new transient mesh.
  76. *
  77. * @see MeshHeap::alloc
  78. */
  79. TransientMesh(const MeshHeapPtr& parentHeap, UINT32 id, UINT32 numVertices,
  80. UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
  81. /**
  82. * @brief Marks the mesh as destroyed so we know that we don't need to destroy it ourselves.
  83. */
  84. void markAsDestroyed() { mIsDestroyed = true; }
  85. /**
  86. * @copydoc RenderTarget::createCore
  87. */
  88. SPtr<CoreObjectCore> createCore() const override;
  89. protected:
  90. bool mIsDestroyed;
  91. MeshHeapPtr mParentHeap;
  92. UINT32 mId;
  93. };
  94. }