/// <summary> /// Invalidates the specified terrain layer in the data cached by the renderer. /// </summary> /// <param name="tile">The terrain tile owning the terrain layer.</param> /// <param name="layer">The terrain layer which should be invalidated.</param> /// <inheritdoc cref="Invalidate()"/> /// <exception cref="ArgumentNullException"> /// <paramref name="tile"/> or <paramref name="layer"/> is <see langword="null"/>. /// </exception> public void Invalidate(TerrainTile tile, TerrainLayer layer) { if (tile == null) { throw new ArgumentNullException("tile"); } if (layer == null) { throw new ArgumentNullException("layer"); } UpdateAabb(); Aabb aabb = layer.Aabb ?? tile.Aabb; if (layer.Material.Contains(TerrainClipmapRenderer.RenderPassBase) && !RegionsContain(InvalidBaseRegions, aabb)) { InvalidBaseRegions.Add(aabb); // If there are 2 or more AABBs, then they need clipping. AreInvalidBaseRegionsClipped = (InvalidBaseRegions.Count == 1); } if (layer.Material.Contains(TerrainClipmapRenderer.RenderPassDetail) && !RegionsContain(InvalidDetailRegions, aabb)) { InvalidDetailRegions.Add(aabb); // If there are 2 or more AABBs, then they need clipping. AreInvalidDetailRegionsClipped = (InvalidDetailRegions.Count == 1); } }
/// <summary> /// Invalidates the specified terrain layer in the data cached by the renderer. /// </summary> /// <param name="layer">The terrain layer which should be invalidated.</param> /// <inheritdoc cref="Invalidate()"/> /// <exception cref="ArgumentNullException"> /// <paramref name="layer"/> is <see langword="null"/>. /// </exception> /// <exception cref="GraphicsException"> /// <paramref name="layer"/> does not have a valid AABB. This method cannot be used. Use one of /// the other method overloads instead. /// </exception> public void Invalidate(TerrainLayer layer) { if (layer == null) { throw new ArgumentNullException("layer"); } if (!layer.Aabb.HasValue) { throw new GraphicsException("The specified terrain layer does not have a valid AABB."); } Aabb aabb = layer.Aabb.Value; if (layer.Material.Contains(TerrainClipmapRenderer.RenderPassBase) && !RegionsContain(InvalidBaseRegions, aabb)) { InvalidBaseRegions.Add(aabb); // If there are 2 or more AABBs, then they need clipping. AreInvalidBaseRegionsClipped = (InvalidBaseRegions.Count == 1); } if (layer.Material.Contains(TerrainClipmapRenderer.RenderPassDetail) && !RegionsContain(InvalidDetailRegions, aabb)) { InvalidDetailRegions.Add(aabb); // If there are 2 or more AABBs, then they need clipping. AreInvalidDetailRegionsClipped = (InvalidDetailRegions.Count == 1); } }
//-------------------------------------------------------------- #region Methods //-------------------------------------------------------------- /// <overloads> /// <summary> /// Invalidates the data cached by the renderer. /// </summary> /// </overloads> /// /// <summary> /// Invalidates all data cached by the renderer. /// </summary> /// <remarks> /// <para> /// This method notifies the renderers that cached data (e.g. terrain clipmaps) needs to be /// updated. /// </para> /// <para> /// The <see cref="Invalidate()"/> method or its overloads are called automatically when terrain /// tiles or layers are added to/removed from the terrain. If any other data that affects the /// appearance of the terrain is changed, the method <see cref="Invalidate()"/> needs to be /// called manually. /// </para> /// </remarks> public void Invalidate() { UpdateAabb(); InvalidBaseRegions.Clear(); InvalidBaseRegions.Add(Aabb); AreInvalidBaseRegionsClipped = true; InvalidDetailRegions.Clear(); InvalidDetailRegions.Add(Aabb); AreInvalidDetailRegionsClipped = true; }
/// <summary> /// Invalidates the specified region in the data cached by the renderer. /// </summary> /// <param name="aabb">The axis-aligned bounding box of the invalid region.</param> /// <inheritdoc cref="Invalidate()"/> public void Invalidate(Aabb aabb) { if (!RegionsContain(InvalidBaseRegions, aabb)) { InvalidBaseRegions.Add(aabb); // If there are 2 or more AABBs, then they need clipping. AreInvalidBaseRegionsClipped = (InvalidBaseRegions.Count == 1); } if (!RegionsContain(InvalidDetailRegions, aabb)) { InvalidDetailRegions.Add(aabb); // If there are 2 or more AABBs, then they need clipping. AreInvalidDetailRegionsClipped = (InvalidDetailRegions.Count == 1); } }