Fabric.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <NvCloth/Types.h>
  10. #include <System/NvTypes.h>
  11. namespace NvCloth
  12. {
  13. //! Fabric objects are the instances of FabricCookedData.
  14. //! There will be only one Fabric created per FabricCookedData,
  15. //! hold by SystemComponent and identified by FabricId.
  16. //!
  17. //! It has a counter of how many Cloth instances have been created using this fabric,
  18. //! the moment the counter is zero (when the last cloth using this fabric has been destroyed)
  19. //! th fabric will be automatically destroyed.
  20. class Fabric
  21. {
  22. public:
  23. Fabric(
  24. const FabricCookedData& cookedData,
  25. NvFabricUniquePtr nvFabric)
  26. : m_id(cookedData.m_id)
  27. , m_nvFabric(AZStd::move(nvFabric))
  28. , m_cookedData(cookedData)
  29. {
  30. }
  31. //! Returns the list of phase types (horizontal, vertical, bending or shearing)
  32. //! created for the fabric when it was cooked.
  33. const AZStd::vector<int32_t>& GetPhaseTypes() const
  34. {
  35. return m_cookedData.m_internalData.m_phaseTypes;
  36. }
  37. //! Fabric unique id.
  38. //! @note It is the same id from its FabricCookedData.
  39. FabricId m_id;
  40. //! NvCloth fabric object.
  41. NvFabricUniquePtr m_nvFabric;
  42. //! Fabric cooked data used to construct this fabric.
  43. FabricCookedData m_cookedData;
  44. //! Counter of Cloth instances created with this fabric.
  45. int m_numClothsUsingFabric = 0;
  46. };
  47. } // namespace NvCloth