예제 #1
0
파일: QuadTree.cs 프로젝트: suzuke/forge
        /// <summary>
        /// Creates a new chunk located at the given x and z index coordinates.
        /// </summary>
        private Node <TItem> GenerateChunk(int xIndex, int zIndex)
        {
            int xWorld, zWorld;

            WorldIndexCoordinateTransform.ConvertIndexToWorld(_worldScale,
                                                              xIndex, zIndex, out xWorld, out zWorld);

            Rect rect = new Rect(xWorld, zWorld, xWorld + _worldScale, zWorld + _worldScale);

            return(new Node <TItem>(rect));
        }
예제 #2
0
파일: QuadTree.cs 프로젝트: suzuke/forge
        /// <summary>
        /// Returns the chunk located at the given x and z world coordinates.
        /// </summary>
        private Node <TItem> GetChunk(int xWorld, int zWorld)
        {
            int xIndex, zIndex;

            WorldIndexCoordinateTransform.ConvertWorldToIndex(_worldScale,
                                                              xWorld, zWorld, out xIndex, out zIndex);

            if (xIndex >= _chunks.GetLength(0) || zIndex >= _chunks.GetLength(1))
            {
                _chunks = GrowArray(_chunks, xIndex + 1, zIndex + 1, GenerateChunk);
            }

            return(_chunks[xIndex, zIndex]);
        }