DiffuseGlobalIlluminationComponentController.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #include <AzCore/RTTI/BehaviorContext.h>
  9. #include <Atom/RPI.Public/Scene.h>
  10. #include <Components/DiffuseGlobalIlluminationComponentController.h>
  11. namespace AZ
  12. {
  13. namespace Render
  14. {
  15. void DiffuseGlobalIlluminationComponentController::Reflect(ReflectContext* context)
  16. {
  17. DiffuseGlobalIlluminationComponentConfig::Reflect(context);
  18. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  19. {
  20. serializeContext->Class<DiffuseGlobalIlluminationComponentController>()
  21. ->Version(0)
  22. ->Field("Configuration", &DiffuseGlobalIlluminationComponentController::m_configuration);
  23. }
  24. }
  25. void DiffuseGlobalIlluminationComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  26. {
  27. provided.push_back(AZ_CRC_CE("DiffuseGlobalIlluminationService"));
  28. }
  29. void DiffuseGlobalIlluminationComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  30. {
  31. incompatible.push_back(AZ_CRC_CE("DiffuseGlobalIlluminationService"));
  32. }
  33. void DiffuseGlobalIlluminationComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  34. {
  35. AZ_UNUSED(required);
  36. }
  37. DiffuseGlobalIlluminationComponentController::DiffuseGlobalIlluminationComponentController(const DiffuseGlobalIlluminationComponentConfig& config)
  38. : m_configuration(config)
  39. {
  40. }
  41. void DiffuseGlobalIlluminationComponentController::Activate(EntityId entityId)
  42. {
  43. m_featureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntity<DiffuseGlobalIlluminationFeatureProcessorInterface>(entityId);
  44. OnConfigChanged();
  45. }
  46. void DiffuseGlobalIlluminationComponentController::Deactivate()
  47. {
  48. }
  49. void DiffuseGlobalIlluminationComponentController::SetConfiguration(const DiffuseGlobalIlluminationComponentConfig& config)
  50. {
  51. m_configuration = config;
  52. OnConfigChanged();
  53. }
  54. const DiffuseGlobalIlluminationComponentConfig& DiffuseGlobalIlluminationComponentController::GetConfiguration() const
  55. {
  56. return m_configuration;
  57. }
  58. void DiffuseGlobalIlluminationComponentController::OnConfigChanged()
  59. {
  60. m_featureProcessor->SetQualityLevel(m_configuration.m_qualityLevel);
  61. }
  62. } // namespace Render
  63. } // namespace AZ