From 54f1b38fec980befcac933e5fc783f7ddf2bff82 Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 13 May 2024 17:26:29 +0200 Subject: [PATCH] Scale thing float offset by thing's mobjscale + more object scale handling improvements --- Source/Core/GZBuilder/Data/MapInfo.cs | 7 +++++++ Source/Core/Map/Thing.cs | 12 ++++++------ Source/Core/SRB2/SOCLevelHeader.cs | 3 +++ .../BuilderModes/VisualModes/BaseVisualThing.cs | 10 ++++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Source/Core/GZBuilder/Data/MapInfo.cs b/Source/Core/GZBuilder/Data/MapInfo.cs index f65741b5..2a14393c 100755 --- a/Source/Core/GZBuilder/Data/MapInfo.cs +++ b/Source/Core/GZBuilder/Data/MapInfo.cs @@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data // biwa private bool forceworldpanning; + // SRB2 + private float objectscale; + #endregion #region ================== Properties @@ -84,6 +87,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data // biwa public bool ForceWorldPanning { get { return forceworldpanning; } internal set { forceworldpanning = value; isdefined = true; } } + // SRB2 + public float ObjectScale { get { return objectscale; } internal set { objectscale = value; isdefined = true; } } + #endregion #region ================== Constructor @@ -96,6 +102,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data outsidefogdensity = 255; lightmode = GZDoomLightMode.UNDEFINED; pixelratio = DataManager.DOOM_PIXEL_RATIO; + objectscale = 1.0f; } #endregion diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index 77d32a7a..f78f6f8a 100755 --- a/Source/Core/Map/Thing.cs +++ b/Source/Core/Map/Thing.cs @@ -113,9 +113,9 @@ namespace CodeImp.DoomBuilder.Map internal Dictionary Flags { get { return flags; } } public int Action { get { return action; } set { BeforePropsChange(); action = value; } } public int[] Args { get { return args; } } - public float Size { get { return GetScaledObjectSize(size); } } + public float Size { get { return size * GetObjectScale(); } } public float RenderSize { get { return rendersize; } } - public float Height { get { return GetScaledObjectSize(height); } } //mxd + public float Height { get { return height * GetObjectScale(); } } //mxd public PixelColor Color { get { return color; } } public bool FixedSize { get { return fixedsize; } } public int Tag { get { return tag; } set { BeforePropsChange(); tag = value; if((tag < General.Map.FormatInterface.MinTag) || (tag > General.Map.FormatInterface.MaxTag)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } } @@ -761,12 +761,12 @@ namespace CodeImp.DoomBuilder.Map map?.ChangeThingIndex(Index, newindex); } - public float GetScaledObjectSize(float value) + public float GetObjectScale() { if (General.Map.Config.EngineName == "srb2") - value *= (float)UniFields.GetFloat(this.Fields, "mobjscale", 1.0f); - - return value; + return (float)UniFields.GetFloat(this.Fields, "mobjscale", 1.0f) * General.Map.Data.MapInfo.ObjectScale; + else + return 1.0f; } #endregion diff --git a/Source/Core/SRB2/SOCLevelHeader.cs b/Source/Core/SRB2/SOCLevelHeader.cs index a67ec478..6ae51188 100644 --- a/Source/Core/SRB2/SOCLevelHeader.cs +++ b/Source/Core/SRB2/SOCLevelHeader.cs @@ -76,6 +76,9 @@ namespace CodeImp.DoomBuilder.ZDoom case "skynum": mapinfo.Sky1 = "SKY" + tokens[1]; break; + case "objectscale": + mapinfo.ObjectScale = 1.0f; // SRB2 todo: add proper conversion from FRACUNIT-based values to float + break; default: break; } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index cc868155..18a3d773 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -489,16 +489,18 @@ namespace CodeImp.DoomBuilder.BuilderModes } // SRB2 floating things hack - // TODO: replace this with config-based parameter once SOC/Lua parsing exists + // TODO: replace this with... something better int[] float16 = new int[] {558, 559, 560}; int[] float24 = new int[] {300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 320, 321, 330, 331, 332, 333, 334, 335, 520, 1706, 1800}; + int sign = Thing.IsFlipped ? -1 : 1; + if (Thing.Type == 322 && Thing.Args[1] == 0) // Emblems have float flag on args[1] - pos.z = (Thing.IsFlipped) ? pos.z - 24 : pos.z + 24; + pos.z += (24 * sign) * Thing.GetObjectScale(); else if (float16.Contains(Thing.Type) && Thing.Args[0] == 0) - pos.z = (Thing.IsFlipped) ? pos.z - 16 : pos.z + 16; + pos.z += (16 * sign) * Thing.GetObjectScale(); else if (float24.Contains(Thing.Type) && Thing.Args[0] == 0) - pos.z = (Thing.IsFlipped) ? pos.z - 24 : pos.z + 24; + pos.z += (24 * sign) * Thing.GetObjectScale(); //if (info.ZOffset != 0) pos.z += Thing.IsFlipped ? -info.ZOffset : info.ZOffset;