EditorSystemComponent.h 2.8 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. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <AzFramework/Physics/Common/PhysicsEvents.h>
  11. #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
  12. #include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
  13. #include <IEditor.h>
  14. #include <PhysX/Debug/PhysXDebugInterface.h>
  15. namespace PhysXDebug
  16. {
  17. class EditorSystemComponent
  18. : public AzToolsFramework::Components::EditorComponentBase
  19. , protected AzToolsFramework::EditorEntityContextNotificationBus::Handler
  20. , public CrySystemEventBus::Handler
  21. , private AzToolsFramework::EditorEvents::Bus::Handler
  22. , private IEditorNotifyListener
  23. {
  24. public:
  25. AZ_COMPONENT(EditorSystemComponent, "{E6F88D74-5758-453E-8FE0-2FB5E5E53890}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  28. {
  29. provided.push_back(AZ_CRC_CE("PhysXDebugEditorService"));
  30. }
  31. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  32. {
  33. required.push_back(AZ_CRC_CE("PhysicsService"));
  34. }
  35. protected:
  36. // AZ::Component
  37. void Activate() override;
  38. void Deactivate() override;
  39. // CrySystemEvents
  40. void OnCrySystemShutdown(ISystem&) override;
  41. // AzToolsFramework::EditorEvents
  42. void NotifyRegisterViews() override;
  43. private:
  44. // EditorEntityContextNotificationBus interface implementation
  45. void OnStartPlayInEditorBegin() override;
  46. void OnStopPlayInEditor() override;
  47. // IEditorNotifyListener interface implementation
  48. void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
  49. /// Initially connect to the PhysX Visualization debugger based on the current PhysX configuration.
  50. void AutoConnectPVD();
  51. /// Register for Cry Editor events.
  52. void RegisterForEditorEvents();
  53. /// Unregister for Cry Editor events.
  54. void UnregisterForEditorEvents();
  55. void OnColliderProximityVisualizationChanged(const PhysX::Debug::ColliderProximityVisualization& visualizationData);
  56. PhysX::Debug::ColliderProximityVisualizationChangedEvent::Handler m_colliderProximityVisualizationChangedEventHandler;
  57. AZ::Vector3 m_cameraPositionCache = AZ::Vector3::CreateZero();
  58. void OnPvdConfigurationChanged(const PhysX::Debug::PvdConfiguration& config);
  59. PhysX::Debug::PvdConfigurationChangedEvent::Handler m_pvdConfigurationChangeHandler;
  60. };
  61. }