protected override void RequestLodMeshData(LODMesh lodMesh, LODInfo lodInfo) { lodMesh.RequestMeshData( () => MeshGenerator.GenerateMeshData( waterData.size + 1, lodInfo), OnLodMeshReady); }
public void UpdateChunk() { if (hasMapData == false) { return; } var viewerPos = TerrainChunkGenerator.get.ViewerPos; var maxViewDistance = TerrainChunkGenerator.get.MaxViewDistance; float viewerDsistFromNearestEdge = Mathf.Sqrt(bounds.SqrDistance(viewerPos)); bool visible = viewerDsistFromNearestEdge <= maxViewDistance; if (visible) { int lodIndex = 0; for (int i = 0; i < detailLevels.Length - 1; i++) { if (viewerDsistFromNearestEdge > detailLevels[i].viewDistanceThreshold) { lodIndex = i + 1; } else { break; } } if (lodIndex != previousLod) { var lodMesh = lodMeshes[lodIndex]; if (lodMesh.hasMesh) { previousLod = lodIndex; meshFilter.mesh = lodMesh.mesh; } else if (lodMesh.requestedMesh == false) { lodMesh.RequestMeshData(mapData); } } if (lodIndex == 0) { if (collisionLODMesh.hasMesh) { meshCollider.sharedMesh = collisionLODMesh.mesh; } else if (!collisionLODMesh.requestedMesh) { collisionLODMesh.RequestMeshData(mapData); } } } SetVisible(visible); }
protected override void RequestLodMeshData(LODMesh lodMesh, LODInfo lodInfo) { lodMesh.RequestMeshData( () => VoxelMeshGenerator.GenerateVoxelMeshData( terrainData.size, terrainData.cellSize, lodInfo, heightLevelMapData), OnLodMeshReady); }
protected override void RequestLodMeshData(LODMesh lodMesh, LODInfo lodInfo) { lodMesh.RequestMeshData( () => MeshGenerator.GenerateMeshData( terrainData.size + 1, lodInfo, heightMapData, terrainData.heightScale, terrainData.heightCurve), OnLodMeshReady); }