diff --git a/Source/Core/Controls/Scripting/ScriptEditorPanel.cs b/Source/Core/Controls/Scripting/ScriptEditorPanel.cs index 5186b98c..2ace8291 100644 --- a/Source/Core/Controls/Scripting/ScriptEditorPanel.cs +++ b/Source/Core/Controls/Scripting/ScriptEditorPanel.cs @@ -994,7 +994,7 @@ namespace CodeImp.DoomBuilder.Controls if(!(tab is ScriptResourceDocumentTab)) continue; ScriptResourceDocumentTab restab = (ScriptResourceDocumentTab)tab; - if(restab.Filename == resource.FilePathName) + if(restab.Resource.LumpIndex == resource.LumpIndex && restab.Resource.FilePathName == resource.FilePathName) { tabs.SelectedTab = restab; return restab; diff --git a/Source/Core/Controls/Scripting/ScriptResourceDocumentTab.cs b/Source/Core/Controls/Scripting/ScriptResourceDocumentTab.cs index d7cb1ca8..4f01fb88 100644 --- a/Source/Core/Controls/Scripting/ScriptResourceDocumentTab.cs +++ b/Source/Core/Controls/Scripting/ScriptResourceDocumentTab.cs @@ -30,6 +30,7 @@ namespace CodeImp.DoomBuilder.Controls public override bool IsSaveAsRequired { get { return false; } } public override bool IsReadOnly { get { return source.IsReadOnly; } } public override string Filename { get { return filepathname; } } + internal ScriptResource Resource { get { return source; } } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs index 7ccc7b83..07a1b142 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -97,7 +97,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // This changes the height protected abstract void ChangeHeight(int amount); protected abstract void ChangeTextureScale(int incrementX, int incrementY); //mxd - protected abstract void UpdateSkyRenderFlag(); //mxd public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd //mxd diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs index 49197d5a..18a48a6b 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs @@ -200,46 +200,37 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd. Update sky render flag - UpdateSkyRenderFlag(); - - // Apply vertices - base.SetVertices(verts); - return (verts.Length > 0); - } - - //mxd - protected override void UpdateSkyRenderFlag() - { bool isrenderedassky = renderassky; renderassky = (level.sector.CeilTexture == General.Map.Config.SkyFlatName); if(isrenderedassky != renderassky && Sector.Sides != null) { - // Upper/middle geometry may need updating... + // Upper sidedef geometry may need updating... foreach(Sidedef side in level.sector.Sidedefs) { VisualSidedefParts parts = Sector.GetSidedefParts(side); - if(parts.upper != null) + + // Upper side can exist in either our, or the neightbouring sector, right? + if(parts.upper != null && parts.upper.Triangles > 0) { parts.upper.UpdateSkyRenderFlag(); - - // On the other side as well... - if(side.Other != null && side.Other.Sector != null && - (side.Other.HighTexture == "-" || side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName)) - { - BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector); - if(other != null && other.Sides != null) - { - parts = other.GetSidedefParts(side.Other); - if(parts.upper != null) parts.upper.UpdateSkyRenderFlag(); - } - } } - else if(parts.middlesingle != null) + else if(side.Other != null && side.Other.Sector != null && side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName) { - parts.middlesingle.UpdateSkyRenderFlag(); + // Update upper side of the neightbouring sector + BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector); + if(other != null && other.Sides != null) + { + parts = other.GetSidedefParts(side.Other); + if(parts.upper != null && parts.upper.Triangles > 0) + parts.upper.UpdateSkyRenderFlag(); + } } } } + + // Apply vertices + base.SetVertices(verts); + return (verts.Length > 0); } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs index 5ca68f49..0fafc513 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs @@ -184,48 +184,13 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd. Update sky render flag - UpdateSkyRenderFlag(); + renderassky = (level.sector.FloorTexture == General.Map.Config.SkyFlatName); // Apply vertices base.SetVertices(verts); return (verts.Length > 0); } - //mxd - protected override void UpdateSkyRenderFlag() - { - bool isrenderedassky = renderassky; - renderassky = (level.sector.FloorTexture == General.Map.Config.SkyFlatName || level.sector.LongFloorTexture == MapSet.EmptyLongName); - if(isrenderedassky != renderassky && Sector.Sides != null) - { - // Middle/Lower geometry may need updating... - foreach(Sidedef side in level.sector.Sidedefs) - { - VisualSidedefParts parts = Sector.GetSidedefParts(side); - if(parts.lower != null) - { - parts.lower.UpdateSkyRenderFlag(); - - // On the other side as well... - if(side.Other != null && side.Other.Sector != null && - (side.Other.LowTexture == "-" || side.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName)) - { - BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector); - if(other != null && other.Sides != null) - { - parts = other.GetSidedefParts(side.Other); - if(parts.lower != null) parts.lower.UpdateSkyRenderFlag(); - } - } - } - else if(parts.middlesingle != null) - { - parts.middlesingle.UpdateSkyRenderFlag(); - } - } - } - } - #endregion #region ================== Methods diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs index dbb01223..bbb4e1fc 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs @@ -61,19 +61,6 @@ namespace CodeImp.DoomBuilder.BuilderModes public override bool Setup() { Vector2D vl, vr; - - //mxd. Apply sky hack? - UpdateSkyRenderFlag(); - - //mxd. lightfog flag support - int lightvalue; - bool lightabsolute; - GetLightValue(out lightvalue, out lightabsolute); - - Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_bottom", 1.0f), - Sidedef.Fields.GetValue("scaley_bottom", 1.0f)); - Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_bottom", 0.0f), - Sidedef.Fields.GetValue("offsety_bottom", 0.0f)); // Left and right vertices for this sidedef if(Sidedef.IsFront) @@ -91,6 +78,29 @@ namespace CodeImp.DoomBuilder.BuilderModes SectorData sd = Sector.GetSectorData(); SectorData osd = mode.GetSectorData(Sidedef.Other.Sector); if(!osd.Updated) osd.Update(); + + //mxd + float vlzf = sd.Floor.plane.GetZ(vl); + float vrzf = sd.Floor.plane.GetZ(vr); + float ovlzf = osd.Floor.plane.GetZ(vl); + float ovrzf = osd.Floor.plane.GetZ(vr); + + //mxd. Side is visible when our sector's floor is lower than the other's at any vertex + if(!(vlzf < ovlzf || vrzf < ovrzf)) + { + base.SetVertices(null); + return false; + } + + //mxd. lightfog flag support + int lightvalue; + bool lightabsolute; + GetLightValue(out lightvalue, out lightabsolute); + + Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_bottom", 1.0f), + Sidedef.Fields.GetValue("scaley_bottom", 1.0f)); + Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_bottom", 0.0f), + Sidedef.Fields.GetValue("offsety_bottom", 0.0f)); // Texture given? if(Sidedef.LongLowTexture != MapSet.EmptyLongName) @@ -168,10 +178,10 @@ namespace CodeImp.DoomBuilder.BuilderModes // Create initial polygon, which is just a quad between floor and ceiling WallPolygon poly = new WallPolygon(); - poly.Add(new Vector3D(vl.x, vl.y, sd.Floor.plane.GetZ(vl))); + poly.Add(new Vector3D(vl.x, vl.y, vlzf)); poly.Add(new Vector3D(vl.x, vl.y, sd.Ceiling.plane.GetZ(vl))); poly.Add(new Vector3D(vr.x, vr.y, sd.Ceiling.plane.GetZ(vr))); - poly.Add(new Vector3D(vr.x, vr.y, sd.Floor.plane.GetZ(vr))); + poly.Add(new Vector3D(vr.x, vr.y, vrzf)); // Determine initial color int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; @@ -184,7 +194,10 @@ namespace CodeImp.DoomBuilder.BuilderModes // Cut off the part above the other floor CropPoly(ref poly, osd.Floor.plane, false); - CropPoly(ref poly, osd.Ceiling.plane, true); + + //INFO: Makes sence only when ceiling plane is lower than floor plane. Also ZDoom clips ceiling instead here. + if(ovlzf > osd.Ceiling.plane.GetZ(vl) || ovrzf > osd.Ceiling.plane.GetZ(vr)) + CropPoly(ref poly, osd.Ceiling.plane, true); // Cut out pieces that overlap 3D floors in this sector List polygons = new List { poly }; @@ -209,28 +222,6 @@ namespace CodeImp.DoomBuilder.BuilderModes base.SetVertices(null); //mxd return false; } - - //mxd - internal void UpdateSkyRenderFlag() - { - bool isdoublesided = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null); - - //TECH: when a side part has no texture, sky hack will be applied when either front or back sectors' floor uses SkyFlatName texture - //TECH: this glitches in both ZDoom and GZDoom when only lower sector's floor has SkyFlatName - if(Sidedef.LowTexture == "-") - { - renderassky = (isdoublesided - && (Sidedef.Sector.FloorTexture == General.Map.Config.SkyFlatName - || Sidedef.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName)); - } - //TECH: otherwise, sky hack will be applied when both front and back sector floors use SkyFlatName texture - else - { - renderassky = (isdoublesided - && Sidedef.Sector.FloorTexture == General.Map.Config.SkyFlatName - && Sidedef.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName); - } - } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs index 5dc90e88..5005c508 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs @@ -68,7 +68,11 @@ namespace CodeImp.DoomBuilder.BuilderModes this.extrafloor = extrafloor; //mxd. Extrafloor may've become invalid during undo/redo... - if(sourceside == null) return false; + if(sourceside == null) + { + base.SetVertices(null); + return false; + } Vector2D vl, vr; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs index c186dfdc..e240d2c9 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs @@ -68,7 +68,11 @@ namespace CodeImp.DoomBuilder.BuilderModes public override bool Setup() { //mxd - if(Sidedef.LongMiddleTexture == MapSet.EmptyLongName) return false; + if(Sidedef.LongMiddleTexture == MapSet.EmptyLongName) + { + base.SetVertices(null); + return false; + } Vector2D vl, vr; diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs index 0a03ac9f..4a2a0aa7 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs @@ -62,9 +62,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { Vector2D vl, vr; - //mxd. Apply sky hack? - UpdateSkyRenderFlag(); - //mxd. lightfog flag support int lightvalue; bool lightabsolute; @@ -205,12 +202,6 @@ namespace CodeImp.DoomBuilder.BuilderModes return false; } - //mxd - internal void UpdateSkyRenderFlag() - { - renderassky = (Sidedef.LongMiddleTexture == MapSet.EmptyLongName && Sidedef.Sector != null && Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName); - } - #endregion #region ================== Methods diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs index 93fea6db..7e753cab 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs @@ -61,19 +61,6 @@ namespace CodeImp.DoomBuilder.BuilderModes public override bool Setup() { Vector2D vl, vr; - - //mxd. Apply sky hack? - UpdateSkyRenderFlag(); - - //mxd. lightfog flag support - int lightvalue; - bool lightabsolute; - GetLightValue(out lightvalue, out lightabsolute); - - Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_top", 1.0f), - Sidedef.Fields.GetValue("scaley_top", 1.0f)); - Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_top", 0.0f), - Sidedef.Fields.GetValue("offsety_top", 0.0f)); // Left and right vertices for this sidedef if(Sidedef.IsFront) @@ -91,6 +78,30 @@ namespace CodeImp.DoomBuilder.BuilderModes SectorData sd = Sector.GetSectorData(); SectorData osd = mode.GetSectorData(Sidedef.Other.Sector); if(!osd.Updated) osd.Update(); + + //mxd + float vlzc = sd.Ceiling.plane.GetZ(vl); + float vrzc = sd.Ceiling.plane.GetZ(vr); + + //mxd. Side is visible when our sector's ceiling is higher than the other's at any vertex + if(!(vlzc > osd.Ceiling.plane.GetZ(vl) || vrzc > osd.Ceiling.plane.GetZ(vr))) + { + base.SetVertices(null); + return false; + } + + //mxd. Apply sky hack? + UpdateSkyRenderFlag(); + + //mxd. lightfog flag support + int lightvalue; + bool lightabsolute; + GetLightValue(out lightvalue, out lightabsolute); + + Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_top", 1.0f), + Sidedef.Fields.GetValue("scaley_top", 1.0f)); + Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_top", 0.0f), + Sidedef.Fields.GetValue("offsety_top", 0.0f)); // Texture given? if((Sidedef.LongHighTexture != MapSet.EmptyLongName)) @@ -161,8 +172,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // Create initial polygon, which is just a quad between floor and ceiling WallPolygon poly = new WallPolygon(); poly.Add(new Vector3D(vl.x, vl.y, sd.Floor.plane.GetZ(vl))); - poly.Add(new Vector3D(vl.x, vl.y, sd.Ceiling.plane.GetZ(vl))); - poly.Add(new Vector3D(vr.x, vr.y, sd.Ceiling.plane.GetZ(vr))); + poly.Add(new Vector3D(vl.x, vl.y, vlzc)); + poly.Add(new Vector3D(vr.x, vr.y, vrzc)); poly.Add(new Vector3D(vr.x, vr.y, sd.Floor.plane.GetZ(vr))); // Determine initial color @@ -204,23 +215,9 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd internal void UpdateSkyRenderFlag() { - bool isdoublesided = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null); - - //TECH: when a side part has no texture, sky hack will be applied when either front or back sectors' ceiling uses SkyFlatName texture - //TECH: this glitches in both ZDoom and GZDoom when only higher sector's ceiling has SkyFlatName - if(Sidedef.HighTexture == "-") - { - renderassky = (isdoublesided - && (Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName - || Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName)); - } - //TECH: otherwise, sky hack will be applied when both front and back sector ceilings use SkyFlatName texture - else - { - renderassky = (isdoublesided - && Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName - && Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName); - } + renderassky = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null + && Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName + && Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName); } #endregion diff --git a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs index fa6d2503..24ac98cb 100644 --- a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs +++ b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs @@ -660,7 +660,7 @@ namespace CodeImp.DoomBuilder.TagExplorer bExportToFile.Enabled = (treeView.Nodes != null && treeView.Nodes.Count > 0); // Loose focus when the main windows is active - if(focusDisplay && Form.ActiveForm == General.Interface) General.Interface.FocusDisplay(); + if(focusDisplay) General.Interface.FocusDisplay(); } //tag/action search @@ -1098,7 +1098,7 @@ namespace CodeImp.DoomBuilder.TagExplorer private void updatetimer_Tick(object sender, EventArgs e) { updatetimer.Stop(); - UpdateTree(true); + UpdateTree(Form.ActiveForm == General.Interface); } private void bExportToFile_Click(object sender, EventArgs e)