BsTransientMesh.h 2.8 KB

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