File: Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomComponent.cpp
Description
UGroomComponent::SetForcedLOD(-1) is intended to clear forced LOD and return to automatic LOD selection (Predicted/Immediate). However, it unconditionally calls SwitchSimulationLOD()
with CurrentLOD = -1, which is not a valid LOD index.
This causes two problems:
Problem 1: Unnecessary SwitchSimulationLOD call when already in auto mode
Problem 2: SwitchSimulationLOD called with -1 when transitioning from Forced to auto
Suggested Fix
After determining CurrLODSelectionType, add an early return when not setting a valid forced LOD:
CurrLODSelectionType = bNeedSimulationNeed ? EHairLODSelectionType::Predicted : EHairLODSelectionType::Immediate;
}
// If not setting a valid forced LOD, just reset state and let auto system handle the rest
if (CurrLODSelectionType != EHairLODSelectionType::Forced)
{
LODForcedIndex = CurrLODIndex;
LODSelectionType = CurrLODSelectionType;
return;
}
// Inform simulation about LOD switch.
SwitchSimulationLOD(PrevLODIndex, CurrLODIndex, CurrLODSelectionType);