Thing angles outside of 0-359 are now preserved when copypasting or placing new Things

This commit is contained in:
MascaraSnake 2016-09-16 23:07:18 +02:00
parent a0c77248b7
commit 130101a227
4 changed files with 15 additions and 12 deletions

View file

@ -141,7 +141,7 @@ namespace CodeImp.DoomBuilder.Config
private int defaultfloorheight; private int defaultfloorheight;
private int defaultceilheight; private int defaultceilheight;
private int defaultthingtype = 1; private int defaultthingtype = 1;
private float defaultthingangle; private int defaultthingangle;
private List<string> defaultthingflags; private List<string> defaultthingflags;
#endregion #endregion
@ -251,7 +251,7 @@ namespace CodeImp.DoomBuilder.Config
public int DefaultCeilingHeight { get { return defaultceilheight; } set { defaultceilheight = value; } } public int DefaultCeilingHeight { get { return defaultceilheight; } set { defaultceilheight = value; } }
public int DefaultThingType { get { return defaultthingtype; } set { defaultthingtype = value; } } public int DefaultThingType { get { return defaultthingtype; } set { defaultthingtype = value; } }
public float DefaultThingAngle { get { return defaultthingangle; } set { defaultthingangle = value; } } public int DefaultThingAngle { get { return defaultthingangle; } set { defaultthingangle = value; } }
#endregion #endregion

View file

@ -439,7 +439,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(CheckBox c in flags.Checkboxes) foreach(CheckBox c in flags.Checkboxes)
if(c.CheckState == CheckState.Checked) defaultflags.Add(c.Tag.ToString()); if(c.CheckState == CheckState.Checked) defaultflags.Add(c.Tag.ToString());
General.Settings.DefaultThingType = thingtype.GetResult(General.Settings.DefaultThingType); General.Settings.DefaultThingType = thingtype.GetResult(General.Settings.DefaultThingType);
General.Settings.DefaultThingAngle = Angle2D.DegToRad((float)angle.GetResult((int)Angle2D.RadToDeg(General.Settings.DefaultThingAngle) - 90) + 90); General.Settings.DefaultThingAngle = angle.GetResult(General.Settings.DefaultThingAngle);
General.Settings.SetDefaultThingFlags(defaultflags); General.Settings.SetDefaultThingFlags(defaultflags);
// Done // Done

View file

@ -505,7 +505,7 @@ namespace CodeImp.DoomBuilder.Windows
if(c.CheckState == CheckState.Checked) defaultflags.Add(c.Tag.ToString()); if(c.CheckState == CheckState.Checked) defaultflags.Add(c.Tag.ToString());
} }
General.Settings.DefaultThingType = thingtype.GetResult(General.Settings.DefaultThingType); General.Settings.DefaultThingType = thingtype.GetResult(General.Settings.DefaultThingType);
General.Settings.DefaultThingAngle = Angle2D.DegToRad((float)angle.GetResult((int)Angle2D.RadToDeg(General.Settings.DefaultThingAngle) - 90) + 90); General.Settings.DefaultThingAngle = angle.GetResult(General.Settings.DefaultThingAngle);
General.Settings.SetDefaultThingFlags(defaultflags); General.Settings.SetDefaultThingFlags(defaultflags);
// Store value linking // Store value linking

View file

@ -158,7 +158,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
private List<Vector2D> vertexpos; private List<Vector2D> vertexpos;
private List<Vector2D> thingpos; private List<Vector2D> thingpos;
private List<float> thingangle; private List<float> thingangle;
private ICollection<Vertex> unselectedvertices; private List<int> thingangledoom;
private ICollection<Vertex> unselectedvertices;
private ICollection<Linedef> unselectedlines; private ICollection<Linedef> unselectedlines;
// Modification // Modification
@ -731,7 +732,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void UpdateGeometry() private void UpdateGeometry()
{ {
float[] newthingangle = thingangle.ToArray(); float[] newthingangle = thingangle.ToArray();
int index; int index;
// Flip things horizontally // Flip things horizontally
if(size.x < 0.0f) if(size.x < 0.0f)
@ -834,7 +835,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
index = 0; index = 0;
foreach(Thing t in selectedthings) foreach(Thing t in selectedthings)
{ {
if(!fixedrotationthingtypes.Contains(t.SRB2Type)) //mxd. Polyobject Anchors, I hate you! if(!fixedrotationthingtypes.Contains(t.SRB2Type) && newthingangle[index] != thingangle[index]) //mxd. Polyobject Anchors, I hate you!
t.Rotate(Angle2D.Normalized(newthingangle[index])); t.Rotate(Angle2D.Normalized(newthingangle[index]));
index++; index++;
} }
@ -1093,7 +1094,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
vertexpos = new List<Vector2D>(selectedvertices.Count); vertexpos = new List<Vector2D>(selectedvertices.Count);
thingpos = new List<Vector2D>(selectedthings.Count); thingpos = new List<Vector2D>(selectedthings.Count);
thingangle = new List<float>(selectedthings.Count); thingangle = new List<float>(selectedthings.Count);
fixedrotationthingtypes = new List<int>(); //mxd thingangledoom = new List<int>(selectedthings.Count);
fixedrotationthingtypes = new List<int>(); //mxd
// A selection must be made! // A selection must be made!
if((selectedvertices.Count > 0) || (selectedthings.Count > 0)) if((selectedvertices.Count > 0) || (selectedthings.Count > 0))
@ -1135,7 +1137,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Keep original coordinates // Keep original coordinates
thingpos.Add(t.Position); thingpos.Add(t.Position);
thingangle.Add(t.Angle); thingangle.Add(t.Angle);
} thingangledoom.Add(t.AngleDoom);
}
// Calculate size // Calculate size
size = right - offset; size = right - offset;
@ -1243,7 +1246,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
index = 0; index = 0;
foreach(Thing t in selectedthings) foreach(Thing t in selectedthings)
{ {
t.Rotate(thingangle[index]); t.Rotate(thingangledoom[index]);
t.Move(thingpos[index++]); t.Move(thingpos[index++]);
} }
@ -1305,7 +1308,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
index = 0; index = 0;
foreach(Thing t in selectedthings) foreach(Thing t in selectedthings)
{ {
t.Rotate(thingangle[index]); t.Rotate(thingangledoom[index]);
t.Move(thingpos[index++]); t.Move(thingpos[index++]);
} }
@ -1333,7 +1336,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
index = 0; index = 0;
foreach(Thing t in selectedthings) foreach(Thing t in selectedthings)
{ {
t.Rotate(thingangle[index]); t.Rotate(thingangledoom[index]);
t.Move(thingpos[index++]); t.Move(thingpos[index++]);
} }