コード例 #1
0
    Voxel QueryCreateVoxel(int x, int y, int z)
    {
        int   hashKey = GetHashKey(x, y, z);
        Voxel v       = voxelStorage.Query(hashKey);

        if (v == null)
        {
            v = InitializeVoxel(x, y, z, cellSize, initialVoxelValue, 0);
            voxelStorage.Insert(v, hashKey);
        }
        return(v);
    }
コード例 #2
0
ファイル: Voxel.cs プロジェクト: worrel/tango-examples-unity
 public void Insert(Voxel voxel, int hashkey)
 {
     if (key == -1)
     {
         key        = hashkey;
         this.voxel = voxel;
         return;
     }
     if (hashkey == key)
     {
         this.voxel = voxel;
         return;
     }
     if (hashkey < key)
     {
         if (leftTree == null)
         {
             leftTree        = new VoxelTree();
             leftTree.key    = hashkey;
             leftTree.voxel  = voxel;
             leftTree.parent = this;
         }
         else
         {
             leftTree.Insert(voxel, hashkey);
         }
     }
     else
     {
         if (rightTree == null)
         {
             rightTree        = new VoxelTree();
             rightTree.key    = hashkey;
             rightTree.voxel  = voxel;
             rightTree.parent = this;
         }
         else
         {
             rightTree.Insert(voxel, hashkey);
         }
     }
 }