Render Things whose Z position indicates the position of the center rather than the bottom accordingly

This commit is contained in:
MascaraSnake 2016-01-13 21:39:26 +01:00
parent 7a25614155
commit 1e10c8b129
9 changed files with 37 additions and 13 deletions

View file

@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.IO
unflippableTypes = new List<int>();
startTypes = new List<int>();
floatableTypes = new List<int>();
centerHitboxTypes = new List<int>();
}
#endregion

View file

@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.IO
unflippableTypes = new List<int>();
startTypes = new List<int>();
floatableTypes = new List<int>();
centerHitboxTypes = new List<int>();
}
#endregion

View file

@ -84,5 +84,6 @@ namespace CodeImp.DoomBuilder.IO
List<int> UnflippableTypes { get; }
List<int> StartTypes { get; }
List<int> FloatableTypes { get; }
List<int> CenterHitboxTypes { get; }
}
}

View file

@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.IO
protected List<int> unflippableTypes;
protected List<int> startTypes;
protected List<int> floatableTypes;
protected List<int> centerHitboxTypes;
#endregion
#region ================== Properties
@ -113,6 +114,7 @@ namespace CodeImp.DoomBuilder.IO
public List<int> UnflippableTypes { get { return unflippableTypes; } }
public List<int> StartTypes { get { return startTypes; } }
public List<int> FloatableTypes { get { return floatableTypes; } }
public List<int> CenterHitboxTypes { get { return centerHitboxTypes; } }
#endregion
#region ================== Constructor / Disposer

View file

@ -148,6 +148,8 @@ namespace CodeImp.DoomBuilder.IO
startTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
floatableTypes = new List<int>() { 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 312, 323, 330, 331, 332, 333, 334, 335, 521, 1800 };
centerHitboxTypes = new List<int>() { 604, 605, 606, 607, 608, 609, 1705, 1713 };
}
#endregion

View file

@ -55,6 +55,7 @@ namespace CodeImp.DoomBuilder.IO
unflippableTypes = new List<int>();
startTypes = new List<int>();
floatableTypes = new List<int>();
centerHitboxTypes = new List<int>();
// Make configuration
Configuration config = new Configuration();

View file

@ -131,6 +131,7 @@ namespace CodeImp.DoomBuilder.Map
public bool IsReverse { get { return General.Map.SRB2 && !Unflippable && IsFlagSet("2"); } }
public bool Unflippable { get { return General.Map.FormatInterface.UnflippableTypes.Contains(Type); } }
public bool IsFloatable { get { return General.Map.FormatInterface.FloatableTypes.Contains(Type); } }
public bool CenterHitbox { get { return General.Map.FormatInterface.CenterHitboxTypes.Contains(Type); } }
#endregion
#region ================== Constructor / Disposer

View file

@ -439,10 +439,10 @@ namespace CodeImp.DoomBuilder.VisualModes
}
else
{
float top = position_v3.Z + thing.Height;
float bottom = position_v3.Z;
float top = position_v3.Z + (thing.CenterHitbox ? thing.Height/2 : thing.Height);
float bottom = position_v3.Z - (thing.CenterHitbox ? thing.Height / 2 : 0);
WorldVertex v0 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + 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);
@ -471,7 +471,7 @@ namespace CodeImp.DoomBuilder.VisualModes
{
Matrix transform = Matrix.Scaling(thing.Size, thing.Size, thing.Size)
* (Matrix.RotationY(-Thing.RollRad) * Matrix.RotationX(-Thing.PitchRad) * Matrix.RotationZ(Thing.Angle))
* (sizeless ? position : position * Matrix.Translation(0.0f, 0.0f, thingheight / 2f));
* ((sizeless || thing.CenterHitbox) ? position : position * Matrix.Translation(0.0f, 0.0f, thingheight / 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

View file

@ -349,8 +349,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
WorldVertex[] verts = new WorldVertex[6];
if(sizeless) //mxd
{
float hh = height / 2;
{
float hh = height / 2;
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety - hh, sectorcolor, 0.0f, 1.0f);
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, hh + offsety, sectorcolor, 0.0f, 0.0f);
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, hh + offsety, sectorcolor, 1.0f, 0.0f);
@ -358,7 +358,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
verts[4] = verts[2];
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, offsety - hh, sectorcolor, 1.0f, 1.0f);
}
else
else if (Thing.CenterHitbox)
{
float hh = height / 2;
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, -hh, sectorcolor, 0.0f, 1.0f);
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, hh, sectorcolor, 0.0f, 0.0f);
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, hh, sectorcolor, 1.0f, 0.0f);
verts[3] = verts[0];
verts[4] = verts[2];
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, -hh, sectorcolor, 1.0f, 1.0f);
}
else
{
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety, sectorcolor, 0.0f, 1.0f);
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, height + offsety, sectorcolor, 0.0f, 0.0f);
@ -479,14 +489,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z - thingradius/2);
boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingradius/2);
}
else
else if (Thing.CenterHitbox)
{
boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z);
boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingheight);
boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z - thingheight/2);
boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingheight/2);
}
// Done
changed = false;
else
{
boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z);
boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingheight);
}
// Done
changed = false;
return true;
}