static void Push(FastQueueInt q_, byte[] light, int vLight, int newPos) { if (light[newPos] < vLight - 1) { light[newPos] = Game.IntToByte(vLight - 1); q_.Push(newPos); } }
public ShadowsBase() { q_ = new FastQueueInt(); q_.Initialize(1024); lighttoflood = new FastStackInt(); lighttoflood.Initialize(1024); workData = new int[16 * 16 * 16]; }
static void Push(FastQueueInt q, byte[] light, int vlight, int n) { if (light[n] < vlight - 1) { light[n] = Game.IntToByte(vlight - 1); q.Push(n); } }
public ShadowsBetweenChunks() { chunksLight = new byte[3 * 3 * 3][]; for (int i = 0; i < 3 * 3 * 3; i++) { chunksLight[i] = new byte[16 * 16 * 16]; } chunksData = new int[3 * 3 * 3][]; for (int i = 0; i < 3 * 3 * 3; i++) { chunksData[i] = new int[16 * 16 * 16]; } q = new FastQueueInt(); q.Initialize(1024); }
public LightFlood() { q = new FastQueueInt(); q.Initialize(1024); }
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); } } }