private static uint Interleave3(ByteXYZ val) { unchecked { ulong x = (((ulong)val.X & 0x7F)) | (((ulong)val.Y & 0x7F) << 7) | (((ulong)val.Z & 0x7F) << 14); x = (x | (x << 32)) & 0x001F00000000FFFFUL; x = (x | (x << 16)) & 0x001F0000FF0000FFUL; x = (x | (x << 8)) & 0x100F00F00F00F00FUL; x = (x | (x << 4)) & 0x10C30C30C30C30C3UL; x = (x | (x << 2)) & 0x1249249249249249UL; return((uint)((x | (x >> 20) | (x >> 40)) & 0x1FFFFF)); } }
// Region coords to sector name - based on https://bitbucket.org/Esvandiary/edts/src/master/pgnames.py public static string GetSectorName(ByteXYZ pos) { if (CachedSectorsByCoords.ContainsKey(pos)) { return(CachedSectorsByCoords[pos]); } else { int offset = (pos.Z << 14) + (pos.Y << 7) + pos.X; string sectorname; if (IsC1Sector(offset)) { sectorname = GetC1Name(offset); } else { sectorname = GetC2Name(offset); } CachedSectorsByCoords[pos] = sectorname; return(sectorname); } }
public static string GetC2SectorName(ByteXYZ pos) { return(GetC2Name((pos.Z << 14) + (pos.Y << 7) + pos.X)); }