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 committed by spherallic
parent 87be49a8fd
commit 099f8d316c
13 changed files with 47 additions and 42 deletions

View file

@ -27,6 +27,9 @@
<p><img src="synch_cam3.jpg" alt="" width="740" height="515" /></p> <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>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><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> </div>
</body> </body>

View file

@ -653,7 +653,8 @@ namespace CodeImp.DoomBuilder.Editing
if(renderer.StartOverlay(true)) if(renderer.StartOverlay(true))
{ {
//mxd. Center 2d view on camera position in 3d view //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); Vector2D campos = new Vector2D(General.Map.VisualCamera.Position.x, General.Map.VisualCamera.Position.y);
renderer2d.PositionView(campos.x, campos.y); renderer2d.PositionView(campos.x, campos.y);

View file

@ -2269,7 +2269,7 @@ namespace CodeImp.DoomBuilder.Geometry
} }
//mxd. Try to create/remove/reassign outer sidedefs. Selected linedefs and verts are marked //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<Sidedef> outersides = new HashSet<Sidedef>();
HashSet<Linedef> singlesidedlines = new HashSet<Linedef>(); HashSet<Linedef> singlesidedlines = new HashSet<Linedef>();

View file

@ -2583,7 +2583,7 @@ namespace CodeImp.DoomBuilder.Map
} }
/// <summary>mxd. This finds the line closest to the specified position excluding given list of linedefs.</summary> /// <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; Linedef closest = null;
float distance = float.MaxValue; float distance = float.MaxValue;
@ -2591,7 +2591,7 @@ namespace CodeImp.DoomBuilder.Map
// Go for all linedefs in selection // Go for all linedefs in selection
foreach(Linedef l in linedefs) foreach(Linedef l in linedefs)
{ {
if(linesToExclude.Contains(l)) continue; if(linesToExclude.Contains(l)) continue;
// Calculate distance and check if closer than previous find // Calculate distance and check if closer than previous find
float d = l.SafeDistanceToSq(pos, true); float d = l.SafeDistanceToSq(pos, true);
if(d < distance) 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 //mxd. Synch camera position to cursor position or center of the screen in 2d-mode
if(General.Settings.GZSynchCameras) if(General.Settings.GZSynchCameras)
{ {
//If initial position is inside or nearby a sector - adjust camera.z accordingly // Keep previous camera position if Control is held and camera was previously moved in Visual mode
float posz = General.Map.VisualCamera.Position.z; if(!General.Interface.CtrlState || General.Map.VisualCamera.Position.GetLengthSq() == 0)
Sector nearestsector = General.Map.Map.GetSectorByCoordinates(initialcameraposition, blockmap);
if(nearestsector == null)
{ {
Linedef nearestline = MapSet.NearestLinedef(General.Map.Map.Linedefs, initialcameraposition); //If initial position is inside or nearby a sector - adjust camera.z accordingly
if(nearestline != null) float posz = General.Map.VisualCamera.Position.z;
Sector nearestsector = General.Map.Map.GetSectorByCoordinates(initialcameraposition, blockmap);
if(nearestsector == null)
{ {
float side = nearestline.SideOfLine(initialcameraposition); Linedef nearestline = MapSet.NearestLinedef(General.Map.Map.Linedefs, initialcameraposition);
Sidedef nearestside = (side < 0.0f ? nearestline.Front : nearestline.Back) ?? (side < 0.0f ? nearestline.Back : nearestline.Front); if(nearestline != null)
if(nearestside != null) nearestsector = nearestside.Sector; {
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;
}
General.Map.VisualCamera.Position = new Vector3D(initialcameraposition.x, initialcameraposition.y, posz);
} }
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);
} }
else else
{ {

View file

@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines); HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines);
// Process outer sidedefs // Process outer sidedefs
Tools.AdjustOuterSidedefs(toadjust, selectedlines); Tools.AdjustOuterSidedefs(toadjust, new HashSet<Linedef>(selectedlines));
} }
// If only a single linedef was selected, deselect it now // 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)); toadjust.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines));
// Process outer sidedefs // Process outer sidedefs
Tools.AdjustOuterSidedefs(toadjust, selectedlines); Tools.AdjustOuterSidedefs(toadjust, new HashSet<Linedef>(selectedlines));
} }
// If only a single sector was selected, deselect it now // 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 // Add sectors, which have all their linedefs selected
// (otherwise those would be destroyed after moving the selection) // (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); HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines);
// Process outer sidedefs // Process outer sidedefs

View file

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

View file

@ -1492,11 +1492,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//align things //align things
int thingsCount = General.Map.Map.Things.Count;
foreach(Thing t in toAlign) foreach(Thing t in toAlign)
{ {
List<Linedef> excludedLines = new List<Linedef>(); HashSet<Linedef> excludedLines = new HashSet<Linedef>();
bool aligned; bool aligned;
do do
@ -1507,7 +1505,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!aligned) if(!aligned)
{ {
excludedLines.Add(l); excludedLines.Add(l);
if(excludedLines.Count == thingsCount) if(excludedLines.Count == General.Map.Map.Linedefs.Count)
{ {
ThingTypeInfo tti = General.Map.Data.GetThingInfo(t.SRB2Type); ThingTypeInfo tti = General.Map.Data.GetThingInfo(t.SRB2Type);
General.ErrorLogger.Add(ErrorType.Warning, "Unable to align " + tti.Title + " (index " + t.Index + ") to any linedef!"); 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) 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); foreach(Sidedef side in sector.Sidedefs) sectorlines.Add(side.Line);
if(sectorlines.Count > 0) if(sectorlines.Count > 0)

View file

@ -1579,11 +1579,12 @@ gzdbvisualmode
{ {
title = "Visual Mode"; title = "Visual Mode";
category = "modes"; category = "modes";
description = "Switches to the 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 'Sync selection between Visual and Classic modes' setting.";
allowkeys = true; allowkeys = true;
allowmouse = true; allowmouse = true;
allowscroll = true; allowscroll = true;
disregardshift = true; disregardshift = true;
disregardcontrol = true;
default = 81; //Q default = 81; //Q
} }

View file

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