public void SpawnVoxels(VoxelizationInfo info)
    {
        List <VoxelizationServer.AABCGrid> aABCGrids = info.aABCGrids;

        //int total = 0;
        if (aABCGrids != null)
        {
            foreach (VoxelizationServer.AABCGrid aABCGrid in aABCGrids)
            {
                Vector3 preCalc = aABCGrid.GetOrigin();
                for (short x = 0; x < aABCGrid.GetWidth(); ++x)
                {
                    for (short y = 0; y < aABCGrid.GetHeight(); ++y)
                    {
                        for (short z = 0; z < aABCGrid.GetDepth(); ++z)
                        {
                            if (aABCGrid.IsAABCActiveUnsafe(x, y, z))
                            {
                                Vector3 cubeCenter = aABCGrid.GetAABCCenterUnsafe(x, y, z) + preCalc;

                                voxelController = voxelPool.GetObject();
                                if (voxelController != null)
                                {
                                    //++total;
                                    Transform voxelTrans = voxelController.gameObject.transform;
                                    voxelTrans.position = cubeCenter;
                                    voxelTrans.rotation = Quaternion.identity;
                                    //voxelTrans.rotation = Random.rotation;
                                    voxelTrans.localScale = info.voxelScale;
                                    if (!info.randomMaterial)
                                    {
                                        voxelController.GetComponent <Renderer>().sharedMaterial = info.mat;
                                    }
                                    else
                                    {
                                        voxelController.GetComponent <Renderer>().sharedMaterial = colorObjMng.GetVoxelRandomMaterial();
                                    }

                                    voxelController.spawnLevels = 1;
                                }
                            }
                        }
                    }
                }

                //Set a collider in place to make voxels "explode"
                if (info.spawnCollider)
                {
                    GameObject voxelCollider = voxelColliderPool.GetObject();
                    if (voxelCollider != null)
                    {
                        voxelCollider.transform.localScale = info.voxelColliderScale;
                        voxelCollider.transform.position   = aABCGrid.GetCenter();
                    }
                }
            }
        }
        //Debug.Log("Spider spawned: " + total);
    }
    /*public void SpawnVoxels()
     * {
     *  //int total = 0;
     *  if (aABCGrids != null)
     *  {
     *      foreach (VoxelizationServer.AABCGrid aABCGrid in aABCGrids)
     *      {
     *          Vector3 preCalc = aABCGrid.GetOrigin();
     *          for (short x = 0; x < aABCGrid.GetWidth(); ++x)
     *          {
     *              for (short y = 0; y < aABCGrid.GetHeight(); ++y)
     *              {
     *                  for (short z = 0; z < aABCGrid.GetDepth(); ++z)
     *                  {
     *                      if (aABCGrid.IsAABCActiveUnsafe(x, y, z))
     *                      {
     *                          Vector3 cubeCenter = aABCGrid.GetAABCCenterUnsafe(x, y, z) + preCalc;
     *
     *                          voxelController = voxelPool.GetObject();
     *                          if(voxelController != null)
     *                          {
     *                              //++total;
     *                              Transform voxelTrans = voxelController.gameObject.transform;
     *                              voxelTrans.position = cubeCenter;
     *                              voxelTrans.rotation = Quaternion.identity;
     *                              //voxelTrans.rotation = Random.rotation;
     *                              voxelTrans.localScale = voxelScale;
     *                              if(!randomMaterial)
     *                              {
     *                                  voxelController.GetComponent<Renderer>().sharedMaterial = mat;
     *                              }
     *                              else
     *                              {
     *                                  voxelController.GetComponent<Renderer>().sharedMaterial = colorObjMng.GetVoxelRandomMaterial();
     *                              }
     *
     *                              voxelController.spawnLevels = 1;
     *                          }
     *                      }
     *                  }
     *              }
     *          }
     *
     *          //Set a collider in place to make voxels "explode"
     *          if (spawnColliderThisTime)
     *          {
     *              GameObject voxelCollider = voxelColliderPool.GetObject();
     *              if (voxelCollider != null)
     *              {
     *                  voxelCollider.transform.localScale = voxelColliderScale;
     *                  voxelCollider.transform.position = aABCGrid.GetCenter();
     *              }
     *          }
     *      }
     *  }
     *  //Debug.Log("Spider spawned: " + total);
     *
     *  //Return to default
     *  spawnColliderThisTime = spawnVoxelCollider;
     * }*/

    public void SpawnVoxels()
    {
        VoxelizationInfo info = new VoxelizationInfo(aABCGrids, voxelScale, randomMaterial, mat, spawnColliderThisTime, voxelColliderScale);

        rsc.voxelizationMng.AddInfoToPendingSpawns(info);

        //Return to default
        spawnColliderThisTime = spawnVoxelCollider;
    }
    public void SpawnFakeVoxels()
    {
        Vector3 position = transform.position;

        position.y -= transform.localPosition.y;
        fakeAABCGrid.SetCenter(position);

        VoxelizationInfo info = new VoxelizationInfo(fakeAABCGrids, voxelScale, randomMaterial, mat, spawnColliderThisTime, voxelColliderScale);

        rsc.voxelizationMng.AddInfoToPendingSpawns(info);

        //Return to default
        spawnColliderThisTime = spawnVoxelCollider;
    }
 public void AddInfoToPendingSpawns(VoxelizationInfo spawnInfo)
 {
     pendingSpawns.Enqueue(spawnInfo);
 }