Class ChunkMeshLayerGroup
Entity component that holds a group of ChunkMeshLayer instances, providing functionality to create, initialize, and manage them.
Inheritance
Inherited Members
Namespace: Fwt.HexTerrains.ChunkMehes.Data
Assembly: fwt.hexterrains.dll
Syntax
public class ChunkMeshLayerGroup : HexTerrainLayerGroup<ChunkMeshLayer>, IDisposable, ISerializableTerrainLayer, IComponentData, IQueryTypeParameter
Methods
CalcCellMetrics(JobHandle)
Schedules the calculation of cell metrics for all layers, ensuring that the specified job dependency is respected.
Declaration
public virtual JobHandle CalcCellMetrics(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | A job handle representing the dependency that must be completed before cell metric calculations begin. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that can be used to ensure that the scheduled cell metric calculations are completed. If there are no layers, returns the original dependency. |
Remarks
This method iterates through all layers and schedules their cell metric calculations, combining their dependencies with the provided job handle. If the Layers collection is null, no additional jobs are scheduled.
CalcDirtyMeshSources(JobHandle)
Calculates and schedules jobs to update mesh sources for all dirty layers, combining their dependencies with the specified job handle.
Declaration
public virtual JobHandle CalcDirtyMeshSources(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | A job handle representing the dependency that must be completed before mesh source updates begin. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that represents the combined dependencies of all scheduled mesh source update jobs and the specified dependency. |
Remarks
If there are no layers to process, the method returns the input dependency unchanged. This method is intended for use in job-based update pipelines where mesh data may need to be recalculated or refreshed.
CalcMeshSources(ChunksGridLayer, JobHandle)
Calculates and schedules mesh source jobs for all visual chunk mesh layers in the current collection.
Declaration
public virtual JobHandle CalcMeshSources(ChunksGridLayer chunksGridLayer, JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| ChunksGridLayer | chunksGridLayer | The grid layer containing chunk data to be processed for mesh source generation. |
| JobHandle | dependency | A job handle representing the dependency that must be completed before mesh source jobs are scheduled. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that represents the combined dependencies of all scheduled mesh source jobs. If no layers are present, returns the input dependency. |
Remarks
This method iterates through all layers in the collection and schedules mesh source jobs for those that are visual chunk mesh layers. The returned job handle can be used to ensure that all mesh source jobs have completed before proceeding.
CreateChunkMeshes()
Creates the mesh representations for all chunk layers in the collection.
Declaration
public virtual void CreateChunkMeshes()
Remarks
This method iterates through each layer in the Layers collection and invokes mesh creation for layers that support chunk meshes. If Layers is null, the method performs no action. Override this method to customize mesh creation behavior for derived types.
CreateTerrainLayer<TInitArgs>(TInitArgs)
This function is called to create a new terrain layer of type TTerrainLayer. Default implementation uses an Activator to create a new instance of TTerrainLayer, expecting that the TTerrainLayer has a parameterless constructor. Override this function in your derived class to have a custom way of creating a terrain layer.
Declaration
public override ChunkMeshLayer CreateTerrainLayer<TInitArgs>(TInitArgs initArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| TInitArgs | initArgs | Initialization arguments for creating a layer |
Returns
| Type | Description |
|---|---|
| ChunkMeshLayer | Returns a created instance of the terrain layer of type (inherited from) TTerrainLayer |
Type Parameters
| Name | Description |
|---|---|
| TInitArgs | Init terrain layer arguments object that is used in create layer process. Default implementation ignores this parameter, but in your overrided implementation it may be needed |
Overrides
InitTerrainLayer<TInitArgs>(ChunkMeshLayer, HexTerrainSettings, TInitArgs)
Initializes the terrain layer with the specified settings and initialization arguments.
Declaration
public override void InitTerrainLayer<TInitArgs>(ChunkMeshLayer layer, HexTerrainSettings settings, TInitArgs initArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| ChunkMeshLayer | layer | nested terrain layer to be initialized with provided init args |
| HexTerrainSettings | settings | HexTerrainSettings of the terrain this layers list is attached to |
| TInitArgs | initArgs | Initialization arguments for provided nested terrain layer |
Type Parameters
| Name | Description |
|---|---|
| TInitArgs | Initialization arguments for a nested terrain layer |
Overrides
Render(ChunksGridLayer, HexTerrainViewMode, LocalToWorld, Camera)
Renders all visual chunk mesh layers using the specified parameters.
Declaration
public virtual void Render(ChunksGridLayer chunksGridLayer, HexTerrainViewMode viewMode, LocalToWorld terrainTransform, Camera camera)
Parameters
| Type | Name | Description |
|---|---|---|
| ChunksGridLayer | chunksGridLayer | ChunksGridLayer of the terrain |
| HexTerrainViewMode | viewMode | view mode in which to render the terrain (which render config to use is dependent on this value) |
| LocalToWorld | terrainTransform | transform of the terrain entity |
| Camera | camera | camera to render the chunk meshes for |
SyncData(JobHandle)
Synchronizes the data between different layers before the calculation of the CellMetrics..
Declaration
public virtual JobHandle SyncData(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency | A job handle representing the dependency that must be completed before synchronization begins. |
Returns
| Type | Description |
|---|---|
| JobHandle | A job handle that can be used to track the completion of the synchronization operation. If there are no layers to synchronize, returns the original dependency. |
Remarks
This method iterates through all layers and synchronizes their data based on the provided dependency. If a layer is null, it is skipped. The returned job handle can be used to ensure that all synchronization jobs have completed before proceeding.