public bool isConnected() { bool output = true; int val = 1; int fillVal = 2; List <cell> openList = new List <cell>(); cell tempCell = new cell(); myGrid.data.CopyTo(gridCopy.data, 0);//updates the copy of the grid for double buffering if (gridCopy.cellValueExists(ref tempCell, val)) { openList.Add(tempCell); gridCopy.setVal(tempCell.x, tempCell.y, tempCell.z, fillVal); } while (openList.Count > 0) { tempCell = openList[0]; addCell(ref openList, tempCell.x + 1, tempCell.y, tempCell.z, val, fillVal); addCell(ref openList, tempCell.x - 1, tempCell.y, tempCell.z, val, fillVal); addCell(ref openList, tempCell.x, tempCell.y - 1, tempCell.z, val, fillVal); addCell(ref openList, tempCell.x, tempCell.y + 1, tempCell.z, val, fillVal); addCell(ref openList, tempCell.x, tempCell.y, tempCell.z - 1, val, fillVal); addCell(ref openList, tempCell.x, tempCell.y, tempCell.z + 1, val, fillVal); openList.RemoveAt(0); } output = !gridCopy.inGrid(val); return(output); }
public cell startCell() { cell myCell = new cell(); myGrid.cellValueExistsReplace(ref myCell, 2, 4); return(myCell); }
public Vector3 startPosition() { cell myCell = new cell(); myGrid.cellValueExistsReplace(ref myCell, 1, 2); Vector3 myPos = new Vector3(myCell.x * voxel.transform.localScale.x, myCell.y * voxel.transform.localScale.y, myCell.z * voxel.transform.localScale.z); return(myPos); }
public void addCell(ref List <cell> myList, int x, int y, int z, int val, int fillVal) { cell nextCell = new cell(); if (gridCopy.queryCell(x, y, z, val, ref nextCell)) { myList.Add(nextCell); gridCopy.data[gridCopy.getIndex(x, y, z)] = fillVal; } }
public cell getCell(int index) { int x = index / (gridWidth * gridWidth); index -= x * gridWidth * gridWidth; int y = index / gridWidth; index -= y * gridWidth; int z = index; cell outCell = new cell(x, y, z, data[index]); return(outCell); }
public bool cellValueExists(ref cell myCell, int val) { bool output = true; for (int i = 0; i < dataSize; i++) { if (data[i] == val) { myCell = getCell(i); break; } } return(output); }
public bool queryCell(int x, int y, int z, int val, ref cell myCell) { bool output = onGrid(x, y, z); int testVal, index; if (output) { index = getIndex(x, y, z); testVal = data[index]; output = testVal == val; if (output) { myCell = getCell(index); } } return(output); }
public int adj(int index, int val, bool includeEdge = false) { cell tempCell = getCell(index); return(adj(tempCell.x, tempCell.y, tempCell.z, val, includeEdge)); }
public voxelPlus(GameObject myVox, cell pos) { myCell = pos; vox = myVox; }