public void FloodLight(int[] chunk, byte[] light, int startx, int starty, int startz, int[] dataLightRadius, bool[] dataTransparent) { int start = Index3d(startx, starty, startz, 16, 16); if (light[start] == minlight) { return; } q.Clear(); q.Push(start); for (; ;) { if (q.Count == 0) { break; } int vPos = q.Pop(); int vLight = light[vPos]; if (vLight == minlight) { continue; } int vBlock = chunk[vPos]; if (!dataTransparent[vBlock] && dataLightRadius[vBlock] == 0) { continue; } int x = MapUtilCi.PosX(vPos, 16, 16); int y = MapUtilCi.PosY(vPos, 16, 16); int z = MapUtilCi.PosZ(vPos, 16, 16); if (x < 15) { Push(q, light, vLight, vPos + XPlus); } if (x > 0) { Push(q, light, vLight, vPos + XMinus); } if (y < 15) { Push(q, light, vLight, vPos + YPlus); } if (y > 0) { Push(q, light, vLight, vPos + YMinus); } if (z < 15) { Push(q, light, vLight, vPos + ZPlus); } if (z > 0) { Push(q, light, vLight, vPos + ZMinus); } } }
public static void FloodLight_(FastQueueInt q, int[] portion, byte[] light, int startx, int starty, int startz, int[] dataLightRadius, bool[] dataTransparent) { const int portionsize = 16; int pos = Index3d(startx, starty, startz, portionsize, portionsize); if (light[pos] == minlight) { return; } int lightradius = dataLightRadius[portion[pos]]; if (lightradius != 0) { light[pos] = Game.IntToByte(lightradius); } //if (light[pos + 1] == light[pos] // && light[pos - 1] == light[pos] // && light[pos + portionsize] == light[pos] // && light[pos - portionsize] == light[pos] // && light[pos + portionsize * portionsize] == light[pos] // && light[pos - portionsize * portionsize] == light[pos]) //{ // return; //} q.Clear(); int start = Index3d(startx, starty, startz, portionsize, portionsize); q.Push(start); for (; ;) { if (q.Count == 0) { break; } int vpos = q.Pop(); int vlight = light[vpos]; if (vlight == minlight) { continue; } int vblock = portion[vpos]; if (!dataTransparent[vblock] && dataLightRadius[vblock] == 0) { continue; } int x = MapUtilCi.PosX(vpos, 16, 16); int y = MapUtilCi.PosY(vpos, 16, 16); int z = MapUtilCi.PosZ(vpos, 16, 16); if (x < 15) { Push(q, light, vlight, vpos + XPlus); } if (x > 0) { Push(q, light, vlight, vpos + XMinus); } if (y < 15) { Push(q, light, vlight, vpos + YPlus); } if (y > 0) { Push(q, light, vlight, vpos + YMinus); } if (z < 15) { Push(q, light, vlight, vpos + ZPlus); } if (z > 0) { Push(q, light, vlight, vpos + ZMinus); } } }