Example #1
0
    public OctreeEntry <T> GetAt(int x, int y, int z)
    {
        int hashIndex = Vector3i.Hash(x, y, z);

        if (quickieDictionary.ContainsKey(hashIndex))
        {
            // The cell lies within the tree's bounds
            return(quickieDictionary[hashIndex]);
        }

        // The tree does not contain the cell
        return(default(OctreeEntry <T>));
    }
Example #2
0
    public void RemoveAt(int x, int y, int z)
    {
        if (root.Contains(x, y, z))
        {
            root.RemoveAt(x, y, z);
        }

        int hashIndex = Vector3i.Hash(x, y, z);

        // The dictionary should always ccontain the hashIndex
        if (quickieDictionary.ContainsKey(hashIndex))
        {
            // The cell lies within the tree's bounds
            quickieDictionary.Remove(hashIndex);
        }
    }
Example #3
0
    public OctreeEntry <T> SetAt(int x, int y, int z, T value)
    {
        if (root.Contains(x, y, z))
        {
            OctreeEntry <T> entry = root.SetAt(x, y, z, value);

            quickieDictionary[Vector3i.Hash(x, y, z)] = entry;

            return(entry);
        }

        // Grow the octree towards the cell
        GrowTowards(x, y, z);

        // Attempt to set again
        return(SetAt(x, y, z, value));
    }