Improved performance in visual mode related to visual slopes

This commit is contained in:
biwa 2021-02-06 14:51:00 +01:00
parent 90e7dd1149
commit 5ed77c5d05
5 changed files with 79 additions and 30 deletions

View file

@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Rendering
void AddSectorGeometry(VisualGeometry g);
void AddThingGeometry(VisualThing t);
void SetVisualVertices(List<VisualVertex> verts);
void SetVisualSlopeHandles(List<VisualSlope> handles);
void SetVisualSlopeHandles(ICollection<VisualSlope> handles);
void SetEventLines(List<Line3D> lines);
void RenderCrosshair();
void SetFogMode(bool usefog);

View file

@ -116,7 +116,7 @@ namespace CodeImp.DoomBuilder.Rendering
private List<VisualVertex> visualvertices;
// Visual slope handles
private List<VisualSlope> visualslopehandles;
private ICollection<VisualSlope> visualslopehandles;
//mxd. Event lines
private List<Line3D> eventlines;
@ -1842,7 +1842,7 @@ namespace CodeImp.DoomBuilder.Rendering
//mxd
public void SetVisualVertices(List<VisualVertex> verts) { visualvertices = verts; }
public void SetVisualSlopeHandles(List<VisualSlope> handles) { visualslopehandles = handles; }
public void SetVisualSlopeHandles(ICollection<VisualSlope> handles) { visualslopehandles = handles; }
//mxd
public void SetEventLines(List<Line3D> lines) { eventlines = lines; }

View file

@ -89,6 +89,7 @@ namespace CodeImp.DoomBuilder.VisualModes
protected List<VisualThing> visiblethings;
protected List<VisualSector> visiblesectors;
protected List<VisualGeometry> visiblegeometry;
protected HashSet<VisualSlope> renderslopehandles;
#endregion
@ -101,6 +102,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public Dictionary<Sector, List<VisualSlope>> AllSlopeHandles { get { return allslopehandles; } }
public Dictionary<Sector, List<VisualSlope>> SidedefSlopeHandles { get { return sidedefslopehandles; } }
public Dictionary<Sector, List<VisualSlope>> VertexSlopeHandles { get { return vertexslopehandles; } }
public HashSet<VisualSlope> RenderSlopeHandles { get { return renderslopehandles; } }
// Rendering
public IRenderer3D Renderer { get { return renderer; } }
@ -126,6 +128,7 @@ namespace CodeImp.DoomBuilder.VisualModes
this.visiblesectors = new List<VisualSector>(50);
this.visiblegeometry = new List<VisualGeometry>(200);
this.visiblethings = new List<VisualThing>(100);
this.renderslopehandles = new HashSet<VisualSlope>();
this.processgeometry = true;
this.processthings = true;
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd

View file

@ -524,26 +524,49 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (updateinfo)
{
if (newtarget.picked is VisualSidedefSlope)
{
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn
VisualSlope handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)newtarget.picked, this);
if (handle != null)
handle.SmartPivot = true;
}
else if(newtarget.picked is VisualVertexSlope)
{
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn
VisualSlope handle = VisualVertexSlope.GetSmartPivotHandle((VisualVertexSlope)newtarget.picked, this);
if (handle != null)
handle.SmartPivot = true;
}
else if(target.picked is VisualSlope)
if (target.picked is VisualSlope) // Old target
{
// Don't render old slope handle anymore
if (!((VisualSlope)target.picked).Selected && !((VisualSlope)target.picked).Pivot)
renderslopehandles.Remove((VisualSlope)target.picked);
// Clear smart pivot handles, otherwise it will keep being displayed
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
foreach (VisualSlope checkhandle in kvp.Value)
checkhandle.SmartPivot = false;
{
if (checkhandle.SmartPivot)
{
checkhandle.SmartPivot = false;
if (!checkhandle.Selected && !checkhandle.Pivot)
renderslopehandles.Remove(checkhandle);
}
}
}
if (newtarget.picked is VisualSidedefSlope)
{
renderslopehandles.Add((VisualSidedefSlope)newtarget.picked);
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn
VisualSlope handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)newtarget.picked, this);
if (handle != null)
{
handle.SmartPivot = true;
renderslopehandles.Add(handle);
}
}
else if(newtarget.picked is VisualVertexSlope)
{
renderslopehandles.Add((VisualVertexSlope)newtarget.picked);
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn
VisualSlope handle = VisualVertexSlope.GetSmartPivotHandle((VisualVertexSlope)newtarget.picked, this);
if (handle != null)
{
handle.SmartPivot = true;
renderslopehandles.Add(handle);
}
}
}
@ -1633,14 +1656,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetVisualVertices(verts);
}
// Visual slope handles
List<VisualSlope> handles = new List<VisualSlope>();
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
foreach (VisualSlope handle in kvp.Value)
if (handle.Selected || handle.Pivot || handle.SmartPivot || target.picked == handle)
handles.Add(handle);
renderer.SetVisualSlopeHandles(handles);
renderer.SetVisualSlopeHandles(renderslopehandles);
// Done rendering geometry
renderer.FinishGeometry();
@ -2482,6 +2498,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
handle.Pivot = false;
}
}
renderslopehandles.Clear();
}
}
@ -4329,7 +4347,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Clear smart pivot handles, otherwise it will keep being displayed
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
foreach (VisualSlope checkhandle in kvp.Value)
checkhandle.SmartPivot = false;
if (checkhandle.SmartPivot && !(checkhandle.Selected || checkhandle.Pivot))
{
checkhandle.SmartPivot = false;
renderslopehandles.Remove(checkhandle);
}
}
}
@ -4345,7 +4367,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Clear smart pivot handles, otherwise it will keep being displayed
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
foreach (VisualSlope checkhandle in kvp.Value)
checkhandle.SmartPivot = false;
{
if (checkhandle.SmartPivot && !(checkhandle.Selected || checkhandle.Pivot))
{
checkhandle.SmartPivot = false;
renderslopehandles.Remove(checkhandle);
}
}
}
}

View file

@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.VisualModes
{
this.selected = false;
mode.RemoveSelectedObject(this);
mode.RenderSlopeHandles.Remove(this);
}
else
{
@ -61,6 +62,7 @@ namespace CodeImp.DoomBuilder.VisualModes
this.selected = true;
mode.AddSelectedObject(this);
mode.RenderSlopeHandles.Add(this);
}
}
@ -76,10 +78,26 @@ namespace CodeImp.DoomBuilder.VisualModes
if (handle.Selected)
General.Interface.DisplayStatus(Windows.StatusType.Warning, "It is not allowed to mark selected slope handles as pivot slope handles.");
else
handle.Pivot = !handle.Pivot;
{
if (handle.Pivot)
{
mode.RenderSlopeHandles.Remove(handle);
handle.Pivot = false;
}
else
{
mode.RenderSlopeHandles.Add(handle);
handle.Pivot = true;
}
}
}
else
{
if(!handle.Selected && !handle.SmartPivot)
mode.RenderSlopeHandles.Remove(handle);
handle.Pivot = false;
}
}
}
}