World Partition, Getting the Level bounds

Hi!

We are using World Partition for our level streaming setup and have a system that binds to the OnLevelAdded callback. When that fires we want to gauge the bounds of the newly loaded level to determine whether this newly loaded level overlaps with an area of interest to initialize a particular state on its actors.

we are using the following snippet to get the bounds

if (InLevel->LevelBoundsActor.IsValid())
{
    LevelBounds = InLevel->LevelBoundsActor.Get()->GetComponentsBoundingBox();
}
else
{
    LevelBounds = ALevelBounds::CalculateLevelBounds(InLevel);
}

Ultimately it looks like world partition does not generate LevelBoundsActors for its cells automatically, so we see us falling back to CalculateLevelBounds, which can be very costly based on the amount of actors in the level.

Now for the question; It seems that the core of our issue is that we don’t have LevelBounds actors, generating these manually seems like the wrong approach to this problem as world partition is handling the splitting up of our game world.

Is there a better way with world partition to get the bounds for the loaded level cell if it does not generate the LevelBounds actor internally automatically? And if there is not, how could we best approach adding the generation of such an actor into the world partition system?

Thank you!

[Attachment Removed]

Hello!

The LevelBounds actor is leftovers from the World Composition system which is not maintained anymore. A few other systems, (HoudiniEngine, thumbnail renderer) do create it when needed but this actor is legacy at this point.

I don’t think it is a problem to create ALevelBounds and inject them into the WP cells. You could use a custom UWorldPartitionRuntimeCellTransformer and do it through its Transform method. The implementation would look like this:

void UCustomRuntimeCellTransformerISM::Transform(ULevel* InLevel)
{
	LevelBounds = NewObject<ALevelBounds>(InLevel);
	LevelBounds->UpdateLevelBoundsImmediately();
	Level->LevelBoundsActor = LevelBounds;
 
	return;
}

The “location” of the custom transformer in the stack (world properties) should not matter as the transformations should not affect the bounds of the cells. You could put it last just in case you have other customer transformers that do change the bounds.

Regards,

Martin

[Attachment Removed]