public static void Scatter(OCMap map, OCColumnMap columnMap, int cx, int cz) { int x1 = cx * OCChunk.SIZE_X; int z1 = cz * OCChunk.SIZE_Z; int x2 = x1 + OCChunk.SIZE_X; int z2 = z1 + OCChunk.SIZE_Z; OCSunLightMap lightmap = map.GetSunLightmap(); list.Clear(); for (int x = x1; x < x2; x++) { for (int z = z1; z < z2; z++) { int maxY = ComputeMaxY(lightmap, x, z) + 1; for (int y = 0; y < maxY; y++) { if (lightmap.GetLight(x, y, z) > MIN_LIGHT) { list.Add(new Vector3i(x, y, z)); } } } } Scatter(map, columnMap, list); }
private static void Scatter(OCMap map, OCColumnMap columnMap, List <Vector3i> list) // рассеивание { OCSunLightMap lightmap = map.GetSunLightmap(); for (int i = 0; i < list.Count; i++) { Vector3i pos = list[i]; if (pos.y < 0) { continue; } OCBlockData block = map.GetBlock(pos); int light = lightmap.GetLight(pos) - OCLightComputerUtils.GetLightStep(block); if (light <= MIN_LIGHT) { continue; } Vector3i chunkPos = OCChunk.ToChunkPosition(pos); if (columnMap != null && !columnMap.IsBuilt(chunkPos.x, chunkPos.z)) { continue; } foreach (Vector3i dir in Vector3i.directions) { Vector3i nextPos = pos + dir; block = map.GetBlock(nextPos); if (block != null && block.IsAlpha() && lightmap.SetMaxLight((byte)light, nextPos)) { list.Add(nextPos); } if (block != null && !block.IsEmpty()) { OCLightComputerUtils.SetLightDirty(map, nextPos); } } } }
private static void Scatter(OCMap map, OCColumnMap columnMap, List<Vector3i> list) { // рассеивание OCSunLightMap lightmap = map.GetSunLightmap(); for(int i=0; i<list.Count; i++) { Vector3i pos = list[i]; if(pos.y<0) continue; OCBlockData block = map.GetBlock(pos); int light = lightmap.GetLight(pos) - OCLightComputerUtils.GetLightStep(block); if(light <= MIN_LIGHT) continue; Vector3i chunkPos = OCChunk.ToChunkPosition(pos); if(columnMap != null && !columnMap.IsBuilt(chunkPos.x, chunkPos.z)) continue; foreach(Vector3i dir in Vector3i.directions) { Vector3i nextPos = pos + dir; block = map.GetBlock(nextPos); if(block != null && block.IsAlpha() && lightmap.SetMaxLight((byte)light, nextPos) ) { list.Add( nextPos ); } if(block != null && !block.IsEmpty()) OCLightComputerUtils.SetLightDirty(map, nextPos); } } }
public static void Scatter(OCMap map, OCColumnMap columnMap, int cx, int cz) { int x1 = cx*OCChunk.SIZE_X; int z1 = cz*OCChunk.SIZE_Z; int x2 = x1+OCChunk.SIZE_X; int z2 = z1+OCChunk.SIZE_Z; OCSunLightMap lightmap = map.GetSunLightmap(); list.Clear(); for(int x=x1; x<x2; x++) { for(int z=z1; z<z2; z++) { int maxY = ComputeMaxY(lightmap, x, z)+1; for(int y=0; y<maxY; y++) { if(lightmap.GetLight(x, y, z) > MIN_LIGHT) { list.Add( new Vector3i(x, y, z) ); } } } } Scatter(map, columnMap, list); }