3
0

WhiteBoxMeshAsset.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Asset/AssetManager.h>
  10. #include <AzCore/Asset/AssetTypeInfoBus.h>
  11. #include <WhiteBox/WhiteBoxToolApi.h>
  12. namespace WhiteBox
  13. {
  14. namespace Pipeline
  15. {
  16. //! Represents a white box mesh asset.
  17. //! This asset can be modified in memory by the white box tool.
  18. class WhiteBoxMeshAsset : public AZ::Data::AssetData
  19. {
  20. public:
  21. friend class WhiteBoxMeshAssetHandler;
  22. AZ_CLASS_ALLOCATOR(WhiteBoxMeshAsset, AZ::SystemAllocator);
  23. AZ_RTTI(WhiteBoxMeshAsset, "{6784304A-4ED6-42FD-A5C9-316265F071F2}", AZ::Data::AssetData);
  24. ~WhiteBoxMeshAsset()
  25. {
  26. ReleaseMemory();
  27. }
  28. void SetMesh(Api::WhiteBoxMeshPtr mesh)
  29. {
  30. m_mesh = AZStd::move(mesh);
  31. m_status = AssetStatus::Ready;
  32. }
  33. WhiteBoxMesh* GetMesh()
  34. {
  35. return m_mesh.get();
  36. }
  37. Api::WhiteBoxMeshPtr ReleaseMesh()
  38. {
  39. return AZStd::move(m_mesh);
  40. }
  41. void SetWhiteBoxData(Api::WhiteBoxMeshStream whiteBoxData)
  42. {
  43. m_whiteBoxData = AZStd::move(whiteBoxData);
  44. }
  45. const Api::WhiteBoxMeshStream& GetWhiteBoxData() const
  46. {
  47. return m_whiteBoxData;
  48. }
  49. void Serialize()
  50. {
  51. Api::WriteMesh(*m_mesh, m_whiteBoxData);
  52. }
  53. private:
  54. void ReleaseMemory()
  55. {
  56. m_mesh.reset();
  57. }
  58. Api::WhiteBoxMeshPtr m_mesh;
  59. Api::WhiteBoxMeshStream m_whiteBoxData; //! Data used for creating undo commands.
  60. };
  61. } // namespace Pipeline
  62. } // namespace WhiteBox