12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <Atom/Feature/CoreLights/SimplePointLightFeatureProcessorInterface.h>
- #include <Atom/RPI.Public/Scene.h>
- #include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
- #include <CoreLights/SimplePointLightDelegate.h>
- namespace AZ::Render
- {
- SimplePointLightDelegate::SimplePointLightDelegate(EntityId entityId, bool isVisible)
- : LightDelegateBase<SimplePointLightFeatureProcessorInterface>(entityId, isVisible)
- {
- InitBase(entityId);
- if (GetLightHandle().IsValid())
- {
- GetFeatureProcessor()->SetPosition(GetLightHandle(), GetTransform().GetTranslation());
- }
- }
- float SimplePointLightDelegate::CalculateAttenuationRadius(float lightThreshold) const
- {
- // Calculate the radius at which the irradiance will be equal to cutoffIntensity.
- const float intensity = GetPhotometricValue().GetCombinedIntensity(PhotometricUnit::Lumen);
- return Sqrt(intensity / lightThreshold);
- }
- float SimplePointLightDelegate::GetSurfaceArea() const
- {
- return 0.0f;
- }
- void SimplePointLightDelegate::HandleShapeChanged()
- {
- if (GetLightHandle().IsValid())
- {
- GetFeatureProcessor()->SetPosition(GetLightHandle(), GetTransform().GetTranslation());
- }
- }
- void SimplePointLightDelegate::DrawDebugDisplay(
- const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const
- {
- if (isSelected)
- {
- debugDisplay.SetColor(color);
- // Draw a sphere for the attenuation radius
- debugDisplay.DrawWireSphere(transform.GetTranslation(), GetConfig()->m_attenuationRadius);
- }
- }
- void SimplePointLightDelegate::SetAffectsGI(bool affectsGI)
- {
- if (GetLightHandle().IsValid())
- {
- GetFeatureProcessor()->SetAffectsGI(GetLightHandle(), affectsGI);
- }
- }
- void SimplePointLightDelegate::SetAffectsGIFactor(float affectsGIFactor)
- {
- if (GetLightHandle().IsValid())
- {
- GetFeatureProcessor()->SetAffectsGIFactor(GetLightHandle(), affectsGIFactor);
- }
- }
- Aabb SimplePointLightDelegate::GetLocalVisualizationBounds() const
- {
- return Aabb::CreateCenterRadius(Vector3::CreateZero(), GetConfig()->m_attenuationRadius);
- }
- } // namespace AZ::Render
|