Added support for non-1.2 pixel ratios if view stretching is enabled (reported by Nash); Fixed: map names in quotes were not recognized properly.

This commit is contained in:
ZZYZX 2017-08-27 08:09:28 +03:00
parent b8e68083c0
commit e7328e4caa
7 changed files with 72 additions and 16 deletions

View file

@ -209,13 +209,33 @@ namespace CodeImp.DoomBuilder.Data
return false;
}
}
#endregion
#region ================== Constructor / Disposer
internal const float DOOM_PIXEL_RATIO = 1.2f;
// Constructor
internal DataManager()
public float VerticalViewStretch
{
get
{
if (mapinfo == null)
return DOOM_PIXEL_RATIO;
return mapinfo.PixelRatio;
}
}
public float InvertedVerticalViewStretch
{
get
{
return 1.0f / VerticalViewStretch;
}
}
#endregion
#region ================== Constructor / Disposer
// Constructor
internal DataManager()
{
// We have no destructor
GC.SuppressFinalize(this);

View file

@ -1,5 +1,6 @@
#region ================== Namespaces
using CodeImp.DoomBuilder.Data;
using SlimDX;
#endregion
@ -46,6 +47,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
private int vertwallshade;
private int horizwallshade;
// [ZZ]
private float pixelratio;
#endregion
#region ================== Properties
@ -71,6 +75,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
public int VertWallShade { get { return vertwallshade; } internal set { vertwallshade = value; isdefined = true; } }
public int HorizWallShade { get { return horizwallshade; } internal set { horizwallshade = value; isdefined = true; } }
// [ZZ]
public float PixelRatio { get { return pixelratio; } internal set { pixelratio = value; isdefined = true; } }
#endregion
#region ================== Constructor
@ -82,6 +89,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
fogdensity = 255;
outsidefogdensity = 255;
lightmode = GZDoomLightMode.UNDEFINED;
pixelratio = DataManager.DOOM_PIXEL_RATIO;
}
#endregion

View file

@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
{
this.scale = scale;
transform = rotation * Matrix.Scaling(scale) * offset;
transformstretched = Matrix.Scaling(1.0f, 1.0f, Renderer3D.GZDOOM_INVERTED_VERTICAL_VIEW_STRETCH) * transform;
transformstretched = Matrix.Scaling(1.0f, 1.0f, General.Map.Data.InvertedVerticalViewStretch) * transform;
}
//mxd. This greatly speeds up Dictionary lookups

View file

@ -30,6 +30,6 @@ using CodeImp.DoomBuilder;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.3.0.2985")]
[assembly: AssemblyVersion("2.3.0.2988")]
[assembly: NeutralResourcesLanguageAttribute("en")]
[assembly: AssemblyHash("113d86a")]
[assembly: AssemblyHash("b8e6808")]

View file

@ -38,8 +38,6 @@ namespace CodeImp.DoomBuilder.Rendering
private const float PROJ_NEAR_PLANE = 1f;
private const float FOG_RANGE = 0.9f;
internal const float GZDOOM_VERTICAL_VIEW_STRETCH = 1.2f;
internal const float GZDOOM_INVERTED_VERTICAL_VIEW_STRETCH = 1.0f / GZDOOM_VERTICAL_VIEW_STRETCH;
private const int SHADERPASS_LIGHT = 17; //mxd
private const int SHADERPASS_SKYBOX = 5; //mxd
@ -138,7 +136,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal Renderer3D(D3DDevice graphics) : base(graphics)
{
// Initialize
CreateProjection();
//CreateProjection(); // [ZZ] don't do undefined things once not even ready
CreateMatrices2D();
renderthingcages = true;
showselection = true;
@ -235,7 +233,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal void CreateProjection()
{
// Calculate aspect
float screenheight = General.Map.Graphics.RenderTarget.ClientSize.Height * (General.Settings.GZStretchView ? GZDOOM_INVERTED_VERTICAL_VIEW_STRETCH : 1.0f); //mxd
float screenheight = General.Map.Graphics.RenderTarget.ClientSize.Height * (General.Settings.GZStretchView ? General.Map.Data.InvertedVerticalViewStretch : 1.0f); //mxd
float aspect = General.Map.Graphics.RenderTarget.ClientSize.Width / screenheight;
// The DirectX PerspectiveFovRH matrix method calculates the scaling in X and Y as follows:

View file

@ -116,10 +116,12 @@ namespace CodeImp.DoomBuilder.ZDoom
// Get map lump name
SkipWhitespace(true);
token = ReadToken().ToLowerInvariant();
if(token != this.mapname)
// [ZZ] Note: map name is sometimes in quotes. I think this was "fixed" some time ago, but apparently not.
token = StripQuotes(token);
if (token != this.mapname)
{
// Map number? Try to build map name from it...
int n;
// Map number? Try to build map name from it...
int n;
if(int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
{
token = ((n > 0 && n < 10) ? "map0" + n : "map" + n);
@ -472,6 +474,11 @@ namespace CodeImp.DoomBuilder.ZDoom
if(!ParseLightMode()) return false;
break;
// [ZZ]
case "pixelratio":
if (!ParsePixelRatio()) return false;
break;
case "}": return true; // Block end
case "{": // Skip inner blocks
@ -724,6 +731,29 @@ namespace CodeImp.DoomBuilder.ZDoom
return true;
}
private bool ParsePixelRatio()
{
SkipWhitespace(true);
if (!NextTokenIs("=")) return false; // New format only
SkipWhitespace(true);
string token = ReadToken();
float val;
if (!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
{
// Not numeric!
ReportError("Expected PixelRatio value, but got \"" + token + "\"");
return false;
}
// Store
mapinfo.PixelRatio = val;
// All done here
return true;
}
#endregion
}

View file

@ -29,5 +29,5 @@ using System.Resources;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.3.0.2985")]
[assembly: AssemblyVersion("2.3.0.2988")]
[assembly: NeutralResourcesLanguageAttribute("en")]