Give Page Feedback | API

Chunk Managers - Overview

Chunk Managers are responsible for managing the lifecycle of Asset Chunks, as well as some Asset Chunk related logic.

When a World needs Asset Chunks for a World Cell, it goes to the Chunk Manager to get them. The Chunk Manager, in turn, will either pull the Asset Chunks from some sort of internal pool or (if they do not exist in the pool) ask the Chunk Streamer to stream in new Asset Chunks.

Conversely, when the World does not need the Asset Chunks for a World Cell any longer, it passes the Cell to the Chunk Manager so that it may decide what to do with them. This may involve pooling the Chunks to be reused later, or it may involve passing the Chunks to the Chunk Streamer so that the Streamer can remove/unload the Chunks from the scene.

In this way, the Chunk Manager is the provider for the World when it needs new Asset Chunks while also serving as the decision maker on what happens to Asset Chunks when they are no longer needed by the World.

In fact, the World actually never communicates with the Chunk Streamer directly. If new Asset Chunks need to be streamed in, or old Asset Chunks streamed out, those requests are made by the Chunk Manager. In this way, the Chunk Manager is the only point of contact for the World when it needs to get or remove Asset Chunks.

To Pool Or Not To Pool . . . That Is The Question

When Chunk Managers receive World Cells whose Asset Chunks are no longer needed, they have a decision to make. Should those Asset Chunks be kept around in the scene with the hope that they will soon be reused? Put another way, should the Asset Chunks be pooled?

Pooling can be very beneficial as it reduces the number of Asset Chunks that need to be created and destroyed, actions which typically produce garbage and/or have performance implications. The drawback, of course, is that pooling increases the memory used by your game, memory which may be needed for other systems.

You will need to weigh the memory cost against the performance boost and reduced garbage production in order to determine whether pooling should be used..

Fortunately, the World allows you to assign Chunk Manager's on a per World Grouping or per LOD basis, so you have a great deal of control over which Asset Chunks should use pooling and which should not.

Besides controlling whether Asset Chunks are pooled, Chunk Managers also control some Chunk Related logic. This logic currently covers getting and setting the position of Asset Chunks, as well as activating and deactivating them, though this logic may be expanded in the future if deemed necessary.

Having control over this logic allows you to create custom Chunk Manager's specifically designed to work with custom Asset Chunk types that aren't Game Object based.

Choosing A Chunk Manager

You have several options available to you when choosing a Chunk Manager. You can choose one of the three default Chunk Manager's, two of which provide pooling focused solutions, or if none of the default solutions work, you can create a Custom Chunk Manager or Custom Pooling Chunk Manager. All options have dedicated Sections with this Chapter, so get to work!