예제 #1
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));
        }
예제 #2
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));
        }
예제 #3
0
        public virtual void GetValue(double x, double y, ISimplexData2D data)
        {
            //Get points for A2 lattice
            double s  = _stretch2D * (x + y);
            double xs = x + s;
            double ys = y + s;

            //Get base points and offsets
            int    xsb = Libnoise.FastFloor(xs);
            int    ysb = Libnoise.FastFloor(ys);
            double xsi = xs - xsb;
            double ysi = ys - ysb;

            //Index to point list
            int a     = (int)(ysi - xsi + 1);
            int index = (a << 2) | (int)(xsi + ysi / 2.0 + a / 2.0) << 3 |
                        (int)(ysi + xsi / 2.0 + 1.0 / 2.0 - a / 2.0) << 4;

            //Get unskewed offsets.
            double ssi = (xsi + ysi) * _squish2D;
            double xi  = xsi + ssi;
            double yi  = ysi + ssi;

            // clear data
            data.Clear();

            //Point contributions
            for (int i = 0; i < 4; i++)
            {
                LatticePoint2D lattice = _lookup2D[index + i];

                double dx   = xi + lattice.Dx;
                double dy   = yi + lattice.Dy;
                double attn = 2.0 - (dx * dx) - (dy * dy);
                if (attn <= 0)
                {
                    continue;
                }

                int    pxm    = (xsb + lattice.Xsv) & 1023;
                int    pym    = (ysb + lattice.Ysv) & 1023;
                int    giP    = _perm[pxm] ^ pym;
                int    gi     = _perm2D[giP];
                double gx     = Gradients2D[gi];
                double gy     = Gradients2D[gi + 1];
                double extrp  = gx * dx + gy * dy;
                int    giSph2 = _perm2DSph2[giP];
                data.Request().Apply(attn, extrp, gx, gy, giSph2, dx, dy);
            }
        }
        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;
        }