Fixed, Visual mode, UDMF: in some cases Fade color was not applied to floor and ceiling surfaces of 3d floors.

Fixed, Visual mode: in some cases not all sidedef geometry was updated when updating sectors with Plane Align (181) action. Also fixed some more unnecessary geometry updates.
Fixed, Linedefs mode, Things mode: in some cases deleting linedefs/things caused a crash when trying to update text labels.
Fixed, Draw Lines mode: in some cases the drawing was prematurely finished when "Auto-finish drawing" option was enabled.
This commit is contained in:
MaxED 2016-04-22 13:28:23 +00:00
parent d888e57c76
commit e03936a0d6
10 changed files with 113 additions and 66 deletions

View file

@ -43,6 +43,7 @@ namespace CodeImp.DoomBuilder
private static long starttime = -1;
private static long storedtime;
private static int counter;
private static string storedtext = string.Empty;
private static DebugConsole me;
#endregion
@ -95,6 +96,8 @@ namespace CodeImp.DoomBuilder
#region ================== Methods
public static void StoreText(string text) { storedtext += text + Environment.NewLine; }
public static void SetStoredText() { Write(DebugMessageType.INFO, storedtext, false); storedtext = string.Empty; }
public static void SetText(string text) { Write(DebugMessageType.INFO, text, false); } // Useful to display frequently updated text without flickering
public static void WriteLine(string text) { Write(DebugMessageType.INFO, text + Environment.NewLine, true); }
public static void WriteLine(DebugMessageType type, string text) { Write(type, text + Environment.NewLine, true); }
@ -219,10 +222,21 @@ namespace CodeImp.DoomBuilder
private void AddMessage(DebugMessageType type, string text, bool scroll, bool append)
{
text = textheaders[type] + text;
console.SelectionStart = console.TextLength;
console.SelectionColor = textcolors[type];
if(append) console.AppendText(text);
else console.Text = text;
if(append)
{
console.SelectionStart = console.TextLength;
console.SelectionColor = textcolors[type];
console.AppendText(text);
}
else
{
console.SuspendLayout();
console.Text = text;
console.SelectAll();
console.SelectionColor = textcolors[type];
console.Select(0, 0);
console.ResumeLayout();
}
if(scroll && autoscroll.Checked) console.ScrollToCaret();
}

View file

@ -173,5 +173,21 @@ namespace CodeImp.DoomBuilder.Geometry
}
#endregion
#region ================== Statics (mxd)
// This compares a vector
public static bool operator ==(Plane a, Plane b)
{
return (a.normal == b.normal) && (a.offset == b.offset);
}
// This compares a vector
public static bool operator !=(Plane a, Plane b)
{
return (a.normal != b.normal) || (a.offset != b.offset);
}
#endregion
}
}

View file

@ -89,15 +89,12 @@ namespace CodeImp.DoomBuilder.Rendering
// This calculates the sector brightness level
public int CalculateBrightness(int level)
{
float flevel = level;
// Simulat doom light levels
// Simulate doom light levels
if((level < 192) && General.Map.Config.DoomLightLevels)
flevel = (192.0f - (192 - level) * 1.5f);
level = (int)(192.0f - (192 - level) * 1.5f);
byte blevel = (byte)General.Clamp((int)flevel, 0, 255);
PixelColor c = new PixelColor(255, blevel, blevel, blevel);
return c.ToInt();
byte blevel = (byte)General.Clamp(level, 0, 255);
return new PixelColor(255, blevel, blevel, blevel).ToInt();
}
//mxd. This calculates wall brightness level with doom-style shading

View file

@ -636,7 +636,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Result position will split a line?
result = General.Map.Map.NearestLinedef(target);
if(result.DistanceTo(target, true) > BuilderPlug.Me.StitchRange) return null;
if(result.SideOfLine(target) != 0) return null;
}
return result;

View file

@ -1320,14 +1320,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.IsChanged = true;
General.Map.Map.Update();
// Invoke a new mousemove so that the highlighted item updates
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
OnMouseMove(e);
// Redraw screen
SetupSectorLabels(); //mxd
UpdateSelectionInfo(); //mxd
General.Map.Renderer2D.UpdateExtraFloorFlag(); //mxd
General.Interface.RedrawDisplay();
// Invoke a new mousemove so that the highlighted item updates
OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0));
}
[BeginAction("dissolveitem", BaseAction = true)] //mxd
@ -1389,15 +1389,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Update cache values
General.Map.IsChanged = true;
General.Map.Map.Update();
// Invoke a new mousemove so that the highlighted item updates
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
OnMouseMove(e);
// Redraw screen
SetupSectorLabels(); //mxd
UpdateSelectionInfo(); //mxd
General.Map.Renderer2D.UpdateExtraFloorFlag(); //mxd
General.Interface.RedrawDisplay();
// Invoke a new mousemove so that the highlighted item updates
OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0));
}
}

View file

@ -1340,13 +1340,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Update helper lines
UpdateHelperObjects();
// Invoke a new mousemove so that the highlighted item updates
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
OnMouseMove(e);
// Redraw screen
UpdateSelectionInfo(); //mxd
General.Interface.RedrawDisplay();
// Invoke a new mousemove so that the highlighted item updates
OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0));
}
}

View file

@ -493,11 +493,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This updates the VisualSectors and VisualThings that have their Changed property set
private void UpdateChangedObjects()
{
//mxd
SectorData[] toupdate = new SectorData[sectordata.Values.Count];
sectordata.Values.CopyTo(toupdate, 0);
foreach(SectorData data in toupdate) data.Update();
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
if(vs.Value != null)

View file

@ -158,15 +158,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(mode.VisualSectorExists(sd.Other.Sector))
{
SectorData other = mode.GetSectorDataEx(sd.Other.Sector);
if(other != null)
{
other.Reset(false);
}
else
{
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector);
vs.Changed = true;
}
if(other != null) other.Reset(false);
}
}
}

View file

@ -11,6 +11,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Linedef that is used to create this effect
private readonly Linedef l;
private Plane storedfloor; //mxd. SectorData recreates floor/ceiling planes before updating effects
private Plane storedceiling; //mxd
// Constructor
public EffectLineSlope(SectorData data, Linedef sourcelinedef) : base(data)
@ -45,6 +47,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
if(foundv == null) return; //mxd
bool updatesides = false;
// Align floor with back of line
if((l.Args[0] == 1) && (l.Front.Sector == data.Sector))
@ -52,10 +55,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Back.Sector.FloorHeight);
Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Back.Sector.FloorHeight);
Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.FloorHeight);
if(l.SideOfLine(v3) < 0.0f)
data.Floor.plane = new Plane(v1, v2, v3, true);
else
data.Floor.plane = new Plane(v2, v1, v3, true);
data.Floor.plane = (l.SideOfLine(v3) < 0.0f ? new Plane(v1, v2, v3, true) : new Plane(v2, v1, v3, true));
//mxd. Update only when actually changed
if(storedfloor != data.Floor.plane)
{
storedfloor = data.Floor.plane;
updatesides = true;
}
}
// Align floor with front of line
else if((l.Args[0] == 2) && (l.Back.Sector == data.Sector))
@ -63,10 +70,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Front.Sector.FloorHeight);
Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Front.Sector.FloorHeight);
Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.FloorHeight);
if(l.SideOfLine(v3) < 0.0f)
data.Floor.plane = new Plane(v1, v2, v3, true);
else
data.Floor.plane = new Plane(v2, v1, v3, true);
data.Floor.plane = (l.SideOfLine(v3) < 0.0f ? new Plane(v1, v2, v3, true) : new Plane(v2, v1, v3, true));
//mxd. Update only when actually changed
if(storedfloor != data.Floor.plane)
{
storedfloor = data.Floor.plane;
updatesides = true;
}
}
// Align ceiling with back of line
@ -75,10 +86,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Back.Sector.CeilHeight);
Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Back.Sector.CeilHeight);
Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.CeilHeight);
if(l.SideOfLine(v3) > 0.0f)
data.Ceiling.plane = new Plane(v1, v2, v3, false);
else
data.Ceiling.plane = new Plane(v2, v1, v3, false);
data.Ceiling.plane = (l.SideOfLine(v3) > 0.0f ? new Plane(v1, v2, v3, false) : new Plane(v2, v1, v3, false));
//mxd. Update only when actually changed
if(storedceiling != data.Ceiling.plane)
{
storedceiling = data.Ceiling.plane;
updatesides = true;
}
}
// Align ceiling with front of line
else if((l.Args[1] == 2) && (l.Back.Sector == data.Sector))
@ -86,10 +101,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Front.Sector.CeilHeight);
Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Front.Sector.CeilHeight);
Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.CeilHeight);
if(l.SideOfLine(v3) > 0.0f)
data.Ceiling.plane = new Plane(v1, v2, v3, false);
else
data.Ceiling.plane = new Plane(v2, v1, v3, false);
data.Ceiling.plane = (l.SideOfLine(v3) > 0.0f ? new Plane(v1, v2, v3, false) : new Plane(v2, v1, v3, false));
//mxd. Update only when actually changed
if(storedceiling != data.Ceiling.plane)
{
storedceiling = data.Ceiling.plane;
updatesides = true;
}
}
//mxd. Update outer sidedef geometry
if(updatesides)
{
foreach(Sidedef side in data.Sector.Sidedefs)
{
if(side.Other != null && side.Other.Sector != null && data.Mode.VisualSectorExists(side.Other.Sector))
{
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(side.Other.Sector);
vs.GetSidedefParts(side.Other).SetupAllParts();
}
}
}
}
}

View file

@ -356,7 +356,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
lightlevels[lightlevels.Count - 1].colorbelow = stored.colorbelow;
lightlevels[lightlevels.Count - 1].brightnessbelow = stored.brightnessbelow;
lightlevels[lightlevels.Count - 1].color = stored.colorbelow.ToInt();
lightlevels[lightlevels.Count - 1].color = GetLevelColor(stored);
}
//mxd. Cast light properties from top to bottom
@ -377,12 +377,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
l.colorbelow = stored.colorbelow;
l.brightnessbelow = stored.brightnessbelow;
l.color = stored.color;
l.color = GetLevelColor(stored);
}
else if(l.restrictlighting)
{
if(!pl.restrictlighting && pl != ceiling) stored = pl;
l.color = stored.color;
l.color = GetLevelColor(stored);
// This is the bottom side of extrafloor with "restrict lighting" flag. Make it cast stored light props.
if(l.type == SectorLevelType.Ceiling)
@ -393,11 +393,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Use light and color settings from previous layer
l.colorbelow = pl.colorbelow;
l.brightnessbelow = pl.brightnessbelow;
l.color = pl.colorbelow.ToInt();
l.color = GetLevelColor(pl);
// Also colorize previous layer using next higher level color
if(i + 2 < lightlevels.Count)
pl.color = lightlevels[i + 2].colorbelow.ToInt();
if(i + 2 < lightlevels.Count) pl.color = GetLevelColor(lightlevels[i + 2]);
}
else
{
@ -439,12 +438,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(src.colorbelow.a > 0 && src.brightnessbelow != -1)
{
// Only surface brightness is retained when a glowing flat is used as extrafloor texture
if(!l.affectedbyglow)
{
PixelColor brightness = PixelColor.FromInt(mode.CalculateBrightness(src.brightnessbelow));
PixelColor color = PixelColor.Modulate(src.colorbelow, brightness);
l.color = color.WithAlpha(255).ToInt();
}
if(!l.affectedbyglow) l.color = GetLevelColor(src);
// Transfer brightnessbelow and colorbelow if current level is not extrafloor top
if(!(l.extrafloor && l.type == SectorLevelType.Floor))
@ -597,6 +591,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
return found;
}
//mxd
private int GetLevelColor(SectorLevel src)
{
PixelColor brightness = PixelColor.FromInt(mode.CalculateBrightness(src.brightnessbelow));
PixelColor color = PixelColor.Modulate(src.colorbelow, brightness);
return color.WithAlpha(255).ToInt();
}
#endregion
}