BsTransientMesh.h 2.5 KB

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