3D floor slopes are now maintained when dragging their control sectors (#1057)

This commit is contained in:
9sphere 2024-06-16 11:47:38 +02:00 committed by GitHub
parent 6c9b3b5d91
commit 8f7104c23d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -432,7 +432,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Update floor/ceiling texture offsets and slopes? //mxd. Update floor/ceiling texture offsets and slopes?
if (General.Map.UDMF) if (General.Map.UDMF)
{ {
Dictionary<Sector, List<Sector>> threedfloorcontrolsectors = new Dictionary<Sector, List<Sector>>();
Vector2D offset = dragitem.Position - dragitemposition; Vector2D offset = dragitem.Position - dragitemposition;
// Sectors may've been created/removed when applying dragging... // Sectors may've been created/removed when applying dragging...
@ -441,6 +440,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Sectors that have to be updated. They contain the dragged sectors, but also 3D floor control sectors // Sectors that have to be updated. They contain the dragged sectors, but also 3D floor control sectors
HashSet<Sector> updatesectors = new HashSet<Sector>(draggedsectors); HashSet<Sector> updatesectors = new HashSet<Sector>(draggedsectors);
// Keep track of control sectors in general, and control sectors relevant to other dragged sectors
HashSet<Sector> controlsectors = new HashSet<Sector>();
HashSet<Sector> addcontrolsectors = new HashSet<Sector>();
// Check if the dragged sectors are referenced as 3D floors, and add the control sectors to the list of // Check if the dragged sectors are referenced as 3D floors, and add the control sectors to the list of
// sectors that need updating // sectors that need updating
@ -449,12 +451,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (ld.Action != 160) // Action 160 defines a 3D floor if (ld.Action != 160) // Action 160 defines a 3D floor
continue; continue;
if (ld.Args[0] == 0) // First argument of the action is the sector tag. 0 is not a valid value
continue;
controlsectors.Add(ld.Front.Sector);
foreach (Sector s in draggedsectors) foreach (Sector s in draggedsectors)
{ {
if (ld.Args[0] == 0 || !s.Tags.Contains(ld.Args[0])) // First argument of the action is the sector tag. 0 is not a valid value if (!s.Tags.Contains(ld.Args[0]))
continue; continue;
updatesectors.Add(ld.Front.Sector); updatesectors.Add(ld.Front.Sector);
addcontrolsectors.Add(ld.Front.Sector);
} }
} }
@ -462,6 +470,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach (Sector s in updatesectors) foreach (Sector s in updatesectors)
{ {
bool updateoffsets = (draggedsectors.Contains(s) && BuilderPlug.Me.LockSectorTextureOffsetsWhileDragging) || (!draggedsectors.Contains(s) && BuilderPlug.Me.Lock3DFloorSectorTextureOffsetsWhileDragging); bool updateoffsets = (draggedsectors.Contains(s) && BuilderPlug.Me.LockSectorTextureOffsetsWhileDragging) || (!draggedsectors.Contains(s) && BuilderPlug.Me.Lock3DFloorSectorTextureOffsetsWhileDragging);
bool updateslopes = !((controlsectors.Contains(s) ^ addcontrolsectors.Contains(s)) && draggedsectors.Contains(s));
// Update texture offsets // Update texture offsets
if (updateoffsets) if (updateoffsets)
@ -524,6 +533,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
} }
if (updateslopes)
{
// Update floor slope? // Update floor slope?
if (s.FloorSlope.GetLengthSq() > 0 && !double.IsNaN(s.FloorSlopeOffset / s.FloorSlope.z)) if (s.FloorSlope.GetLengthSq() > 0 && !double.IsNaN(s.FloorSlopeOffset / s.FloorSlope.z))
{ {
@ -541,6 +552,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
} }
} }
}
// Update cached values // Update cached values
General.Map.Map.Update(); General.Map.Map.Update();