Skip to content

Commit 71f8479

Browse files
committed
Added argument option "chunk-size"
1 parent fe59fcd commit 71f8479

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Install first : `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.co
4444
--c --color enable color when generating heightmap
4545
--cl --color-limit=VALUE set the maximal number of colors for the palette
4646
--cm --color-from-file=VALUE load color from another file
47+
--cs --chunk-size=VALUE set the chunk size (default: 125, min: 11, max: 255)
4748
--e --excavate delete all voxels which doesn't have at least one face connected with air
4849
--fl --flood fill all invisibles voxels
4950
--flo --fix-lonely delete all voxels where all connected voxels are air

SchematicToVoxCore/Program.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Program
3636
private static int _heightMap = 1;
3737
private static int _gridSize = 126;
3838
private static int _colorLimit = 256;
39+
private static int _chunkSize = 125;
3940

4041
private const int MAX_WORLD_WIDTH = 2001;
4142
private const int MAX_WORLD_HEIGHT = 2001;
@@ -50,6 +51,7 @@ public static void Main(string[] args)
5051
{"c|color", "enable color when generating heightmap", v => _color = v != null},
5152
{"cm|color-from-file=", "load colors from file", v => _inputColorFile = v },
5253
{"cl|color-limit=", "set the maximal number of colors for the palette", (int v) => _colorLimit =v },
54+
{"cs|chunk-size=", "set the chunk size", (int v) => _chunkSize = v},
5355
{"e|excavate", "delete all voxels which doesn't have at least one face connected with air", v => _excavate = v != null },
5456
{"fl|flood", "fill all invisible voxels", v => _flood = v != null },
5557
{"flo|fix-lonely", "delete all voxels where all connected voxels are air", v => _lonely = v != null },
@@ -146,7 +148,8 @@ private static void CheckArguments()
146148
throw new ArgumentException("[ERROR] --color-limit argument must be positive");
147149
if (_colorLimit > 256)
148150
throw new ArgumentException("[ERROR] --color-limit argument must be lower than 256");
149-
151+
if (_chunkSize <= 10 || _chunkSize > 255)
152+
throw new ArgumentException("[ERROR] --chunk-size argument must be lower than 256 and greater than 10");
150153
}
151154

152155
private static void DisplayArguments()
@@ -169,6 +172,8 @@ private static void DisplayArguments()
169172
Console.WriteLine("[INFO] Specified increase size: " + _scale);
170173
if (_gridSize != 126)
171174
Console.WriteLine("[INFO] Specified grid size: " + _gridSize);
175+
if (_chunkSize != 125)
176+
Console.WriteLine("[INFO] Specified chunk size: " + _chunkSize);
172177
if (_slow != 0)
173178
Console.WriteLine("[INFO] Specified winding_number: " + _slow);
174179
if (_excavate)
@@ -305,11 +310,11 @@ private static void SchematicToVox(AbstractToSchematic converter, string outputP
305310
{
306311
PaletteSchematicConverter converterPalette = new PaletteSchematicConverter(_inputPaletteFile, _colorLimit);
307312
schematic = converterPalette.ConvertSchematic(schematic);
308-
writer.WriteModel(outputPath + ".vox", converterPalette.GetPalette(), schematic);
313+
writer.WriteModel(_chunkSize, outputPath + ".vox", converterPalette.GetPalette(), schematic);
309314
}
310315
else
311316
{
312-
writer.WriteModel(outputPath + ".vox", null, schematic);
317+
writer.WriteModel(_chunkSize, outputPath + ".vox", null, schematic);
313318
}
314319
}
315320

SchematicToVoxCore/Vox/VoxWriter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ public class VoxWriter : VoxParser
3232
private List<Color> _palette;
3333
private uint[,,] _blocks;
3434

35-
private const int CHUNK_SIZE = 125;
35+
private int CHUNK_SIZE = 125;
3636

37-
public bool WriteModel(string absolutePath, List<Color> palette, Schematic schematic)
37+
public bool WriteModel(int chunkSize, string absolutePath, List<Color> palette, Schematic schematic)
3838
{
39+
CHUNK_SIZE = chunkSize;
3940
_width = _length = _height = _countSize = _totalBlockCount = _countRegionNonEmpty = 0;
4041
_schematic = schematic;
4142
_palette = palette;

0 commit comments

Comments
 (0)