diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragGeometryMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragGeometryMode.cs index 218af0fb..4077d0a4 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/DragGeometryMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragGeometryMode.cs @@ -432,7 +432,6 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Update floor/ceiling texture offsets and slopes? if (General.Map.UDMF) { - Dictionary> threedfloorcontrolsectors = new Dictionary>(); Vector2D offset = dragitem.Position - dragitemposition; // 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 HashSet updatesectors = new HashSet(draggedsectors); + // Keep track of control sectors in general, and control sectors relevant to other dragged sectors + HashSet controlsectors = new HashSet(); + HashSet addcontrolsectors = new HashSet(); // Check if the dragged sectors are referenced as 3D floors, and add the control sectors to the list of // sectors that need updating @@ -449,12 +451,18 @@ namespace CodeImp.DoomBuilder.BuilderModes if (ld.Action != 160) // Action 160 defines a 3D floor 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) { - 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; updatesectors.Add(ld.Front.Sector); + addcontrolsectors.Add(ld.Front.Sector); } } @@ -462,6 +470,7 @@ namespace CodeImp.DoomBuilder.BuilderModes foreach (Sector s in updatesectors) { 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 if (updateoffsets) @@ -524,20 +533,23 @@ namespace CodeImp.DoomBuilder.BuilderModes } } - // Update floor slope? - if (s.FloorSlope.GetLengthSq() > 0 && !double.IsNaN(s.FloorSlopeOffset / s.FloorSlope.z)) + if (updateslopes) { - Plane floor = new Plane(s.FloorSlope, s.FloorSlopeOffset); - Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2); - s.FloorSlopeOffset = -Vector3D.DotProduct(s.FloorSlope, new Vector3D(center + offset, floor.GetZ(center))); - } + // Update floor slope? + if (s.FloorSlope.GetLengthSq() > 0 && !double.IsNaN(s.FloorSlopeOffset / s.FloorSlope.z)) + { + Plane floor = new Plane(s.FloorSlope, s.FloorSlopeOffset); + Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2); + s.FloorSlopeOffset = -Vector3D.DotProduct(s.FloorSlope, new Vector3D(center + offset, floor.GetZ(center))); + } - // Update ceiling slope? - if (s.CeilSlope.GetLengthSq() > 0 && !double.IsNaN(s.CeilSlopeOffset / s.CeilSlope.z)) - { - Plane ceiling = new Plane(s.CeilSlope, s.CeilSlopeOffset); - Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2); - s.CeilSlopeOffset = -Vector3D.DotProduct(s.CeilSlope, new Vector3D(center + offset, ceiling.GetZ(center))); + // Update ceiling slope? + if (s.CeilSlope.GetLengthSq() > 0 && !double.IsNaN(s.CeilSlopeOffset / s.CeilSlope.z)) + { + Plane ceiling = new Plane(s.CeilSlope, s.CeilSlopeOffset); + Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2); + s.CeilSlopeOffset = -Vector3D.DotProduct(s.CeilSlope, new Vector3D(center + offset, ceiling.GetZ(center))); + } } } }