public CreateTileTask(TileProducer owner, int level, int tx, int ty, List <Slot> slot) { m_owner = owner; m_level = level; m_tx = tx; m_ty = ty; Slot = slot; }
public void InsertProducer(int id, TileProducer producer) { if (m_producers.ContainsKey(id)) { throw new InvalidOperationException("Producer id already inserted"); } m_producers.Add(id, producer); }
/// <summary> /// Find all the quads in a terrain that need to be drawn. If a quad is a leaf and is visible it should /// be drawn. If that quads tile is not ready the first ready parent is drawn /// NOTE - because of the current set up all task are run on the frame they are generated so /// the leaf quads will always have tiles that are ready to be drawn /// </summary> private void FindDrawableQuads(TerrainQuad quad, List <TileSampler> samplers) { quad.Drawable = false; if (!quad.IsVisible) { quad.Drawable = true; return; } if (quad.IsLeaf) { for (int i = 0; i < samplers.Count; ++i) { TileProducer p = samplers[i].Producer; int l = quad.Level; int tx = quad.Tx; int ty = quad.Ty; if (p.HasTile(l, tx, ty) && p.FindTile(l, tx, ty, false, true) == null) { return; } } } else { int nDrawable = 0; for (int i = 0; i < 4; ++i) { FindDrawableQuads(quad.GetChild(i), samplers); if (quad.GetChild(i).Drawable) { ++nDrawable; } } if (nDrawable < 4) { for (int i = 0; i < samplers.Count; ++i) { TileProducer p = samplers[i].Producer; int l = quad.Level; int tx = quad.Tx; int ty = quad.Ty; if (p.HasTile(l, tx, ty) && p.FindTile(l, tx, ty, false, true) == null) { return; } } } } quad.Drawable = true; }