UGroomComponent::TickComponent sets bResetSimulation = true every frame when !IsVisible(), causing NiagaraDataInterfaceHairStrands to trigger a full simulation reset via ForceReset each tick. This results in higher GPU cost than when the component is visible.
Key Code:
void UGroomComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
//Some Code
bResetSimulation |= SimulationSettings.SimulationSetup.bResetSimulation;
if (!IsVisible() || (GetOwner() && GetOwner()->IsHidden()))
{
bResetSimulation = true;
}
//Some Code
}
bool UNiagaraDataInterfaceHairStrands::PerInstanceTick(void* PerInstanceData, FNiagaraSystemInstance* SystemInstance, float InDeltaSeconds)
{
FNDIHairStrandsData* InstanceData = static_cast<FNDIHairStrandsData*>(PerInstanceData);
FNDIHairStrandsInfo InfoData;
ExtractDatasAndResources(SystemInstance, InfoData);
if (SourceComponent != nullptr)
{
InstanceData->ForceReset = SourceComponent->bResetSimulation || RequiresSimulationReset(SystemInstance, InstanceData->SkeletalMeshes);
if (InstanceData->ForceReset)
{
FNDIHairStrandsBuffer* LocalStrandsBuffer = InstanceData->HairStrandsBuffer;
ENQUEUE_RENDER_COMMAND(FNiagaraDIDestroyInstanceData) (
[LocalStrandsBuffer](FRHICommandListImmediate& CmdList)
{
if(LocalStrandsBuffer)
{
LocalStrandsBuffer->bShouldReset = true;
}
}
);
}
}
InstanceData->Update(this, InfoData, InDeltaSeconds);
return false;
}