CapsuleLightDelegate.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <CoreLights/LightDelegateBase.h>
  10. #include <AzCore/Component/TransformBus.h>
  11. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  12. #include <LmbrCentral/Shape/CapsuleShapeComponentBus.h>
  13. #include <LmbrCentral/Shape/ShapeComponentBus.h>
  14. #include <Atom/Feature/CoreLights/CapsuleLightFeatureProcessorInterface.h>
  15. namespace AZ::Render
  16. {
  17. //! Manages rendering a capsule light through the capsule light feature processor and communication with a capsule shape bus for the
  18. //! area light component.
  19. class CapsuleLightDelegate final : public LightDelegateBase<CapsuleLightFeatureProcessorInterface>
  20. {
  21. public:
  22. CapsuleLightDelegate(LmbrCentral::CapsuleShapeComponentRequests* shapeBus, EntityId entityId, bool isVisible);
  23. // LightDelegateBase overrides...
  24. float GetSurfaceArea() const override;
  25. float GetEffectiveSolidAngle() const override;
  26. float CalculateAttenuationRadius(float lightThreshold) const override;
  27. void DrawDebugDisplay(
  28. const Transform& transform,
  29. const Color& color,
  30. AzFramework::DebugDisplayRequests& debugDisplay,
  31. bool isSelected) const override;
  32. void SetAffectsGI(bool affectsGI) override;
  33. void SetAffectsGIFactor(float affectsGIFactor) override;
  34. Aabb GetLocalVisualizationBounds() const override;
  35. private:
  36. // LightDelegateBase overrides...
  37. void HandleShapeChanged() override;
  38. // Gets the height of the capsule shape without caps
  39. float GetInteriorHeight() const;
  40. struct CapsuleVisualizationDimensions
  41. {
  42. float m_radius;
  43. float m_height;
  44. };
  45. CapsuleVisualizationDimensions CalculateCapsuleVisualizationDimensions() const;
  46. LmbrCentral::CapsuleShapeComponentRequests* m_capsuleShapeBus = nullptr;
  47. };
  48. } // namespace AZ::Render