From 560d8fca57b7688de1ef4c69ce14811f28d98ae1 Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 8 May 2024 15:39:20 +0200 Subject: [PATCH] Improve mobjscale handling & show it in classic editing modes --- Source/Core/Map/Thing.cs | 12 +++++- Source/Core/VisualModes/VisualThing.cs | 40 +++++++++---------- .../VisualModes/BaseVisualThing.cs | 5 +-- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index 3a4fb538..77d32a7a 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 size; } } + public float Size { get { return GetScaledObjectSize(size); } } public float RenderSize { get { return rendersize; } } - public float Height { get { return height; } } //mxd + public float Height { get { return GetScaledObjectSize(height); } } //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,6 +761,14 @@ namespace CodeImp.DoomBuilder.Map map?.ChangeThingIndex(Index, newindex); } + public float GetScaledObjectSize(float value) + { + if (General.Map.Config.EngineName == "srb2") + value *= (float)UniFields.GetFloat(this.Fields, "mobjscale", 1.0f); + + return value; + } + #endregion } } diff --git a/Source/Core/VisualModes/VisualThing.cs b/Source/Core/VisualModes/VisualThing.cs index d00b50a8..a6bc299e 100755 --- a/Source/Core/VisualModes/VisualThing.cs +++ b/Source/Core/VisualModes/VisualThing.cs @@ -560,36 +560,36 @@ namespace CodeImp.DoomBuilder.VisualModes // Trash cage buffer if(cagebuffer != null) cagebuffer.Dispose(); cagebuffer = null; - float thingsize = thing.Size * (float)UniFields.GetFloat(Thing.Fields, "mobjscale", 1.0f); - float thingheight = thing.Height * (float)UniFields.GetFloat(Thing.Fields, "mobjscale", 1.0f); + //float thingsize = thing.Size * (float)UniFields.GetFloat(Thing.Fields, "mobjscale", 1.0f); + //float thingheight = thing.Height * (float)UniFields.GetFloat(Thing.Fields, "mobjscale", 1.0f); // Make a new cage List cageverts; if(sizeless) { - WorldVertex v0 = new WorldVertex(-thingsize + position_v3.X, -thingsize + position_v3.Y, position_v3.Z); - WorldVertex v1 = new WorldVertex(thingsize + position_v3.X, thingsize + position_v3.Y, position_v3.Z); - WorldVertex v2 = new WorldVertex(thingsize + position_v3.X, -thingsize + position_v3.Y, position_v3.Z); - WorldVertex v3 = new WorldVertex(-thingsize + position_v3.X, thingsize + position_v3.Y, position_v3.Z); - WorldVertex v4 = new WorldVertex(position_v3.X, position_v3.Y, thingsize + position_v3.Z); - WorldVertex v5 = new WorldVertex(position_v3.X, position_v3.Y, -thingsize + position_v3.Z); + WorldVertex v0 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, position_v3.Z); + WorldVertex v1 = new WorldVertex(thing.Size + position_v3.X, thing.Size + position_v3.Y, position_v3.Z); + WorldVertex v2 = new WorldVertex(thing.Size + position_v3.X, -thing.Size + position_v3.Y, position_v3.Z); + WorldVertex v3 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, position_v3.Z); + WorldVertex v4 = new WorldVertex(position_v3.X, position_v3.Y, thing.Size + position_v3.Z); + WorldVertex v5 = new WorldVertex(position_v3.X, position_v3.Y, -thing.Size + position_v3.Z); cageverts = new List(new[] { v0, v1, v2, v3, v4, v5 }); } else { - float top = position_v3.Z + (info.CenterHitbox ? thingheight / 2 : thingheight); - float bottom = position_v3.Z - (info.CenterHitbox ? thingheight / 2 : 0); + float top = position_v3.Z + (info.CenterHitbox ? thing.Height / 2 : thing.Height); + float bottom = position_v3.Z - (info.CenterHitbox ? thing.Height / 2 : 0); - WorldVertex v0 = new WorldVertex(-thingsize + position_v3.X, -thingsize + position_v3.Y, bottom); - WorldVertex v1 = new WorldVertex(-thingsize + position_v3.X, thingsize + position_v3.Y, bottom); - WorldVertex v2 = new WorldVertex(thingsize + position_v3.X, thingsize + position_v3.Y, bottom); - WorldVertex v3 = new WorldVertex(thingsize + position_v3.X, -thingsize + position_v3.Y, bottom); + WorldVertex v0 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, bottom); + WorldVertex v1 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, bottom); + WorldVertex v2 = new WorldVertex(thing.Size + position_v3.X, thing.Size + position_v3.Y, bottom); + WorldVertex v3 = new WorldVertex(thing.Size + position_v3.X, -thing.Size + position_v3.Y, bottom); - WorldVertex v4 = new WorldVertex(-thingsize + position_v3.X, -thingsize + position_v3.Y, top); - WorldVertex v5 = new WorldVertex(-thingsize + position_v3.X, thingsize + position_v3.Y, top); - WorldVertex v6 = new WorldVertex(thingsize + position_v3.X, thingsize + position_v3.Y, top); - WorldVertex v7 = new WorldVertex(thingsize + position_v3.X, -thingsize + position_v3.Y, top); + WorldVertex v4 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, top); + WorldVertex v5 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, top); + WorldVertex v6 = new WorldVertex(thing.Size + position_v3.X, thing.Size + position_v3.Y, top); + WorldVertex v7 = new WorldVertex(thing.Size + position_v3.X, -thing.Size + position_v3.Y, top); cageverts = new List(new[] { v0, v1, v1, v2, @@ -608,9 +608,9 @@ namespace CodeImp.DoomBuilder.VisualModes // Make new arrow if(Thing.IsDirectional) { - Matrix transform = Matrix.Scaling(thingsize, thingsize, thingsize) + Matrix transform = Matrix.Scaling(thing.Size, thing.Size, thing.Size) * (Matrix.RotationY((float)-Thing.RollRad) * Matrix.RotationX((float)-Thing.PitchRad) * Matrix.RotationZ((float)Thing.Angle)) - * ((sizeless || info.CenterHitbox) ? position : position * Matrix.Translation(0.0f, 0.0f, thingheight / 2f)); + * ((sizeless || info.CenterHitbox) ? position : position * Matrix.Translation(0.0f, 0.0f, thing.Height / 2f)); WorldVertex a0 = new WorldVertex(Vector3D.Transform(0.0f, 0.0f, 0.0f, transform)); //start WorldVertex a1 = new WorldVertex(Vector3D.Transform(0.0f, -1.5f, 0.0f, transform)); //end diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 487aa04a..cc868155 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -196,9 +196,8 @@ namespace CodeImp.DoomBuilder.BuilderModes fogfactor = 0f; //mxd //mxd. Check thing size - float mobjscale = (float)UniFields.GetFloat(Thing.Fields, "mobjscale", 1.0f); - float thingradius = Thing.Size * mobjscale; // Thing.Size has ThingRadius arg override applied - thingheight = Thing.Height * mobjscale; // Thing.Height has ThingHeight arg override applied + float thingradius = Thing.Size; // Thing.Size has ThingRadius arg override applied + thingheight = Thing.Height; // Thing.Height has ThingHeight arg override applied if(thingradius < 0.1f || thingheight < 0.1f) {