Foliage disappears when we load levels with Lighting Scenario option ON

Hello,

We have a disappearing problem here, with 4.17.1. When we call LoadStreamLevel function our Foliage (all trees and grass) just disappears. It happens in packaged build (Win64) or in Standalone mode.

One important note here. The problem comes only when we load levels with Lighting Scenario option ON.

However, in 4.16 all was fine.

,

We’re having exactly the same issue. After loading a level with Lighting Scenario option ON all the foliage objects dissapear, but just in a packaged game. It doesn’t happen if we are playing in the editor.
Any clue about it?
Our version is 4.19.

Just in case someone gets the same issue, We finally found a workaround to solve the problem.
We noticed that using the console command “foliage.RebuildFoliageTrees” brought our trees back, so we copied the code of this function to a class we used in our project and exposed it to use in blueprints, so we can call it after the LoadStreamLevel function. The only problem is that we have to call it after a Delay to ensure the level is fully loaded before our call.

You can find the code in the function RebuildFoliageTrees in .\Engine\Source\Runtime\Engine\Private\HierarchicalInstancedStaticMesh.cpp

static void RebuildFoliageTrees(const TArray<FString>& Args)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	UE_LOG(LogConsoleResponse, Display, TEXT("Rebuild Foliage Trees"));
#endif
	for (TObjectIterator<UHierarchicalInstancedStaticMeshComponent> It; It; ++It)
	{
		UHierarchicalInstancedStaticMeshComponent* Comp = *It;
		if (Comp && !Comp->IsTemplate() && !Comp->IsPendingKill())
		{
			Comp->BuildTreeIfOutdated(false, true);
			Comp->MarkRenderStateDirty();
		}
	}
}