예제 #1
0
        public static float GetRiverStrength(BlockCoordinates blockPos, OverworldGeneratorV2 generator)
        {
            int    worldX     = blockPos.X;
            int    worldZ     = blockPos.Z;
            double pX         = worldX;
            double pZ         = worldZ;
            var    jitterData = SimplexData2D.NewDisk();

            //New river curve function. No longer creates worldwide curve correlations along cardinal axes.
            generator.SimplexInstance(1).GetValue((float)worldX / 240.0f, (float)worldZ / 240.0f, jitterData);
            pX += jitterData.GetDeltaX() * generator.RiverLargeBendSize;
            pZ += jitterData.GetDeltaY() * generator.RiverLargeBendSize;

            generator.SimplexInstance(2).GetValue((float)worldX / 80.0f, (float)worldZ / 80.0f, jitterData);
            pX += jitterData.GetDeltaX() * generator.RiverSmallBendSize;
            pZ += jitterData.GetDeltaY() * generator.RiverSmallBendSize;

            pX /= generator.RiverSeperation;
            pZ /= generator.RiverSeperation;

            //New cellular noise.
            double riverFactor = generator.CellularInstance(0).Eval2D(pX, pZ).InteriorValue;

            // the output is a curved function of relative distance from the center, so adjust to make it flatter
            riverFactor = BayesianAdjustment((float)riverFactor, 0.5f);
            if (riverFactor > generator.RiverValleyLevel)
            {
                return(0);
            } // no river effect

            return((float)(riverFactor / generator.RiverValleyLevel - 1d));
        }
예제 #2
0
        public float LakePressure(OverworldGeneratorV2 generator, int x, int y, float border, float lakeInterval,
                                  float largeBendSize, float mediumBendSize, float smallBendSize)
        {
            if (!this.Config.AllowScenicLakes)
            {
                return(1f);
            }

            double         pX         = x;
            double         pY         = y;
            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            generator.SimplexInstance(1).GetValue(x / 240.0d, y / 240.0d, jitterData);
            pX += jitterData.GetDeltaX() * largeBendSize;
            pY += jitterData.GetDeltaY() * largeBendSize;

            generator.SimplexInstance(0).GetValue(x / 80.0d, y / 80.0d, jitterData);
            pX += jitterData.GetDeltaX() * mediumBendSize;
            pY += jitterData.GetDeltaY() * mediumBendSize;

            generator.SimplexInstance(4).GetValue(x / 30.0d, y / 30.0d, jitterData);
            pX += jitterData.GetDeltaX() * smallBendSize;
            pY += jitterData.GetDeltaY() * smallBendSize;

            VoronoiResult lakeResults = generator.CellularInstance(0).Eval2D(pX / lakeInterval, pY / lakeInterval);

            return((float)(1.0d - lakeResults.InteriorValue));
        }
예제 #3
0
        public override float Added(OverworldGeneratorV2 generator, float x, float y)
        {
            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            generator.SimplexInstance(1).GetValue(x / Wavelength, y / Wavelength, jitterData);
            int pX = (int)Math.Round(x + jitterData.GetDeltaX() * Amplitude);
            int pY = (int)Math.Round(y + jitterData.GetDeltaY() * Amplitude);

            return(Jittered.Added(generator, pX, pY));
        }
        public override float GenerateNoise(OverworldGeneratorV2 generator, int passedX, int passedY, float border, float river)
        {
            var jitterData = SimplexData2D.NewDisk();

            generator.SimplexInstance(1).GetValue(passedX / _jitterWavelength, passedY / _jitterWavelength, jitterData);
            float x         = (float)(passedX + jitterData.GetDeltaX() * _jitterAmplitude);
            float y         = (float)(passedY + jitterData.GetDeltaY() * _jitterAmplitude);
            float bordercap = (bordercap = border * 3.5f - 2.5f) > 1 ? 1.0f : bordercap;
            float rivercap  = (rivercap = 3f * river) > 1 ? 1.0f : rivercap;
            float bumpiness = generator.SimplexInstance(2).GetValue(x / _bumpinessWavelength, y / _bumpinessWavelength) * _bumpinessMultiplier;
            float simplex   = _plateau.Added(generator, x, y) * bordercap * rivercap + bumpiness;
            float added     = PlateauUtil.StepIncrease(simplex, _stepStart, _stepFinish, _stepHeight) / border;

            return(Riverized(generator, BaseHeight + GetGroundNoise(x, y, _groundNoise, generator), river) + added);
        }
        private void FixBiomes(ChunkColumn column,
                               ChunkLandscape landscape, int[] neighboring)
        {
            var orginalBiomes = landscape.Biome.ToArray();

            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            BiomeBase[] jitteredBiomes = new BiomeBase[256];
            BiomeBase   jitterbiome, actualbiome;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    int x = (column.X * 16) + i;
                    int z = (column.Z * 16) + j;
                    this.SimplexInstance(0).GetValue(x, z, jitterData);
                    int pX = (int)Math.Round(x + jitterData.GetDeltaX() * BlendRadius);
                    int pZ = (int)Math.Round(z + jitterData.GetDeltaY() * BlendRadius);
                    actualbiome = landscape.Biome[(x & 15) * 16 + (z & 15)];
                    jitterbiome = landscape.Biome[(pX & 15) * 16 + (pZ & 15)];
                    jitteredBiomes[i * 16 + j] = (actualbiome.Config.SurfaceBlendIn && jitterbiome.Config.SurfaceBlendOut) ? jitterbiome : actualbiome;
                }
            }


            BiomeBase realisticBiome;
            int       realisticBiomeId;


            var noise = landscape.Noise;
            var riverStrength = landscape.River;

            // currently just stuffs the genLayer into the jitter;
            for (int i = 0; i < MAX_BIOMES; i++)
            {
                realisticBiome = orginalBiomes[i];

                bool canBeRiver = riverStrength[i] > 0.7;

                if (noise[i] > 61.5)
                {
                    // replace
                    jitteredBiomes[i] = realisticBiome;
                }
                else
                {
                    // check for river
                    if (canBeRiver && (realisticBiome.Type & BiomeType.Ocean) == 0 && (realisticBiome.Type & BiomeType.Swamp) == 0)
                    {
                        // make river
                        jitteredBiomes[i] = BiomeProvider.GetBiome(realisticBiome.GetRiverBiome());
                    }
                    else
                    {
                        // replace
                        jitteredBiomes[i] = realisticBiome;
                    }
                }
            }

            //  SmoothingSearchStatus beachSearch = new SmoothingSearchStatus(BeachBiome);
            SmoothingSearchStatus landSearch = new SmoothingSearchStatus(LandBiome);

            /*  beachSearch.SetNotHunted();
             * beachSearch.SetAbsent();
             *
             * landSearch.SetNotHunted();
             * landSearch.SetAbsent();*/
            // beachSearch.Hunt(neighboring);
            landSearch.Hunt(neighboring);

            float beachTop = 64.5f;

            for (int i = 0; i < MAX_BIOMES; i++)
            {
                float beachBottom = 61.5f;

                if (noise[i] < beachBottom || noise[i] > RiverAdjusted(beachTop, riverStrength[i]))
                {
                    continue;// this block isn't beach level
                }

                if ((jitteredBiomes[i].Type & BiomeType.Swamp) != 0)
                {
                    continue;
                }

                /* if (beachSearch.IsNotHunted())
                 * {
                 *   beachSearch.Hunt(neighboring);
                 *   landSearch.Hunt(neighboring);
                 * }*/

                //   int foundBiome = beachSearch.Biomes[i];
                // if (foundBiome != -1) {
                int nearestLandBiome = landSearch.Biomes[i];

                if (nearestLandBiome > -1)
                {
                    var foundBiome = BiomeProvider.GetBiome(nearestLandBiome).GetBeachBiome();
                    var biome      = BiomeProvider.GetBiome(foundBiome);

                    if (biome != null && biome.Terrain != null && biome.Surface != null)
                    {
                        jitteredBiomes[i] = biome;
                    }
                }

                //
                // }
            }

            landscape.Biome = jitteredBiomes;
        }