ClothComponent.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/Component/Component.h>
  10. #include <AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h>
  11. #include <Components/ClothConfiguration.h>
  12. #include <Components/ClothComponentMesh/ClothComponentMesh.h>
  13. namespace NvCloth
  14. {
  15. //! Class for runtime Cloth Component.
  16. class ClothComponent
  17. : public AZ::Component
  18. , public AZ::Render::MeshComponentNotificationBus::Handler
  19. {
  20. public:
  21. AZ_COMPONENT(ClothComponent, "{AC9B8FA0-A6DA-4377-8219-25BA7E4A22E9}");
  22. static void Reflect(AZ::ReflectContext* context);
  23. ClothComponent() = default;
  24. explicit ClothComponent(const ClothConfiguration& config);
  25. AZ_DISABLE_COPY_MOVE(ClothComponent);
  26. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  27. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. const ClothComponentMesh* GetClothComponentMesh() const { return m_clothComponentMesh.get(); }
  30. protected:
  31. // AZ::Component overrides ...
  32. void Activate() override;
  33. void Deactivate() override;
  34. // AZ::Render::MeshComponentNotificationBus::Handler overrides ...
  35. void OnModelReady(const AZ::Data::Asset<AZ::RPI::ModelAsset>& modelAsset, const AZ::Data::Instance<AZ::RPI::Model>& model) override;
  36. void OnModelPreDestroy() override;
  37. private:
  38. ClothConfiguration m_config;
  39. AZStd::unique_ptr<ClothComponentMesh> m_clothComponentMesh;
  40. };
  41. } // namespace NvCloth