public void Apply(VoxelStencil stencil) { int xStart = stencil.XStart; int xEnd = stencil.XEnd; int yStart = stencil.YStart; int yEnd = stencil.YEnd; if (xStart < 0) { xStart = 0; } if (xEnd >= m_resolution) { xEnd = m_resolution - 1; } if (yStart < 0) { yStart = 0; } if (yEnd >= m_resolution) { yEnd = m_resolution - 1; } for (int y = yStart; y <= yEnd; y++) { int i = y * m_resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { m_voxels[i].m_state = stencil.Apply(x, y, m_voxels[i].m_state); } } Refresh(); }
public void Apply(VoxelStencil stencil) { int xStart = stencil.XStart; if (xStart < 0) { xStart = 0; } int xEnd = stencil.XEnd; if (xEnd >= Resoultion) { xEnd = Resoultion - 1; } int yStart = stencil.YStart; if (yStart < 0) { yStart = 0; } int yEnd = stencil.YEnd; if (yEnd >= Resoultion) { yEnd = Resoultion - 1; } for (int y = yStart; y <= yEnd; y++) { int i = y*Resoultion + xStart; for (int x = xStart; x <= xEnd; x++, i++) { _voxels[i] = stencil.Apply(x, y); } } SetVoxelColor(); }
public bool Apply(VoxelStencil stencil) { int xStart = stencil.XStart; if (xStart < 0) { xStart = 0; } int xEnd = stencil.XEnd; if (xEnd >= resolution) { xEnd = resolution - 1; } int yStart = stencil.YStart; if (yStart < 0) { yStart = 0; } int yEnd = stencil.YEnd; if (yEnd >= resolution) { yEnd = resolution - 1; } bool didUpdate = false; for (int y = yStart; y <= yEnd; y++) { int i = y * resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { if (voxels[i].state != stencil.fillType) { voxels[i].state = stencil.Apply(x, y, voxels[i].state); didUpdate = true; } } } Refresh(); if (didUpdate) { shouldUpdateCollider = true; } return(didUpdate); }
public void Apply(VoxelStencil stencil) { int xStart = stencil.XStart; if (xStart < 0) { xStart = 0; } int xEnd = stencil.XEnd; if (xEnd >= resolution) { xEnd = resolution - 1; } int yStart = stencil.YStart; if (yStart < 0) { yStart = 0; } int yEnd = stencil.YEnd; if (yEnd >= resolution) { yEnd = resolution - 1; } for (int y = yStart; y <= yEnd; y++) { int i = y * resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { voxels[i].state = stencil.Apply(x, y, voxels[i].state); } } Refresh(); }
public void Apply(VoxelStencil stencil) { int xStart = (int)(stencil.XStart / voxelSize); if (xStart < 0) { xStart = 0; } int xEnd = (int)(stencil.XEnd / voxelSize); if (xEnd >= resolution) { xEnd = resolution - 1; } int yStart = (int)(stencil.YStart / voxelSize); if (yStart < 0) { yStart = 0; } int yEnd = (int)(stencil.YEnd / voxelSize); if (yEnd >= resolution) { yEnd = resolution - 1; } for (int y = yStart; y <= yEnd; y++) { int i = y * resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { stencil.Apply(voxels[i]); } } SetCrossings(stencil, xStart, xEnd, yStart, yEnd); Refresh(); }
private void ApplyChunkStencil(VoxelGrid grid, VoxelStencil stencil) { int xStart = stencil.XStart; if (xStart < 0) { xStart = 0; } int xEnd = stencil.XEnd; if (xEnd >= grid.resolution) { xEnd = grid.resolution - 1; } int yStart = stencil.YStart; if (yStart < 0) { yStart = 0; } int yEnd = stencil.YEnd; if (yEnd >= grid.resolution) { yEnd = grid.resolution - 1; } for (int y = yStart; y <= yEnd; y++) { int i = y * grid.resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { grid.voxels[i].state = stencil.Apply(x, y, grid.voxels[i].state); } } grid.UpdateGrid(); }
public bool Apply(VoxelStencil stencil) { var xStart = stencil.XStart; if (xStart < 0) { xStart = 0; } var xEnd = stencil.XEnd; if (xEnd >= resolution) { xEnd = resolution - 1; } var yStart = stencil.YStart; if (yStart < 0) { yStart = 0; } var yEnd = stencil.YEnd; if (yEnd >= resolution) { yEnd = resolution - 1; } var didUpdate = false; for (var y = yStart; y <= yEnd; y++) { var i = VoxelIndexFromLocalPos(xStart, y); for (var x = xStart; x <= xEnd; x++, i++) { if (voxels[i].state != stencil.fillType) { // Deleting if (stencil.fillType == 0) { var deletingBlock = blockCollection.blocks[voxels[i].state]; var tempState = stencil.Apply(x, y, voxels[i].state); if (tempState == stencil.fillType) { voxels[i].state = tempState; var itemType = deletingBlock.itemType; var amount = deletingBlock.amount; var item = new Item { itemType = itemType, amount = amount }; var worldMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); WorldItem.SpawnWorldItem(new Vector2(worldMousePos.x, worldMousePos.y), item); didUpdate = true; } } // Placing if (stencil.fillType != 0 && voxels[i].state == 0) { var placingItemType = BlockManager.Read().blocks[stencil.fillType].itemType; voxels[i].state = stencil.Apply(x, y, voxels[i].state); uiHotBar.Place(); didUpdate = true; } } } } Refresh(); if (didUpdate) { shouldUpdateCollider = true; } return(didUpdate); }
public void Apply(VoxelStencil stencil) { int xStart = Mathf.Max(stencil.XStart, 0); int xEnd = Mathf.Min(stencil.XEnd, resolution - 1); int yStart = Mathf.Max(stencil.YStart, 0); int yEnd = Mathf.Min(stencil.YEnd, resolution - 1); for (int y = yStart; y <= yEnd; y++) { int i = y * resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { voxels[i].state = stencil.Apply(x, y, voxels[i].state); } } Refresh(); }
public void Apply(int x, int y, VoxelStencil stencil) { voxels[y * resolution + x] = stencil.Apply(x, y); SetVoxelColors(); }