Example #1
0
        public override IEnumerable <ProceduralObject> Generate(BoundingSphereD include, BoundingSphereD?exclude)
        {
            var mult = _config.ViewDistance / include.Radius;

            include.Radius *= mult;
            if (exclude.HasValue)
            {
                exclude = new BoundingSphereD(exclude.Value.Center, exclude.Value.Radius * mult);
            }

            var min = Vector3D.Floor((include.Center - include.Radius) / _config.SystemSpacing);
            var max = Vector3D.Floor(((include.Center + include.Radius) / _config.SystemSpacing) + 1.0D);

            for (var x = min.X; x < max.X; x++)
            {
                for (var y = min.Y; y < max.Y; y++)
                {
                    for (var z = min.Z; z < max.Z; z++)
                    {
                        var seedVec = new Vector3I(x, y, z);
                        var seed    = seedVec.GetHashCode();
                        var rand    = new Random(seed);
                        if (rand.NextDouble() >= _config.SystemProbability)
                        {
                            continue;
                        }
                        if (_systems.ContainsKey(seedVec))
                        {
                            continue;
                        }
                        var world = (new Vector3D(x, y, z) + 0.5) * _config.SystemSpacing + rand.NextVector3D() * (_config.SystemSpacing / 8);
                        if (include.Contains(world) == ContainmentType.Disjoint || (exclude.HasValue && exclude.Value.Contains(world) != ContainmentType.Disjoint))
                        {
                            continue;
                        }

                        var list = _config.Systems.Where(s => s.MinDistanceFromOrigin <= world.Length()).ToList();
                        var ttl  = list.Sum(s => s.Probability);
                        foreach (var s in list)
                        {
                            if (ttl <= s.Probability)
                            {
                                var position = MatrixD.CreateFromQuaternion(rand.NextQuaternion());
                                position.Translation = world;
                                var result = new ProceduralSystem(this, s, rand.NextLong(), position);
                                _systems.Add(seedVec, result);
                                foreach (var b in result.Bodies)
                                {
                                    _addQueue.Enqueue(b);
                                }
                                yield return(result);

                                break;
                            }
                            ttl -= s.Probability;
                        }
                    }
                }
            }
        }
 public void Init(ref Vector3I pos, MyPlanet planet)
 {
     m_pos = pos;
     m_cellHashCode = pos.GetHashCode() + planet.PositionLeftBottomCorner.GetHashCode();
     m_planet = planet;
     SectorBox = new BoundingBoxD(m_planet.PositionLeftBottomCorner + pos * SECTOR_SIZE_METERS, m_planet.PositionLeftBottomCorner + pos * SECTOR_SIZE_METERS + SECTOR_SIZE_METERS);
     m_sectorCenter = SectorBox.Center;
 }
 public void Init(ref Vector3I pos, MyPlanet planet)
 {
     m_pos          = pos;
     m_cellHashCode = pos.GetHashCode() + planet.PositionLeftBottomCorner.GetHashCode();
     m_planet       = planet;
     SectorBox      = new BoundingBoxD(m_planet.PositionLeftBottomCorner + pos * SECTOR_SIZE_METERS, m_planet.PositionLeftBottomCorner + pos * SECTOR_SIZE_METERS + SECTOR_SIZE_METERS);
     m_sectorCenter = SectorBox.Center;
 }
Example #4
0
            public MoveId(ref Vector3I position, ref Vector3I direction)
            {
                this.position  = position;
                this.direction = direction;

                unchecked
                {
                    hashCode = 17;
                    hashCode = hashCode * 31 + position.GetHashCode();
                    hashCode = hashCode * 31 + direction.GetHashCode();
                }
            }
Example #5
0
        public override int GetHashCode()
        {
            if (IsDynamic)
            {
                return((int)_entityId);
            }

            var hash = _chunkPosition.GetHashCode();

            if (_tail != null)
            {
                for (int i = 0; i < _tail.Length; i++)
                {
                    hash += (int)_tail[i] << (int)(32 * ((float)i + 1) / _tail.Length);
                }
            }

            return(hash);
        }
Example #6
0
        /// <summary>
        /// Specialy created to render quickly the landscape in order to be used by LandscapeItem Manager
        /// </summary>
        /// <param name="chunkBytes"></param>
        /// <param name="chunkPosition"></param>
        public void GenerateMacroLandscape(Vector3I chunkPosition, out Biome biome, out byte[] chunkBytes, out FastRandom chunkRnd, out ChunkColumnInfo[] columnsInfo)
        {
            Range3I chunkWorldRange = new Range3I()
            {
                Position = new Vector3I(chunkPosition.X * AbstractChunk.ChunkSize.X, 0, chunkPosition.Z * AbstractChunk.ChunkSize.Z),
                Size     = AbstractChunk.ChunkSize
            };

            chunkBytes  = new byte[AbstractChunk.ChunkBlocksByteLength];
            columnsInfo = new ChunkColumnInfo[AbstractChunk.ChunkSize.X * AbstractChunk.ChunkSize.Z];
            chunkRnd    = new FastRandom(_worldParameters.Seed + chunkPosition.GetHashCode());

            double[,] biomeMap;
            GenerateLandscape(chunkBytes, ref chunkWorldRange, out biomeMap);
            TerraForming(chunkBytes, columnsInfo, ref chunkWorldRange, biomeMap, chunkRnd);

            var metaData = CreateChunkMetaData(columnsInfo);

            biome = _config.ProcessorParam.Biomes[metaData.ChunkMasterBiomeType];
        }
Example #7
0
 public override int GetHashCode()
 {
     return(Size.GetHashCode() * 1610612741 + Center.GetHashCode());
 }
 public override int GetHashCode()
 {
     return(A.GetHashCode() * 1610612741 + B.GetHashCode());
 }
Example #9
0
 public override int GetHashCode()
 {
     return(VoxelMap.GetHashCode() * 1610612741 + Pos.GetHashCode());
 }
Example #10
0
 public override int GetHashCode()
 {
     return(BlockDefinition.Id.GetHashCode() + 17 * Position.GetHashCode() + 137 * Orientation.GetHashCode());
 }
Example #11
0
 public override int GetHashCode()
 {
     return(relativePosRounded.GetHashCode() ^ direction.GetHashCode());
 }
Example #12
0
 public override int GetHashCode()
 {
     return(Grid.GetHashCode() * 1610612741 + Coords.GetHashCode());
 }
Example #13
0
        public void TestGetHashCode()
        {
            Vector3I a = new Vector3I(1, 2, 3);
            Vector3I b = new Vector3I(4, 5, 6);
            Vector3I c = new Vector3I(1, 2, 3);

            Assert.AreEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }