From e37b3989bedc1b4c3beec5bdd8268a9ff38fb624 Mon Sep 17 00:00:00 2001 From: pruiksma Date: Mon, 10 May 2021 15:31:33 -0500 Subject: [PATCH] ATOM-15515 Fixing nullptr reference in OnShapeChanged() when visibility is turned back on for shapeless punctual light types. --- .../Code/Source/CoreLights/LightDelegateBase.inl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/LightDelegateBase.inl b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/LightDelegateBase.inl index 406df42547..c255f02400 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/LightDelegateBase.inl +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/LightDelegateBase.inl @@ -101,6 +101,7 @@ namespace AZ template void LightDelegateBase::OnShapeChanged(ShapeChangeReasons changeReason) { + AZ_Assert(m_shapeBus, "OnShapeChanged called without a shape bus present."); if (changeReason == ShapeChangeReasons::TransformChanged) { AZ::Aabb aabb; // unused, but required for GetTransformAndLocalBounds() @@ -133,7 +134,11 @@ namespace AZ { // now visible, acquire light handle and update values. m_lightHandle = m_featureProcessor->AcquireLight(); - OnShapeChanged(ShapeChangeReasons::TransformChanged); + if (m_shapeBus) + { + // For lights that get their transform from the shape bus, force an OnShapeChanged to update the transform. + OnShapeChanged(ShapeChangeReasons::TransformChanged); + } } }