I want to be able to manually disable/enable rendering of different sections of a landscape at run-time.
if(landscape == nullptr)
{
return;
}
TArray<ULandscapeComponent *> comps = landscape->LandscapeComponents;
for (int32 i = 0; i < comps.Num(); ++i)
{
ULandscapeComponent* comp = comps[i];
bool on = rand() % 2 == 0;
comp->SetHiddenInGame(!on);
comp->SetVisibility(on);
}
This is just a test to figure out the functionality of it. It just gives the components a 50% chance to be rendered randomly.
Either and both of
comp->SetHiddenInGame(!on);
comp->SetVisibility(on);
those two lines work… kinda. When I run the game in the editor and run this code, nothing changes on the landscapes. Nothing at all, until I end the game. When I end the play and it goes back to the editor, the landscape updates with the new rendering options, and keeps the rendering options even when I re-enter the game in the editor. However, even in second pass, the in-game rendering doesn’t change. There are several things that I’ve tried to make the landscape rendering update:
comp->MarkRenderStateDirty();
comp->MarkRenderDynamicDataDirty();
comp->MarkRenderTransformDirty();
comp->RecreateRenderState_Concurrent();
None of those lines force the landscape rendering to update. Is there another way to force it to update? or is this just a wild goose-chase?