TerrainWorldRendererComponent.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <TerrainRenderer/TerrainFeatureProcessor.h>
  11. namespace LmbrCentral
  12. {
  13. template<typename, typename>
  14. class EditorWrappedComponentBase;
  15. }
  16. namespace AZ::RPI
  17. {
  18. class Scene;
  19. }
  20. namespace Terrain
  21. {
  22. struct TerrainWorldRendererConfig final
  23. : public AZ::ComponentConfig
  24. {
  25. AZ_CLASS_ALLOCATOR(TerrainWorldRendererConfig, AZ::SystemAllocator);
  26. AZ_RTTI(TerrainWorldRendererConfig, "{08C5863C-092D-4A69-8226-4978E4F6E343}", AZ::ComponentConfig);
  27. static void Reflect(AZ::ReflectContext* context);
  28. DetailMaterialConfiguration m_detailMaterialConfig;
  29. MeshConfiguration m_meshConfig;
  30. ClipmapConfiguration m_clipmapConfig;
  31. };
  32. class TerrainWorldRendererComponent
  33. : public AZ::Component
  34. {
  35. public:
  36. template<typename, typename>
  37. friend class LmbrCentral::EditorWrappedComponentBase;
  38. AZ_COMPONENT(TerrainWorldRendererComponent, "{3B0DB71E-5944-437C-8C88-70F8B405BFC7}");
  39. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  40. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  41. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  42. static void Reflect(AZ::ReflectContext* context);
  43. TerrainWorldRendererComponent(const TerrainWorldRendererConfig& configuration);
  44. TerrainWorldRendererComponent() = default;
  45. ~TerrainWorldRendererComponent() override;
  46. //////////////////////////////////////////////////////////////////////////
  47. // AZ::Component interface implementation
  48. void Activate() override;
  49. void Deactivate() override;
  50. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  51. bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
  52. protected:
  53. AZ::RPI::Scene* GetScene() const;
  54. private:
  55. TerrainWorldRendererConfig m_configuration;
  56. bool m_terrainRendererActive{ false };
  57. TerrainFeatureProcessor* m_terrainFeatureProcessor{ nullptr };
  58. };
  59. }