mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Sectors Mode: the sectors things are in are only determined if necessary, which should increase performance when switching into Sectors Mode in very big maps
This commit is contained in:
parent
997c8ebef3
commit
f4307a4c64
2 changed files with 54 additions and 11 deletions
|
@ -275,7 +275,23 @@ namespace CodeImp.DoomBuilder.Map
|
|||
sector = map.GetSectorByCoordinates(pos);
|
||||
}
|
||||
|
||||
// This determines which sector the thing is in by looking at the blockmap and links it
|
||||
/// <summary>
|
||||
/// Determines what sector a thing is in, given a blockmap
|
||||
/// </summary>
|
||||
/// <param name="blockmap">The blockmap to use</param>
|
||||
public void DetermineSector(BlockMap<BlockEntry> blockmap)
|
||||
{
|
||||
BlockEntry be = blockmap.GetBlockAt(pos);
|
||||
|
||||
foreach (Sector s in be.Sectors)
|
||||
if (s.Intersect(pos))
|
||||
{
|
||||
sector = s;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This determines which sector the thing is in and links it
|
||||
public void DetermineSector(VisualBlockMap blockmap)
|
||||
{
|
||||
// Find nearest sectors using the blockmap
|
||||
|
|
|
@ -70,8 +70,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. Cached overlays stuff
|
||||
private FlatVertex[] overlayGeometry;
|
||||
private Dictionary<Sector, string[]> selectedEffectLabels;
|
||||
private Dictionary<Sector, string[]> unselectedEffectLabels;
|
||||
|
||||
private Dictionary<Sector, string[]> unselectedEffectLabels;
|
||||
|
||||
// The blockmap makes synchronized editing faster
|
||||
BlockMap<BlockEntry> blockmap;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -542,8 +545,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. Also (de)select things?
|
||||
if(General.Interface.AltState ^ BuilderPlug.Me.SyncronizeThingEdit)
|
||||
{
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
if(t.Sector == s && t.Selected != s.Selected) t.Selected = s.Selected;
|
||||
List<BlockEntry> belist = blockmap.GetSquareRange(s.BBox);
|
||||
|
||||
foreach(BlockEntry be in belist)
|
||||
{
|
||||
foreach(Thing t in be.Things)
|
||||
{
|
||||
if (t.Sector == null)
|
||||
t.DetermineSector(blockmap);
|
||||
|
||||
if (t.Sector == s && t.Selected != s.Selected) t.Selected = s.Selected;
|
||||
}
|
||||
}
|
||||
//foreach(Thing t in General.Map.Map.Things)
|
||||
// if(t.Sector == s && t.Selected != s.Selected) t.Selected = s.Selected;
|
||||
}
|
||||
|
||||
if(update)
|
||||
|
@ -725,19 +740,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. Update the tooltip
|
||||
BuilderPlug.Me.MenusForm.SyncronizeThingEditButton.ToolTipText = "Synchronized Things Editing" + Environment.NewLine + BuilderPlug.Me.MenusForm.SyncronizeThingEditSectorsItem.ToolTipText;
|
||||
|
||||
//mxd. Determine thing sectors. Cause SyncronizeThingEdit requires that
|
||||
foreach(Thing t in General.Map.Map.Things) t.DetermineSector();
|
||||
// Create the blockmap
|
||||
RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);
|
||||
area = MapSet.IncreaseArea(area, General.Map.Map.Things);
|
||||
blockmap = new BlockMap<BlockEntry>(area);
|
||||
blockmap.AddSectorsSet(General.Map.Map.Sectors);
|
||||
blockmap.AddThingsSet(General.Map.Map.Things);
|
||||
|
||||
//mxd. Select things as well?
|
||||
if(BuilderPlug.Me.SyncronizeThingEdit)
|
||||
{
|
||||
ICollection<Sector> sectors = General.Map.Map.GetSelectedSectors(true);
|
||||
if(sectors.Count > 0)
|
||||
|
||||
foreach(Sector s in sectors)
|
||||
{
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
List<BlockEntry> belist = blockmap.GetSquareRange(s.BBox);
|
||||
|
||||
foreach (BlockEntry be in belist)
|
||||
{
|
||||
if(!t.Selected && t.Sector != null && sectors.Contains(t.Sector))
|
||||
t.Selected = true;
|
||||
foreach (Thing t in be.Things)
|
||||
{
|
||||
if (t.Sector == null)
|
||||
t.DetermineSector(blockmap);
|
||||
|
||||
if (t.Sector == s && t.Selected != s.Selected) t.Selected = s.Selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue