EditorMixedGradientComponent.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 "EditorMixedGradientComponent.h"
  9. namespace GradientSignal
  10. {
  11. void EditorMixedGradientComponent::Reflect(AZ::ReflectContext* context)
  12. {
  13. EditorGradientComponentBase::ReflectSubClass<EditorMixedGradientComponent, BaseClassType>(context);
  14. }
  15. void EditorMixedGradientComponent::Init()
  16. {
  17. ForceOneEntry();
  18. BaseClassType::Init();
  19. }
  20. void EditorMixedGradientComponent::Activate()
  21. {
  22. ForceOneEntry();
  23. BaseClassType::Activate();
  24. }
  25. AZ::u32 EditorMixedGradientComponent::ConfigurationChanged()
  26. {
  27. ForceOneEntry();
  28. SetSamplerOwnerEntity(m_configuration, GetEntityId());
  29. return EditorGradientComponentBase::ConfigurationChanged();
  30. }
  31. void EditorMixedGradientComponent::ForceOneEntry()
  32. {
  33. if (m_configuration.m_layers.empty())
  34. {
  35. m_configuration.m_layers.emplace_back();
  36. m_configuration.m_layers.front().m_operation = MixedGradientLayer::MixingOperation::Initialize;
  37. SetDirty();
  38. }
  39. }
  40. }