Merged in GZDB r2483.

This commit is contained in:
MascaraSnake 2016-01-25 16:50:03 +01:00
parent ac82d01def
commit a45b2124d0
23 changed files with 224 additions and 229 deletions

View file

@ -1146,6 +1146,7 @@ constants
TF_USEACTORFOG; TF_USEACTORFOG;
TF_NOJUMP; TF_NOJUMP;
TF_OVERRIDE; TF_OVERRIDE;
TF_SENSITIVEZ;
TIF_NOTAKEINFINITE; TIF_NOTAKEINFINITE;
VAF_DMGTYPEAPPLYTODIRECT; VAF_DMGTYPEAPPLYTODIRECT;
WARPF_ABSOLUTEOFFSET; WARPF_ABSOLUTEOFFSET;

View file

@ -62,6 +62,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
{ {
vertwallshade = 16; vertwallshade = 16;
horizwallshade = -16; horizwallshade = -16;
fogdensity = 255;
outsidefogdensity = 255;
} }
#endregion #endregion

View file

@ -147,7 +147,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
// Find classname // Find classname
SkipWhitespace(true); SkipWhitespace(true);
string lightname = StripTokenQuotes(ReadToken()).ToLowerInvariant(); string lightname = StripTokenQuotes(ReadToken());
if (string.IsNullOrEmpty(lightname)) if (string.IsNullOrEmpty(lightname))
{ {
@ -442,7 +442,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
SkipWhitespace(true); SkipWhitespace(true);
// Read object class // Read object class
string objectclass = StripTokenQuotes(ReadToken()).ToLowerInvariant(); string objectclass = StripTokenQuotes(ReadToken());
if (string.IsNullOrEmpty(objectclass)) if (string.IsNullOrEmpty(objectclass))
{ {
@ -479,7 +479,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
else if (!foundlight && foundframe && token == "light") // Just use first light and be done with it else if (!foundlight && foundframe && token == "light") // Just use first light and be done with it
{ {
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken().ToLowerInvariant(); // Should be light name token = ReadToken(); // Should be light name
if (!string.IsNullOrEmpty(token)) if (!string.IsNullOrEmpty(token))
{ {

View file

@ -81,8 +81,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
while (SkipWhitespace(true)) while (SkipWhitespace(true))
{ {
string token = ReadToken().ToLowerInvariant(); string token = ReadToken().ToLowerInvariant();
if (string.IsNullOrEmpty(token)) break; if (string.IsNullOrEmpty(token) || token == "$gzdb_skip") break;
bool stopparsing = false;
switch (token) switch (token)
{ {
@ -158,20 +157,14 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
case "spawnnums": case "spawnnums":
if (!ParseSpawnNums()) return false; if (!ParseSpawnNums()) return false;
break; break;
case "$gzdb_skip":
stopparsing = true; // Finished with this file
break;
} }
if (stopparsing) break;
} }
// Check values // Check values
if (mapinfo.FadeColor.Red > 0 || mapinfo.FadeColor.Green > 0 || mapinfo.FadeColor.Blue > 0) if (mapinfo.FogDensity > 0 && (mapinfo.FadeColor.Red > 0 || mapinfo.FadeColor.Green > 0 || mapinfo.FadeColor.Blue > 0))
mapinfo.HasFadeColor = true; mapinfo.HasFadeColor = true;
if (mapinfo.OutsideFogColor.Red > 0 || mapinfo.OutsideFogColor.Green > 0 || mapinfo.OutsideFogColor.Blue > 0) if (mapinfo.OutsideFogDensity > 0 && (mapinfo.OutsideFogColor.Red > 0 || mapinfo.OutsideFogColor.Green > 0 || mapinfo.OutsideFogColor.Blue > 0))
mapinfo.HasOutsideFogColor = true; mapinfo.HasOutsideFogColor = true;
// All done // All done
@ -649,10 +642,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
return false; return false;
} }
if (densitytype == "fogdensity") val = Math.Max(0, val);
mapinfo.FogDensity = (int)(1024 * (256.0f / val)); if (densitytype == "fogdensity") mapinfo.FogDensity = val;
else else mapinfo.OutsideFogDensity = val;
mapinfo.OutsideFogDensity = (int)(1024 * (256.0f / val));
// All done here // All done here
return true; return true;

View file

@ -29,7 +29,16 @@ using SlimDX;
namespace CodeImp.DoomBuilder.Map namespace CodeImp.DoomBuilder.Map
{ {
public sealed class Sector : SelectableElement public enum SectorFogMode //mxd
{
NONE, // no fog
CLASSIC, // black fog when sector brightness < 243
FOGDENSITY, // sector uses "fogdensity" MAPINFO property
OUTSIDEFOGDENSITY, // sector uses "outsidefogdensity" MAPINFO property
FADE // sector uses UDMF "fade" sector property
}
public sealed class Sector : SelectableElement
{ {
#region ================== Constants #region ================== Constants
@ -76,13 +85,12 @@ namespace CodeImp.DoomBuilder.Map
private ReadOnlyCollection<LabelPositionInfo> labels; private ReadOnlyCollection<LabelPositionInfo> labels;
private readonly SurfaceEntryCollection surfaceentries; private readonly SurfaceEntryCollection surfaceentries;
//mxd. Rendering //mxd. Rendering
private Color4 fogColor; private Color4 fogcolor;
private bool hasFogColor; private SectorFogMode fogmode;
private bool useOutsideFog;
//mxd. Slopes //mxd. Slopes
private Vector3D floorslope; private Vector3D floorslope;
private float flooroffset; private float flooroffset;
private Vector3D ceilslope; private Vector3D ceilslope;
private float ceiloffset; private float ceiloffset;
@ -117,13 +125,12 @@ namespace CodeImp.DoomBuilder.Map
public FlatVertex[] FlatVertices { get { return flatvertices; } } public FlatVertex[] FlatVertices { get { return flatvertices; } }
public ReadOnlyCollection<LabelPositionInfo> Labels { get { return labels; } } public ReadOnlyCollection<LabelPositionInfo> Labels { get { return labels; } }
//mxd. Rednering //mxd. Rednering
public Color4 FogColor { get { return fogColor; } } public Color4 FogColor { get { return fogcolor; } }
public bool HasFogColor { get { return hasFogColor; } } public SectorFogMode FogMode { get { return fogmode; } }
public bool UsesOutsideFog { get { return useOutsideFog; } }
//mxd. Slopes //mxd. Slopes
public Vector3D FloorSlope { get { return floorslope; } set { BeforePropsChange(); floorslope = value; updateneeded = true; } } public Vector3D FloorSlope { get { return floorslope; } set { BeforePropsChange(); floorslope = value; updateneeded = true; } }
public float FloorSlopeOffset { get { return flooroffset; } set { BeforePropsChange(); flooroffset = value; updateneeded = true; } } public float FloorSlopeOffset { get { return flooroffset; } set { BeforePropsChange(); flooroffset = value; updateneeded = true; } }
public Vector3D CeilSlope { get { return ceilslope; } set { BeforePropsChange(); ceilslope = value; updateneeded = true; } } public Vector3D CeilSlope { get { return ceilslope; } set { BeforePropsChange(); ceilslope = value; updateneeded = true; } }
public float CeilSlopeOffset { get { return ceiloffset; } set { BeforePropsChange(); ceiloffset = value; updateneeded = true; } } public float CeilSlopeOffset { get { return ceiloffset; } set { BeforePropsChange(); ceiloffset = value; updateneeded = true; } }
@ -473,11 +480,10 @@ namespace CodeImp.DoomBuilder.Map
this.Fields.Clear(); this.Fields.Clear();
if(isvirtual) this.Fields.Add(MapSet.VirtualSectorField, MapSet.VirtualSectorValue); if(isvirtual) this.Fields.Add(MapSet.VirtualSectorField, MapSet.VirtualSectorValue);
this.Flags.Clear(); this.Flags.Clear();
hasFogColor = false; this.fogmode = SectorFogMode.NONE;
useOutsideFog = false;
// Reset Slopes // Reset Slopes
floorslope = new Vector3D(); floorslope = new Vector3D();
flooroffset = 0; flooroffset = 0;
ceilslope = new Vector3D(); ceilslope = new Vector3D();
ceiloffset = 0; ceiloffset = 0;
@ -881,20 +887,29 @@ namespace CodeImp.DoomBuilder.Map
//mxd //mxd
public void UpdateFogColor() public void UpdateFogColor()
{ {
// Sector uses outisde fog when it's ceiling is sky or Sector_Outside effect (87) is set if (General.Map.UDMF && Fields.ContainsKey("fadecolor"))
useOutsideFog = (General.Map.Data.MapInfo.HasOutsideFogColor && (ceiltexname == General.Map.Config.SkyFlatName || (effect == 87 && General.Map.Config.SectorEffects.ContainsKey(effect)))); {
fogcolor = new Color4((int)Fields["fadecolor"].Value);
if(General.Map.UDMF && Fields.ContainsKey("fadecolor")) fogmode = SectorFogMode.FADE;
fogColor = new Color4((int)Fields["fadecolor"].Value); }
else if(useOutsideFog) // Sector uses outisde fog when it's ceiling is sky or Sector_Outside effect (87) is set
fogColor = General.Map.Data.MapInfo.OutsideFogColor; else if (General.Map.Data.MapInfo.HasOutsideFogColor &&
else if(General.Map.Data.MapInfo.HasFadeColor) (ceiltexname == General.Map.Config.SkyFlatName || (effect == 87 && General.Map.Config.SectorEffects.ContainsKey(effect))))
fogColor = General.Map.Data.MapInfo.FadeColor; {
else fogcolor = General.Map.Data.MapInfo.OutsideFogColor;
fogColor = new Color4(); fogmode = SectorFogMode.OUTSIDEFOGDENSITY;
}
hasFogColor = fogColor.Red > 0 || fogColor.Green > 0 || fogColor.Blue > 0; else if (General.Map.Data.MapInfo.HasFadeColor)
} {
fogcolor = General.Map.Data.MapInfo.FadeColor;
fogmode = SectorFogMode.FOGDENSITY;
}
else
{
fogcolor = new Color4();
fogmode = (brightness < 248 ? SectorFogMode.CLASSIC : SectorFogMode.NONE);
}
}
#endregion #endregion
} }

View file

@ -768,9 +768,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine the shader pass we want to use for this object // Determine the shader pass we want to use for this object
int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass; int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass;
//mxd. Render fog? //mxd. Render fog?
if(General.Settings.GZDrawFog && !fullbrightness && sector.Sector.Brightness < 248) if (General.Settings.GZDrawFog && !fullbrightness && sector.Sector.FogMode != SectorFogMode.NONE)
wantedshaderpass += 8; wantedshaderpass += 8;
// Switch shader pass? // Switch shader pass?
if(currentshaderpass != wantedshaderpass) if(currentshaderpass != wantedshaderpass)
@ -846,9 +846,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine the shader pass we want to use for this object // Determine the shader pass we want to use for this object
int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass; int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass;
//mxd. If fog is enagled, switch to shader, which calculates it //mxd. If fog is enagled, switch to shader, which calculates it
if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && (t.Thing.Sector.HasFogColor || t.Thing.Sector.Brightness < 248)) if (General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.FogMode != SectorFogMode.NONE)
wantedshaderpass += 8; wantedshaderpass += 8;
//mxd. Create the matrix for positioning //mxd. Create the matrix for positioning
world = CreateThingPositionMatrix(t); world = CreateThingPositionMatrix(t);
@ -1046,9 +1046,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine the shader pass we want to use for this object // Determine the shader pass we want to use for this object
int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass; int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass;
//mxd. Render fog? //mxd. Render fog?
if(General.Settings.GZDrawFog && !fullbrightness && sector.Sector.Brightness < 248) if (General.Settings.GZDrawFog && !fullbrightness && sector.Sector.FogMode != SectorFogMode.NONE)
wantedshaderpass += 8; wantedshaderpass += 8;
// Switch shader pass? // Switch shader pass?
if(currentshaderpass != wantedshaderpass) if(currentshaderpass != wantedshaderpass)
@ -1155,9 +1155,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine the shader pass we want to use for this object // Determine the shader pass we want to use for this object
int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass; int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass;
//mxd. if fog is enagled, switch to shader, which calculates it //mxd. if fog is enagled, switch to shader, which calculates it
if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && (t.Thing.Sector.HasFogColor || t.Thing.Sector.Brightness < 248)) if (General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.FogMode != SectorFogMode.NONE)
wantedshaderpass += 8; wantedshaderpass += 8;
//mxd. Create the matrix for positioning //mxd. Create the matrix for positioning
world = CreateThingPositionMatrix(t); world = CreateThingPositionMatrix(t);
@ -1408,9 +1408,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine the shader pass we want to use for this object // Determine the shader pass we want to use for this object
int wantedshaderpass = ((((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass); int wantedshaderpass = ((((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass);
//mxd. if fog is enagled, switch to shader, which calculates it //mxd. if fog is enagled, switch to shader, which calculates it
if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && (t.Thing.Sector.HasFogColor || t.Thing.Sector.Brightness < 248)) if (General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.FogMode != SectorFogMode.NONE)
wantedshaderpass += 8; wantedshaderpass += 8;
// Switch shader pass? // Switch shader pass?
if(currentshaderpass != wantedshaderpass) if(currentshaderpass != wantedshaderpass)
@ -1509,9 +1509,9 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine the shader pass we want to use for this object // Determine the shader pass we want to use for this object
int wantedshaderpass = ((((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass); int wantedshaderpass = ((((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass);
//mxd. if fog is enagled, switch to shader, which calculates it //mxd. if fog is enagled, switch to shader, which calculates it
if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && (t.Thing.Sector.HasFogColor || t.Thing.Sector.Brightness < 248)) if (General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.FogMode != SectorFogMode.NONE)
wantedshaderpass += 8; wantedshaderpass += 8;
// Switch shader pass? // Switch shader pass?
if(currentshaderpass != wantedshaderpass) if(currentshaderpass != wantedshaderpass)

View file

@ -198,40 +198,44 @@ namespace CodeImp.DoomBuilder.VisualModes
boundingBox = BoundingBoxTools.CalculateBoundingPlane(bbs); boundingBox = BoundingBoxTools.CalculateBoundingPlane(bbs);
} }
//mxd. Calculate fogdistance //mxd. Calculate fogdistance
//TODO: this doesn't match any GZDoom light mode... //TODO: this doesn't match any GZDoom light mode...
//GZDoom: gl_renderstate.h, SetFog(); //GZDoom: gl_renderstate.h, SetFog();
//GZDoom: gl_lightlevel.cpp gl_SetFog(); //GZDoom: gl_lightlevel.cpp gl_SetFog();
protected float CalculateFogDensity(int brightness) protected float CalculateFogFactor(int brightness) { return CalculateFogFactor(Sector.Sector.FogMode, brightness); }
{ public static float CalculateFogFactor(SectorFogMode mode, int brightness)
float density; {
if(Sector.Sector.UsesOutsideFog && General.Map.Data.MapInfo.OutsideFogDensity > 0) float density;
{ switch (mode)
density = General.Map.Data.MapInfo.OutsideFogDensity; {
} case SectorFogMode.OUTSIDEFOGDENSITY:
else if(!Sector.Sector.UsesOutsideFog && General.Map.Data.MapInfo.FogDensity > 0) density = General.Map.Data.MapInfo.OutsideFogDensity;
{ break;
density = General.Map.Data.MapInfo.FogDensity;
}
else if(brightness < 248)
{
density = General.Clamp(255 - brightness, 30, 255);
}
else
{
density = 0f;
}
if(Sector.Sector.HasFogColor) case SectorFogMode.FOGDENSITY:
{ density = General.Map.Data.MapInfo.FogDensity;
density *= 4; break;
}
return density * FOG_DENSITY_SCALER; case SectorFogMode.FADE:
} density = General.Clamp(255 - brightness, 30, 255) * 4;
break;
//mxd. Used to get proper sector from 3d-floors case SectorFogMode.CLASSIC:
public virtual Sector GetControlSector() density = General.Clamp(255 - brightness, 30, 255);
break;
case SectorFogMode.NONE:
density = 0f;
break;
default: throw new NotImplementedException("Unknown SectorFogMode!");
}
return density * FOG_DENSITY_SCALER;
}
//mxd. Used to get proper sector from 3d-floors
public virtual Sector GetControlSector()
{ {
return sector.Sector; return sector.Sector;
} }

View file

@ -73,8 +73,8 @@ namespace CodeImp.DoomBuilder.VisualModes
protected Dictionary<Thing, VisualThing> allthings; protected Dictionary<Thing, VisualThing> allthings;
protected Dictionary<Sector, VisualSector> allsectors; protected Dictionary<Sector, VisualSector> allsectors;
protected List<VisualBlockEntry> visibleblocks; protected List<VisualBlockEntry> visibleblocks;
protected List<VisualThing> visiblethings; protected Dictionary<Thing, VisualThing> visiblethings;
protected Dictionary<Sector, VisualSector> visiblesectors; protected Dictionary<Sector, VisualSector> visiblesectors;
protected List<VisualGeometry> visiblegeometry; protected List<VisualGeometry> visiblegeometry;
#endregion #endregion
@ -102,12 +102,12 @@ namespace CodeImp.DoomBuilder.VisualModes
this.renderer = General.Map.Renderer3D; this.renderer = General.Map.Renderer3D;
this.blockmap = new VisualBlockMap(); this.blockmap = new VisualBlockMap();
this.allsectors = new Dictionary<Sector, VisualSector>(General.Map.Map.Sectors.Count); this.allsectors = new Dictionary<Sector, VisualSector>(General.Map.Map.Sectors.Count);
this.allthings = new Dictionary<Thing,VisualThing>(General.Map.Map.Things.Count); this.allthings = new Dictionary<Thing, VisualThing>(General.Map.Map.Things.Count);
this.visibleblocks = new List<VisualBlockEntry>(); this.visibleblocks = new List<VisualBlockEntry>();
this.visiblesectors = new Dictionary<Sector, VisualSector>(50); this.visiblesectors = new Dictionary<Sector, VisualSector>(50);
this.visiblegeometry = new List<VisualGeometry>(200); this.visiblegeometry = new List<VisualGeometry>(200);
this.visiblethings = new List<VisualThing>(100); this.visiblethings = new Dictionary<Thing, VisualThing>(100);
this.processgeometry = true; this.processgeometry = true;
this.processthings = true; this.processthings = true;
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
@ -515,10 +515,10 @@ namespace CodeImp.DoomBuilder.VisualModes
// Make collections // Make collections
visiblesectors = new Dictionary<Sector, VisualSector>(visiblesectors.Count); visiblesectors = new Dictionary<Sector, VisualSector>(visiblesectors.Count);
visiblegeometry = new List<VisualGeometry>(visiblegeometry.Capacity); visiblegeometry = new List<VisualGeometry>(visiblegeometry.Capacity);
visiblethings = new List<VisualThing>(visiblethings.Capacity); visiblethings = new Dictionary<Thing, VisualThing>(visiblethings.Count);
// Get the blocks within view range // Get the blocks within view range
visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D); visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D);
// Fill collections with geometry and things // Fill collections with geometry and things
foreach(VisualBlockEntry block in visibleblocks) foreach(VisualBlockEntry block in visibleblocks)
@ -569,11 +569,11 @@ namespace CodeImp.DoomBuilder.VisualModes
allthings.Add(t, vt); allthings.Add(t, vt);
} }
if(vt != null) if (vt != null && !visiblethings.ContainsKey(vt.Thing))
{ {
visiblethings.Add(vt); visiblethings.Add(vt.Thing, vt);
} }
} }
} }
} }
@ -797,12 +797,12 @@ namespace CodeImp.DoomBuilder.VisualModes
} }
} }
} }
// Add all the visible things
foreach(VisualThing vt in visiblethings) pickables.Add(vt);
//mxd. And all visual vertices // Add all the visible things
if(General.Map.UDMF && General.Settings.GZShowVisualVertices) foreach (VisualThing vt in visiblethings.Values) pickables.Add(vt);
//mxd. And all visual vertices
if (General.Map.UDMF && General.Settings.GZShowVisualVertices)
{ {
foreach(KeyValuePair<Vertex, VisualVertexPair> pair in vertices) foreach(KeyValuePair<Vertex, VisualVertexPair> pair in vertices)
pickables.AddRange(pair.Value.Vertices); pickables.AddRange(pair.Value.Vertices);

View file

@ -20,6 +20,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using CodeImp.DoomBuilder.Config; using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Data;
#endregion #endregion
@ -590,6 +591,8 @@ namespace CodeImp.DoomBuilder.ZDoom
if(HasPropertyWithValue("$sprite")) if(HasPropertyWithValue("$sprite"))
{ {
string sprite = GetPropertyValueString("$sprite", 0); //mxd string sprite = GetPropertyValueString("$sprite", 0); //mxd
if ((sprite.Length > DataManager.INTERNAL_PREFIX.Length) &&
sprite.ToLowerInvariant().StartsWith(DataManager.INTERNAL_PREFIX)) return sprite; //mxd
if (General.Map.Data.GetSpriteExists(sprite)) return sprite; //mxd. Added availability check if (General.Map.Data.GetSpriteExists(sprite)) return sprite; //mxd. Added availability check
//mxd. Bitch and moan //mxd. Bitch and moan

View file

@ -84,11 +84,11 @@ namespace CodeImp.DoomBuilder.ZDoom
// Syntax // Syntax
whitespace = "\n \t\r\u00A0"; //mxd. non-breaking space is also space :) whitespace = "\n \t\r\u00A0"; //mxd. non-breaking space is also space :)
specialtokens = ":{}+-\n;,"; specialtokens = ":{}+-\n;,";
// Initialize // Initialize
actors = new Dictionary<string, ActorStructure>(StringComparer.Ordinal); actors = new Dictionary<string, ActorStructure>(StringComparer.OrdinalIgnoreCase);
archivedactors = new Dictionary<string, ActorStructure>(StringComparer.Ordinal); archivedactors = new Dictionary<string, ActorStructure>(StringComparer.OrdinalIgnoreCase);
parsedlumps = new HashSet<string>(StringComparer.OrdinalIgnoreCase); //mxd parsedlumps = new HashSet<string>(StringComparer.OrdinalIgnoreCase); //mxd
} }
// Disposer // Disposer
@ -124,7 +124,8 @@ namespace CodeImp.DoomBuilder.ZDoom
if(!string.IsNullOrEmpty(objdeclaration)) if(!string.IsNullOrEmpty(objdeclaration))
{ {
objdeclaration = objdeclaration.ToLowerInvariant(); objdeclaration = objdeclaration.ToLowerInvariant();
switch(objdeclaration) if (objdeclaration == "$gzdb_skip") break;
switch (objdeclaration)
{ {
case "actor": case "actor":
{ {
@ -226,8 +227,6 @@ namespace CodeImp.DoomBuilder.ZDoom
} }
break; break;
case "$gzdb_skip": break;
default: default:
{ {
// Unknown structure! // Unknown structure!

View file

@ -77,12 +77,23 @@ namespace CodeImp.DoomBuilder.ZDoom
{ {
if(!base.Parse(stream, sourcefilename, clearerrors)) return false; if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
//mxd. Make vitrual path from filename //mxd. Make vitrual path from filename
string virtualpath = sourcefilename.Substring(8).TrimStart(pathtrimchars); string virtualpath;
if(virtualpath.ToLowerInvariant() == "txt") virtualpath = string.Empty; if (sourcefilename.Contains("#")) // It's TEXTURES lump
{
// Continue until at the end of the stream virtualpath = Path.GetFileName(sourcefilename);
while(SkipWhitespace(true)) if (!string.IsNullOrEmpty(virtualpath)) virtualpath = virtualpath.Substring(0, virtualpath.LastIndexOf("#", StringComparison.Ordinal));
}
else // If it's actual filename, try to use extension(s) as virtualpath
{
virtualpath = Path.GetFileName(sourcefilename);
if (!string.IsNullOrEmpty(virtualpath)) virtualpath = virtualpath.Substring(8).TrimStart(pathtrimchars);
if (!string.IsNullOrEmpty(virtualpath) && virtualpath.ToLowerInvariant() == "txt") virtualpath = string.Empty;
if (string.IsNullOrEmpty(virtualpath)) virtualpath = "[TEXTURES]";
}
// Continue until at the end of the stream
while (SkipWhitespace(true))
{ {
// Read a token // Read a token
string objdeclaration = ReadToken(); string objdeclaration = ReadToken();
@ -194,9 +205,9 @@ namespace CodeImp.DoomBuilder.ZDoom
} }
break; break;
case "$gzdb_skip": break; case "$gzdb_skip": return !this.HasError;
default: default:
{ {
// Unknown structure! // Unknown structure!
// Best we can do now is just find the first { and then // Best we can do now is just find the first { and then

View file

@ -215,20 +215,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
WallPolygon np = SplitPoly(ref p, plane, false); WallPolygon np = SplitPoly(ref p, plane, false);
if(np.Count > 0) if(np.Count > 0)
{ {
//mxd. Determine color if (l.type == SectorLevelType.Glow)
int lightlevel; {
//mxd. Glow levels should not affect light level
np.color = p.color;
}
else
{
//mxd. Determine color
int lightlevel;
// Sidedef part is not affected by 3d floor brightness // Sidedef part is not affected by 3d floor brightness
if(l.disablelighting || !l.extrafloor) if (l.type != SectorLevelType.Light && (l.disablelighting || !l.extrafloor))
lightlevel = (lightabsolute ? lightvalue : l.brightnessbelow + lightvalue); lightlevel = (lightabsolute ? lightvalue : l.brightnessbelow + lightvalue);
// 3d floor transfers brightness below it ignoring sidedef's brightness // 3d floors and light transfer effects transfers brightness below them ignoring sidedef's brightness
else else
lightlevel = l.brightnessbelow; lightlevel = l.brightnessbelow;
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); //mxd PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); //mxd
np.color = PixelColor.Modulate(l.colorbelow, wallbrightness).WithAlpha(255).ToInt(); np.color = PixelColor.Modulate(l.colorbelow, wallbrightness).WithAlpha(255).ToInt();
}
if(p.Count == 0) if (p.Count == 0)
{ {
polygons[pi] = np; polygons[pi] = np;
} }

View file

@ -1377,7 +1377,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0); renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0);
// Render all visible things // Render all visible things
foreach(VisualThing t in visiblethings) foreach(VisualThing t in visiblethings.Values)
renderer.AddThingGeometry(t); renderer.AddThingGeometry(t);
} }

View file

@ -226,21 +226,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Level is glowing // Level is glowing
if(level.affectedbyglow && level.type == SectorLevelType.Floor) if(level.affectedbyglow && level.type == SectorLevelType.Floor)
{ {
// Get glow brightness // Extrafloor glow doesn't affect thing brightness
SectorData glowdata = (level.sector != Thing.Sector ? mode.GetSectorData(level.sector) : sd); if (level.sector == Thing.Sector)
float planez = level.plane.GetZ(thingpos); {
float planez = level.plane.GetZ(thingpos);
int glowbrightness = glowdata.FloorGlow.Brightness / 2; // Get glow brightness
SectorLevel nexthigher = sd.GetLevelAbove(new Vector3D(thingpos, planez)); int glowbrightness = sd.FloorGlow.Brightness / 2;
SectorLevel nexthigher = sd.GetLevelAbove(new Vector3D(thingpos, planez));
// Interpolate thing brightness between glow and regular ones // Interpolate thing brightness between glow and regular ones
if(nexthigher != null) if (nexthigher != null)
{ {
float higherz = nexthigher.plane.GetZ(thingpos); float higherz = nexthigher.plane.GetZ(thingpos);
float delta = General.Clamp(1.0f - (thingpos.z - planez) / (higherz - planez), 0f, 1f); float delta = General.Clamp(1.0f - (thingpos.z - planez) / (higherz - planez), 0f, 1f);
brightness = (int)((glowbrightness + level.sector.Brightness / 2) * delta + nexthigher.sector.Brightness * (1.0f - delta)); brightness = (int)((glowbrightness + level.sector.Brightness / 2) * delta + nexthigher.sector.Brightness * (1.0f - delta));
} }
} }
}
// Level below this one is glowing. Only possible for floor glow(?) // Level below this one is glowing. Only possible for floor glow(?)
else if(level.type == SectorLevelType.Glow) else if(level.type == SectorLevelType.Glow)
{ {
@ -260,32 +263,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness); PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness);
sectorcolor = areacolor.WithAlpha(alpha).ToInt(); sectorcolor = areacolor.WithAlpha(alpha).ToInt();
//mxd. Calculate fogfactor //mxd. Calculate fogfactor
float density; fogfactor = VisualGeometry.CalculateFogFactor(level.sector.FogMode, brightness);
if(Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.OutsideFogDensity > 0) }
{
density = General.Map.Data.MapInfo.OutsideFogDensity;
}
else if(!Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.FogDensity > 0)
{
density = General.Map.Data.MapInfo.FogDensity;
}
else if(brightness < 248)
{
density = General.Clamp(255 - brightness, 30, 255);
}
else
{
density = 0f;
}
if(level.sector.HasFogColor)
{
density *= 4;
}
fogfactor = density * VisualGeometry.FOG_DENSITY_SCALER;
}
} }
//TECH: even Bright Thing frames are affected by custom fade... //TECH: even Bright Thing frames are affected by custom fade...
else else
@ -293,29 +273,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
Vector3D thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position)); Vector3D thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position));
SectorLevel level = sd.GetLevelAboveOrAt(thingpos); SectorLevel level = sd.GetLevelAboveOrAt(thingpos);
if(level != null && level.sector.HasFogColor) if (level != null && level.sector.FogMode > SectorFogMode.CLASSIC)
{ {
//mxd. Calculate fogfactor //mxd. Calculate fogfactor
float density; fogfactor = VisualGeometry.CalculateFogFactor(level.sector.FogMode, level.brightnessbelow);
if(Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.OutsideFogDensity > 0) }
{
density = General.Map.Data.MapInfo.OutsideFogDensity;
}
else if(!Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.FogDensity > 0)
{
density = General.Map.Data.MapInfo.FogDensity;
}
else if(level.brightnessbelow < 248)
{
density = General.Clamp(255 - level.brightnessbelow, 30, 255);
}
else
{
density = 0f;
}
fogfactor = density * VisualGeometry.FOG_DENSITY_SCALER * 4;
}
} }
} }

View file

@ -136,7 +136,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd. Determine fog density //mxd. Determine fog density
fogfactor = CalculateFogDensity(targetbrightness); fogfactor = CalculateFogFactor(targetbrightness);
// Make vertices // Make vertices
ReadOnlyCollection<Vector2D> triverts = Sector.Sector.Triangles.Vertices; ReadOnlyCollection<Vector2D> triverts = Sector.Sector.Triangles.Vertices;

View file

@ -137,7 +137,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd. Determine fog density //mxd. Determine fog density
fogfactor = CalculateFogDensity(targetbrightness); fogfactor = CalculateFogFactor(targetbrightness);
// Make vertices // Make vertices
ReadOnlyCollection<Vector2D> triverts = Sector.Sector.Triangles.Vertices; ReadOnlyCollection<Vector2D> triverts = Sector.Sector.Triangles.Vertices;

View file

@ -95,9 +95,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Determine initial color // Determine initial color
int lightlevel = sd.Ceiling.brightnessbelow + lightvalue; int lightlevel = sd.Ceiling.brightnessbelow + lightvalue;
// Calculate fog density // Calculate fog density
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
poly.color = PixelColor.INT_WHITE; poly.color = PixelColor.INT_WHITE;
// Cut off the part below the other floor and above the other ceiling // Cut off the part below the other floor and above the other ceiling
CropPoly(ref poly, osd.Ceiling.plane, true); CropPoly(ref poly, osd.Ceiling.plane, true);
@ -138,11 +138,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
private bool IsFogBoundary() private bool IsFogBoundary()
{ {
if(Sidedef.Sector.Index == Sidedef.Other.Sector.Index) return false; // There can't be a boundary if both sides are in the same sector. if(Sidedef.Sector.Index == Sidedef.Other.Sector.Index) return false; // There can't be a boundary if both sides are in the same sector.
if(Sidedef.Sector.HasFogColor == Sidedef.Other.Sector.HasFogColor) return false;
if(!Sidedef.Sector.HasFogColor && !Sidedef.Other.Sector.HasFogColor) return false;
if(Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName && Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName) return false; if(Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName && Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName) return false;
return true; return (Sidedef.Sector.FogMode > SectorFogMode.CLASSIC && Sidedef.Other.Sector.FogMode <= SectorFogMode.CLASSIC);
} }
// This performs a fast test in object picking // This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) { return false; } public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) { return false; }

View file

@ -176,8 +176,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This calculates light with doom-style wall shading //mxd. This calculates light with doom-style wall shading
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
poly.color = wallcolor.WithAlpha(255).ToInt(); poly.color = wallcolor.WithAlpha(255).ToInt();
// Cut off the part above the other floor // Cut off the part above the other floor
CropPoly(ref poly, osd.Floor.plane, false); CropPoly(ref poly, osd.Floor.plane, false);

View file

@ -221,8 +221,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This calculates light with doom-style wall shading //mxd. This calculates light with doom-style wall shading
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
poly.color = wallcolor.WithAlpha(255).ToInt(); poly.color = wallcolor.WithAlpha(255).ToInt();
// Cut off the part above the 3D floor and below the 3D ceiling // Cut off the part above the 3D floor and below the 3D ceiling
CropPoly(ref poly, extrafloor.Floor.plane, false); CropPoly(ref poly, extrafloor.Floor.plane, false);

View file

@ -209,10 +209,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
byte alpha = (byte)extrafloor.Alpha; byte alpha = (byte)extrafloor.Alpha;
if (extrafloor.DontRenderSides) alpha = 0; if (extrafloor.DontRenderSides) alpha = 0;
int wallcolor = PixelColor.Modulate(levelcolor, wallbrightness).WithAlpha(alpha).ToInt(); int wallcolor = PixelColor.Modulate(levelcolor, wallbrightness).WithAlpha(alpha).ToInt();
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
// Cut off the part above the 3D floor and below the 3D ceiling // Cut off the part above the 3D floor and below the 3D ceiling
CropPoly(ref poly, bottom, false); CropPoly(ref poly, bottom, false);
CropPoly(ref poly, top, false); CropPoly(ref poly, top, false);
// Cut out pieces that overlap 3D floors in this sector // Cut out pieces that overlap 3D floors in this sector

View file

@ -184,8 +184,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This calculates light with doom-style wall shading //mxd. This calculates light with doom-style wall shading
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
poly.color = wallcolor.WithAlpha(255).ToInt(); poly.color = wallcolor.WithAlpha(255).ToInt();
// Cut off the part below the other floor and above the other ceiling // Cut off the part below the other floor and above the other ceiling
CropPoly(ref poly, osd.Ceiling.plane, true); CropPoly(ref poly, osd.Ceiling.plane, true);

View file

@ -182,8 +182,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This calculates light with doom-style wall shading //mxd. This calculates light with doom-style wall shading
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
poly.color = wallcolor.WithAlpha(255).ToInt(); poly.color = wallcolor.WithAlpha(255).ToInt();
// Cut out pieces that overlap 3D floors in this sector // Cut out pieces that overlap 3D floors in this sector
List<WallPolygon> polygons = new List<WallPolygon> { poly }; List<WallPolygon> polygons = new List<WallPolygon> { poly };

View file

@ -171,8 +171,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This calculates light with doom-style wall shading //mxd. This calculates light with doom-style wall shading
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness);
fogfactor = CalculateFogDensity(lightlevel); fogfactor = CalculateFogFactor(lightlevel);
poly.color = wallcolor.WithAlpha(255).ToInt(); poly.color = wallcolor.WithAlpha(255).ToInt();
// Cut off the part below the other ceiling // Cut off the part below the other ceiling
CropPoly(ref poly, osd.Ceiling.plane, false); CropPoly(ref poly, osd.Ceiling.plane, false);