mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-20 19:02:12 +00:00
3D Floor Mode: increased performance when creating new 3D floors
This commit is contained in:
parent
233153cdb5
commit
dbe0a7b414
4 changed files with 56 additions and 37 deletions
|
@ -789,6 +789,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
var sectorsToThreeDFloors = new Dictionary<Sector, List<ThreeDFloor>>();
|
||||
var sectorGroups = new List<List<Sector>>();
|
||||
List<int> tagblacklist = new List<int>();
|
||||
int numnewcontrolsectors = 0;
|
||||
|
||||
if(selectedSectors == null)
|
||||
selectedSectors = new List<Sector>(General.Map.Map.GetSelectedSectors(true));
|
||||
|
@ -818,22 +819,30 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
|
||||
General.Map.UndoRedo.CreateUndo("Modify 3D floors");
|
||||
|
||||
// Create a list of all tags used by the control sectors. This is necessary so that
|
||||
// tags that will be assigned to not yet existing geometry will not be used
|
||||
foreach (ThreeDFloor tdf in threedfloors)
|
||||
{
|
||||
// Create a list of all tags used by the control sectors. This is necessary so that
|
||||
// tags that will be assigned to not yet existing geometry will not be used
|
||||
foreach (int tag in tdf.Tags)
|
||||
if (!tagblacklist.Contains(tag))
|
||||
tagblacklist.Add(tag);
|
||||
|
||||
// Collect the number of control sectors that have to be created
|
||||
if (tdf.IsNew)
|
||||
numnewcontrolsectors++;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
List<DrawnVertex> drawnvertices = new List<DrawnVertex>();
|
||||
|
||||
if (numnewcontrolsectors > 0)
|
||||
drawnvertices = Me.ControlSectorArea.GetNewControlSectorVertices(numnewcontrolsectors);
|
||||
|
||||
foreach (ThreeDFloor tdf in threedfloors)
|
||||
{
|
||||
if (tdf.Rebuild)
|
||||
tdf.DeleteControlSector();
|
||||
|
||||
if (tdf.IsNew || tdf.Rebuild)
|
||||
tdf.CreateGeometry(tagblacklist);
|
||||
if (tdf.IsNew)
|
||||
tdf.CreateGeometry(tagblacklist, drawnvertices);
|
||||
|
||||
tdf.UpdateGeometry();
|
||||
}
|
||||
|
@ -959,6 +968,17 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
// Remove unused tags from the 3D floors
|
||||
foreach (ThreeDFloor tdf in threedfloors)
|
||||
tdf.Cleanup();
|
||||
|
||||
// Snap to map format accuracy
|
||||
General.Map.Map.SnapAllToAccuracy();
|
||||
|
||||
// Update textures
|
||||
General.Map.Data.UpdateUsedTextures();
|
||||
|
||||
// Update caches
|
||||
General.Map.Map.Update();
|
||||
General.Interface.RedrawDisplay();
|
||||
General.Map.IsChanged = true;
|
||||
}
|
||||
|
||||
public SlopeVertexGroup AddSlopeVertexGroup(List<SlopeVertex> vertices, out int id)
|
||||
|
|
|
@ -336,6 +336,12 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
|
||||
public List<DrawnVertex> GetNewControlSectorVertices()
|
||||
{
|
||||
return GetNewControlSectorVertices(1);
|
||||
}
|
||||
|
||||
public List<DrawnVertex> GetNewControlSectorVertices(int numsectors)
|
||||
{
|
||||
List<DrawnVertex> dv = new List<DrawnVertex>();
|
||||
BlockMap<BlockEntry> blockmap = CreateBlockmap();
|
||||
|
||||
int margin = (int)((gridsize - sectorsize) / 2);
|
||||
|
@ -353,7 +359,6 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
// The way our blockmap is built and queried we will always get exactly one block
|
||||
if (blocks[0].Sectors.Count == 0)
|
||||
{
|
||||
List<DrawnVertex> dv = new List<DrawnVertex>();
|
||||
Point p = new Point(x + margin, y - margin);
|
||||
|
||||
dv.Add(SectorVertex(p.X, p.Y));
|
||||
|
@ -362,7 +367,10 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
dv.Add(SectorVertex(p.X, p.Y - BuilderPlug.Me.ControlSectorArea.SectorSize));
|
||||
dv.Add(SectorVertex(p.X, p.Y));
|
||||
|
||||
return dv;
|
||||
numsectors--;
|
||||
|
||||
if (numsectors == 0)
|
||||
return dv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
private int topheight;
|
||||
private int bottomheight;
|
||||
private bool isnew;
|
||||
private bool rebuild;
|
||||
private int udmftag;
|
||||
private List<int> tags;
|
||||
|
||||
|
@ -73,7 +72,6 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
public int TopHeight { get { return topheight; } set { topheight = value; } }
|
||||
public int BottomHeight { get { return bottomheight; } set { bottomheight = value; } }
|
||||
public bool IsNew { get { return isnew; } set { isnew = value; } }
|
||||
public bool Rebuild { get { return rebuild; } set { rebuild = value; } }
|
||||
public int UDMFTag { get { return udmftag; } set { udmftag = value; } }
|
||||
public List<int> Tags { get { return tags; } set { tags = value; } }
|
||||
public Vector3D FloorSlope { get { return floorslope; } set { floorslope = value; } }
|
||||
|
@ -217,16 +215,15 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
}
|
||||
}
|
||||
|
||||
public bool CreateGeometry(List<int> tagblacklist)
|
||||
public bool CreateGeometry(List<int> tagblacklist, List<DrawnVertex> alldrawnvertices)
|
||||
{
|
||||
int newtag;
|
||||
|
||||
return CreateGeometry(tagblacklist, false, out newtag);
|
||||
return CreateGeometry(tagblacklist, alldrawnvertices, false, out newtag);
|
||||
}
|
||||
|
||||
public bool CreateGeometry(List<int> tagblacklist, bool forcenewtag, out int newtag)
|
||||
public bool CreateGeometry(List<int> tagblacklist, List<DrawnVertex> alldrawnvertices, bool forcenewtag, out int newtag)
|
||||
{
|
||||
List<DrawnVertex> drawnvertices = new List<DrawnVertex>();
|
||||
List<Vertex> vertices = new List<Vertex>();
|
||||
Vector3D slopetopthingpos = new Vector3D(0, 0, 0);
|
||||
Vector3D slopebottomthingpos = new Vector3D(0, 0, 0);
|
||||
|
@ -234,7 +231,19 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
|
||||
newtag = -1;
|
||||
|
||||
drawnvertices = BuilderPlug.Me.ControlSectorArea.GetNewControlSectorVertices();
|
||||
// We need 5 vertices to draw the control sector
|
||||
if(alldrawnvertices.Count < 5)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Could not draw new sector: not enough vertices");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the first 5 vertices in the list and also remove them from the list, so that creating further
|
||||
// control sectors won't use them
|
||||
List<DrawnVertex> drawnvertices = alldrawnvertices.GetRange(0, 5);
|
||||
alldrawnvertices.RemoveRange(0, 5);
|
||||
|
||||
// drawnvertices = BuilderPlug.Me.ControlSectorArea.GetNewControlSectorVertices();
|
||||
|
||||
if (Tools.DrawLines(drawnvertices) == false)
|
||||
{
|
||||
|
@ -275,21 +284,6 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
BindTag(udmftag);
|
||||
}
|
||||
|
||||
// Snap to map format accuracy
|
||||
General.Map.Map.SnapAllToAccuracy();
|
||||
|
||||
General.Map.Map.BeginAddRemove();
|
||||
//MapSet.JoinVertices(vertices, vertices, false, MapSet.STITCH_DISTANCE);
|
||||
General.Map.Map.EndAddRemove();
|
||||
|
||||
// Update textures
|
||||
General.Map.Data.UpdateUsedTextures();
|
||||
|
||||
// Update caches
|
||||
General.Map.Map.Update();
|
||||
General.Interface.RedrawDisplay();
|
||||
General.Map.IsChanged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -372,11 +366,6 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
}
|
||||
|
||||
General.Map.Map.EndAddRemove();
|
||||
|
||||
// Update cache values
|
||||
General.Map.IsChanged = true;
|
||||
General.Map.Map.Update();
|
||||
|
||||
}
|
||||
|
||||
public void DeleteControlSector()
|
||||
|
|
|
@ -1539,6 +1539,8 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
|
||||
General.Map.UndoRedo.CreateUndo(duplicateundodescription);
|
||||
|
||||
List<DrawnVertex> drawnvertices = BuilderPlug.Me.ControlSectorArea.GetNewControlSectorVertices(duplicatethreedfloors.Count);
|
||||
|
||||
// Create a new control sector for each 3D floor that needs to be duplicated. Force it to generate
|
||||
// a new tag, and store the old (current) and new tag
|
||||
foreach (ThreeDFloor tdf in duplicatethreedfloors)
|
||||
|
@ -1548,7 +1550,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
|
||||
try
|
||||
{
|
||||
tdf.CreateGeometry(new List<int>(), true, out newtag);
|
||||
tdf.CreateGeometry(new List<int>(), drawnvertices, true, out newtag);
|
||||
tagreplacements[oldtag] = newtag;
|
||||
}
|
||||
catch(NoSpaceInCSAException e)
|
||||
|
|
Loading…
Reference in a new issue