SpecularReflectionsComponentController.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <SpecularReflections/SpecularReflectionsComponentController.h>
  11. namespace AZ
  12. {
  13. namespace Render
  14. {
  15. void SpecularReflectionsComponentController::Reflect(ReflectContext* context)
  16. {
  17. SpecularReflectionsComponentConfig::Reflect(context);
  18. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  19. {
  20. serializeContext->Class<SpecularReflectionsComponentController>()
  21. ->Version(0)
  22. ->Field("Configuration", &SpecularReflectionsComponentController::m_configuration);
  23. }
  24. }
  25. void SpecularReflectionsComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  26. {
  27. provided.push_back(AZ_CRC("ReflectionsService", 0x1c061096));
  28. }
  29. void SpecularReflectionsComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  30. {
  31. incompatible.push_back(AZ_CRC("ReflectionsService", 0x1c061096));
  32. }
  33. void SpecularReflectionsComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  34. {
  35. AZ_UNUSED(required);
  36. }
  37. SpecularReflectionsComponentController::SpecularReflectionsComponentController(const SpecularReflectionsComponentConfig& config)
  38. : m_configuration(config)
  39. {
  40. }
  41. void SpecularReflectionsComponentController::Activate(EntityId entityId)
  42. {
  43. AZ::ApplicationTypeQuery appType;
  44. ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::QueryApplicationType, appType);
  45. if (appType.IsHeadless())
  46. {
  47. return;
  48. }
  49. m_featureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntity<SpecularReflectionsFeatureProcessorInterface>(entityId);
  50. OnConfigChanged();
  51. }
  52. void SpecularReflectionsComponentController::Deactivate()
  53. {
  54. }
  55. void SpecularReflectionsComponentController::SetConfiguration(const SpecularReflectionsComponentConfig& config)
  56. {
  57. m_configuration = config;
  58. OnConfigChanged();
  59. }
  60. const SpecularReflectionsComponentConfig& SpecularReflectionsComponentController::GetConfiguration() const
  61. {
  62. return m_configuration;
  63. }
  64. void SpecularReflectionsComponentController::OnConfigChanged()
  65. {
  66. m_featureProcessor->SetSSROptions(m_configuration.m_ssr.m_options);
  67. }
  68. } // namespace Render
  69. } // namespace AZ