diff --git a/Source/Core/GZBuilder/Data/LinksCollector.cs b/Source/Core/GZBuilder/Data/LinksCollector.cs index 7889233b..3f739d82 100644 --- a/Source/Core/GZBuilder/Data/LinksCollector.cs +++ b/Source/Core/GZBuilder/Data/LinksCollector.cs @@ -18,7 +18,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data public bool ProcessPolyobjects; } - public static List GetThingLinks(ICollection visualThings) + public static List> GetThingLinks(ICollection visualThings) { List things = new List(); foreach (VisualThing vt in visualThings) things.Add(vt.Thing); @@ -26,15 +26,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data ThingsCheckResult result = CheckThings(things); if (result.ProcessPathNodes || result.ProcessInterpolationPoints || result.ProcessThingsWithGoal || result.ProcessCameras || result.ProcessPolyobjects) return GetThingLinks(result, true); - return new List(); + return null; } - - public static List GetThingLinks(ICollection things) + + public static List> GetThingLinks(ICollection things) { ThingsCheckResult result = CheckThings(things); if (result.ProcessPathNodes || result.ProcessInterpolationPoints || result.ProcessThingsWithGoal || result.ProcessCameras || result.ProcessPolyobjects) return GetThingLinks(result, false); - return new List(); + return null; } private static ThingsCheckResult CheckThings(ICollection things) @@ -62,9 +62,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data return result; } - private static List GetThingLinks(ThingsCheckResult result, bool correctHeight) + private static List> GetThingLinks(ThingsCheckResult result, bool correctHeight) { - List lines = new List(); + List> lines = new List> { new List(), new List() }; Dictionary> pathNodes = new Dictionary>(); Dictionary> interpolationPoints = new Dictionary>(); List thingsWithGoal = new List(); @@ -152,7 +152,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { end = tt.Position; if(correctHeight) end.z += GetCorrectHeight(tt); - lines.Add(new Line3D(start, end)); + lines[0].Add(new Line3D(start, end)); } } } @@ -176,7 +176,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data end = tt.Position; if(correctHeight) end.z += GetCorrectHeight(tt); - lines.Add(new Line3D(start, end, Line3DType.ACTIVATOR)); + lines[1].Add(new Line3D(start, end, General.Colors.Selection)); } } } @@ -202,7 +202,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { end = tt.Position; if(correctHeight) end.z += GetCorrectHeight(tt); - lines.Add(new Line3D(start, end)); + lines[0].Add(new Line3D(start, end)); } } } @@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { end = tt.Position; if(correctHeight) end.z += GetCorrectHeight(tt); - lines.Add(new Line3D(start, end, Line3DType.ACTIVATOR)); + lines[1].Add(new Line3D(start, end, General.Colors.Selection)); } } } @@ -250,7 +250,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { end = tt.Position; if(correctHeight) end.z += GetCorrectHeight(tt); - lines.Add(new Line3D(start, end, Line3DType.ACTIVATOR)); + lines[1].Add(new Line3D(start, end, General.Colors.Selection)); } } @@ -264,7 +264,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { end = tt.Position; if(correctHeight) end.z += GetCorrectHeight(tt); - lines.Add(new Line3D(start, end, Line3DType.ACTIVATOR)); + lines[1].Add(new Line3D(start, end, General.Colors.Selection)); } } } @@ -285,7 +285,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { end = startspot.Position; if(correctHeight) end.z += GetCorrectHeight(startspot); - lines.Add(new Line3D(start, end, Line3DType.ACTIVATOR)); + lines[1].Add(new Line3D(start, end, General.Colors.Selection)); } } } diff --git a/Source/Core/GZBuilder/Geometry/Line3D.cs b/Source/Core/GZBuilder/Geometry/Line3D.cs index 5d666f14..2bf61438 100644 --- a/Source/Core/GZBuilder/Geometry/Line3D.cs +++ b/Source/Core/GZBuilder/Geometry/Line3D.cs @@ -1,35 +1,29 @@ using System; using CodeImp.DoomBuilder.Geometry; +using CodeImp.DoomBuilder.Rendering; namespace CodeImp.DoomBuilder.GZBuilder.Geometry { - public enum Line3DType - { - DEFAULT, - ACTIVATOR, - } - public class Line3D { // Coordinates public Vector3D v1; public Vector3D v2; - public Line3DType LineType { get { return lineType; } } - private Line3DType lineType; + public PixelColor color; // Constructors public Line3D(Vector3D v1, Vector3D v2) { this.v1 = v1; this.v2 = v2; - this.lineType = Line3DType.DEFAULT; + this.color = General.Colors.InfoLine; } - public Line3D(Vector3D v1, Vector3D v2, Line3DType lineType) + public Line3D(Vector3D v1, Vector3D v2, PixelColor color) { this.v1 = v1; this.v2 = v2; - this.lineType = lineType; + this.color = color; } public Vector3D GetDelta() { return v2 - v1; } @@ -39,7 +33,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Geometry { // Calculate and return the angle Vector2D d = GetDelta(); - return -(float)Math.Atan2(-d.y, d.x) + Angle2D.PIHALF;//mxd // (float)Math.PI * 0.5f; + return -(float)Math.Atan2(-d.y, d.x) + Angle2D.PIHALF; } } } diff --git a/Source/Core/Rendering/FlatVertex.cs b/Source/Core/Rendering/FlatVertex.cs index 45b9ff1b..9e2ca7a5 100644 --- a/Source/Core/Rendering/FlatVertex.cs +++ b/Source/Core/Rendering/FlatVertex.cs @@ -24,7 +24,7 @@ namespace CodeImp.DoomBuilder.Rendering public struct FlatVertex { // Vertex format - public const int Stride = 6 * 4; + public const int Stride = 24; //6 * 4 // Members public float x; diff --git a/Source/Core/Rendering/IRenderer2D.cs b/Source/Core/Rendering/IRenderer2D.cs index f9916758..88475ef8 100644 --- a/Source/Core/Rendering/IRenderer2D.cs +++ b/Source/Core/Rendering/IRenderer2D.cs @@ -58,8 +58,6 @@ namespace CodeImp.DoomBuilder.Rendering void Present(); // Drawing methods - void RenderArrow(Line3D line, PixelColor c); //mxd - void PlotArrow(Line3D line, PixelColor c); //mxd void PlotLine(Vector2D start, Vector2D end, PixelColor c); void PlotLinedef(Linedef l, PixelColor c); void PlotLinedefSet(ICollection linedefs); @@ -74,6 +72,7 @@ namespace CodeImp.DoomBuilder.Rendering void RenderRectangleFilled(RectangleF rect, PixelColor c, bool transformrect); void RenderRectangleFilled(RectangleF rect, PixelColor c, bool transformrect, ImageData texture); void RenderLine(Vector2D start, Vector2D end, float thickness, PixelColor c, bool transformcoords); + void RenderArrows(List line); //mxd void RenderText(TextLabel text); void RenderGeometry(FlatVertex[] vertices, ImageData texture, bool transformcoords); void RenderHighlight(FlatVertex[] vertices, int color); //mxd diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index 5e5cbe0a..8112fb74 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -1687,27 +1687,73 @@ namespace CodeImp.DoomBuilder.Rendering } //mxd - public void RenderArrow(Line3D line, PixelColor c) - { - float scaler = 20f / scale; - - RenderLine(line.v1, line.v2, 0.8f, c, true); - float angle = line.GetAngle(); - //arrowhead - RenderLine(line.v2, new Vector2D(line.v2.x - scaler * (float)Math.Sin(angle - 0.46f), line.v2.y + scaler * (float)Math.Cos(angle - 0.46f)), 0.8f, c, true); - RenderLine(line.v2, new Vector2D(line.v2.x - scaler * (float)Math.Sin(angle + 0.46f), line.v2.y + scaler * (float)Math.Cos(angle + 0.46f)), 0.8f, c, true); - } - - //mxd - public void PlotArrow(Line3D line, PixelColor c) + public void RenderArrows(List lines) { + if(lines.Count == 0) return; + FlatVertex[] verts = new FlatVertex[lines.Count * 6]; //2 verts per line * 3 lines float scaler = 16f / scale; + int color; - PlotLine(line.v1, line.v2, c); - float angle = line.GetAngle(); - //arrowhead - PlotLine(line.v2, new Vector2D(line.v2.x - scaler * (float)Math.Sin(angle - 0.46f), line.v2.y + scaler * (float)Math.Cos(angle - 0.46f)), c); - PlotLine(line.v2, new Vector2D(line.v2.x - scaler * (float)Math.Sin(angle + 0.46f), line.v2.y + scaler * (float)Math.Cos(angle + 0.46f)), c); + // Create verts array + for(int i = 0; i < lines.Count; i++) + { + color = lines[i].color.ToInt(); + + // Calculate positions + Vector2D v1 = ((Vector2D)lines[i].v1).GetTransformed(translatex, translatey, scale, -scale); //start + Vector2D v2 = ((Vector2D)lines[i].v2).GetTransformed(translatex, translatey, scale, -scale); //end + + float angle = lines[i].GetAngle(); + Vector2D v3 = new Vector2D(lines[i].v2.x - scaler * (float)Math.Sin(angle - 0.46f), lines[i].v2.y + scaler * (float)Math.Cos(angle - 0.46f)).GetTransformed(translatex, translatey, scale, -scale); //arrowhead end 1 + Vector2D v4 = new Vector2D(lines[i].v2.x - scaler * (float)Math.Sin(angle + 0.46f), lines[i].v2.y + scaler * (float)Math.Cos(angle + 0.46f)).GetTransformed(translatex, translatey, scale, -scale); //arrowhead end 2 + + verts[i * 6].x = v1.x; + verts[i * 6].y = v1.y; + verts[i * 6].c = color; + + verts[i * 6 + 1].x = v2.x; + verts[i * 6 + 1].y = v2.y; + verts[i * 6 + 1].c = color; + + // Arrowhead + verts[i * 6 + 2] = verts[i * 6 + 1]; + verts[i * 6 + 3].x = v3.x; + verts[i * 6 + 3].y = v3.y; + verts[i * 6 + 3].c = color; + + verts[i * 6 + 4] = verts[i * 6 + 1]; + verts[i * 6 + 5].x = v4.x; + verts[i * 6 + 5].y = v4.y; + verts[i * 6 + 5].c = color; + } + + // Write to buffer + VertexBuffer vb = new VertexBuffer(General.Map.Graphics.Device, FlatVertex.Stride * verts.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); + DataStream s = vb.Lock(0, FlatVertex.Stride * verts.Length, LockFlags.Discard); + s.WriteRange(verts); + vb.Unlock(); + s.Dispose(); + + // Set renderstates for rendering + graphics.Device.SetRenderState(RenderState.CullMode, Cull.None); + graphics.Device.SetRenderState(RenderState.ZEnable, false); + graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false); + graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false); + graphics.Device.SetRenderState(RenderState.TextureFactor, -1); + graphics.Device.SetRenderState(RenderState.FogEnable, false); + SetWorldTransformation(false); + graphics.Device.SetTexture(0, General.Map.Data.WhiteTexture.Texture); + graphics.Shaders.Display2D.Texture1 = General.Map.Data.WhiteTexture.Texture; + graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear); + + // Draw + graphics.Shaders.Display2D.Begin(); + graphics.Shaders.Display2D.BeginPass(1); + graphics.Device.SetStreamSource(0, vb, 0, FlatVertex.Stride); + graphics.Device.DrawPrimitives(PrimitiveType.LineList, 0, lines.Count * 3); + graphics.Shaders.Display2D.EndPass(); + graphics.Shaders.Display2D.End(); + vb.Dispose(); } // This renders a line with given color @@ -1759,7 +1805,7 @@ namespace CodeImp.DoomBuilder.Rendering // Draw graphics.Shaders.Display2D.Begin(); graphics.Shaders.Display2D.BeginPass(0); - graphics.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 2, verts); + graphics.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 2, verts); graphics.Shaders.Display2D.EndPass(); graphics.Shaders.Display2D.End(); } diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 10089d11..0b97f2d0 100644 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -466,26 +466,8 @@ namespace CodeImp.DoomBuilder.Rendering //mxd. LINKS if (General.Settings.GZShowEventLines) { - //mxd. gather links - List lines = LinksCollector.GetThingLinks(thingsbydistance); - if(lines.Count > 0) - { - List normalLines = new List(); - List activatorLines = new List(); - - foreach(Line3D l in lines) - { - if(l.LineType == Line3DType.DEFAULT) - normalLines.Add(l); - else - activatorLines.Add(l); - } - - if(normalLines.Count > 0) - RenderArrows(normalLines, General.Colors.InfoLine.ToColorValue()); - if(activatorLines.Count > 0) - RenderArrows(activatorLines, General.Colors.Selection3D.ToColorValue()); - } + List> lines = LinksCollector.GetThingLinks(thingsbydistance); + if(lines != null) foreach(List list in lines) if(list.Count > 0) RenderArrows(list); } // ADDITIVE PASS @@ -680,7 +662,7 @@ namespace CodeImp.DoomBuilder.Rendering } //mxd - private void RenderArrows(List lines, Color4 color) + private void RenderArrows(List lines) { //create vertices WorldVertex[] verts = new WorldVertex[lines.Count * 6]; @@ -718,7 +700,7 @@ namespace CodeImp.DoomBuilder.Rendering ApplyMatrices3D(); // Setup color - graphics.Shaders.World3D.VertexColor = color; + graphics.Shaders.World3D.VertexColor = lines[0].color.ToColorValue(); //render graphics.Shaders.World3D.ApplySettings(); diff --git a/Source/Core/Rendering/WorldVertex.cs b/Source/Core/Rendering/WorldVertex.cs index 2f828346..06ba0f6a 100644 --- a/Source/Core/Rendering/WorldVertex.cs +++ b/Source/Core/Rendering/WorldVertex.cs @@ -26,7 +26,7 @@ namespace CodeImp.DoomBuilder.Rendering public struct WorldVertex { // Vertex format - public const int Stride = 9 * 4; //mxd: was 6 * 4 + public const int Stride = 36; //mxd: 9 * 4, was 6 * 4 // Members public float x; diff --git a/Source/Core/ZDoom/ZDTextParser.cs b/Source/Core/ZDoom/ZDTextParser.cs index b25d65a9..8353fb34 100644 --- a/Source/Core/ZDoom/ZDTextParser.cs +++ b/Source/Core/ZDoom/ZDTextParser.cs @@ -182,7 +182,7 @@ namespace CodeImp.DoomBuilder.ZDoom if(datastream.Position == datastream.Length) //mxd { // ZDoom doesn't give even a warning message about this, so we shouldn't report error or fail parsing. - General.ErrorLogger.Add(ErrorType.Warning, "DECORATE warning in '" + sourcename + "', line " + GetCurrentLineNumber() + ". Block comment is not closed"); + General.ErrorLogger.Add(ErrorType.Warning, "DECORATE warning in '" + sourcename + "', line " + GetCurrentLineNumber() + ". Block comment is not closed."); return true; } diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 5eb38499..5c9276b2 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -21,16 +21,17 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; -using CodeImp.DoomBuilder.Windows; +using CodeImp.DoomBuilder.Actions; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Data; +using CodeImp.DoomBuilder.Editing; +using CodeImp.DoomBuilder.Geometry; +using CodeImp.DoomBuilder.GZBuilder.Geometry; +using CodeImp.DoomBuilder.GZBuilder.Tools; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; -using CodeImp.DoomBuilder.Geometry; -using CodeImp.DoomBuilder.Editing; -using CodeImp.DoomBuilder.Actions; using CodeImp.DoomBuilder.Types; -using CodeImp.DoomBuilder.Config; -using CodeImp.DoomBuilder.GZBuilder.Tools; -using CodeImp.DoomBuilder.Data; +using CodeImp.DoomBuilder.Windows; #endregion @@ -362,17 +363,17 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnRedrawDisplay() { renderer.RedrawSurface(); + List eventlines = new List(); //mxd // Render lines if(renderer.StartPlotter(true)) { renderer.PlotLinedefSet(General.Map.Map.Linedefs); - if(!panning) //mxd - for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.Me.PlotAssociations(renderer, association[i]); + for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.PlotAssociations(renderer, association[i], eventlines); if((highlighted != null) && !highlighted.IsDisposed) { - if(!panning) BuilderPlug.Me.PlotReverseAssociations(renderer, highlightasso); + BuilderPlug.PlotReverseAssociations(renderer, highlightasso, eventlines); renderer.PlotLinedef(highlighted, General.Colors.Highlight); } renderer.PlotVerticesSet(General.Map.Map.Vertices); @@ -390,12 +391,13 @@ namespace CodeImp.DoomBuilder.BuilderModes // Render selection if(renderer.StartOverlay(true)) { - if(!panning && !selecting) //mxd + if(!selecting) //mxd { - for (int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.Me.RenderAssociations(renderer, association[i]); - if ((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.Me.RenderReverseAssociations(renderer, highlightasso); //mxd + for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.RenderAssociations(renderer, association[i], eventlines); + if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.RenderReverseAssociations(renderer, highlightasso, eventlines); //mxd } if(selecting) RenderMultiSelection(); + renderer.RenderArrows(eventlines); //mxd renderer.Finish(); } @@ -549,7 +551,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); - if(panning) return; //mxd. Skip all this jass while panning + if(panning) return; //mxd. Skip all this jazz while panning //mxd if(selectpressed && !editpressed && !selecting) @@ -611,15 +613,15 @@ namespace CodeImp.DoomBuilder.BuilderModes //render preview if(renderer.StartOverlay(true)) { - if(!panning) - { - for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.Me.RenderAssociations(renderer, association[i]); - if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.Me.RenderReverseAssociations(renderer, highlightasso); //mxd - } + List eventlines = new List(); //mxd + for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.RenderAssociations(renderer, association[i], eventlines); + if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.RenderReverseAssociations(renderer, highlightasso, eventlines); //mxd + float dist = Math.Min(Vector2D.Distance(mousemappos, insertPreview), BuilderPlug.Me.SplitLinedefsRange); byte alpha = (byte)(255 - (dist / BuilderPlug.Me.SplitLinedefsRange) * 128); float vsize = (renderer.VertexSize + 1.0f) / renderer.Scale; renderer.RenderRectangleFilled(new RectangleF(insertPreview.x - vsize, insertPreview.y - vsize, vsize * 2.0f, vsize * 2.0f), General.Colors.InfoLine.WithAlpha(alpha), true); + renderer.RenderArrows(eventlines); //mxd renderer.Finish(); renderer.Present(); } @@ -631,11 +633,11 @@ namespace CodeImp.DoomBuilder.BuilderModes //undraw preveiw if(renderer.StartOverlay(true)) { - if(!panning) - { - for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.Me.RenderAssociations(renderer, association[i]); - if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.Me.RenderReverseAssociations(renderer, highlightasso); //mxd - } + List eventlines = new List(); //mxd + for(int i = 0; i < Linedef.NUM_ARGS; i++) BuilderPlug.RenderAssociations(renderer, association[i], eventlines); + if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.RenderReverseAssociations(renderer, highlightasso, eventlines); //mxd + + renderer.RenderArrows(eventlines); //mxd renderer.Finish(); renderer.Present(); } diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index e4e459ef..6b2f3efe 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -18,18 +18,19 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Windows.Forms; -using CodeImp.DoomBuilder.Windows; +using CodeImp.DoomBuilder.Actions; +using CodeImp.DoomBuilder.BuilderModes.Interface; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Editing; +using CodeImp.DoomBuilder.Geometry; +using CodeImp.DoomBuilder.GZBuilder.Geometry; +using CodeImp.DoomBuilder.GZBuilder.Tools; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; -using CodeImp.DoomBuilder.Geometry; -using CodeImp.DoomBuilder.Editing; -using System.Drawing; -using CodeImp.DoomBuilder.Actions; using CodeImp.DoomBuilder.Types; -using CodeImp.DoomBuilder.BuilderModes.Interface; -using CodeImp.DoomBuilder.GZBuilder.Tools; -using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Windows; #endregion @@ -714,6 +715,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnRedrawDisplay() { renderer.RedrawSurface(); + List eventlines = new List(); //mxd // Render lines and vertices if(renderer.StartPlotter(true)) @@ -723,7 +725,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if((highlighted != null) && !highlighted.IsDisposed) { renderer.PlotSector(highlighted, General.Colors.Highlight); - if(!panning) BuilderPlug.Me.PlotReverseAssociations(renderer, highlightasso); + BuilderPlug.PlotReverseAssociations(renderer, highlightasso, eventlines); } renderer.Finish(); } @@ -742,8 +744,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Render selection if(renderer.StartOverlay(false)) { - if(!panning && highlighted != null && !highlighted.IsDisposed) BuilderPlug.Me.RenderReverseAssociations(renderer, highlightasso); //mxd + if(highlighted != null && !highlighted.IsDisposed) BuilderPlug.RenderReverseAssociations(renderer, highlightasso, eventlines); //mxd if(selecting) RenderMultiSelection(); + renderer.RenderArrows(eventlines); //mxd renderer.Finish(); } diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index 7251cf0a..a69437c8 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -151,17 +151,17 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnRedrawDisplay() { renderer.RedrawSurface(); + List eventlines = new List(); //mxd // Render lines and vertices if (renderer.StartPlotter(true)) { renderer.PlotLinedefSet(General.Map.Map.Linedefs); renderer.PlotVerticesSet(General.Map.Map.Vertices); - if(!panning) //mxd - { - for(int i = 0; i < Thing.NUM_ARGS; i++) BuilderPlug.Me.PlotAssociations(renderer, association[i]); - if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.Me.PlotReverseAssociations(renderer, highlightasso); - } + + for(int i = 0; i < Thing.NUM_ARGS; i++) BuilderPlug.PlotAssociations(renderer, association[i], eventlines); + if((highlighted != null) && !highlighted.IsDisposed) BuilderPlug.PlotReverseAssociations(renderer, highlightasso, eventlines); + renderer.Finish(); } @@ -170,22 +170,26 @@ namespace CodeImp.DoomBuilder.BuilderModes { renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, Presentation.THINGS_HIDDEN_ALPHA); renderer.RenderThingSet(General.Map.ThingsFilter.VisibleThings, 1.0f); - if(!panning) //mxd - for(int i = 0; i < Thing.NUM_ARGS; i++) BuilderPlug.Me.RenderAssociations(renderer, association[i]); + for(int i = 0; i < Thing.NUM_ARGS; i++) BuilderPlug.RenderAssociations(renderer, association[i], eventlines); + if((highlighted != null) && !highlighted.IsDisposed) { renderer.RenderThing(highlighted, General.Colors.Highlight, 1.0f); - if(!panning) BuilderPlug.Me.RenderReverseAssociations(renderer, highlightasso); //mxd + BuilderPlug.RenderReverseAssociations(renderer, highlightasso, eventlines); //mxd } //mxd - if(!panning && General.Settings.GZShowEventLines) + if(General.Settings.GZShowEventLines) { - List lines = GZBuilder.Data.LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings); - - foreach(Line3D l in lines) + List> lines = GZBuilder.Data.LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings); + if(lines != null) { - renderer.RenderArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); + lines[0].AddRange(eventlines); + foreach(List list in lines) if(list.Count > 0) renderer.RenderArrows(list); + } + else + { + renderer.RenderArrows(eventlines); } } @@ -471,7 +475,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); - if(panning) return; //mxd. Skip all this jass while panning + if(panning) return; //mxd. Skip all this jazz while panning //mxd if(selectpressed && !editpressed && !selecting) diff --git a/Source/Plugins/BuilderModes/General/BuilderPlug.cs b/Source/Plugins/BuilderModes/General/BuilderPlug.cs index dfca129a..d027c12a 100644 --- a/Source/Plugins/BuilderModes/General/BuilderPlug.cs +++ b/Source/Plugins/BuilderModes/General/BuilderPlug.cs @@ -522,105 +522,77 @@ namespace CodeImp.DoomBuilder.BuilderModes } // This renders the associated sectors/linedefs with the indication color - public void PlotAssociations(IRenderer2D renderer, Association asso) + public static void PlotAssociations(IRenderer2D renderer, Association asso, List eventlines) { // Tag must be above zero if(asso.tag < 1) return; // Sectors? - if(asso.type == UniversalType.SectorTag) + switch(asso.type) { - List lines = new List(); //mxd - foreach(Sector s in General.Map.Map.Sectors) - { - if(s.Tag == asso.tag) + case UniversalType.SectorTag: { + foreach(Sector s in General.Map.Map.Sectors) { + if(s.Tag != asso.tag) continue; renderer.PlotSector(s, General.Colors.Indication); - if (General.Settings.GZShowEventLines) - { - Vector2D end = (s.Labels.Count > 0 ? s.Labels[0].position : new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2)); - lines.Add(new Line3D(asso.Center, end)); //mxd - } + + if(!General.Settings.GZShowEventLines) continue; + Vector2D end = (s.Labels.Count > 0 ? s.Labels[0].position : new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2)); + eventlines.Add(new Line3D(asso.Center, end)); //mxd } + break; } - if(General.Settings.GZShowEventLines) //mxd - { - foreach(Line3D l in lines) - renderer.PlotArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); - } - } - // Linedefs? - else if(asso.type == UniversalType.LinedefTag) - { - List lines = new List(); //mxd - foreach(Linedef l in General.Map.Map.Linedefs) - { - if(l.Tag == asso.tag) + case UniversalType.LinedefTag: { + foreach(Linedef l in General.Map.Map.Linedefs) { + if(l.Tag != asso.tag) continue; renderer.PlotLinedef(l, General.Colors.Indication); - if(General.Settings.GZShowEventLines) - lines.Add(new Line3D(asso.Center, l.GetCenterPoint()));//mxd + if(General.Settings.GZShowEventLines) eventlines.Add(new Line3D(asso.Center, l.GetCenterPoint())); //mxd } - } - - if(General.Settings.GZShowEventLines) //mxd - { - foreach(Line3D l in lines) - renderer.PlotArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); + break; } } } - // This renders the associated things with the indication color - public void RenderAssociations(IRenderer2D renderer, Association asso) + public static void RenderAssociations(IRenderer2D renderer, Association asso, List eventlines) { // Tag must be above zero if(asso.tag < 1) return; // Things? - if(asso.type == UniversalType.ThingTag) + switch(asso.type) { - List lines = new List(); //mxd - foreach(Thing t in General.Map.Map.Things) - { - if(t.Tag == asso.tag) + case UniversalType.ThingTag: { + foreach(Thing t in General.Map.Map.Things) { + if(t.Tag != asso.tag) continue; renderer.RenderThing(t, General.Colors.Indication, 1.0f); - if(General.Settings.GZShowEventLines) - lines.Add(new Line3D(asso.Center, t.Position));//mxd + if(General.Settings.GZShowEventLines) eventlines.Add(new Line3D(asso.Center, t.Position)); //mxd } + break; } - if(General.Settings.GZShowEventLines) //mxd - { - foreach(Line3D l in lines) - renderer.RenderArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); - } - } - else if(asso.type == UniversalType.SectorTag) //mxd. Render sector highlight - { - foreach(Sector s in General.Map.Map.Sectors) - { - if(s.Tag == asso.tag) + + case UniversalType.SectorTag: + foreach(Sector s in General.Map.Map.Sectors) { + if(s.Tag != asso.tag) continue; int highlightedColor = General.Colors.Highlight.WithAlpha(128).ToInt(); FlatVertex[] verts = new FlatVertex[s.FlatVertices.Length]; s.FlatVertices.CopyTo(verts, 0); for(int i = 0; i < verts.Length; i++) verts[i].c = highlightedColor; renderer.RenderGeometry(verts, null, true); } - } + break; } } // This renders the associated sectors/linedefs with the indication color - public void PlotReverseAssociations(IRenderer2D renderer, Association asso) + public static void PlotReverseAssociations(IRenderer2D renderer, Association asso, List eventlines) { // Tag must be above zero if(asso.tag < 1) return; - - List lines = new List(); //mxd // Doom style referencing to sectors? if(General.Map.Config.LineTagIndicatesSectors && (asso.type == UniversalType.SectorTag)) @@ -629,64 +601,39 @@ namespace CodeImp.DoomBuilder.BuilderModes foreach(Linedef l in General.Map.Map.Linedefs) { // Any action on this line? - if(l.Action > 0) - { - if(l.Tag == asso.tag) - { - renderer.PlotLinedef(l, General.Colors.Indication); - - if(General.Settings.GZShowEventLines) //mxd - lines.Add(new Line3D(l.GetCenterPoint(), asso.Center)); //mxd - } - } - } - if(General.Settings.GZShowEventLines) //mxd - { - foreach(Line3D l in lines) - renderer.PlotArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); + if(l.Action <= 0 || l.Tag != asso.tag) continue; + renderer.PlotLinedef(l, General.Colors.Indication); + if(General.Settings.GZShowEventLines) eventlines.Add(new Line3D(l.GetCenterPoint(), asso.Center)); //mxd } } - else + + // Linedefs + foreach(Linedef l in General.Map.Map.Linedefs) { - // Linedefs - foreach(Linedef l in General.Map.Map.Linedefs) + // Known action on this line? + if((l.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(l.Action)) { - // Known action on this line? - if((l.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(l.Action)) + LinedefActionInfo action = General.Map.Config.LinedefActions[l.Action]; + if( ((action.Args[0].Type == (int)asso.type) && (l.Args[0] == asso.tag)) || + ((action.Args[1].Type == (int)asso.type) && (l.Args[1] == asso.tag)) || + ((action.Args[2].Type == (int)asso.type) && (l.Args[2] == asso.tag)) || + ((action.Args[3].Type == (int)asso.type) && (l.Args[3] == asso.tag)) || + ((action.Args[4].Type == (int)asso.type) && (l.Args[4] == asso.tag)) ) { - LinedefActionInfo action = General.Map.Config.LinedefActions[l.Action]; - if( ((action.Args[0].Type == (int)asso.type) && (l.Args[0] == asso.tag)) || - ((action.Args[1].Type == (int)asso.type) && (l.Args[1] == asso.tag)) || - ((action.Args[2].Type == (int)asso.type) && (l.Args[2] == asso.tag)) || - ((action.Args[3].Type == (int)asso.type) && (l.Args[3] == asso.tag)) || - ((action.Args[4].Type == (int)asso.type) && (l.Args[4] == asso.tag)) ) - { - renderer.PlotLinedef(l, General.Colors.Indication); - - if(General.Settings.GZShowEventLines) //mxd - lines.Add(new Line3D(l.GetCenterPoint(), asso.Center)); - } + renderer.PlotLinedef(l, General.Colors.Indication); + if(General.Settings.GZShowEventLines) eventlines.Add(new Line3D(l.GetCenterPoint(), asso.Center)); //mxd } } - - if(General.Settings.GZShowEventLines) //mxd - { - foreach(Line3D l in lines) - renderer.PlotArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); - } } } - // This renders the associated things with the indication color - public void RenderReverseAssociations(IRenderer2D renderer, Association asso) + public static void RenderReverseAssociations(IRenderer2D renderer, Association asso, List eventlines) { // Tag must be above zero if(asso.tag < 1) return; - List lines = new List(); //mxd - // Things foreach(Thing t in General.Map.Map.Things) { @@ -701,17 +648,10 @@ namespace CodeImp.DoomBuilder.BuilderModes ((action.Args[4].Type == (int)asso.type) && (t.Args[4] == asso.tag)) ) { renderer.RenderThing(t, General.Colors.Indication, 1.0f); - if(General.Settings.GZShowEventLines) //mxd - lines.Add(new Line3D(t.Position, asso.Center)); + if(General.Settings.GZShowEventLines) eventlines.Add(new Line3D(t.Position, asso.Center)); //mxd } } } - - if(General.Settings.GZShowEventLines) //mxd - { - foreach(Line3D l in lines) - renderer.RenderArrow(l, l.LineType == Line3DType.ACTIVATOR ? General.Colors.Selection : General.Colors.InfoLine); - } } #endregion