Skip to content

Commit 07538b7

Browse files
committed
Add option to TrimNegative to not trim y
1 parent 4aab05a commit 07538b7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

FancadeLoaderLib.Tests/BlockDataTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ public void TrimNegative_ShiftsBlocksToOrigin()
8787

8888
blockData.TrimNegative();
8989

90+
Assert.That(blockData.Size, Is.EqualTo(new int3(1, 4, 3)));
91+
Assert.That(blockData.GetBlock(new int3(0, 2, 0)), Is.EqualTo(99));
92+
}
93+
94+
[Test]
95+
public void TrimNegative_TrimY_ShiftsBlocksToOrigin()
96+
{
97+
var blockData = new BlockData(new Array3D<ushort>(new int3(4, 4, 4)));
98+
blockData.SetBlock(new int3(3, 2, 1), 99);
99+
100+
blockData.TrimNegative(trimY: true);
101+
90102
Assert.That(blockData.Size, Is.EqualTo(new int3(1, 2, 3)));
91103
Assert.That(blockData.GetBlock(new int3(0, 0, 0)), Is.EqualTo(99));
92104
}

FancadeLoaderLib/BlockData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public void Trim(bool shrink = true)
382382
}
383383
}
384384

385-
public void TrimNegative(bool shrink = true)
385+
public void TrimNegative(bool shrink = true, bool trimY = false)
386386
{
387387
if (Size == int3.Zero)
388388
{
@@ -456,7 +456,7 @@ public void TrimNegative(bool shrink = true)
456456
endZ:
457457
if (minX != int.MinValue && minY != int.MinValue && minZ != int.MinValue)
458458
{
459-
int3 minPos = new int3(minX, minY, minZ);
459+
int3 minPos = new int3(minX, trimY ? minY : 0, minZ);
460460

461461
if (minPos == int3.Zero)
462462
{

0 commit comments

Comments
 (0)