From ce2274dc0534244e9f79d883d2a6fb14b20a9574 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 11 Feb 2016 13:08:34 +1100 Subject: [PATCH] Fix ore veins being too small. (Thanks MarsBarsFood) --- ClassicalSharp/Generator/NotchyGenerator.Utils.cs | 13 ++++++++----- ClassicalSharp/Generator/NotchyGenerator.cs | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ClassicalSharp/Generator/NotchyGenerator.Utils.cs b/ClassicalSharp/Generator/NotchyGenerator.Utils.cs index b7773f126..579971f96 100644 --- a/ClassicalSharp/Generator/NotchyGenerator.Utils.cs +++ b/ClassicalSharp/Generator/NotchyGenerator.Utils.cs @@ -10,11 +10,14 @@ namespace ClassicalSharp.Generator { // TODO: figure out how noise functions differ, probably based on rnd. public sealed partial class NotchyGenerator { - void FillOblateSpheroid( int x, int y, int z, int radius, byte block ) { - int xStart = Math.Max( x - radius, 0 ), xEnd = Math.Min( x + radius, width - 1 ); - int yStart = Math.Max( y - radius, 0 ), yEnd = Math.Min( y + radius, height - 1 ); - int zStart = Math.Max( z - radius, 0 ), zEnd = Math.Min( z + radius, length - 1 ); - int radiusSq = radius * radius; + void FillOblateSpheroid( int x, int y, int z, float radius, byte block ) { + int xStart = Utils.Floor( Math.Max( x - radius, 0 ) ); + int xEnd = Utils.Floor( Math.Min( x + radius, width - 1 ) ); + int yStart = Utils.Floor( Math.Max( y - radius, 0 ) ); + int yEnd = Utils.Floor( Math.Min( y + radius, height - 1 ) ); + int zStart = Utils.Floor( Math.Max( z - radius, 0 ) ); + int zEnd = Utils.Floor( Math.Min( z + radius, length - 1 ) ); + float radiusSq = radius * radius; for( int yy = yStart; yy <= yEnd; yy++ ) for( int zz = zStart; zz <= zEnd; zz++ ) diff --git a/ClassicalSharp/Generator/NotchyGenerator.cs b/ClassicalSharp/Generator/NotchyGenerator.cs index 48f303658..fcb11fbeb 100644 --- a/ClassicalSharp/Generator/NotchyGenerator.cs +++ b/ClassicalSharp/Generator/NotchyGenerator.cs @@ -132,7 +132,7 @@ namespace ClassicalSharp.Generator { double radius = (height - cenY) / (double)height; radius = 1.2 + (radius * 3.5 + 1) * caveRadius; radius = radius + Math.Sin( j * Math.PI / caveLen ); - FillOblateSpheroid( cenX, cenY, cenZ, (int)radius, (byte)Block.Air ); + FillOblateSpheroid( cenX, cenY, cenZ, (float)radius, (byte)Block.Air ); } } } @@ -161,7 +161,7 @@ namespace ClassicalSharp.Generator { phi = phi / 2 + deltaPhi / 4; deltaPhi = deltaPhi * 0.9 + rnd.NextDouble() - rnd.NextDouble(); - int radius = (int)(abundance * Math.Sin( j * Math.PI / veinLen ) + 1); + float radius = abundance * (float)Math.Sin( j * Math.PI / veinLen ) + 1; FillOblateSpheroid( (int)veinX, (int)veinY, (int)veinZ, radius, block ); } }