EditorOcclusionCullingPlaneComponent.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <OcclusionCullingPlane/EditorOcclusionCullingPlaneComponent.h>
  9. #include <AzFramework/StringFunc/StringFunc.h>
  10. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  11. #include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
  12. #include <AzToolsFramework/API/EditorAssetSystemAPI.h>
  13. #include <AzCore/Component/Entity.h>
  14. namespace AZ
  15. {
  16. namespace Render
  17. {
  18. void EditorOcclusionCullingPlaneComponent::Reflect(AZ::ReflectContext* context)
  19. {
  20. BaseClass::Reflect(context);
  21. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  22. {
  23. serializeContext->Class<EditorOcclusionCullingPlaneComponent, BaseClass>()
  24. ->Version(1, ConvertToEditorRenderComponentAdapter<1>)
  25. ;
  26. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  27. {
  28. editContext->Class<EditorOcclusionCullingPlaneComponent>(
  29. "Occlusion Culling Plane", "The OcclusionCullingPlane component is used to cull meshes that are inside the view frustum and behind the occlusion plane")
  30. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  31. ->Attribute(AZ::Edit::Attributes::Category, "Graphics/Occlusion")
  32. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg")
  33. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg")
  34. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  35. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  36. ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/occlusion-culling-plane/")
  37. ;
  38. editContext->Class<OcclusionCullingPlaneComponentController>(
  39. "OcclusionCullingPlaneComponentController", "")
  40. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  41. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  42. ->DataElement(AZ::Edit::UIHandlers::Default, &OcclusionCullingPlaneComponentController::m_configuration, "Configuration", "")
  43. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  44. ;
  45. editContext->Class<OcclusionCullingPlaneComponentConfig>(
  46. "OcclusionCullingPlaneComponentConfig", "")
  47. ->ClassElement(AZ::Edit::ClassElements::Group, "Settings")
  48. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  49. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &OcclusionCullingPlaneComponentConfig::m_showVisualization, "Show Visualization", "Show the occlusion culling plane visualization")
  50. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  51. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &OcclusionCullingPlaneComponentConfig::m_transparentVisualization, "Transparent Visualization", "Sets the occlusion culling plane visualization as transparent")
  52. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  53. ;
  54. }
  55. }
  56. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  57. {
  58. behaviorContext->ConstantProperty("EditorOcclusionCullingPlaneComponentTypeId", BehaviorConstant(Uuid(EditorOcclusionCullingPlaneComponentTypeId)))
  59. ->Attribute(AZ::Script::Attributes::Module, "render")
  60. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  61. }
  62. }
  63. EditorOcclusionCullingPlaneComponent::EditorOcclusionCullingPlaneComponent()
  64. {
  65. }
  66. EditorOcclusionCullingPlaneComponent::EditorOcclusionCullingPlaneComponent(const OcclusionCullingPlaneComponentConfig& config)
  67. : BaseClass(config)
  68. {
  69. }
  70. void EditorOcclusionCullingPlaneComponent::Activate()
  71. {
  72. BaseClass::Activate();
  73. AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
  74. }
  75. void EditorOcclusionCullingPlaneComponent::Deactivate()
  76. {
  77. AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
  78. BaseClass::Deactivate();
  79. }
  80. } // namespace Render
  81. } // namespace AZ