Changed, "Make Brightness Gradient" action: MAPINFO FadeColor and OutsideFogColor properties are now used when first or last sector doesn't have "fadecolor" property when making a fade gradient.

Fixed (probably), D3DDevice: looks like CreatePresentParameters() can also throw "D3DERR_DEVICELOST" error in some cases...
This commit is contained in:
MaxED 2015-02-20 13:22:43 +00:00
parent e06a764d50
commit 0ba6490b8a
3 changed files with 38 additions and 13 deletions

View file

@ -2258,6 +2258,19 @@ namespace CodeImp.DoomBuilder.Geometry
return maxWidth > 0 ? maxWidth : 1;
}
//mxd
public static Color GetSectorFadeColor(Sector s)
{
if(s.Fields.ContainsKey("fadecolor")) return PixelColor.FromInt(s.Fields.GetValue("fadecolor", 0)).ToColor();
if(General.Map.Data.MapInfo.HasOutsideFogColor && s.CeilTexture == General.Map.Config.SkyFlatName)
{
return General.Map.Data.MapInfo.OutsideFogColor.ToColor();
}
if(General.Map.Data.MapInfo.HasFadeColor) return General.Map.Data.MapInfo.FadeColor.ToColor();
return Color.Black;
}
#endregion
}
}

View file

@ -389,11 +389,11 @@ namespace CodeImp.DoomBuilder.Rendering
backbuffer = null;
depthbuffer = null;
// Make present parameters
PresentParameters displaypp = CreatePresentParameters(adapter);
try
{
// Make present parameters
PresentParameters displaypp = CreatePresentParameters(adapter);
// Reset the device
device.Reset(displaypp);
}

View file

@ -1810,7 +1810,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd
private void ApplyColorGradient(ICollection<Sector> orderedselection, Sector start, Sector end, InterpolationTools.Mode interpolationmode, string key, int defaultvalue)
private static void ApplyColorGradient(ICollection<Sector> orderedselection, Sector start, Sector end, InterpolationTools.Mode interpolationmode, string key, int defaultvalue)
{
if(!start.Fields.ContainsKey(key) && !end.Fields.ContainsKey(key))
{
@ -1818,21 +1818,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
else
{
Color startColor = PixelColor.FromInt(start.Fields.GetValue(key, defaultvalue)).ToColor();
Color endColor = PixelColor.FromInt(end.Fields.GetValue(key, defaultvalue)).ToColor();
Color startColor, endColor;
if(key == "fadecolor")
{
startColor = Tools.GetSectorFadeColor(start);
endColor = Tools.GetSectorFadeColor(end);
}
else
{
startColor = PixelColor.FromInt(start.Fields.GetValue(key, defaultvalue)).ToColor();
endColor = PixelColor.FromInt(end.Fields.GetValue(key, defaultvalue)).ToColor();
}
// Go for all sectors in between first and last
int index = 0;
foreach(Sector s in orderedselection)
{
s.Fields.BeforeFieldsChange();
float u = index / (float)(orderedselection.Count - 1);
Color c = Color.FromArgb(0, General.Clamp(InterpolationTools.Interpolate(startColor.R, endColor.R, u, interpolationmode), 0, 255),
General.Clamp(InterpolationTools.Interpolate(startColor.G, endColor.G, u, interpolationmode), 0, 255),
General.Clamp(InterpolationTools.Interpolate(startColor.B, endColor.B, u, interpolationmode), 0, 255));
if(index > 0 && index < orderedselection.Count - 1)
{
s.Fields.BeforeFieldsChange();
float u = index / (float) (orderedselection.Count - 1);
Color c = Color.FromArgb(0, General.Clamp(InterpolationTools.Interpolate(startColor.R, endColor.R, u, interpolationmode), 0, 255),
General.Clamp(InterpolationTools.Interpolate(startColor.G, endColor.G, u, interpolationmode), 0, 255),
General.Clamp(InterpolationTools.Interpolate(startColor.B, endColor.B, u, interpolationmode), 0, 255));
UDMFTools.SetInteger(s.Fields, key, c.ToArgb(), defaultvalue);
s.UpdateNeeded = true;
UDMFTools.SetInteger(s.Fields, key, c.ToArgb(), defaultvalue);
s.UpdateNeeded = true;
}
index++;
}
}