Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions TombEditor/EditorActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4874,15 +4874,21 @@ public static void TryStampObject(ObjectInstance instance, IWin32Window owner)

public static void TryPasteSectors(SectorsClipboardData data, IWin32Window owner)
{
_editor.UndoManager.PushGeometryChanged(_editor.SelectedRoom);

int x0 = _editor.SelectedSectors.Area.X0;
int z0 = _editor.SelectedSectors.Area.Y0;
int x1 = Math.Min(_editor.SelectedRoom.NumXSectors - 1, x0 + data.Width);
int z1 = Math.Min(_editor.SelectedRoom.NumZSectors - 1, z0 + data.Height);

if (x1 <= x0 || z1 <= z0)
return;

var pastedArea = new RectangleInt2(x0, z0, x1 - 1, z1 - 1);
var affectedRooms = _editor.SelectedRoom.GetAdjoiningRoomsFromArea(pastedArea.Inflate(1));
affectedRooms.Add(_editor.SelectedRoom);

_editor.UndoManager.PushGeometryChanged(affectedRooms);

var sectors = data.GetSectors();
var portals = new List<PortalInstance>();

for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++)
Expand All @@ -4894,20 +4900,17 @@ public static void TryPasteSectors(SectorsClipboardData data, IWin32Window owner
if (_editor.SelectedSectors.Empty ||
_editor.SelectedSectors.Single ||
_editor.SelectedSectors.Area.Contains(new VectorInt2(x, z)))
{
portals.AddRange(_editor.SelectedRoom.Sectors[x, z].Portals);
_editor.SelectedRoom.Sectors[x, z].ReplaceGeometry(_editor.Level, currentSector);
}
}

// Redraw rooms in portals
portals.Select(p => p.AdjoiningRoom).ToList().ForEach(room =>
SmartBuildGeometry(_editor.SelectedRoom, pastedArea);

foreach (var affectedRoom in affectedRooms)
{
room.Rebuild(_editor.ShouldRelight, _editor.Configuration.Rendering3D_HighQualityLightPreview);
_editor.RoomGeometryChange(room);
});
if (affectedRoom != _editor.SelectedRoom)
_editor.RoomGeometryChange(affectedRoom);
}

_editor.SelectedRoom.Rebuild(_editor.ShouldRelight, _editor.Configuration.Rendering3D_HighQualityLightPreview);
_editor.RoomSectorPropertiesChange(_editor.SelectedRoom);
}

Expand Down