Class CellObjectLayer
Terrain layer that contains a visual object per cell.
Renders cell objects using Graphics.DrawMeshInstanced using provided BulkRenderer and CellObjectConfigs.
Inheritance
CellObjectLayer
Assembly: fwt.hexterrains.dll
Syntax
public class CellObjectLayer : CellItemLayer, IDisposable, ISerializableTerrainLayer
Fields
AllCellObjectVisuals
List of all cell object visuals settings.
Each cell object can have multiple visuals (RenderEntities, e.g. mesh+submeshIndex+material combination) that can be rendered.
So all possible visuals for all cell objects are stored in this list.
Each cell object index corresponds to a range of LOD settings in AllCellObjectsLODSettings list.
LOD settings store how much cell object visuals and starting from which index to take from this list to render that cell object.
Declaration
public NativeList<CellObjectVisualItemSettings> AllCellObjectVisuals
Field Value
AllCellObjectsLODSettings
List of all cell objects LOD settings.
Meaning that if a layer has 5 LOD layers, here will be 5 settings for each cell object,
so to find a 2nd LOD for a cell object with index 3, we will take AllCellObjectsLODSettings[3 * 5 + 2].
Declaration
public NativeList<CellObjectLODSettings> AllCellObjectsLODSettings
Field Value
BulkRenderer
Bulk Renderer that stores meshes, materials and other settings for rendering meshes using Graphics.DrawMeshInstanced
Declaration
public IBulkRenderer BulkRenderer
Field Value
LODSettings
List of LOD settings for cell objects.
All cell objects will use these settings to determine how to render themselves based on the distance to the camera.
Declaration
public NativeList<CellObjectLayerLODSettings> LODSettings
Field Value
VisualsByLOD
Declaration
public List<BulkRenderItemsDataLayer> VisualsByLOD
Field Value
Properties
LODsCount
Declaration
public virtual int LODsCount { get; set; }
Property Value
MaxSubmeshesPerCell
Maximum number of submeshes (RenderEntitySettings) that can be used to render a single cell object.
Needed for initializing a _renderEntities multiHashMap, which can't change capacity in jobs,
so we have to initialize the collection with maximum needed size.
Declaration
public virtual int MaxSubmeshesPerCell { get; set; }
Property Value
StatesCountPerObject
Number of states per cell object.
When looking for a state for an object we multiply the object index by this value and add the state index.
So if we need a 2nd state of the 3rd object, we will look for index = (3 * StatesPerObject) + 2.
Declaration
public int StatesCountPerObject { get; set; }
Property Value
Methods
CalculateCellObjects(HexTerrainVisibility, float3, float4x4, ChunkMeshLayerGroup, ChunksGridLayer, JobHandle)
Declaration
public virtual JobHandle CalculateCellObjects(HexTerrainVisibility terrainVisibility, float3 cameraPosition, float4x4 terrainTransform, ChunkMeshLayerGroup chunkMeshes, ChunksGridLayer chunksGrid, JobHandle dependency)
Parameters
Returns
| Type |
Description |
| JobHandle |
|
CalculateCellObjectsLOD(HexTerrainVisibility, int, float4x4, BulkRenderItemsDataLayer, ChunkMeshLayer, ChunkMeshLayer, ChunksGridLayer, JobHandle)
Declaration
public virtual JobHandle CalculateCellObjectsLOD(HexTerrainVisibility terrainVisibility, int lodIndex, float4x4 terrainTransform, BulkRenderItemsDataLayer renderItemsDataLayer, ChunkMeshLayer surfaceLayer, ChunkMeshLayer overlapSurfaceLayer, ChunksGridLayer chunksLayer, JobHandle dependency)
Parameters
Returns
| Type |
Description |
| JobHandle |
|
CalculateCellObjectsLODSs(HexTerrainVisibility, float4x4, ChunkMeshLayer, ChunkMeshLayer, ChunksGridLayer, JobHandle)
Declaration
public virtual JobHandle CalculateCellObjectsLODSs(HexTerrainVisibility terrainVisibility, float4x4 terrainTransform, ChunkMeshLayer surfaceLayer, ChunkMeshLayer overlapSurfaceLayer, ChunksGridLayer chunksLayer, JobHandle dependency)
Parameters
Returns
| Type |
Description |
| JobHandle |
|
CreateRenderEntitiesLODLayer(int)
Declaration
public virtual BulkRenderItemsDataLayer CreateRenderEntitiesLODLayer(int lodIndex)
Parameters
| Type |
Name |
Description |
| int |
lodIndex |
|
Returns
Dispose()
Disposes all allocated native memory.
Declaration
public override void Dispose()
Overrides
Init(HexTerrainSettings)
Initializes/Reinitializes the area data.
Declaration
public override void Init(HexTerrainSettings settings)
Parameters
Overrides
InitRenderEntitiesLOD(BulkRenderItemsDataLayer)
Declaration
public virtual void InitRenderEntitiesLOD(BulkRenderItemsDataLayer renderEntitiesDataLayer)
Parameters
InitRenderEntitiesLODs()
Declaration
public virtual void InitRenderEntitiesLODs()
InitVisuals(IList<CellObjectVisualItemSettings>, IList<CellObjectLODSettings>)
Creates (if not already created) and initializes the CellObjectConfigs list with the provided configs.
Copies data from provided array, so it's safe to dispose a copyConfigsFrom array after this call.
Declaration
public virtual void InitVisuals(IList<CellObjectVisualItemSettings> copyVisualItemsFrom, IList<CellObjectLODSettings> copyObjectLODSettingsFrom)
Parameters
Init<TInitArgs>(HexTerrainSettings, TInitArgs)
Initializes the terrain system using the specified settings and initialization arguments.
Declaration
public override void Init<TInitArgs>(HexTerrainSettings settings, TInitArgs initArgs)
Parameters
| Type |
Name |
Description |
| HexTerrainSettings |
settings |
The configuration settings to apply when initializing the terrain system. Cannot be null.
|
| TInitArgs |
initArgs |
Additional arguments required for initialization. The expected type and usage depend on the implementation.
|
Type Parameters
| Name |
Description |
| TInitArgs |
The type of the initialization arguments to be used during terrain system setup.
|
Overrides
Render(Camera, IBulkRenderer, BulkRenderItemsDataLayer)
Declaration
public virtual void Render(Camera camera, IBulkRenderer renderEntitiesConfig, BulkRenderItemsDataLayer renderItemsDataLayer)
Parameters
Render(Camera, float)
Declaration
public virtual void Render(Camera camera, float normalizedCameraZoom)
Parameters
| Type |
Name |
Description |
| Camera |
camera |
|
| float |
normalizedCameraZoom |
|
RenderLODs(Camera, float)
Declaration
public virtual bool RenderLODs(Camera camera, float normalizedCameraZoom)
Parameters
| Type |
Name |
Description |
| Camera |
camera |
|
| float |
normalizedCameraZoom |
|
Returns
Implements
Extension Methods