From a75b8eb6360748fe22faaf6543d5a45f0223bddc Mon Sep 17 00:00:00 2001 From: Ken Pruiksma Date: Wed, 7 Jul 2021 18:00:40 -0500 Subject: [PATCH 1/2] [LYN-3913] Fix conversion to unsupported photometric unit on light type change. When converting to a light type that doesn't support the currently used photometric unit, the editor component will convert the photometric unit to the universally supported lumen. Signed-off-by: Ken Pruiksma --- .../CoreLights/EditorAreaLightComponent.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp index 5dabd7317b..b9d63f6dc3 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp @@ -263,7 +263,23 @@ namespace AZ // Update the cached light type. m_lightType = m_controller.m_configuration.m_lightType; + + // Check to see if the current photometric type is supported by the light type. If not, convert to lumens before deactivating. + auto supportedPhotometricUnits = m_controller.m_configuration.GetValidPhotometricUnits(); + auto foundIt = AZStd::find_if( + supportedPhotometricUnits.begin(), + supportedPhotometricUnits.end(), + [&](const Edit::EnumConstant& entry) -> bool + { + return AZStd::RemoveEnum::type(m_controller.m_configuration.m_intensityMode) == entry.m_value; + } + ); + if (foundIt == supportedPhotometricUnits.end()) + { + m_controller.ConvertToIntensityMode(PhotometricUnit::Lumen); + } + // componets may be removed or added here, so deactivate now and reactivate the entity when everything is done shifting around. GetEntity()->Deactivate(); @@ -320,7 +336,7 @@ namespace AZ // Some light types don't require a shape, this is ok. break; } - + GetEntity()->Activate(); // Set more reasonable default values for certain shapes. @@ -333,7 +349,12 @@ namespace AZ LmbrCentral::DiskShapeComponentRequestBus::Event(GetEntityId(), &LmbrCentral::DiskShapeComponentRequests::SetRadius, 0.05f); break; } - + + if (foundIt == supportedPhotometricUnits.end()) + { + m_controller.ConvertToIntensityMode(PhotometricUnit::Lumen); + } + return true; } From 6c0264862e4cc588ff0fb9974a80238785925727 Mon Sep 17 00:00:00 2001 From: Ken Pruiksma Date: Wed, 7 Jul 2021 18:05:36 -0500 Subject: [PATCH 2/2] Removing unnecessary code Signed-off-by: Ken Pruiksma --- .../Code/Source/CoreLights/EditorAreaLightComponent.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp index b9d63f6dc3..81e87f3cb5 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp @@ -350,11 +350,6 @@ namespace AZ break; } - if (foundIt == supportedPhotometricUnits.end()) - { - m_controller.ConvertToIntensityMode(PhotometricUnit::Lumen); - } - return true; }