Ejemplo n.º 1
0
        public static uint MortonKey(this Vector2 vec)
        {
            var _x = (uint)vec.x;
            var _y = (uint)vec.y;

            return(BitMath.EncodeMortonKey(_x, _y));
        }
Ejemplo n.º 2
0
        public MortonKey3(int x, int y, int z)
        {
                        #if BITSTACK_DEBUG
            if (x > 1024 || x < 0)
            {
                BitDebug.Exception("MortonKey3(int, int, int) - morton key x component must be between 0-1023 (10 bits), was " + x);
            }

            if (y > 1024 || y < 0)
            {
                BitDebug.Exception("MortonKey3(int, int, int) - morton key y component must be between 0-1023 (10 bits), was " + y);
            }

            if (z > 1024 || z < 0)
            {
                BitDebug.Exception("MortonKey3(int, int, int) - morton key z component must be between 0-1023 (10 bits), was " + z);
            }
                        #endif
            mortonKey = BitMath.EncodeMortonKey((uint)x, (uint)y, (uint)z);
        }
Ejemplo n.º 3
0
        public static Vector3 DecodeMortonKey3(this uint mortonKey)
        {
            var decodedKey = BitMath.DecodeMortonKey3(mortonKey);

            return(new Vector3(decodedKey.Item1, decodedKey.Item2, decodedKey.Item3));
        }
Ejemplo n.º 4
0
        public static Vector2 DecodeMortonKey2(this uint mortonKey)
        {
            var decodedKey = BitMath.DecodeMortonKey2(mortonKey);

            return(new Vector2(decodedKey.Item1, decodedKey.Item2));
        }