// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System; using FlaxEngine; namespace FlaxEditor.Tools.Terrain.Undo { /// /// The terrain holes mask editing action that records before and after states to swap between unmodified and modified terrain data. /// /// /// [Serializable] unsafe class EditTerrainHolesMapAction : EditTerrainMapAction { /// /// Initializes a new instance of the class. /// /// The terrain. public EditTerrainHolesMapAction(FlaxEngine.Terrain terrain) : base(terrain, sizeof(byte)) { } /// public override string ActionString => "Edit terrain holes"; /// protected override IntPtr GetData(ref Int2 patchCoord, object tag) { return new IntPtr(TerrainTools.GetHolesMaskData(Terrain, ref patchCoord)); } /// protected override void SetData(ref Int2 patchCoord, IntPtr data, object tag) { var offset = Int2.Zero; var size = new Int2((int)Mathf.Sqrt(_heightmapLength)); if (TerrainTools.ModifyHolesMask(Terrain, ref patchCoord, (byte*)data, ref offset, ref size)) throw new Exception("Failed to modify the terrain holes."); } } }