Added: holding Control key while switching to/from Visual mode will now temporarily disable position synchronization (works only when 'Synchronize camera position between 2D and 3D modes' Preferences option is enabled).

Fixed severe lock-up after finishing dragging many vertices/linedefs/sectors in Classic modes.
Updated documentation ("Synchronizing camera position").
This commit is contained in:
MaxED 2016-04-29 21:38:43 +00:00
parent 6e4540b314
commit 977adb47f2
15 changed files with 49 additions and 45 deletions

View file

@ -27,6 +27,9 @@
<p><img src="synch_cam3.jpg" alt="" width="740" height="515" /></p>
<p>If you leave Visual mode now, the map will be centered at Visual camera's location:</p>
<p><img src="synch_cam4.jpg" alt="" width="736" height="512" /></p>
<p>If you don't like this behaviour, you can disable it in the <a href="../../../w_preferences.html">Preferences window</a>.</p>
<p>If you don't like this behaviour, disable "<b>Synchronize camera position between 2D and 3D modes</b>" <a href="../../../w_preferences.html">Preferences</a> option.</p>
<h2>Additional keys:</h2>
<p>Holding <b>Shift</b> while switching to/from Visual mode will also synchronize selected map elements.<br />
Holding <b>Ctrl</b> while switching to/from Visual mode will temporarily disable camera synchronization (works only when "<b>Synchronize camera position between 2D and 3D modes</b>" <a href="../../../w_preferences.html">Preferences</a> option is enabled).</p>
</div>
</body>

View file

@ -48,7 +48,6 @@ namespace CodeImp.DoomBuilder.Controls
// The script edit control
protected readonly ScriptEditorControl editor;
private bool preventchanges; //mxd
private string title; //mxd
// Derived classes must set this!
@ -437,7 +436,7 @@ namespace CodeImp.DoomBuilder.Controls
//mxd
private void functionbar_DropDown(object sender, EventArgs e)
{
if(!preventchanges && editor.IsChanged) panel.ShowErrors(UpdateNavigator());
if(editor.IsChanged) panel.ShowErrors(UpdateNavigator());
}
//mxd

View file

@ -653,7 +653,8 @@ namespace CodeImp.DoomBuilder.Editing
if(renderer.StartOverlay(true))
{
//mxd. Center 2d view on camera position in 3d view
if(General.Settings.GZSynchCameras && General.Editing.PreviousMode != null && General.Editing.PreviousMode.IsSubclassOf(typeof (VisualMode)))
if(General.Settings.GZSynchCameras && !General.Interface.CtrlState
&& General.Editing.PreviousMode != null && General.Editing.PreviousMode.IsSubclassOf(typeof(VisualMode)))
{
Vector2D campos = new Vector2D(General.Map.VisualCamera.Position.x, General.Map.VisualCamera.Position.y);
renderer2d.PositionView(campos.x, campos.y);

View file

@ -2254,7 +2254,7 @@ namespace CodeImp.DoomBuilder.Geometry
}
//mxd. Try to create/remove/reassign outer sidedefs. Selected linedefs and verts are marked
public static void AdjustOuterSidedefs(HashSet<Sector> selectedsectors, ICollection<Linedef> selectedlines)
public static void AdjustOuterSidedefs(HashSet<Sector> selectedsectors, HashSet<Linedef> selectedlines)
{
HashSet<Sidedef> outersides = new HashSet<Sidedef>();
HashSet<Linedef> singlesidedlines = new HashSet<Linedef>();

View file

@ -2588,7 +2588,7 @@ namespace CodeImp.DoomBuilder.Map
}
/// <summary>mxd. This finds the line closest to the specified position excluding given list of linedefs.</summary>
public Linedef NearestLinedef(Vector2D pos, ICollection<Linedef> linesToExclude)
public Linedef NearestLinedef(Vector2D pos, HashSet<Linedef> linesToExclude)
{
Linedef closest = null;
float distance = float.MaxValue;
@ -2596,7 +2596,7 @@ namespace CodeImp.DoomBuilder.Map
// Go for all linedefs in selection
foreach(Linedef l in linedefs)
{
if(linesToExclude.Contains(l)) continue;
if(linesToExclude.Contains(l)) continue;
// Calculate distance and check if closer than previous find
float d = l.SafeDistanceToSq(pos, true);
if(d < distance)

View file

@ -170,33 +170,37 @@ namespace CodeImp.DoomBuilder.VisualModes
//mxd. Synch camera position to cursor position or center of the screen in 2d-mode
if(General.Settings.GZSynchCameras)
{
//If initial position is inside or nearby a sector - adjust camera.z accordingly
float posz = General.Map.VisualCamera.Position.z;
Sector nearestsector = General.Map.Map.GetSectorByCoordinates(initialcameraposition, blockmap);
if(nearestsector == null)
// Keep previous camera position if Control is held and camera was previously moved in Visual mode
if(!General.Interface.CtrlState || General.Map.VisualCamera.Position.GetLengthSq() == 0)
{
Linedef nearestline = MapSet.NearestLinedef(General.Map.Map.Linedefs, initialcameraposition);
if(nearestline != null)
//If initial position is inside or nearby a sector - adjust camera.z accordingly
float posz = General.Map.VisualCamera.Position.z;
Sector nearestsector = General.Map.Map.GetSectorByCoordinates(initialcameraposition, blockmap);
if(nearestsector == null)
{
float side = nearestline.SideOfLine(initialcameraposition);
Sidedef nearestside = (side < 0.0f ? nearestline.Front : nearestline.Back) ?? (side < 0.0f ? nearestline.Back : nearestline.Front);
if(nearestside != null) nearestsector = nearestside.Sector;
Linedef nearestline = MapSet.NearestLinedef(General.Map.Map.Linedefs, initialcameraposition);
if(nearestline != null)
{
float side = nearestline.SideOfLine(initialcameraposition);
Sidedef nearestside = (side < 0.0f ? nearestline.Front : nearestline.Back) ?? (side < 0.0f ? nearestline.Back : nearestline.Front);
if(nearestside != null) nearestsector = nearestside.Sector;
}
}
}
if(nearestsector != null)
{
int sectorheight = nearestsector.CeilHeight - nearestsector.FloorHeight;
if(sectorheight < 41)
posz = nearestsector.FloorHeight + Math.Max(16, sectorheight / 2);
else if(General.Map.VisualCamera.Position.z < nearestsector.FloorHeight + 41)
posz = nearestsector.FloorHeight + 41; // same as in doom
else if(General.Map.VisualCamera.Position.z > nearestsector.CeilHeight)
posz = nearestsector.CeilHeight - 4;
}
if(nearestsector != null)
{
int sectorheight = nearestsector.CeilHeight - nearestsector.FloorHeight;
if(sectorheight < 41)
posz = nearestsector.FloorHeight + Math.Max(16, sectorheight / 2);
else if(General.Map.VisualCamera.Position.z < nearestsector.FloorHeight + 41)
posz = nearestsector.FloorHeight + 41; // same as in doom
else if(General.Map.VisualCamera.Position.z > nearestsector.CeilHeight)
posz = nearestsector.CeilHeight - 4;
}
General.Map.VisualCamera.Position = new Vector3D(initialcameraposition.x, initialcameraposition.y, posz);
General.Map.VisualCamera.Position = new Vector3D(initialcameraposition.x, initialcameraposition.y, posz);
}
}
else
{

View file

@ -470,9 +470,9 @@ namespace CodeImp.DoomBuilder.Windows
this.cbSynchCameras.AutoSize = true;
this.cbSynchCameras.Location = new System.Drawing.Point(16, 371);
this.cbSynchCameras.Name = "cbSynchCameras";
this.cbSynchCameras.Size = new System.Drawing.Size(260, 17);
this.cbSynchCameras.Size = new System.Drawing.Size(294, 17);
this.cbSynchCameras.TabIndex = 12;
this.cbSynchCameras.Text = "Sync camera position between 2D and 3D modes";
this.cbSynchCameras.Text = "Synchronize camera position between 2D and 3D modes";
this.cbSynchCameras.UseVisualStyleBackColor = true;
//
// showtexturesizes

View file

@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines);
// Process outer sidedefs
Tools.AdjustOuterSidedefs(toadjust, selectedlines);
Tools.AdjustOuterSidedefs(toadjust, new HashSet<Linedef>(selectedlines));
}
// If only a single linedef was selected, deselect it now

View file

@ -128,7 +128,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
toadjust.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines));
// Process outer sidedefs
Tools.AdjustOuterSidedefs(toadjust, selectedlines);
Tools.AdjustOuterSidedefs(toadjust, new HashSet<Linedef>(selectedlines));
}
// If only a single sector was selected, deselect it now

View file

@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Add sectors, which have all their linedefs selected
// (otherwise those would be destroyed after moving the selection)
ICollection<Linedef> selectedlines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
HashSet<Linedef> selectedlines = new HashSet<Linedef>(General.Map.Map.LinedefsFromMarkedVertices(false, true, false));
HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines);
// Process outer sidedefs

View file

@ -1485,7 +1485,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Update outer sides of the selection
HashSet<Sector> affectedsectors = new HashSet<Sector>(General.Map.Map.GetSelectedSectors(true));
affectedsectors.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines));
Tools.AdjustOuterSidedefs(affectedsectors, selectedlines);
Tools.AdjustOuterSidedefs(affectedsectors, new HashSet<Linedef>(selectedlines));
}
// Stitch geometry

View file

@ -1428,11 +1428,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//align things
int thingsCount = General.Map.Map.Things.Count;
foreach(Thing t in toAlign)
{
List<Linedef> excludedLines = new List<Linedef>();
HashSet<Linedef> excludedLines = new HashSet<Linedef>();
bool aligned;
do
@ -1443,7 +1441,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!aligned)
{
excludedLines.Add(l);
if(excludedLines.Count == thingsCount)
if(excludedLines.Count == General.Map.Map.Linedefs.Count)
{
ThingTypeInfo tti = General.Map.Data.GetThingInfo(t.Type);
General.ErrorLogger.Add(ErrorType.Warning, "Unable to align " + tti.Title + " (index " + t.Index + ") to any linedef!");

View file

@ -100,7 +100,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!merged)
{
List<Linedef> sectorlines = new List<Linedef>(sector.Sidedefs.Count);
HashSet<Linedef> sectorlines = new HashSet<Linedef>();
foreach(Sidedef side in sector.Sidedefs) sectorlines.Add(side.Line);
if(sectorlines.Count > 0)

View file

@ -1266,11 +1266,12 @@ gzdbvisualmode
{
title = "GZDB Visual Mode";
category = "modes";
description = "Switches to the (G)ZDoom visual editing mode. Hold Shift key to invert 'Synhcronise selection between Visual and Classic modes' setting.";
description = "Switches to the (G)ZDoom visual editing mode. Hold Shift key to invert 'Synhcronise selection between Visual and Classic modes' setting. Hold Control key to disable position synchronization when 'Synchronize camera position between 2D and 3D modes' Preferences option is enabled.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
disregardshift = true;
disregardcontrol = true;
default = 81; //Q
}

View file

@ -3365,11 +3365,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//align things
int thingsCount = General.Map.Map.Things.Count;
foreach(Thing t in things)
{
List<Linedef> excludedLines = new List<Linedef>();
HashSet<Linedef> excludedLines = new HashSet<Linedef>();
bool aligned;
do
@ -3381,7 +3379,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
excludedLines.Add(l);
if(excludedLines.Count == thingsCount)
if(excludedLines.Count == General.Map.Map.Linedefs.Count)
{
ThingTypeInfo tti = General.Map.Data.GetThingInfo(t.Type);
General.ErrorLogger.Add(ErrorType.Warning, "Unable to align " + tti.Title + " (index " + t.Index + ") to any linedef!");