BsTransientMesh.h 2.8 KB

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