BsTransientMesh.h 2.3 KB

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