Scale thing float offset by thing's mobjscale + more object scale handling improvements

This commit is contained in:
spherallic 2024-05-13 17:26:29 +02:00
parent 560d8fca57
commit 54f1b38fec
4 changed files with 22 additions and 10 deletions

View file

@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
// biwa // biwa
private bool forceworldpanning; private bool forceworldpanning;
// SRB2
private float objectscale;
#endregion #endregion
#region ================== Properties #region ================== Properties
@ -84,6 +87,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
// biwa // biwa
public bool ForceWorldPanning { get { return forceworldpanning; } internal set { forceworldpanning = value; isdefined = true; } } 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 #endregion
#region ================== Constructor #region ================== Constructor
@ -96,6 +102,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
outsidefogdensity = 255; outsidefogdensity = 255;
lightmode = GZDoomLightMode.UNDEFINED; lightmode = GZDoomLightMode.UNDEFINED;
pixelratio = DataManager.DOOM_PIXEL_RATIO; pixelratio = DataManager.DOOM_PIXEL_RATIO;
objectscale = 1.0f;
} }
#endregion #endregion

View file

@ -113,9 +113,9 @@ namespace CodeImp.DoomBuilder.Map
internal Dictionary<string, bool> Flags { get { return flags; } } internal Dictionary<string, bool> Flags { get { return flags; } }
public int Action { get { return action; } set { BeforePropsChange(); action = value; } } public int Action { get { return action; } set { BeforePropsChange(); action = value; } }
public int[] Args { get { return args; } } 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 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 PixelColor Color { get { return color; } }
public bool FixedSize { get { return fixedsize; } } 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"); } } 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); map?.ChangeThingIndex(Index, newindex);
} }
public float GetScaledObjectSize(float value) public float GetObjectScale()
{ {
if (General.Map.Config.EngineName == "srb2") if (General.Map.Config.EngineName == "srb2")
value *= (float)UniFields.GetFloat(this.Fields, "mobjscale", 1.0f); return (float)UniFields.GetFloat(this.Fields, "mobjscale", 1.0f) * General.Map.Data.MapInfo.ObjectScale;
else
return value; return 1.0f;
} }
#endregion #endregion

View file

@ -76,6 +76,9 @@ namespace CodeImp.DoomBuilder.ZDoom
case "skynum": case "skynum":
mapinfo.Sky1 = "SKY" + tokens[1]; mapinfo.Sky1 = "SKY" + tokens[1];
break; break;
case "objectscale":
mapinfo.ObjectScale = 1.0f; // SRB2 todo: add proper conversion from FRACUNIT-based values to float
break;
default: default:
break; break;
} }

View file

@ -489,16 +489,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// SRB2 floating things hack // 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[] 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[] 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] 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) 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) 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; //if (info.ZOffset != 0) pos.z += Thing.IsFlipped ? -info.ZOffset : info.ZOffset;