3
0

SpecularReflectionsComponentController.cpp 2.6 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 <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. m_featureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntity<SpecularReflectionsFeatureProcessorInterface>(entityId);
  44. OnConfigChanged();
  45. }
  46. void SpecularReflectionsComponentController::Deactivate()
  47. {
  48. }
  49. void SpecularReflectionsComponentController::SetConfiguration(const SpecularReflectionsComponentConfig& config)
  50. {
  51. m_configuration = config;
  52. OnConfigChanged();
  53. }
  54. const SpecularReflectionsComponentConfig& SpecularReflectionsComponentController::GetConfiguration() const
  55. {
  56. return m_configuration;
  57. }
  58. void SpecularReflectionsComponentController::OnConfigChanged()
  59. {
  60. m_featureProcessor->SetSSROptions(m_configuration.m_ssr.m_options);
  61. }
  62. } // namespace Render
  63. } // namespace AZ