mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Improved performance in classic modes when panning the view. This is achieved by parallelizing plotting linedefs and vertices on multiple logical CPU cores. Enabled for linedefs by default. Disabled for vertices by default, since it can cause flickering when vertices are close to each other. Settings can be changed in Preferences -> Appearance
This commit is contained in:
parent
e49c91960b
commit
af25e772e3
4 changed files with 144 additions and 37 deletions
|
@ -98,6 +98,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private bool showfps;
|
||||
private int[] colordialogcustomcolors;
|
||||
private bool autolaunchontest;
|
||||
private bool parallelizedlinedefplotting;
|
||||
private bool parallelizedvertexplotting;
|
||||
|
||||
//mxd. Script editor settings
|
||||
private string scriptfontname;
|
||||
|
@ -214,6 +216,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public bool ShowFPS { get { return showfps; } internal set { showfps = value; } }
|
||||
public int[] ColorDialogCustomColors { get { return colordialogcustomcolors; } internal set { colordialogcustomcolors = value; } }
|
||||
public bool AutoLaunchOnTest { get { return autolaunchontest; } internal set { autolaunchontest = value; } }
|
||||
public bool ParallelizedLinedefPlotting { get { return parallelizedlinedefplotting; } internal set { parallelizedlinedefplotting = value; } }
|
||||
public bool ParallelizedVertexPlotting { get { return parallelizedvertexplotting; } internal set { parallelizedvertexplotting = value; } }
|
||||
|
||||
//mxd. Highlight mode
|
||||
public bool UseHighlight
|
||||
|
@ -369,6 +373,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
switchviewmodes = cfg.ReadSetting("switchviewmodes", false); //mxd
|
||||
showfps = cfg.ReadSetting("showfps", false);
|
||||
autolaunchontest = cfg.ReadSetting("autolaunchontest", false);
|
||||
parallelizedlinedefplotting = cfg.ReadSetting("parallelizedlinedefplotting", true);
|
||||
parallelizedvertexplotting = cfg.ReadSetting("parallelizedvertexplotting", false);
|
||||
|
||||
//mxd. Script editor
|
||||
scriptfontname = cfg.ReadSetting("scriptfontname", "Courier New");
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
@ -2128,6 +2128,45 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// This renders a set of linedefs
|
||||
public void PlotLinedefSet(ICollection<Linedef> linedefs)
|
||||
{
|
||||
// biwa. Code duplication because the performance hit from the overhead of calling PlotLinedef in a loop causes reduced FPS.
|
||||
// Telling the compiler to agressively inline PlotLinedef seems to mostly alleviate the problem, but I'm not sure how reliable that is
|
||||
if (General.Settings.ParallelizedLinedefPlotting)
|
||||
{
|
||||
// Go for all linedefs
|
||||
Parallel.ForEach(linedefs, l =>
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
Vector2D v1 = l.Start.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
Vector2D v2 = l.End.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
||||
//mxd. Should we bother?
|
||||
double lengthsq = (v2 - v1).GetLengthSq();
|
||||
if (lengthsq < minlinelength) return; //mxd
|
||||
|
||||
// Determine color
|
||||
PixelColor c = DetermineLinedefColor(l);
|
||||
|
||||
// Draw line. mxd: added 3d-floor indication
|
||||
if (l.ExtraFloorFlag && General.Settings.GZMarkExtraFloors)
|
||||
plotter.DrawLine3DFloor((int)v1.x, TransformY((int)v1.y), (int)v2.x, TransformY((int)v2.y), ref c, General.Colors.ThreeDFloor);
|
||||
else
|
||||
plotter.DrawLineSolid((int)v1.x, TransformY((int)v1.y), (int)v2.x, TransformY((int)v2.y), ref c);
|
||||
|
||||
//mxd. Should we bother?
|
||||
if (lengthsq < minlinenormallength) return; //mxd
|
||||
|
||||
// Calculate normal indicator
|
||||
double mx = (v2.x - v1.x) * 0.5f;
|
||||
double my = (v2.y - v1.y) * 0.5f;
|
||||
|
||||
// Draw normal indicator
|
||||
plotter.DrawLineSolid((int)(v1.x + mx), TransformY((int)(v1.y + my)),
|
||||
(int)((v1.x + mx) - (my * l.LengthInv) * linenormalsize),
|
||||
TransformY((int)((v1.y + my) + (mx * l.LengthInv) * linenormalsize)), ref c);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go for all linedefs
|
||||
foreach (Linedef l in linedefs)
|
||||
|
@ -2162,6 +2201,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
TransformY((int)((v1.y + my) + (mx * l.LengthInv) * linenormalsize)), ref c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This renders a single vertex
|
||||
public void PlotVertex(Vertex v, int colorindex, bool checkMode = true)
|
||||
|
@ -2200,8 +2240,36 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
return;
|
||||
}
|
||||
|
||||
// biwa. Code duplication because the performance hit from the overhead of calling PlotLinedef in a loop causes reduced FPS.
|
||||
// Telling the compiler to agressively inline PlotLinedef seems to mostly alleviate the problem, but I'm not sure how reliable that is
|
||||
if (General.Settings.ParallelizedVertexPlotting)
|
||||
{
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in vertices) PlotVertex(v, DetermineVertexColor(v));
|
||||
Parallel.ForEach(vertices, v =>
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
Vector2D nv = v.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
||||
int colorindex = DetermineVertexColor(v);
|
||||
|
||||
// Draw pixel here
|
||||
plotter.DrawVertexSolid((int)nv.x, TransformY((int)nv.y), vertexsize, ref General.Colors.Colors[colorindex], ref General.Colors.BrightColors[colorindex], ref General.Colors.DarkColors[colorindex]);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go for all vertices
|
||||
foreach (Vertex v in vertices)
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
Vector2D nv = v.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
||||
int colorindex = DetermineVertexColor(v);
|
||||
|
||||
// Draw pixel here
|
||||
plotter.DrawVertexSolid((int)nv.x, TransformY((int)nv.y), vertexsize, ref General.Colors.Colors[colorindex], ref General.Colors.BrightColors[colorindex], ref General.Colors.DarkColors[colorindex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
47
Source/Core/Windows/PreferencesForm.Designer.cs
generated
47
Source/Core/Windows/PreferencesForm.Designer.cs
generated
|
@ -74,6 +74,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.cbStretchView = new System.Windows.Forms.CheckBox();
|
||||
this.scriptautoclosebrackets = new System.Windows.Forms.CheckBox();
|
||||
this.scriptallmanstyle = new System.Windows.Forms.CheckBox();
|
||||
this.cbParallelizedLinedefPlotting = new System.Windows.Forms.CheckBox();
|
||||
this.cbParallelizedVertexPlotting = new System.Windows.Forms.CheckBox();
|
||||
this.browseScreenshotsFolderDialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.apply = new System.Windows.Forms.Button();
|
||||
this.cancel = new System.Windows.Forms.Button();
|
||||
|
@ -657,7 +659,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// cbMarkExtraFloors
|
||||
//
|
||||
this.cbMarkExtraFloors.AutoSize = true;
|
||||
this.cbMarkExtraFloors.Location = new System.Drawing.Point(18, 466);
|
||||
this.cbMarkExtraFloors.Location = new System.Drawing.Point(18, 442);
|
||||
this.cbMarkExtraFloors.Name = "cbMarkExtraFloors";
|
||||
this.cbMarkExtraFloors.Size = new System.Drawing.Size(175, 17);
|
||||
this.cbMarkExtraFloors.TabIndex = 1;
|
||||
|
@ -669,7 +671,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// cbFlatShadeVertices
|
||||
//
|
||||
this.cbFlatShadeVertices.AutoSize = true;
|
||||
this.cbFlatShadeVertices.Location = new System.Drawing.Point(18, 489);
|
||||
this.cbFlatShadeVertices.Location = new System.Drawing.Point(18, 465);
|
||||
this.cbFlatShadeVertices.Name = "cbFlatShadeVertices";
|
||||
this.cbFlatShadeVertices.Size = new System.Drawing.Size(115, 17);
|
||||
this.cbFlatShadeVertices.TabIndex = 1;
|
||||
|
@ -703,7 +705,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// cbOldHighlightMode
|
||||
//
|
||||
this.cbOldHighlightMode.AutoSize = true;
|
||||
this.cbOldHighlightMode.Location = new System.Drawing.Point(229, 443);
|
||||
this.cbOldHighlightMode.Location = new System.Drawing.Point(229, 419);
|
||||
this.cbOldHighlightMode.Name = "cbOldHighlightMode";
|
||||
this.cbOldHighlightMode.Size = new System.Drawing.Size(207, 17);
|
||||
this.cbOldHighlightMode.TabIndex = 15;
|
||||
|
@ -715,7 +717,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// cbStretchView
|
||||
//
|
||||
this.cbStretchView.AutoSize = true;
|
||||
this.cbStretchView.Location = new System.Drawing.Point(229, 397);
|
||||
this.cbStretchView.Location = new System.Drawing.Point(229, 373);
|
||||
this.cbStretchView.Name = "cbStretchView";
|
||||
this.cbStretchView.Size = new System.Drawing.Size(172, 17);
|
||||
this.cbStretchView.TabIndex = 13;
|
||||
|
@ -747,6 +749,29 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.toolTip1.SetToolTip(this.scriptallmanstyle, resources.GetString("scriptallmanstyle.ToolTip"));
|
||||
this.scriptallmanstyle.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbParallelizedLinedefPlotting
|
||||
//
|
||||
this.cbParallelizedLinedefPlotting.AutoSize = true;
|
||||
this.cbParallelizedLinedefPlotting.Location = new System.Drawing.Point(229, 465);
|
||||
this.cbParallelizedLinedefPlotting.Name = "cbParallelizedLinedefPlotting";
|
||||
this.cbParallelizedLinedefPlotting.Size = new System.Drawing.Size(150, 17);
|
||||
this.cbParallelizedLinedefPlotting.TabIndex = 49;
|
||||
this.cbParallelizedLinedefPlotting.Text = "Parallelized linedef plotting";
|
||||
this.toolTip1.SetToolTip(this.cbParallelizedLinedefPlotting, "Parallelizes linedef plotting over all logical CPU cores.");
|
||||
this.cbParallelizedLinedefPlotting.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbParallelizedVertexPlotting
|
||||
//
|
||||
this.cbParallelizedVertexPlotting.AutoSize = true;
|
||||
this.cbParallelizedVertexPlotting.Location = new System.Drawing.Point(18, 488);
|
||||
this.cbParallelizedVertexPlotting.Name = "cbParallelizedVertexPlotting";
|
||||
this.cbParallelizedVertexPlotting.Size = new System.Drawing.Size(148, 17);
|
||||
this.cbParallelizedVertexPlotting.TabIndex = 50;
|
||||
this.cbParallelizedVertexPlotting.Text = "Parallelized vertex plotting";
|
||||
this.toolTip1.SetToolTip(this.cbParallelizedVertexPlotting, "Parallelizes vertex plotting over all logical CPU cores. Can result in vertices c" +
|
||||
"lose to each other flickering when panning the view");
|
||||
this.cbParallelizedVertexPlotting.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// browseScreenshotsFolderDialog
|
||||
//
|
||||
this.browseScreenshotsFolderDialog.Description = "Select a Folder to Save Screenshots Into";
|
||||
|
@ -1468,6 +1493,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.appearancegroup1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.appearancegroup1.Controls.Add(this.cbParallelizedVertexPlotting);
|
||||
this.appearancegroup1.Controls.Add(this.cbParallelizedLinedefPlotting);
|
||||
this.appearancegroup1.Controls.Add(this.activethingsalphalabel);
|
||||
this.appearancegroup1.Controls.Add(this.label31);
|
||||
this.appearancegroup1.Controls.Add(this.cbMarkExtraFloors);
|
||||
|
@ -1593,7 +1620,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// cbShowFPS
|
||||
//
|
||||
this.cbShowFPS.AutoSize = true;
|
||||
this.cbShowFPS.Location = new System.Drawing.Point(229, 466);
|
||||
this.cbShowFPS.Location = new System.Drawing.Point(229, 442);
|
||||
this.cbShowFPS.Name = "cbShowFPS";
|
||||
this.cbShowFPS.Size = new System.Drawing.Size(148, 17);
|
||||
this.cbShowFPS.TabIndex = 15;
|
||||
|
@ -1612,7 +1639,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// qualitydisplay
|
||||
//
|
||||
this.qualitydisplay.AutoSize = true;
|
||||
this.qualitydisplay.Location = new System.Drawing.Point(18, 397);
|
||||
this.qualitydisplay.Location = new System.Drawing.Point(18, 373);
|
||||
this.qualitydisplay.Name = "qualitydisplay";
|
||||
this.qualitydisplay.Size = new System.Drawing.Size(128, 17);
|
||||
this.qualitydisplay.TabIndex = 10;
|
||||
|
@ -1666,7 +1693,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// animatevisualselection
|
||||
//
|
||||
this.animatevisualselection.AutoSize = true;
|
||||
this.animatevisualselection.Location = new System.Drawing.Point(229, 420);
|
||||
this.animatevisualselection.Location = new System.Drawing.Point(229, 396);
|
||||
this.animatevisualselection.Name = "animatevisualselection";
|
||||
this.animatevisualselection.Size = new System.Drawing.Size(190, 17);
|
||||
this.animatevisualselection.TabIndex = 14;
|
||||
|
@ -1709,7 +1736,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// visualbilinear
|
||||
//
|
||||
this.visualbilinear.AutoSize = true;
|
||||
this.visualbilinear.Location = new System.Drawing.Point(18, 443);
|
||||
this.visualbilinear.Location = new System.Drawing.Point(18, 419);
|
||||
this.visualbilinear.Name = "visualbilinear";
|
||||
this.visualbilinear.Size = new System.Drawing.Size(171, 17);
|
||||
this.visualbilinear.TabIndex = 12;
|
||||
|
@ -1719,7 +1746,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// classicbilinear
|
||||
//
|
||||
this.classicbilinear.AutoSize = true;
|
||||
this.classicbilinear.Location = new System.Drawing.Point(18, 420);
|
||||
this.classicbilinear.Location = new System.Drawing.Point(18, 396);
|
||||
this.classicbilinear.Name = "classicbilinear";
|
||||
this.classicbilinear.Size = new System.Drawing.Size(176, 17);
|
||||
this.classicbilinear.TabIndex = 11;
|
||||
|
@ -2848,5 +2875,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private System.Windows.Forms.ListView lvToastActions;
|
||||
private System.Windows.Forms.ColumnHeader title;
|
||||
private System.Windows.Forms.ColumnHeader description;
|
||||
private System.Windows.Forms.CheckBox cbParallelizedVertexPlotting;
|
||||
private System.Windows.Forms.CheckBox cbParallelizedLinedefPlotting;
|
||||
}
|
||||
}
|
|
@ -99,6 +99,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
cbShowFPS.Checked = General.Settings.ShowFPS;
|
||||
autolaunchontest.Checked = General.Settings.AutoLaunchOnTest;
|
||||
cbFlatShadeVertices.Checked = General.Settings.FlatShadeVertices;
|
||||
cbParallelizedLinedefPlotting.Checked = General.Settings.ParallelizedLinedefPlotting;
|
||||
cbParallelizedVertexPlotting.Checked = General.Settings.ParallelizedVertexPlotting;
|
||||
|
||||
//mxd
|
||||
locatetexturegroup.Checked = General.Settings.LocateTextureGroup;
|
||||
|
@ -360,6 +362,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
General.Settings.ShowFPS = cbShowFPS.Checked;
|
||||
General.Settings.AutoLaunchOnTest = autolaunchontest.Checked;
|
||||
General.Settings.FlatShadeVertices = cbFlatShadeVertices.Checked;
|
||||
General.Settings.ParallelizedLinedefPlotting = cbParallelizedLinedefPlotting.Checked;
|
||||
General.Settings.ParallelizedVertexPlotting = cbParallelizedVertexPlotting.Checked;
|
||||
|
||||
// Script settings
|
||||
General.Settings.ScriptFontBold = scriptfontbold.Checked;
|
||||
|
|
Loading…
Reference in a new issue