Slot for a terrain instance, together with its definition.
Inheritance: IDisposable
Exemple #1
0
        protected void LoadTerrainImpl(TerrainSlot slot, bool synchronous)
        {
            if (!synchronous)
                throw new NotSupportedException("Loading terrain asynchronous is not yet supported!");

            if (slot.Instance == null &&
                (string.IsNullOrEmpty(slot.Def.FileName) || slot.Def.ImportData != null))
            {
                slot.Instance = new Terrain(_sceneManager);
                slot.Instance.ResourceGroup = _resourceGroup;
                slot.Instance.Prepare(_defaultImportData);
                slot.Instance.Position = GetTerrainSlotPosition(slot.X, slot.Y);
                slot.Instance.Load();
                // hook up with neighbours
                for (int i = -1; i <= 1; ++i)
                {
                    for (int j = -1; j <= 1; ++j)
                    {
                        if (i != 0 || j != 0)
                            ConnectNeighbour(slot, i, j);
                    }

                }
            }
        }
Exemple #2
0
 protected void LoadTerrainImpl(TerrainSlot slot)
 {
     LoadTerrainImpl(slot, true);
 }
Exemple #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="createIfMissing"></param>
 /// <returns></returns>
 protected TerrainSlot GetTerrainSlot(long x, long y, bool createIfMissing)
 {
     uint key = PackIndex(x, y);
     TerrainSlot i = null;
     if (_terrainSlots.TryGetValue(key, out i))
     {
         return i;
     }
     else if (createIfMissing)
     {
         i = new TerrainSlot(x, y);
         _terrainSlots.Add(key, i);
         return i;
     }
     return null;
 }
Exemple #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="slot"></param>
 /// <param name="offsetx"></param>
 /// <param name="offsety"></param>
 protected void ConnectNeighbour(TerrainSlot slot, long offsetx, long offsety)
 {
     TerrainSlot neighbourSlot = GetTerrainSlot(slot.X + offsetx, slot.Y + offsety);
     if (neighbourSlot != null && neighbourSlot.Instance != null && neighbourSlot.Instance.IsLoaded)
     {
         // reclaculate if imported
         slot.Instance.SetNeighbour(Terrain.GetNeighbourIndex(offsetx, offsety), neighbourSlot.Instance,
             slot.Def.ImportData != null, true);
     }
 }
Exemple #5
0
		protected void LoadTerrainImpl( TerrainSlot slot, bool synchronous )
		{
			if ( slot.Instance == null && ( !string.IsNullOrEmpty( slot.Def.FileName ) || slot.Def.ImportData != null ) )
			{
				// Allocate in main thread so no race conditions
				slot.Instance = new Terrain( this._sceneManager );
				slot.Instance.ResourceGroup = this._resourceGroup;
				// Use shared pool of buffers
				slot.Instance.GpuBufferAllocator = this.BufferAllocator;

				var req = new LoadRequest();
				req.Slot = slot;
				req.Origin = this;
				Root.Instance.WorkQueue.AddRequest( this._workQueueChannel, WORKQUEUE_LOAD_REQUEST, req, 0, synchronous );
			}
		}