Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions TombEditor/Controls/Panel3D/MouseHandler/Panel3DMouseDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ private void OnMouseButtonDownLeft(Point location)
{
if (ModifierKeys.HasFlag(Keys.Shift))
{
EditorActions.RotateTexture(_editor.SelectedRoom, pos, newSectorPicking.Face);
EditorActions.RotateTexture(_editor.SelectedRoom, pos, new(newSectorPicking.Face, _editor.ActiveTextureLayer));
break;
}
else if (ModifierKeys.HasFlag(Keys.Control))
{
EditorActions.MirrorTexture(_editor.SelectedRoom, pos, newSectorPicking.Face);
EditorActions.MirrorTexture(_editor.SelectedRoom, pos, new(newSectorPicking.Face, _editor.ActiveTextureLayer));
break;
}
}

if (ModifierKeys.HasFlag(Keys.Alt))
{
EditorActions.PickTexture(_editor.SelectedRoom, pos, newSectorPicking.Face);
EditorActions.PickTexture(_editor.SelectedRoom, pos, new(newSectorPicking.Face, _editor.ActiveTextureLayer));
}
else if (_editor.Tool.Tool == EditorToolType.GridPaint && !_editor.HighlightedSectors.Empty)
{
Expand Down Expand Up @@ -212,7 +212,7 @@ private void OnMouseButtonDownLeft(Point location)

case EditorToolType.Brush:
case EditorToolType.Pencil:
EditorActions.ApplyTexture(_editor.SelectedRoom, pos, newSectorPicking.Face, _editor.SelectedTexture);
EditorActions.ApplyTexture(_editor.SelectedRoom, pos, new(newSectorPicking.Face, _editor.ActiveTextureLayer), _editor.SelectedTexture);
_toolHandler.Engage(location.X, location.Y, newSectorPicking, false);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private bool OnMouseMovedLeft(Point location)
{
if (_editor.SelectedSectors.Valid && _editor.SelectedSectors.Area.Contains(pos) ||
_editor.SelectedSectors.Empty)
return EditorActions.ApplyTexture(_editor.SelectedRoom, pos, newSectorPicking.Face, _editor.SelectedTexture, true);
return EditorActions.ApplyTexture(_editor.SelectedRoom, pos, new(newSectorPicking.Face, _editor.ActiveTextureLayer), _editor.SelectedTexture, true);
}
else if (_editor.Tool.Tool == EditorToolType.GridPaint && _toolHandler.Engaged)
{
Expand Down
38 changes: 37 additions & 1 deletion TombEditor/Controls/Panel3D/Panel3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public bool DisablePickingForHiddenRooms
private Buffer<SolidVertex> _flybyPathVertexBuffer;
private Buffer<SolidVertex> _ghostBlockVertexBuffer;
private Buffer<SolidVertex> _boxVertexBuffer;
private Buffer<SolidVertex> _overlayOutlineVertexBuffer;
private List<SolidVertex> _overlayOutlineVertices;
private Room _lastOverlayOutlineRoom;

// Flyby stuff
private const float _flybyPathThickness = 32.0f;
Expand Down Expand Up @@ -217,6 +220,7 @@ protected override void Dispose(bool disposing)
_rasterizerWireframe?.Dispose();
_objectHeightLineVertexBuffer?.Dispose();
_flybyPathVertexBuffer?.Dispose();
_overlayOutlineVertexBuffer?.Dispose();
_gizmo?.Dispose();
_sphere?.Dispose();
_cone?.Dispose();
Expand All @@ -234,6 +238,16 @@ protected override void Dispose(bool disposing)

private IReadOnlyList<Keys> _splitHighlightHotkeys;

private void InvalidateOverlayOutlineCache(Room room = null)
{
if (room is null || _lastOverlayOutlineRoom == room)
{
_lastOverlayOutlineRoom = null;
_overlayOutlineVertexBuffer?.Dispose();
_overlayOutlineVertexBuffer = null;
}
}

private void EditorEventRaised(IEditorEvent obj)
{
if (obj is Editor.InitEvent)
Expand Down Expand Up @@ -276,6 +290,15 @@ obj is Editor.ToolChangedEvent ||
var room = ((IEditorRoomChangedEvent)obj).Room;

_renderingCachedRooms.Remove(room);

// Invalidate overlay outline cache for geometry or face-related changes
if (obj is Editor.RoomGeometryChangedEvent ||
obj is Editor.RoomPositionChangedEvent ||
obj is Editor.RoomSectorPropertiesChangedEvent)
{
InvalidateOverlayOutlineCache(room);
}

if (obj is Editor.RoomGeometryChangedEvent || obj is Editor.RoomPositionChangedEvent)
foreach (var portal in room.Portals)
_renderingCachedRooms.Remove(portal.AdjoiningRoom);
Expand All @@ -292,10 +315,23 @@ obj is Editor.ToolChangedEvent ||
if (obj is Editor.SelectedSectorsChangedEvent ||
obj is Editor.HighlightedSectorChangedEvent)
_renderingCachedRooms.Remove(_editor.SelectedRoom);

if (obj is Editor.SelectedRoomChangedEvent)
{
_renderingCachedRooms.Remove(((Editor.SelectedRoomChangedEvent)obj).Previous);

// Overlay outlines are room-specific, so invalidate cache when switching rooms
InvalidateOverlayOutlineCache();
}

if (obj is Editor.RoomSectorPropertiesChangedEvent)
_renderingCachedRooms.Remove(((Editor.RoomSectorPropertiesChangedEvent)obj).Room);
{
var room = ((Editor.RoomSectorPropertiesChangedEvent)obj).Room;
_renderingCachedRooms.Remove(room);

InvalidateOverlayOutlineCache(room);
}

if (obj is Editor.LoadedTexturesChangedEvent ||
obj is Editor.LoadedImportedGeometriesChangedEvent ||
obj is Editor.LevelChangedEvent ||
Expand Down
Loading