Class ChunksGridLayer
Container for data related to Terrain Chunks Grid. Chunk visibility, Chunk Metrics per chunk, not per cell.
Inherited Members
Namespace: Fwt.HexTerrains.Data
Assembly: fwt.hexterrains.dll
Syntax
public class ChunksGridLayer : HexTerrainLayer, IComponentData, IQueryTypeParameter, IDisposable
Fields
CameraPlanes
Array of camera planes that make a camera frustum
Declaration
protected Plane[] CameraPlanes
Field Value
| Type | Description |
|---|---|
| Plane[] |
ChunkMetrics
Chunk visibility data layer. Contains visibility for each chunk.
Declaration
public ChunkMetricsDataLayer ChunkMetrics
Field Value
| Type | Description |
|---|---|
| ChunkMetricsDataLayer |
ChunkVisibility
Chunk metrics data layer. Contains metrics for each chunk.
Declaration
public ChunkVisibilityDataLayer ChunkVisibility
Field Value
| Type | Description |
|---|---|
| ChunkVisibilityDataLayer |
VisibleChunks
Declaration
public NativeParallelHashSetDataLayer<int> VisibleChunks
Field Value
| Type | Description |
|---|---|
| NativeParallelHashSetDataLayer<int> |
_cachedViewport
Declaration
protected CameraViewPortData _cachedViewport
Field Value
| Type | Description |
|---|---|
| CameraViewPortData |
_cameraFrustum
Declaration
protected FixedArray8<Plane> _cameraFrustum
Field Value
| Type | Description |
|---|---|
| FixedArray8<Plane> |
Properties
TerrainMetrics
Terrain Metrics (Cells count, chunks count, cell size, chunk size, etc.)
Declaration
public HexTerrainMetrics TerrainMetrics { get; protected set; }
Property Value
| Type | Description |
|---|---|
| HexTerrainMetrics |
ViewportData
Cached camera values. Used to avoid recalculations of the every frame
Declaration
public VersionValue<CameraViewPortData> ViewportData { get; protected set; }
Property Value
| Type | Description |
|---|---|
| VersionValue<CameraViewPortData> |
Methods
CalculateChunksVisibility(HexTerrainSettings, Camera, JobHandle)
Declaration
public virtual JobHandle CalculateChunksVisibility(HexTerrainSettings terrainSettings, Camera camera, JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | terrainSettings | |
| Camera | camera | |
| JobHandle | dependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
Cleanup()
Cleans up the chunks grid data on Cleanup frame stage. Usually this clears the dirty flags.
Declaration
public override void Cleanup()
Overrides
CleanupAsync(JobHandle)
Async version of Cleanup() Cleanup() Difference between regular Cleanup() is that it schedules jobs that clean up data layers, so you don't have to wait for the results and can continue working. Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.
Declaration
public override JobHandle CleanupAsync(JobHandle dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| JobHandle | dependency |
Returns
| Type | Description |
|---|---|
| JobHandle |
Overrides
CompleteAllJobs()
Completes all jobs (read and write) related to the chunks grid.
Declaration
public override void CompleteAllJobs()
Overrides
Dispose()
Disposes all allocated native memory.
Declaration
public override void Dispose()
Overrides
Init(HexTerrainSettings)
Initializes/Reinitializes the ChunksGridLayer with the provided settings.
Declaration
public override void Init(HexTerrainSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | settings | terrain settings used to intialize the chunks grid |
Overrides
RecalcChunkMetrics()
Recalculates the chunk metrics for all chunks.
Declaration
public virtual void RecalcChunkMetrics()
SetAllChunksVisible(bool)
Declaration
public virtual void SetAllChunksVisible(bool isVisible)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isVisible |
SetAllDirty(bool)
Sets the dirty flag for all chunks in the grid.
Declaration
public override void SetAllDirty(bool isDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isDirty | the dirty flag to set for all chunks |
Overrides
SetViewportData(CameraViewPortData)
Sets the viewport data. This is used to cache the camera data (position, rotation, scale, size, etc.) to calculate which chunks are visible and where are they visible in case the terrain's edges are connected.
Declaration
public virtual void SetViewportData(CameraViewPortData viewportData)
Parameters
| Type | Name | Description |
|---|---|---|
| CameraViewPortData | viewportData | new viewport data |