From: J Date: Mon, 14 Apr 2025 04:03:49 +0000 (+0000) Subject: Changes ParallaxGenerator to use FastNoiseLite (#36214) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2024a29c60096653bc31209026151994e5140b95;p=space-station-14.git Changes ParallaxGenerator to use FastNoiseLite (#36214) Instead of the NoiseGenerator we use FastNoiseLite If I'm correct, after this we'll be able to remove NoiseGenerator and FastNoise from the codebase entirely! --- diff --git a/Content.Client/Parallax/ParallaxGenerator.cs b/Content.Client/Parallax/ParallaxGenerator.cs index 4fed1fc933..0337de30d1 100644 --- a/Content.Client/Parallax/ParallaxGenerator.cs +++ b/Content.Client/Parallax/ParallaxGenerator.cs @@ -131,7 +131,7 @@ namespace Content.Client.Parallax { private readonly Color InnerColor = Color.White; private readonly Color OuterColor = Color.Black; - private readonly NoiseGenerator.NoiseType NoiseType = NoiseGenerator.NoiseType.Fbm; + private readonly FastNoiseLite.FractalType NoiseType = FastNoiseLite.FractalType.FBm; private readonly uint Seed = 1234; private readonly float Persistence = 0.5f; private readonly float Lacunarity = (float) (Math.PI / 3); @@ -204,10 +204,10 @@ namespace Content.Client.Parallax switch (((TomlValue) tomlObject).Value) { case "fbm": - NoiseType = NoiseGenerator.NoiseType.Fbm; + NoiseType = FastNoiseLite.FractalType.FBm; break; case "ridged": - NoiseType = NoiseGenerator.NoiseType.Ridged; + NoiseType = FastNoiseLite.FractalType.Ridged; break; default: throw new InvalidOperationException(); @@ -217,14 +217,11 @@ namespace Content.Client.Parallax public override void Apply(Image bitmap) { - var noise = new NoiseGenerator(NoiseType); - noise.SetSeed(Seed); + var noise = new FastNoiseLite((int)Seed); + noise.SetFractalType(NoiseType); noise.SetFrequency(Frequency); - noise.SetPersistence(Persistence); - noise.SetLacunarity(Lacunarity); - noise.SetOctaves(Octaves); - noise.SetPeriodX(bitmap.Width); - noise.SetPeriodY(bitmap.Height); + noise.SetFractalLacunarity(Lacunarity); + noise.SetFractalOctaves((int)Octaves); var threshVal = 1 / (1 - Threshold); var powFactor = 1 / Power; @@ -268,7 +265,7 @@ namespace Content.Client.Parallax // Noise mask stuff. private readonly bool Masked; - private readonly NoiseGenerator.NoiseType MaskNoiseType = NoiseGenerator.NoiseType.Fbm; + private readonly FastNoiseLite.FractalType MaskNoiseType = FastNoiseLite.FractalType.FBm; private readonly uint MaskSeed = 1234; private readonly float MaskPersistence = 0.5f; private readonly float MaskLacunarity = (float) (Math.PI * 2 / 3); @@ -357,10 +354,10 @@ namespace Content.Client.Parallax switch (((TomlValue) tomlObject).Value) { case "fbm": - MaskNoiseType = NoiseGenerator.NoiseType.Fbm; + MaskNoiseType = FastNoiseLite.FractalType.FBm; break; case "ridged": - MaskNoiseType = NoiseGenerator.NoiseType.Ridged; + MaskNoiseType = FastNoiseLite.FractalType.Ridged; break; default: throw new InvalidOperationException(); @@ -439,14 +436,10 @@ namespace Content.Client.Parallax { var o = PointSize - 1; var random = new Random(Seed); - var noise = new NoiseGenerator(MaskNoiseType); - noise.SetSeed(MaskSeed); - noise.SetFrequency(MaskFrequency); - noise.SetPersistence(MaskPersistence); - noise.SetLacunarity(MaskLacunarity); - noise.SetOctaves(MaskOctaves); - noise.SetPeriodX(buffer.Width); - noise.SetPeriodY(buffer.Height); + var noise = new FastNoiseLite((int)MaskSeed); + noise.SetFractalType(MaskNoiseType); + noise.SetFractalLacunarity(MaskLacunarity); + noise.SetFractalOctaves((int)MaskOctaves); var threshVal = 1 / (1 - MaskThreshold); var powFactor = 1 / MaskPower;