示例#1
0
    void IEntity.EUpdate(float delta)
    {
        if (Spatial == null)
        {
            Spatial = FindObjectOfType <SpatialIndex>();
        }

        mIsGrounded = Physics.CheckSphere(GroundCheck.position, GroundDistance, GroundMask);

        if (mIsGrounded && mVelocity.y < 0)
        {
            mVelocity.y = -2f;

            Spatial.GetFloorState(transform.position.x, transform.position.z, gameObject);
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        Controller.Move(move * Speed * Time.deltaTime);

        if (Input.GetButtonDown("Jump") && mIsGrounded)
        {
            mVelocity.y = Mathf.Sqrt(JumpHeight * -2f * Physics.gravity.y);
        }

        if (!FlyMode)
        {
            mVelocity += Physics.gravity * Time.deltaTime;
            Controller.Move(mVelocity * Time.deltaTime);
        }
    }
示例#2
0
 internal NtxImport(string fileName, ITranslate t) : base(fileName)
 {
     m_Translator = t;
     m_Result     = new List <Feature>(1000);
     m_Index      = new SpatialIndex();
     m_KeyIndex   = new Dictionary <string, ForeignId>(1000);
 }
示例#3
0
            public Sales_ByLocation()
            {
                AddMap <Sale>(sales => from sale in sales
                              select new
                {
                    _         = (object)null,
                    SaleId    = sale.Id,
                    Locations = sale.Locations.Select(l => new { l.Lat, l.Lng }).ToArray(),
                    TotalSold = 0
                });

                AddMap <Order>(orders => from order in orders
                               select new
                {
                    _ = (object)null,
                    order.SaleId,
                    Locations = new[] { new { Lat = (double)0, Lng = (double)0 } },
                    TotalSold = 1
                });

                Reduce = sitesales => from sitesale in sitesales
                         group sitesale by sitesale.SaleId
                         into sales
                         let locations = sales.SelectMany(x => x.Locations)
                                         from sale in sales
                                         select new
                {
                    _ = locations.Select(l => SpatialIndex.Generate(l.Lat, l.Lng)),
                    // marking this as empty works
                    sale.SaleId,
                    Locations = locations,
                    TotalSold = sales.Sum(x => x.TotalSold)
                };
            }
示例#4
0
文件: Scene.cs 项目: git-thinh/limada
        protected IVisual TestHit(Point p, int hitSize, Func <IVisual, Point, int, bool> hitTest)
        {
            if (p == _noHit)
            {
                return(null);
            }
            if ((Focused != null) && hitTest(Focused, p, hitSize))
            {
                return(Focused);
            }
            if ((Hovered != null) && hitTest(Hovered, p, hitSize))
            {
                return(Hovered);
            }
            int halfSize  = hitSize / 2;
            var hitBounds = new Rectangle(p.X - halfSize, p.Y - halfSize, hitSize, hitSize);

            foreach (var visual in SpatialIndex.Query(hitBounds, ZOrder.EdgesFirst))
            {
                if ((visual == Focused) || (visual == Hovered))
                {
                    continue;
                }
                if (hitTest(visual, p, hitSize))
                {
                    return(visual);
                }
            }

            _noHit = p;
            return(null);
        }
示例#5
0
        public void AddsMultipleAndRemovesSingleEntry()
        {
            var index = new SpatialIndex <MockGameObject>();

            var p1  = new Point(0, 0);
            var obj = new MockGameObject(p1);

            index.Insert(p1, obj);

            var p2 = new Point(-55, 654);

            index.Insert(p2, new MockGameObject(p2));

            // Validate total buckets
            Assert.AreEqual(index.Keys.Count, 2);

            // Validate bucket count
            var bucket = index.Get(p1);

            Assert.AreEqual(bucket.Count, 1);

            index.Remove(p1, obj);

            // Validate total buckets
            Assert.AreEqual(index.Keys.Count, 1);
        }
示例#6
0
        public SpatialDistanceSortField(string field, bool reverse, SpatialIndexQuery qry)
            : base(field, CUSTOM, reverse)
        {
            var shape = SpatialIndex.ReadShape(qry.QueryShape);

            center = shape.GetCenter();
        }
        public IEnumerable <IFieldable> SpatialGenerate(string fieldName, string shapeWKT,
                                                        SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree,
                                                        int maxTreeLevel = 0, double distanceErrorPct = 0.025)
        {
            if (string.IsNullOrEmpty(shapeWKT))
            {
                return(Enumerable.Empty <IFieldable>());
            }

            if (maxTreeLevel == 0)
            {
                switch (spatialSearchStrategy)
                {
                case SpatialSearchStrategy.GeohashPrefixTree:
                    maxTreeLevel = 9;                             // about 2 meters, should be good enough (see: http://unterbahn.com/2009/11/metric-dimensions-of-geohash-partitions-at-the-equator/)
                    break;

                case SpatialSearchStrategy.QuadPrefixTree:
                    maxTreeLevel = 25;                             // about 1 meter, should be good enough
                    break;

                default:
                    throw new ArgumentOutOfRangeException("spatialSearchStrategy");
                }
            }
            var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel));

            var shape = SpatialIndex.ReadShape(shapeWKT);

            return(strategy.CreateIndexableFields(shape)
                   .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.WriteShape(shape), Field.Store.YES, Field.Index.NO), }));
        }
            private double CalculateDistance(int doc)
            {
                var document = currentIndexReader.Document(doc);

                if (document == null)
                {
                    return(double.NaN);
                }
                var field = document.GetField(Constants.SpatialShapeFieldName);

                if (field == null)
                {
                    return(double.NaN);
                }
                var   shapeAsText = field.StringValue;
                Shape shape;

                try
                {
                    shape = SpatialIndex.ReadShape(shapeAsText);
                }
                catch (InvalidOperationException)
                {
                    return(double.NaN);
                }
                var pt = shape as Point;

                if (pt == null)
                {
                    pt = shape.GetCenter();
                }
                return(SpatialIndex.Context.GetDistCalc().Distance(pt, originPt));
            }
示例#9
0
 public WorldModel(int MaxX, int MaxY, int MaxZ)
 {
     this.MaxX = MaxX;
     this.MaxY = MaxY;
     this.MaxZ = MaxZ;
     Models = new List<GameModel>();
     this.SpacialIndex = new SpatialIndex(this, 10, 10);
 }
示例#10
0
 public BusRoute_Spatial()
 {
     Map = busRoutes => from busRoute in busRoutes
           select new
     {
         _ = SpatialIndex.Generate(busRoute.Stop.Latitude, busRoute.Stop.Longitude)
     };
 }
示例#11
0
文件: Spatial.cs 项目: tal952/ravendb
 public MySpatialIndex()
 {
     Map = docs =>
           from doc in docs
           select new
     {
         _ = SpatialIndex.Generate(doc.Latitude, doc.Longitude)
     };
 }
示例#12
0
文件: chad.cs 项目: xinix00/ravendb
 public Place_ByLocationAndCategoryId()
 {
     Map = places => from p in places
           select
           new
     {
         Categories_Id = p.Categories.Select(x => x.Id),
         _             = SpatialIndex.Generate(p.Location.Lat, p.Location.Lng)
     };
 }
示例#13
0
 public ByVehicle()
 {
     Map = vehicles => from vehicle in vehicles
           select new
     {
         vehicle.Model,
         vehicle.Make,
         _ = SpatialIndex.Generate(vehicle.Latitude, vehicle.Longitude)
     };
 }
示例#14
0
 public SpatialStrategy GetStrategyForField(string fieldName)
 {
     return(SpatialStrategies.GetOrAdd(fieldName, s =>
     {
         if (SpatialStrategies.Count > 1024)
         {
             throw new InvalidOperationException("The number of spatial fields in an index is limited ot 1,024");
         }
         return SpatialIndex.CreateStrategy(fieldName, SpatialSearchStrategy.GeohashPrefixTree, GeohashPrefixTree.GetMaxLevelsPossible());
     }));
 }
示例#15
0
 /// <summary> Creates instance of <see cref="ElementSource" /> from persistent storage. </summary>
 /// <param name="directory">Already resolved directory which contains all indecies.</param>
 /// <param name="fileService">File system service.</param>
 /// <param name="objectPool">ObjectPool.</param>
 internal ElementSource(string directory, IFileSystemService fileService, IObjectPool objectPool)
 {
     // load map data from streams
     BoundingBox      = PersistentIndexBuilder.ReadBoundingBox(fileService.ReadStream(string.Format(MapConsts.HeaderPathFormat, directory)));
     KvUsage          = new KeyValueUsage(fileService.ReadStream(string.Format(MapConsts.KeyValueUsagePathFormat, directory)));
     KvIndex          = KeyValueIndex.Load(fileService.ReadStream(string.Format(MapConsts.KeyValueIndexPathFormat, directory)));
     KvStore          = new KeyValueStore(KvIndex, KvUsage, fileService.ReadStream(string.Format(MapConsts.KeyValueStorePathFormat, directory)));
     ElementStore     = new ElementStore(KvStore, fileService.ReadStream(string.Format(MapConsts.ElementStorePathFormat, directory)), objectPool);
     SpatialIndexTree = SpatialIndex.Load(fileService.ReadStream(string.Format(MapConsts.SpatialIndexPathFormat, directory)));
     IsReadOnly       = true;
 }
        private SpatialIndex EnsureSpatialIndex(int i, int j)
        {
            SpatialIndex spatialIndex = this.spatialIndices[i, j];

            if (spatialIndex == null)
            {
                spatialIndex = new SpatialIndex();
                this.spatialIndices[i, j] = spatialIndex;
            }
            return(spatialIndex);
        }
示例#17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CadastralFile"/> class.
        /// </summary>
        /// <param name="name">The name of the xml file</param>
        /// <param name="data">The data that was deserialized</param>
        internal CadastralFile(string name, GeoSurveyPacketData data)
        {
            m_Name   = Path.GetFileName(name);
            m_Data   = data;
            m_Extent = new Window(m_Data.points);
            m_Points = new Dictionary <int, IPoint>(m_Data.points.Length);

            IEditSpatialIndex index = new SpatialIndex();

            foreach (Point p in m_Data.points)
            {
                index.Add(p);
                m_Points.Add(p.pointNo, p);
            }

            foreach (Plan plan in m_Data.plans)
            {
                foreach (Parcel parcel in plan.parcels)
                {
                    // Relate the parcel to it's plan
                    parcel.Plan = plan;

                    foreach (Line line in parcel.lines)
                    {
                        Debug.Assert(line.From == null && line.To == null);

                        // Relate the line to the parcel that it is part of
                        line.Parcel = parcel;

                        line.From = m_Points[line.fromPoint];
                        line.To   = m_Points[line.toPoint];

                        if (line.centerPointSpecified)
                        {
                            line.Center = m_Points[line.centerPoint];
                        }

                        index.Add(line);
                    }

                    /*
                     * foreach (LinePoint lp in parcel.linePoints)
                     * {
                     *  // Relate to the parcel it's referenced by
                     *
                     *  // Relate the associated point
                     * }
                     */
                }
            }

            m_Index = index;
        }
示例#18
0
        public IEnumerable <IFieldable> SpatialGenerate(string fieldName, double?lat, double?lng)
        {
            var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, SpatialSearchStrategy.GeohashPrefixTree,
                                                                                                  GeohashPrefixTree.GetMaxLevelsPossible()));

// ReSharper disable CSharpWarnings::CS0612
            Shape shape = SpatialIndex.Context.MakePoint(lng ?? 0, lat ?? 0);

            return(strategy.CreateIndexableFields(shape)
                   .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.ShapeReadWriter.WriteShape(shape), Field.Store.YES, Field.Index.NO), }));
// ReSharper restore CSharpWarnings::CS0612
        }
示例#19
0
        public int?FindPointIdx([NotNull] Pnt3D point, bool inXY,
                                double tolerance   = double.Epsilon,
                                bool allowIndexing = true)
        {
            if (SpatialIndex == null && allowIndexing &&
                SegmentCount > AllowIndexingThreshold)
            {
                SpatialIndex = SpatialHashSearcher <int> .CreateSpatialSearcher(this);
            }

            if (SpatialIndex != null)
            {
                foreach (int foundSegmentIdx in SpatialIndex.Search(point, tolerance))
                {
                    Line3D segment = this[foundSegmentIdx];

                    bool found = inXY
                                                             ? segment.StartPoint.EqualsXY(point, tolerance)
                                                             : segment.StartPoint.Equals(point, tolerance);

                    if (found)
                    {
                        return(foundSegmentIdx);
                    }
                }
            }
            else
            {
                for (var i = 0; i < SegmentCount; i++)
                {
                    bool found = inXY
                                                             ? _segments[i].StartPoint.EqualsXY(point, tolerance)
                                                             : _segments[i].StartPoint.Equals(point, tolerance);

                    if (found)
                    {
                        return(i);
                    }
                }
            }

            bool isEndPoint = inXY
                                                  ? EndPoint.EqualsXY(point, tolerance)
                                                  : EndPoint.Equals(point, tolerance);

            if (isEndPoint)
            {
                return(PointCount - 1);
            }

            return(null);
        }
示例#20
0
 public AccItems_Spatial()
 {
     Map = items =>
           from i in items
           select new
     {
         i,
         __distance = SpatialIndex.Generate((double)i.Lat, (double)i.Lon),
         i.Name,
         i.Bedrooms,
         i.Attributes
     };
 }
        private SpatialIndex Read_SpatialIndex(BinaryReader reader)
        {
            var result = new SpatialIndex();

            result.Version = ReadVersion(reader, 1, 0x1411C03B0);

            result.Info         = Read_SpatialIndex_Info(reader);
            result.Nodes        = Read_List(reader, Read_SpatialIndex_Node, 1, 0x1411CD350);
            result.LevelOffsets = Read_LevelOffsets(reader, 12);

            result.NumLevels = reader.ReadInt32();

            return(result);
        }
示例#22
0
        public IEnumerable <IFieldable> SpatialGenerate(string fieldName, string shapeWKT,
                                                        SpatialSearchStrategy spatialSearchStrategy = SpatialSearchStrategy.GeohashPrefixTree,
                                                        int maxTreeLevel = 0, double distanceErrorPct = 0.025)
        {
            if (maxTreeLevel == 0)
            {
                maxTreeLevel = GeohashPrefixTree.GetMaxLevelsPossible();
            }
            var strategy = SpatialStrategies.GetOrAdd(fieldName, s => SpatialIndex.CreateStrategy(fieldName, spatialSearchStrategy, maxTreeLevel));

            var shape = SpatialIndex.ShapeReadWriter.ReadShape(shapeWKT);

            return(strategy.CreateIndexableFields(shape)
                   .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.ShapeReadWriter.WriteShape(shape), Field.Store.YES, Field.Index.NO), }));
        }
        private void SetAreaTriggerBuildingsInRangeOf(int x, int z, SpatialIndex spatialIndex)
        {
            Board <Entity>     board  = Service.Get <BoardController>().Board;
            BoardCell <Entity> cellAt = board.GetCellAt(x, z, true);

            spatialIndex.AlreadyScannedAreaTriggerBuildingsInRange = true;
            NodeList <AreaTriggerBuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <AreaTriggerBuildingNode>();

            for (AreaTriggerBuildingNode areaTriggerBuildingNode = nodeList.Head; areaTriggerBuildingNode != null; areaTriggerBuildingNode = areaTriggerBuildingNode.Next)
            {
                Entity entity   = areaTriggerBuildingNode.Entity;
                int    num      = this.CalcSquredDistanceFromTransformToCell(areaTriggerBuildingNode.TransformComp, cellAt);
                int    nearness = this.CalcNearness(num);
                spatialIndex.AddAreaTriggerBuildingsInRangeOf(entity, num, nearness);
            }
        }
        public List <ElementPriorityPair <Entity> > GetAreaTriggerBuildingsInRangeOf(int x, int z)
        {
            Board <Entity> board = Service.Get <BoardController>().Board;

            board.MakeCoordinatesAbsolute(ref x, ref z);
            if (this.IsPositionInvalid(x, z))
            {
                return(null);
            }
            SpatialIndex spatialIndex = this.EnsureSpatialIndex(x, z);

            if (!spatialIndex.AlreadyScannedAreaTriggerBuildingsInRange)
            {
                this.SetAreaTriggerBuildingsInRangeOf(x, z, spatialIndex);
            }
            return(spatialIndex.GetArareaTriggerBuildingsInRange());
        }
        public PriorityList <SmartEntity> GetBuildingsToAttack(int x, int z)
        {
            Board <Entity> board = Service.Get <BoardController>().Board;

            board.MakeCoordinatesAbsolute(ref x, ref z);
            if (this.IsPositionInvalid(x, z))
            {
                return(null);
            }
            SpatialIndex spatialIndex = this.EnsureSpatialIndex(x, z);

            if (!spatialIndex.AlreadyScannedBuildingsToAttack)
            {
                this.SetBuildingsToAttack(x, z, spatialIndex);
            }
            return(spatialIndex.GetBuildingsToAttack());
        }
示例#26
0
        public List <EntityElementPriorityPair> GetTurretsInRangeOf(int x, int z)
        {
            Board board = Service.BoardController.Board;

            board.MakeCoordinatesAbsolute(ref x, ref z);
            if (this.IsPositionInvalid(x, z))
            {
                return(null);
            }
            SpatialIndex spatialIndex = this.EnsureSpatialIndex(x, z);

            if (!spatialIndex.AlreadyScannedTurretsInRange)
            {
                this.SetTurretsInRangeOf(x, z, spatialIndex);
            }
            return(spatialIndex.GetTurretsInRangeOf());
        }
示例#27
0
        public override void Build()
        {
            var sw = new Stopwatch();

            sw.Start();

            var sourceStream = _fileSystemService.ReadStream(_filePath);
            var format       = _filePath.Split('.').Last();
            var reader       = GetReader(format);

            var kvUsageMemoryStream = new MemoryStream();
            var kvUsage             = new KeyValueUsage(kvUsageMemoryStream);

            var keyValueStoreFile = _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueStorePathFormat, _outputDirectory));
            var index             = new KeyValueIndex(Settings.Search.KvIndexCapacity, Settings.Search.PrefixLength);
            var keyValueStore     = new KeyValueStore(index, kvUsage, keyValueStoreFile);

            var storeFile = _fileSystemService.WriteStream(String.Format(MapConsts.ElementStorePathFormat, _outputDirectory));

            Store = new ElementStore(keyValueStore, storeFile, ObjectPool);
            Tree  = new RTree <uint>(65);

            reader.Read(new ReaderContext
            {
                SourceStream  = sourceStream,
                Builder       = this,
                ReuseEntities = false,
                SkipTags      = false,
            });

            Clear();
            Complete();

            using (var kvFileStream = _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueUsagePathFormat, _outputDirectory)))
            {
                var buffer = kvUsageMemoryStream.GetBuffer();
                kvFileStream.Write(buffer, 0, (int)kvUsageMemoryStream.Length);
            }

            KeyValueIndex.Save(index, _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueIndexPathFormat, _outputDirectory)));
            SpatialIndex.Save(Tree, _fileSystemService.WriteStream(String.Format(MapConsts.SpatialIndexPathFormat, _outputDirectory)));
            Store.Dispose();

            sw.Stop();
            Trace.Debug(CategoryKey, Strings.IndexBuildInMs, sw.ElapsedMilliseconds.ToString());
        }
示例#28
0
        public static Sort GetSort(this IndexQuery self, IndexDefinition indexDefinition)
        {
            var spatialQuery = self as SpatialIndexQuery;
            var sortedFields = self.SortedFields;

            if (sortedFields == null || sortedFields.Length <= 0)
            {
                if (spatialQuery == null || string.IsNullOrEmpty(self.Query) == false)
                {
                    return(null);
                }
                sortedFields = new[] { new SortedField(Constants.DistanceFieldName), };
            }

            return(new Sort(sortedFields
                            .Select(sortedField =>
            {
                if (sortedField.Field == Constants.TemporaryScoreValue)
                {
                    return SortField.FIELD_SCORE;
                }
                if (sortedField.Field.StartsWith(Constants.RandomFieldName))
                {
                    var parts = sortedField.Field.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length < 2)                                                     // truly random
                    {
                        return new RandomSortField(Guid.NewGuid().ToString());
                    }
                    return new RandomSortField(parts[1]);
                }
                if (spatialQuery != null && sortedField.Field == Constants.DistanceFieldName)
                {
                    var shape = SpatialIndex.ReadShape(spatialQuery.QueryShape);
                    var dsort = new SpatialDistanceFieldComparatorSource(shape.GetCenter());
                    return new SortField(Constants.DistanceFieldName, dsort, sortedField.Descending);
                }
                var sortOptions = GetSortOption(indexDefinition, sortedField.Field);
                if (sortOptions == null || sortOptions == SortOptions.None)
                {
                    return new SortField(sortedField.Field, CultureInfo.InvariantCulture, sortedField.Descending);
                }

                return new SortField(sortedField.Field, (int)sortOptions.Value, sortedField.Descending);
            })
                            .ToArray()));
        }
示例#29
0
        public IEnumerable <IFieldable> SpatialGenerate(string fieldName, double?lat, double?lng)
        {
            var strategy = GetStrategyForField(fieldName);

            if (lng == null || double.IsNaN(lng.Value))
            {
                return(Enumerable.Empty <IFieldable>());
            }
            if (lat == null || double.IsNaN(lat.Value))
            {
                return(Enumerable.Empty <IFieldable>());
            }

            Shape shape = SpatialIndex.Context.MakePoint(lng.Value, lat.Value);

            return(strategy.CreateIndexableFields(shape)
                   .Concat(new[] { new Field(Constants.SpatialShapeFieldName, SpatialIndex.WriteShape(shape), Field.Store.YES, Field.Index.NO), }));
        }
        private void SetBuildingsToAttack(int x, int z, SpatialIndex spatialIndex)
        {
            Board <Entity>          board    = Service.Get <BoardController>().Board;
            BoardCell <Entity>      cellAt   = board.GetCellAt(x, z, true);
            NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();

            spatialIndex.AlreadyScannedBuildingsToAttack = true;
            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                SmartEntity smartEntity = (SmartEntity)buildingNode.Entity;
                if (smartEntity.DamageableComp != null && this.IsAliveHealthNode(smartEntity))
                {
                    int squaredDistance = this.CalcSquredDistanceFromTransformToCell(smartEntity.TransformComp, cellAt);
                    int nearness        = this.CalcNearness(squaredDistance);
                    spatialIndex.AddBuildingsToAttack(smartEntity, nearness);
                }
            }
        }
示例#31
0
        public ShapeFile(string fileName)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException();
            }

            m_MapName = fileName;
            IEditSpatialIndex index = new SpatialIndex();

            ShapefileDataReader sfdr = Shapefile.CreateDataReader(fileName, new GeometryFactory());
            ShapefileHeader     hdr  = sfdr.ShapeHeader;
            Envelope            ex   = hdr.Bounds;

            m_Extent = new Window(ex.MinX, ex.MinY, ex.MaxX, ex.MaxY);

            foreach (object o in sfdr)
            {
                // You get back an instance of GisSharpBlog.NetTopologySuite.IO.RowStructure, but
                // that's internal, so cast to the interface it implements (we'll attach this to
                // the geometry we wrap).
                //ICustomTypeDescriptor row = (ICustomTypeDescriptor)o;
                AdhocPropertyList row  = CreatePropertyList(sfdr);
                NTS.Geometry      geom = sfdr.Geometry;
                geom.UserData = row;

                List <NTS.Geometry> geoms = GetBasicGeometries(geom);
                foreach (NTS.Geometry g in geoms)
                {
                    g.UserData = row;
                    if (g is NTS.Point)
                    {
                        index.Add(new PointWrapper((NTS.Point)g));
                    }
                    else
                    {
                        index.Add(new GeometryWrapper(g));
                    }
                }
            }

            // Don't permit any further additions
            m_Index = index;
        }
示例#32
0
        /// <summary>
        /// Called when the game is starting.
        /// </summary>
        public override void OnStartup()
        {
            for (var x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    for (int z = 0; z < 10; z++)
                    {
                        this.box[x * 100 + y * 10 + z] = new Box
                        {
                            Bounds = new BoundingBox(new Vector3(x - 4.5f, y - 4.5f, z - 4.5f), new Vector3(0.25f))
                        };
                    }
                }
            }

            this.index = new SpatialIndex<Box>(this.box);
            this.buffer.Cube(0.5f, 0.5f, 0.5f);
        }