DiffuseGlobalIlluminationComponentController.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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("DiffuseGlobalIlluminationService", 0x11b9cbe1));
  28. }
  29. void DiffuseGlobalIlluminationComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  30. {
  31. incompatible.push_back(AZ_CRC("DiffuseGlobalIlluminationService", 0x11b9cbe1));
  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