Esempio n. 1
0
        public bool Set(System.Byte x, System.Byte y, System.Byte z, VOXMaterial value, bool replace = true)
        {
            if (_allocSize == 0)
            {
                this.Create(0xFF);
            }

            var index = HashInt(x, y, z) & _allocSize;
            var entry = _data[index];

            while (entry != null)
            {
                if (entry.x == x && entry.y == y && entry.z == z)
                {
                    if (replace)
                    {
                        _data[index].element = value;
                        return(true);
                    }

                    return(false);
                }

                index = (index + 1) & _allocSize;
                entry = _data[index];
            }

            if (value != VOXMaterial.MaxValue)
            {
                _data[index] = new VOXHashMapNode <System.Byte>(x, y, z, value);
                _count++;

                if (_count >= _allocSize)
                {
                    this.Grow();
                }

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        private bool Grow(VOXHashMapNode <System.Byte> data)
        {
            var index = HashInt(data.x, data.y, data.z) & _allocSize;
            var entry = _data[index];

            while (entry != null)
            {
                index = (index + 1) & _allocSize;
                entry = _data[index];
            }

            if (data.element != VOXMaterial.MaxValue)
            {
                _data[index] = data;
                _count++;

                return(true);
            }

            return(false);
        }