private static int ComputeMaxY(OCSunLightMap lightmap, int x, int z) { int maxY = lightmap.GetSunHeight(x, z); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x - 1, z)); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x + 1, z)); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x, z - 1)); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x, z + 1)); return(maxY); }
public static void RecomputeLightAtPosition(OCMap map, Vector3i pos) { OCSunLightMap lightmap = map.GetSunLightmap(); int oldSunHeight = lightmap.GetSunHeight(pos.x, pos.z); ComputeRayAtPosition(map, pos.x, pos.z); int newSunHeight = lightmap.GetSunHeight(pos.x, pos.z); if (newSunHeight < oldSunHeight) // свет опустился // добавляем свет { list.Clear(); for (int ty = newSunHeight; ty <= oldSunHeight; ty++) { pos.y = ty; lightmap.SetLight(MIN_LIGHT, pos); list.Add(pos); } Scatter(map, list); } if (newSunHeight > oldSunHeight) // свет поднялся // удаляем свет { list.Clear(); for (int ty = oldSunHeight; ty <= newSunHeight; ty++) { pos.y = ty; list.Add(pos); } RemoveLight(map, list); } if (newSunHeight == oldSunHeight) { if (map.GetBlock(pos).IsAlpha()) { UpdateLight(map, pos); } else { RemoveLight(map, pos); } } }
private static int ComputeMaxY(OCSunLightMap lightmap, int x, int z) { int maxY = lightmap.GetSunHeight(x, z); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x-1, z )); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x+1, z )); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x, z-1)); maxY = Mathf.Max(maxY, lightmap.GetSunHeight(x, z+1)); return maxY; }