EditorShapeWeightModifierComponent.cpp 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <PostProcess/ShapeWeightModifier/EditorShapeWeightModifierComponent.h>
  9. #include <AtomLyIntegration/CommonFeatures/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentConstants.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorShapeWeightModifierComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorShapeWeightModifierComponent, BaseClass>()
  20. ->Version(1);
  21. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  22. {
  23. editContext->Class<EditorShapeWeightModifierComponent>(
  24. "PostFX Shape Weight Modifier", "Modifies PostFX override factor based on proximity of an influencer against this entity's bounding sphere")
  25. ->ClassElement(Edit::ClassElements::EditorData, "")
  26. ->Attribute(Edit::Attributes::Category, "Graphics/PostFX")
  27. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg")
  28. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg")
  29. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  30. ->Attribute(Edit::Attributes::AutoExpand, true)
  31. ->Attribute(Edit::Attributes::HelpPageURL, "https://www.o3de.org/docs/user-guide/components/reference/atom/postfx-shape-weight-modifier/")
  32. ;
  33. editContext->Class<ShapeWeightModifierComponentController>("ShapeWeightModifierComponentController", "")
  34. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  35. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  36. ->DataElement(AZ::Edit::UIHandlers::Default, &ShapeWeightModifierComponentController::m_configuration, "Configuration", "")
  37. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  38. ;
  39. editContext->Class<ShapeWeightModifierComponentConfig>("ShapeWeightModifierComponentConfig", "")
  40. ->DataElement(AZ::Edit::UIHandlers::Slider,
  41. &ShapeWeightModifierComponentConfig::m_falloffDistance,
  42. "Fall-off Distance",
  43. "Distance from the shape to smoothly transition the PostFX.")
  44. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  45. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  46. ->Attribute(AZ::Edit::Attributes::Max, std::numeric_limits<float>::max())
  47. ->Attribute(AZ::Edit::Attributes::SoftMax, 100.0f);
  48. ;
  49. }
  50. }
  51. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  52. {
  53. behaviorContext->Class<EditorShapeWeightModifierComponent>()->RequestBus("PostFxWeightRequestBus");
  54. behaviorContext->ConstantProperty("EditorShapeWeightModifierComponentTypeId", BehaviorConstant(Uuid(EditorShapeWeightModifierComponentTypeId)))
  55. ->Attribute(AZ::Script::Attributes::Module, "render")
  56. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  57. }
  58. }
  59. EditorShapeWeightModifierComponent::EditorShapeWeightModifierComponent(const ShapeWeightModifierComponentConfig& config)
  60. : BaseClass(config)
  61. {
  62. }
  63. AZ::u32 EditorShapeWeightModifierComponent::OnConfigurationChanged()
  64. {
  65. return Edit::PropertyRefreshLevels::AttributesAndValues;
  66. }
  67. }
  68. }