From f048600bbf5ea715f36cf7d92e3eeb5286faec84 Mon Sep 17 00:00:00 2001 From: MaxED Date: Tue, 8 Mar 2016 20:37:44 +0000 Subject: [PATCH] Fixed, Visual mode: GLDEFS glow color was incorrectly interpolated on sidedefs. Fixed, Visual mode: in some cases GLDEFS glow effect was not updated after changing floor/ceiling texture. Fixed, Draw Rectangle and Draw Ellipse modes: in some cases pressing "Reset" button did not update the shape preview. Fixed, DB2 bug: sector geometry was not updated after undoing "Flip Sidedefs" action. --- Source/Core/Editing/UndoManager.cs | 16 ++++++--- Source/Core/Geometry/Tools.cs | 6 ++-- Source/Core/Rendering/D3DDevice.cs | 4 +-- .../Interface/DrawEllipseOptionsPanel.cs | 6 +++- .../Interface/DrawRectangleOptionsPanel.cs | 6 +++- .../Interface/PreferencesForm.Designer.cs | 11 ++++--- .../VisualModes/BaseVisualMode.cs | 1 - .../BuilderModes/VisualModes/VisualCeiling.cs | 33 +++++++++---------- .../BuilderModes/VisualModes/VisualFloor.cs | 33 +++++++++---------- 9 files changed, 63 insertions(+), 53 deletions(-) diff --git a/Source/Core/Editing/UndoManager.cs b/Source/Core/Editing/UndoManager.cs index 66f8fea..aab46cc 100644 --- a/Source/Core/Editing/UndoManager.cs +++ b/Source/Core/Editing/UndoManager.cs @@ -1116,8 +1116,12 @@ namespace CodeImp.DoomBuilder.Editing Sidedef sd = (sindex >= 0) ? General.Map.Map.GetSidedefByIndex(sindex) : null; l.AttachFront(sd); l.Marked = true; - if (l.Tag != 0) linedeftags.Add(l.Tag); - if (sd != null) sd.Marked = true; + if (l.Tag != 0) linedeftags.Add(l.Tag); + if (sd != null) + { + sd.Marked = true; + if(sd.Sector != null) sd.Sector.UpdateNeeded = true; //mxd. Sector needs to be updated as well... + } geometrychanged = true; } @@ -1141,8 +1145,12 @@ namespace CodeImp.DoomBuilder.Editing Sidedef sd = (sindex >= 0) ? General.Map.Map.GetSidedefByIndex(sindex) : null; l.AttachBack(sd); l.Marked = true; - if (l.Tag != 0) linedeftags.Add(l.Tag); - if (sd != null) sd.Marked = true; + if (l.Tag != 0) linedeftags.Add(l.Tag); + if (sd != null) + { + sd.Marked = true; + if(sd.Sector != null) sd.Sector.UpdateNeeded = true; //mxd. Sector needs to be updated as well... + } geometrychanged = true; } diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index aac97bd..fa63121 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2236,7 +2236,7 @@ namespace CodeImp.DoomBuilder.Geometry /// Flips sector linedefs so they all face either inward or outward. public static void FlipSectorLinedefs(ICollection sectors, bool selectedlinesonly) { - Dictionary processed = new Dictionary(); + HashSet processed = new HashSet(); foreach(Sector s in sectors) { @@ -2248,7 +2248,7 @@ namespace CodeImp.DoomBuilder.Geometry //sort lines foreach(Sidedef side in s.Sidedefs) { - if(processed.ContainsKey(side.Line)) continue; + if(processed.Contains(side.Line)) continue; if(selectedlinesonly && !side.Line.Selected) { if(side == side.Line.Front) unselectedfrontlines++; @@ -2261,7 +2261,7 @@ namespace CodeImp.DoomBuilder.Geometry else backlines.Add(side.Line); - processed.Add(side.Line, false); + processed.Add(side.Line); } //flip lines diff --git a/Source/Core/Rendering/D3DDevice.cs b/Source/Core/Rendering/D3DDevice.cs index a4fa7c8..888dfb1 100644 --- a/Source/Core/Rendering/D3DDevice.cs +++ b/Source/Core/Rendering/D3DDevice.cs @@ -168,8 +168,8 @@ namespace CodeImp.DoomBuilder.Rendering device.SetRenderState(RenderState.NormalizeNormals, false); device.SetRenderState(RenderState.PointSpriteEnable, false); device.SetRenderState(RenderState.RangeFogEnable, false); - device.SetRenderState(RenderState.ShadeMode, ShadeMode.Flat); //mxd - device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); + device.SetRenderState(RenderState.ShadeMode, ShadeMode.Gouraud); + device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); device.SetRenderState(RenderState.SpecularEnable, false); device.SetRenderState(RenderState.StencilEnable, false); device.SetRenderState(RenderState.TextureFactor, -1); diff --git a/Source/Plugins/BuilderModes/Interface/DrawEllipseOptionsPanel.cs b/Source/Plugins/BuilderModes/Interface/DrawEllipseOptionsPanel.cs index 4539df2..eee4b7e 100644 --- a/Source/Plugins/BuilderModes/Interface/DrawEllipseOptionsPanel.cs +++ b/Source/Plugins/BuilderModes/Interface/DrawEllipseOptionsPanel.cs @@ -60,11 +60,15 @@ namespace CodeImp.DoomBuilder.BuilderModes private void reset_Click(object sender, EventArgs e) { + // Reset values blockevents = true; spikiness.Value = 0; angle.Value = 0; - blockevents = false; subdivs.Value = 6; + blockevents = false; + + // Dispatch event + OnValueChanged(this, EventArgs.Empty); } private void continuousdrawing_CheckedChanged(object sender, EventArgs e) diff --git a/Source/Plugins/BuilderModes/Interface/DrawRectangleOptionsPanel.cs b/Source/Plugins/BuilderModes/Interface/DrawRectangleOptionsPanel.cs index 8530f18..bb4f638 100644 --- a/Source/Plugins/BuilderModes/Interface/DrawRectangleOptionsPanel.cs +++ b/Source/Plugins/BuilderModes/Interface/DrawRectangleOptionsPanel.cs @@ -54,10 +54,14 @@ namespace CodeImp.DoomBuilder.BuilderModes private void reset_Click(object sender, EventArgs e) { + // Reset values blockevents = true; radius.Value = 0; - blockevents = false; subdivs.Value = 0; + blockevents = false; + + // Dispatch event + OnValueChanged(this, EventArgs.Empty); } private void continuousdrawing_CheckedChanged(object sender, EventArgs e) diff --git a/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs b/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs index c61aee0..2b1741a 100644 --- a/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs +++ b/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs @@ -263,9 +263,10 @@ namespace CodeImp.DoomBuilder.BuilderModes this.autodrawonedit.AutoSize = true; this.autodrawonedit.Location = new System.Drawing.Point(13, 24); this.autodrawonedit.Name = "autodrawonedit"; - this.autodrawonedit.Size = new System.Drawing.Size(346, 17); + this.autodrawonedit.Size = new System.Drawing.Size(353, 30); this.autodrawonedit.TabIndex = 11; - this.autodrawonedit.Text = "Start drawing when Edit pressed over empty space in Classic modes"; + this.autodrawonedit.Text = "Start drawing when Edit pressed over empty space in Classic modes\r\nInsert new thi" + + "ng when Edit pressed over empty space in Things mode"; this.autodrawonedit.UseVisualStyleBackColor = true; // // syncSelection @@ -331,7 +332,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // editnewthing // this.editnewthing.AutoSize = true; - this.editnewthing.Location = new System.Drawing.Point(13, 49); + this.editnewthing.Location = new System.Drawing.Point(13, 62); this.editnewthing.Name = "editnewthing"; this.editnewthing.Size = new System.Drawing.Size(248, 17); this.editnewthing.TabIndex = 1; @@ -341,7 +342,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // editnewsector // this.editnewsector.AutoSize = true; - this.editnewsector.Location = new System.Drawing.Point(13, 74); + this.editnewsector.Location = new System.Drawing.Point(13, 87); this.editnewsector.Name = "editnewsector"; this.editnewsector.Size = new System.Drawing.Size(258, 17); this.editnewsector.TabIndex = 2; @@ -351,7 +352,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // additiveselect // this.additiveselect.AutoSize = true; - this.additiveselect.Location = new System.Drawing.Point(13, 99); + this.additiveselect.Location = new System.Drawing.Point(13, 112); this.additiveselect.Name = "additiveselect"; this.additiveselect.Size = new System.Drawing.Size(205, 17); this.additiveselect.TabIndex = 3; diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 7148f88..b9db85e 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -3030,7 +3030,6 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.SetCrosshairBusy(true); General.Interface.RedrawDisplay(); GetTargetEventReceiver(false).OnSelectTexture(); - UpdateChangedObjects(); RebuildElementData(); //mxd. Extrafloors or Glow effects may've been changed renderer.SetCrosshairBusy(false); PostAction(); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs index f8e206c..efb5a88 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs @@ -369,27 +369,11 @@ namespace CodeImp.DoomBuilder.BuilderModes { if(BuilderPlug.Me.CopiedFlat != null) { - mode.CreateUndo("Paste ceiling '" + BuilderPlug.Me.CopiedFlat + "'"); - mode.SetActionResult("Pasted flat '" + BuilderPlug.Me.CopiedFlat + "' on ceiling."); - - //mxd. Glow effect may require SectorData and geometry update - bool prevtextureglows = General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongCeilTexture); + mode.CreateUndo("Paste ceiling \"" + BuilderPlug.Me.CopiedFlat + "\""); + mode.SetActionResult("Pasted flat \"" + BuilderPlug.Me.CopiedFlat + "\" on ceiling."); SetTexture(BuilderPlug.Me.CopiedFlat); - //mxd. Glow effect may require SectorData and geometry update - if(prevtextureglows && !General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongCeilTexture)) - { - SectorData sd = mode.GetSectorData(level.sector); - sd.UpdateForced(); - - if(mode.VisualSectorExists(level.sector)) - { - BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); - vs.UpdateSectorGeometry(false); - } - } - //mxd. 3D floors may need updating... OnTextureChanged(); } @@ -591,7 +575,20 @@ namespace CodeImp.DoomBuilder.BuilderModes // This changes the texture protected override void SetTexture(string texturename) { + //mxd. Glow effect may require SectorData and geometry update + bool prevtextureglows = General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongCeilTexture); + + // Set new texture level.sector.SetCeilTexture(texturename); + + //mxd. Glow effect may require SectorData and geometry update + if(prevtextureglows + && !General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongCeilTexture) + && mode.VisualSectorExists(level.sector)) + { + ((BaseVisualSector)mode.GetVisualSector(level.sector)).Changed = true; + } + General.Map.Data.UpdateUsedTextures(); } diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs index c2bf28b..c0125c0 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs @@ -368,27 +368,11 @@ namespace CodeImp.DoomBuilder.BuilderModes { if(BuilderPlug.Me.CopiedFlat != null) { - mode.CreateUndo("Paste floor '" + BuilderPlug.Me.CopiedFlat + "'"); - mode.SetActionResult("Pasted flat '" + BuilderPlug.Me.CopiedFlat + "' on floor."); - - //mxd. Glow effect may require SectorData and geometry update - bool prevtextureglows = General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongFloorTexture); + mode.CreateUndo("Paste floor \"" + BuilderPlug.Me.CopiedFlat + "\""); + mode.SetActionResult("Pasted flat \"" + BuilderPlug.Me.CopiedFlat + "\" on floor."); SetTexture(BuilderPlug.Me.CopiedFlat); - //mxd. Glow effect may require SectorData and geometry update - if(prevtextureglows && !General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongFloorTexture)) - { - SectorData sd = mode.GetSectorData(level.sector); - sd.UpdateForced(); - - if(mode.VisualSectorExists(level.sector)) - { - BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); - vs.UpdateSectorGeometry(false); - } - } - //mxd. 3D floors may need updating... OnTextureChanged(); } @@ -562,7 +546,20 @@ namespace CodeImp.DoomBuilder.BuilderModes // This changes the texture protected override void SetTexture(string texturename) { + //mxd. Glow effect may require SectorData and geometry update + bool prevtextureglows = General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongFloorTexture); + + // Set new texture level.sector.SetFloorTexture(texturename); + + //mxd. Glow effect may require SectorData and geometry update + if(prevtextureglows + && !General.Map.Data.GlowingFlats.ContainsKey(Sector.Sector.LongFloorTexture) + && mode.VisualSectorExists(level.sector)) + { + ((BaseVisualSector)mode.GetVisualSector(level.sector)).Changed = true; + } + General.Map.Data.UpdateUsedTextures(); }