More conversion from float to double. Doesn't seem to crash anymore.

This commit is contained in:
biwa 2020-05-22 21:39:18 +02:00
parent 91cbcde1eb
commit ab81b17554
47 changed files with 466 additions and 450 deletions

View file

@ -133,13 +133,13 @@ namespace CodeImp.DoomBuilder.Controls
} }
else if(textbox.AllowDecimal) else if(textbox.AllowDecimal)
{ {
float stepsizemod; //mxd double stepsizemod; //mxd
if(usemodifierkeys) if(usemodifierkeys)
stepsizemod = (ctrl ? stepsizeSmall : (shift ? stepsizeBig : stepsizeFloat)); stepsizemod = (ctrl ? stepsizeSmall : (shift ? stepsizeBig : stepsizeFloat));
else else
stepsizemod = stepsizeFloat; stepsizemod = stepsizeFloat;
float newvalue = (float)Math.Round(textbox.GetResultFloat(0.0f) - (buttons.Value * stepsizemod), General.Map.FormatInterface.VertexDecimals); double newvalue = Math.Round(textbox.GetResultFloat(0.0f) - (buttons.Value * stepsizemod), General.Map.FormatInterface.VertexDecimals);
if((newvalue < 0.0f) && !textbox.AllowNegative) newvalue = 0.0f; if((newvalue < 0.0f) && !textbox.AllowNegative) newvalue = 0.0f;
textbox.Text = newvalue.ToString(); textbox.Text = newvalue.ToString();
} }

View file

@ -317,16 +317,16 @@ namespace CodeImp.DoomBuilder.Controls
frontpanel.Text += ". Offset " + l.Front.OffsetX + ", " + l.Front.OffsetY + ". Sector " + l.Front.Sector.Index + " "; frontpanel.Text += ". Offset " + l.Front.OffsetX + ", " + l.Front.OffsetY + ". Sector " + l.Front.Sector.Index + " ";
//sidedef top //sidedef top
hasTopFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_top", "offsety_top", 0.0f, frontTopUDMFOffsetLabel, frontTopUDMFOffset, highlight); hasTopFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_top", "offsety_top", 0.0, frontTopUDMFOffsetLabel, frontTopUDMFOffset, highlight);
hasTopFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_top", "scaley_top", 1.0f, frontTopUDMFScaleLabel, frontTopUDMFScale, highlight); hasTopFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_top", "scaley_top", 1.0, frontTopUDMFScaleLabel, frontTopUDMFScale, highlight);
//sidedef middle //sidedef middle
hasMiddleFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_mid", "offsety_mid", 0.0f, frontMidUDMFOffsetLabel, frontMidUDMFOffset, highlight); hasMiddleFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_mid", "offsety_mid", 0.0, frontMidUDMFOffsetLabel, frontMidUDMFOffset, highlight);
hasMiddleFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_mid", "scaley_mid", 1.0f, frontMidUDMFScaleLabel, frontMidUDMFScale, highlight); hasMiddleFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_mid", "scaley_mid", 1.0, frontMidUDMFScaleLabel, frontMidUDMFScale, highlight);
//sidedef bottom //sidedef bottom
hasBottomFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_bottom", "offsety_bottom", 0.0f, frontBottomUDMFOffsetLabel, frontBottomUDMFOffset, highlight); hasBottomFields = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_bottom", "offsety_bottom", 0.0, frontBottomUDMFOffsetLabel, frontBottomUDMFOffset, highlight);
hasBottomFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_bottom", "scaley_bottom", 1.0f, frontBottomUDMFScaleLabel, frontBottomUDMFScale, highlight); hasBottomFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_bottom", "scaley_bottom", 1.0, frontBottomUDMFScaleLabel, frontBottomUDMFScale, highlight);
//visibility //visibility
frontTopUDMFOffset.Visible = hasTopFields; frontTopUDMFOffset.Visible = hasTopFields;
@ -618,7 +618,7 @@ namespace CodeImp.DoomBuilder.Controls
} }
//mxd //mxd
private static bool SetPairedUDMFFieldsLabel(UniFields fields, string paramX, string paramY, float defaultvalue, Label namelabel, Label valuelabel, bool highlight) private static bool SetPairedUDMFFieldsLabel(UniFields fields, string paramX, string paramY, double defaultvalue, Label namelabel, Label valuelabel, bool highlight)
{ {
double x = UniFields.GetFloat(fields, paramX, defaultvalue); double x = UniFields.GetFloat(fields, paramX, defaultvalue);
double y = UniFields.GetFloat(fields, paramY, defaultvalue); double y = UniFields.GetFloat(fields, paramY, defaultvalue);

View file

@ -69,13 +69,13 @@ namespace CodeImp.DoomBuilder.Controls
if(AllowDecimal) if(AllowDecimal)
{ {
newValue1 = ((float)Math.Round(UniFields.GetFloat(fields, field1, defaultValue), 2)).ToString(); newValue1 = Math.Round(UniFields.GetFloat(fields, field1, defaultValue), 2).ToString();
newValue2 = ((float)Math.Round(UniFields.GetFloat(fields, field2, defaultValue), 2)).ToString(); newValue2 = Math.Round(UniFields.GetFloat(fields, field2, defaultValue), 2).ToString();
} }
else else
{ {
newValue1 = ((float)Math.Round(UniFields.GetFloat(fields, field1, defaultValue))).ToString(); newValue1 = Math.Round(UniFields.GetFloat(fields, field1, defaultValue)).ToString();
newValue2 = ((float)Math.Round(UniFields.GetFloat(fields, field2, defaultValue))).ToString(); newValue2 = Math.Round(UniFields.GetFloat(fields, field2, defaultValue)).ToString();
} }
if(first) if(first)

View file

@ -197,8 +197,8 @@ namespace CodeImp.DoomBuilder.Controls
} }
//ceiling offsets //ceiling offsets
float panX = s.Fields.GetValue("xpanningceiling", 0f); double panX = s.Fields.GetValue("xpanningceiling", 0.0);
float panY = s.Fields.GetValue("ypanningceiling", 0f); double panY = s.Fields.GetValue("ypanningceiling", 0.0);
if(panX != 0 || panY != 0) if(panX != 0 || panY != 0)
{ {
@ -215,8 +215,8 @@ namespace CodeImp.DoomBuilder.Controls
} }
//floor offsets //floor offsets
panX = s.Fields.GetValue("xpanningfloor", 0f); panX = s.Fields.GetValue("xpanningfloor", 0.0);
panY = s.Fields.GetValue("ypanningfloor", 0f); panY = s.Fields.GetValue("ypanningfloor", 0.0);
if(panX != 0 || panY != 0) if(panX != 0 || panY != 0)
{ {
@ -233,8 +233,8 @@ namespace CodeImp.DoomBuilder.Controls
} }
//ceiling scale //ceiling scale
float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f); double scaleX = s.Fields.GetValue("xscaleceiling", 1.0);
float scaleY = s.Fields.GetValue("yscaleceiling", 1.0f); double scaleY = s.Fields.GetValue("yscaleceiling", 1.0);
if(scaleX != 1.0f || scaleY != 1.0f) if(scaleX != 1.0f || scaleY != 1.0f)
{ {
@ -251,10 +251,10 @@ namespace CodeImp.DoomBuilder.Controls
} }
//floor scale //floor scale
scaleX = s.Fields.GetValue("xscalefloor", 1.0f); scaleX = s.Fields.GetValue("xscalefloor", 1.0);
scaleY = s.Fields.GetValue("yscalefloor", 1.0f); scaleY = s.Fields.GetValue("yscalefloor", 1.0);
if(scaleX != 1.0f || scaleY != 1.0f) if(scaleX != 1.0 || scaleY != 1.0)
{ {
showExtededFloorInfo = true; showExtededFloorInfo = true;
floorScale.Enabled = true; floorScale.Enabled = true;
@ -269,8 +269,8 @@ namespace CodeImp.DoomBuilder.Controls
} }
//rotation //rotation
float ceilangle = s.Fields.GetValue("rotationceiling", 0f); double ceilangle = s.Fields.GetValue("rotationceiling", 0.0);
if(ceilangle != 0f) if(ceilangle != 0.0)
{ {
showExtededCeilingInfo = true; showExtededCeilingInfo = true;
ceilingAngle.Enabled = true; ceilingAngle.Enabled = true;
@ -284,7 +284,7 @@ namespace CodeImp.DoomBuilder.Controls
ceilingAngleLabel.Enabled = false; ceilingAngleLabel.Enabled = false;
} }
float floorangle = s.Fields.GetValue("rotationfloor", 0f); double floorangle = s.Fields.GetValue("rotationfloor", 0.0);
if(floorangle != 0f) if(floorangle != 0f)
{ {
showExtededFloorInfo = true; showExtededFloorInfo = true;

View file

@ -94,9 +94,9 @@ namespace CodeImp.DoomBuilder.Controls
{ {
// Hangs from ceiling? // Hangs from ceiling?
if(ti.Hangs) if(ti.Hangs)
zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetCeilingPlane(t.Sector).GetZ(t.Position) - t.Position.z - ti.Height, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")"; //mxd zinfo = t.Position.z + " (" + Math.Round(Sector.GetCeilingPlane(t.Sector).GetZ(t.Position) - t.Position.z - ti.Height, General.Map.FormatInterface.VertexDecimals).ToString(CultureInfo.InvariantCulture) + ")"; //mxd
else else
zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")"; //mxd zinfo = t.Position.z + " (" + Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals).ToString(CultureInfo.InvariantCulture) + ")"; //mxd
} }
// Thing info // Thing info

View file

@ -5,7 +5,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
public class GlowingFlatData public class GlowingFlatData
{ {
public PixelColor Color; public PixelColor Color;
public float Height; public double Height;
public int Brightness = 255; public int Brightness = 255;
public bool Fullbright; public bool Fullbright;
public bool CalculateTextureColor; public bool CalculateTextureColor;

View file

@ -1774,7 +1774,12 @@ namespace CodeImp.DoomBuilder
{ {
return (float)Math.Round(min + (max - min) * random.NextDouble(), 2); return (float)Math.Round(min + (max - min) * random.NextDouble(), 2);
} }
public static double Random(double min, double max)
{
return Math.Round(min + (max - min) * random.NextDouble(), 2);
}
// This returns an element from a collection by index // This returns an element from a collection by index
public static T GetByIndex<T>(ICollection<T> collection, int index) public static T GetByIndex<T>(ICollection<T> collection, int index)
{ {

View file

@ -899,7 +899,7 @@ namespace CodeImp.DoomBuilder.Geometry
} }
// No cceptable line found, just use the first! // No cceptable line found, just use the first!
positions.Add(new LabelPositionInfo(foundposition, (float)Math.Sqrt(founddistance))); positions.Add(new LabelPositionInfo(foundposition, Math.Sqrt(founddistance)));
} }
else else
{ {
@ -914,7 +914,7 @@ namespace CodeImp.DoomBuilder.Geometry
double d = Line2D.GetDistanceToLineSq(triangles.Vertices[islandoffset], triangles.Vertices[islandoffset + 1], v, false); double d = Line2D.GetDistanceToLineSq(triangles.Vertices[islandoffset], triangles.Vertices[islandoffset + 1], v, false);
d = Math.Min(d, Line2D.GetDistanceToLineSq(triangles.Vertices[islandoffset + 1], triangles.Vertices[islandoffset + 2], v, false)); d = Math.Min(d, Line2D.GetDistanceToLineSq(triangles.Vertices[islandoffset + 1], triangles.Vertices[islandoffset + 2], v, false));
d = Math.Min(d, Line2D.GetDistanceToLineSq(triangles.Vertices[islandoffset + 2], triangles.Vertices[islandoffset], v, false)); d = Math.Min(d, Line2D.GetDistanceToLineSq(triangles.Vertices[islandoffset + 2], triangles.Vertices[islandoffset], v, false));
positions.Add(new LabelPositionInfo(v, (float)Math.Sqrt(d))); positions.Add(new LabelPositionInfo(v, Math.Sqrt(d)));
} }
else else
{ {
@ -2196,9 +2196,9 @@ namespace CodeImp.DoomBuilder.Geometry
//add a small offset so we don't end up moving thing into void //add a small offset so we don't end up moving thing into void
if(front) if(front)
t.Move(new Vector2D(pos.x - (float)Math.Cos(l.Angle), pos.y - (float)Math.Sin(l.Angle))); t.Move(new Vector2D(pos.x - Math.Cos(l.Angle), pos.y - Math.Sin(l.Angle)));
else else
t.Move(new Vector2D(pos.x + (float)Math.Cos(l.Angle), pos.y + (float)Math.Sin(l.Angle))); t.Move(new Vector2D(pos.x + Math.Cos(l.Angle), pos.y + Math.Sin(l.Angle)));
//apply new settings //apply new settings
t.SnapToAccuracy(); t.SnapToAccuracy();

View file

@ -93,10 +93,10 @@ namespace CodeImp.DoomBuilder.IO
map.SetCapacity(map.Vertices.Count + count, 0, 0, 0, 0); map.SetCapacity(map.Vertices.Count + count, 0, 0, 0, 0);
for(int i = 0; i < count; i++) for(int i = 0; i < count; i++)
{ {
float x = reader.ReadSingle(); double x = reader.ReadDouble();
float y = reader.ReadSingle(); double y = reader.ReadDouble();
float zc = reader.ReadSingle(); double zc = reader.ReadDouble();
float zf = reader.ReadSingle(); double zf = reader.ReadDouble();
// Create new item // Create new item
Dictionary<string, UniValue> fields = ReadCustomFields(reader); Dictionary<string, UniValue> fields = ReadCustomFields(reader);
@ -149,10 +149,10 @@ namespace CodeImp.DoomBuilder.IO
string tceil = ReadString(reader); string tceil = ReadString(reader);
//mxd. Slopes //mxd. Slopes
float foffset = reader.ReadSingle(); double foffset = reader.ReadDouble();
Vector3D fslope = new Vector3D(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); Vector3D fslope = new Vector3D(reader.ReadDouble(), reader.ReadDouble(), reader.ReadDouble());
float coffset = reader.ReadSingle(); double coffset = reader.ReadDouble();
Vector3D cslope = new Vector3D(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); Vector3D cslope = new Vector3D(reader.ReadDouble(), reader.ReadDouble(), reader.ReadDouble());
//flags //flags
Dictionary<string, bool> stringflags = new Dictionary<string, bool>(StringComparer.Ordinal); Dictionary<string, bool> stringflags = new Dictionary<string, bool>(StringComparer.Ordinal);
@ -352,14 +352,14 @@ namespace CodeImp.DoomBuilder.IO
{ {
int[] args = new int[Linedef.NUM_ARGS]; int[] args = new int[Linedef.NUM_ARGS];
int tag = reader.ReadInt32(); int tag = reader.ReadInt32();
float x = reader.ReadSingle(); double x = reader.ReadDouble();
float y = reader.ReadSingle(); double y = reader.ReadDouble();
float height = reader.ReadSingle(); double height = reader.ReadDouble();
int angledeg = reader.ReadInt32(); int angledeg = reader.ReadInt32();
int pitch = reader.ReadInt32(); //mxd int pitch = reader.ReadInt32(); //mxd
int roll = reader.ReadInt32(); //mxd int roll = reader.ReadInt32(); //mxd
float scaleX = reader.ReadSingle(); //mxd double scaleX = reader.ReadDouble(); //mxd
float scaleY = reader.ReadSingle(); //mxd double scaleY = reader.ReadDouble(); //mxd
int type = reader.ReadInt32(); int type = reader.ReadInt32();
int special = reader.ReadInt32(); int special = reader.ReadInt32();
for(int a = 0; a < Linedef.NUM_ARGS; a++) args[a] = reader.ReadInt32(); for(int a = 0; a < Linedef.NUM_ARGS; a++) args[a] = reader.ReadInt32();
@ -407,7 +407,7 @@ namespace CodeImp.DoomBuilder.IO
switch(valueType) switch(valueType)
{ {
case UniversalType.Float: case UniversalType.Float:
fields.Add(name, new UniValue(type, reader.ReadSingle())); fields.Add(name, new UniValue(type, reader.ReadDouble()));
break; break;
case UniversalType.Boolean: case UniversalType.Boolean:

View file

@ -284,7 +284,12 @@ namespace CodeImp.DoomBuilder.IO
{ {
writer.Write((int)UniversalType.Float); writer.Write((int)UniversalType.Float);
writer.Write((float)f.Value.Value); writer.Write((float)f.Value.Value);
} }
else if(f.Value.Value is double)
{
writer.Write((int)UniversalType.Float);
writer.Write((double)f.Value.Value);
}
else if(f.Value.Value.GetType().IsPrimitive) else if(f.Value.Value.GetType().IsPrimitive)
{ {
writer.Write((int)UniversalType.Integer); writer.Write((int)UniversalType.Integer);

View file

@ -130,15 +130,15 @@ namespace CodeImp.DoomBuilder.IO
public void rwVector2D(ref Vector2D v) public void rwVector2D(ref Vector2D v)
{ {
v.x = reader.ReadSingle(); v.x = reader.ReadDouble();
v.y = reader.ReadSingle(); v.y = reader.ReadDouble();
} }
public void rwVector3D(ref Vector3D v) public void rwVector3D(ref Vector3D v)
{ {
v.x = reader.ReadSingle(); v.x = reader.ReadDouble();
v.y = reader.ReadSingle(); v.y = reader.ReadDouble();
v.z = reader.ReadSingle(); v.z = reader.ReadDouble();
} }
// Write-only is not supported // Write-only is not supported
@ -204,16 +204,16 @@ namespace CodeImp.DoomBuilder.IO
public void rVector2D(out Vector2D v) public void rVector2D(out Vector2D v)
{ {
v = new Vector2D(); v = new Vector2D();
v.x = reader.ReadSingle(); v.x = reader.ReadDouble();
v.y = reader.ReadSingle(); v.y = reader.ReadDouble();
} }
public void rVector3D(out Vector3D v) public void rVector3D(out Vector3D v)
{ {
v = new Vector3D(); v = new Vector3D();
v.x = reader.ReadSingle(); v.x = reader.ReadDouble();
v.y = reader.ReadSingle(); v.y = reader.ReadDouble();
v.z = reader.ReadSingle(); v.z = reader.ReadDouble();
} }
#endregion #endregion

View file

@ -427,10 +427,10 @@ namespace CodeImp.DoomBuilder.IO
//mxd. Can be in scientific notation (like "1E-06") //mxd. Can be in scientific notation (like "1E-06")
else if(s.IndexOf('.') > -1 || s.ToLowerInvariant().Contains("e-")) else if(s.IndexOf('.') > -1 || s.ToLowerInvariant().Contains("e-"))
{ {
float fval = 0; double fval = 0;
// Convert to float (remove the f first) // Convert to float (remove the f first)
try { fval = Convert.ToSingle(s.Trim(), CultureInfo.InvariantCulture); } try { fval = Convert.ToDouble(s.Trim(), CultureInfo.InvariantCulture); }
catch(FormatException) catch(FormatException)
{ {
// ERROR: Invalid value in assignment // ERROR: Invalid value in assignment
@ -724,7 +724,7 @@ namespace CodeImp.DoomBuilder.IO
// Output the value as double (7 decimals) // Output the value as double (7 decimals)
double d = (double)cs[i].Value; double d = (double)cs[i].Value;
db.Append(leveltabs); db.Append(cs[i].Key); db.Append(spacing); db.Append("="); db.Append(leveltabs); db.Append(cs[i].Key); db.Append(spacing); db.Append("=");
db.Append(spacing); db.Append(d.ToString("0.0000000", CultureInfo.InvariantCulture)); db.Append(";"); db.Append(newline); db.Append(spacing); db.Append(d.ToString("0.0##############", CultureInfo.InvariantCulture)); /* db.Append(d.ToString("0.0000000", CultureInfo.InvariantCulture)); */ db.Append(";"); db.Append(newline);
} }
// Check if value is of other numeric type // Check if value is of other numeric type
else if(cs[i].Value.GetType().IsPrimitive) else if(cs[i].Value.GetType().IsPrimitive)

View file

@ -173,16 +173,16 @@ namespace CodeImp.DoomBuilder.IO
UniversalCollection c = collections[i]; UniversalCollection c = collections[i];
int[] args = new int[Linedef.NUM_ARGS]; int[] args = new int[Linedef.NUM_ARGS];
string where = "thing " + i; string where = "thing " + i;
float x = GetCollectionEntry(c, "x", true, 0.0f, where); double x = GetCollectionEntry(c, "x", true, 0.0, where);
float y = GetCollectionEntry(c, "y", true, 0.0f, where); double y = GetCollectionEntry(c, "y", true, 0.0, where);
float height = GetCollectionEntry(c, "height", false, 0.0f, where); double height = GetCollectionEntry(c, "height", false, 0.0, where);
int tag = GetCollectionEntry(c, "id", false, 0, where); int tag = GetCollectionEntry(c, "id", false, 0, where);
int angledeg = GetCollectionEntry(c, "angle", false, 0, where); int angledeg = GetCollectionEntry(c, "angle", false, 0, where);
int pitch = GetCollectionEntry(c, "pitch", false, 0, where); //mxd int pitch = GetCollectionEntry(c, "pitch", false, 0, where); //mxd
int roll = GetCollectionEntry(c, "roll", false, 0, where); //mxd int roll = GetCollectionEntry(c, "roll", false, 0, where); //mxd
float scaleX = GetCollectionEntry(c, "scalex", false, 1.0f, where); //mxd double scaleX = GetCollectionEntry(c, "scalex", false, 1.0, where); //mxd
float scaleY = GetCollectionEntry(c, "scaley", false, 1.0f, where); //mxd double scaleY = GetCollectionEntry(c, "scaley", false, 1.0, where); //mxd
float scale = GetCollectionEntry(c, "scale", false, 0f, where); //mxd double scale = GetCollectionEntry(c, "scale", false, 0.0, where); //mxd
int type = GetCollectionEntry(c, "type", true, 0, where); int type = GetCollectionEntry(c, "type", true, 0, where);
int special = GetCollectionEntry(c, "special", false, 0, where); int special = GetCollectionEntry(c, "special", false, 0, where);
args[0] = GetCollectionEntry(c, "arg0", false, 0, where); args[0] = GetCollectionEntry(c, "arg0", false, 0, where);
@ -403,15 +403,15 @@ namespace CodeImp.DoomBuilder.IO
if(tag == 0 && tags.Count > 1) tags.RemoveAt(0); if(tag == 0 && tags.Count > 1) tags.RemoveAt(0);
//mxd. Read slopes //mxd. Read slopes
float fslopex = GetCollectionEntry(c, "floorplane_a", false, 0.0f, where); double fslopex = GetCollectionEntry(c, "floorplane_a", false, 0.0, where);
float fslopey = GetCollectionEntry(c, "floorplane_b", false, 0.0f, where); double fslopey = GetCollectionEntry(c, "floorplane_b", false, 0.0, where);
float fslopez = GetCollectionEntry(c, "floorplane_c", false, 0.0f, where); double fslopez = GetCollectionEntry(c, "floorplane_c", false, 0.0, where);
float foffset = GetCollectionEntry(c, "floorplane_d", false, float.NaN, where); double foffset = GetCollectionEntry(c, "floorplane_d", false, double.NaN, where);
float cslopex = GetCollectionEntry(c, "ceilingplane_a", false, 0.0f, where); double cslopex = GetCollectionEntry(c, "ceilingplane_a", false, 0.0, where);
float cslopey = GetCollectionEntry(c, "ceilingplane_b", false, 0.0f, where); double cslopey = GetCollectionEntry(c, "ceilingplane_b", false, 0.0, where);
float cslopez = GetCollectionEntry(c, "ceilingplane_c", false, 0.0f, where); double cslopez = GetCollectionEntry(c, "ceilingplane_c", false, 0.0, where);
float coffset = GetCollectionEntry(c, "ceilingplane_d", false, float.NaN, where); double coffset = GetCollectionEntry(c, "ceilingplane_d", false, double.NaN, where);
//mxd. Read flags //mxd. Read flags
Dictionary<string, bool> stringflags = new Dictionary<string, bool>(StringComparer.Ordinal); Dictionary<string, bool> stringflags = new Dictionary<string, bool>(StringComparer.Ordinal);
@ -456,14 +456,14 @@ namespace CodeImp.DoomBuilder.IO
// Read fields // Read fields
UniversalCollection c = collections[i]; UniversalCollection c = collections[i];
string where = "vertex " + i; string where = "vertex " + i;
float x = GetCollectionEntry(c, "x", true, 0.0f, where); double x = GetCollectionEntry(c, "x", true, 0.0, where);
float y = GetCollectionEntry(c, "y", true, 0.0f, where); double y = GetCollectionEntry(c, "y", true, 0.0, where);
// [ZZ] Correct location if it's NaN. Note that there cannot be any meaningful value here, so I just reset it to 0,0 to avoid triggering the NaN exception // [ZZ] Correct location if it's NaN. Note that there cannot be any meaningful value here, so I just reset it to 0,0 to avoid triggering the NaN exception
// TODO: remove once the cause of NaN is reported // TODO: remove once the cause of NaN is reported
if (float.IsNaN(x) || float.IsNaN(y)) if (double.IsNaN(x) || double.IsNaN(y))
{ {
x = y = 0f; x = y = 0.0;
General.ErrorLogger.Add(ErrorType.Warning, string.Format("Vertex {0} has NaN coordinates, resetting to 0,0", i)); General.ErrorLogger.Add(ErrorType.Warning, string.Format("Vertex {0} has NaN coordinates, resetting to 0,0", i));
} }
@ -472,8 +472,8 @@ namespace CodeImp.DoomBuilder.IO
if(v != null) if(v != null)
{ {
//mxd. zoffsets //mxd. zoffsets
v.ZCeiling = GetCollectionEntry(c, "zceiling", false, float.NaN, where); //mxd v.ZCeiling = GetCollectionEntry(c, "zceiling", false, double.NaN, where); //mxd
v.ZFloor = GetCollectionEntry(c, "zfloor", false, float.NaN, where); //mxd v.ZFloor = GetCollectionEntry(c, "zfloor", false, double.NaN, where); //mxd
// Custom fields // Custom fields
ReadCustomFields(c, v, "vertex"); ReadCustomFields(c, v, "vertex");
@ -506,7 +506,7 @@ namespace CodeImp.DoomBuilder.IO
// Let's be kind and cast any int to a float if needed // Let's be kind and cast any int to a float if needed
if(type == (int)UniversalType.Float && e.Value is int) if(type == (int)UniversalType.Float && e.Value is int)
{ {
value = (float)(int)e.Value; value = (double)(int)e.Value;
} }
else if(!e.IsValidType(e.Value.GetType())) else if(!e.IsValidType(e.Value.GetType()))
{ {
@ -550,7 +550,7 @@ namespace CodeImp.DoomBuilder.IO
// Determine default type // Determine default type
if(e.Value is int) type = (int)UniversalType.Integer; if(e.Value is int) type = (int)UniversalType.Integer;
else if(e.Value is float) type = (int)UniversalType.Float; else if(e.Value is double) type = (int)UniversalType.Float;
else if(e.Value is bool) type = (int)UniversalType.Boolean; else if(e.Value is bool) type = (int)UniversalType.Boolean;
else if(e.Value is string) type = (int)UniversalType.String; else if(e.Value is string) type = (int)UniversalType.String;
@ -573,10 +573,10 @@ namespace CodeImp.DoomBuilder.IO
if(e.Key == entryname) if(e.Key == entryname)
{ {
// Let's be kind and cast any int to a float if needed // Let's be kind and cast any int to a float if needed
if((typeof(T) == typeof(float)) && (e.Value is int)) if((typeof(T) == typeof(double)) && (e.Value is int))
{ {
// Make it a float // Make it a float
object fvalue = (float)(int)e.Value; object fvalue = (double)(int)e.Value;
result = (T)fvalue; result = (T)fvalue;
} }
else else

View file

@ -298,14 +298,20 @@ namespace CodeImp.DoomBuilder.IO
//mxd. Slopes //mxd. Slopes
if(s.FloorSlope.GetLengthSq() > 0) if(s.FloorSlope.GetLengthSq() > 0)
{ {
/*
coll.Add("floorplane_a", Math.Round(s.FloorSlope.x, Sector.SLOPE_DECIMALS)); coll.Add("floorplane_a", Math.Round(s.FloorSlope.x, Sector.SLOPE_DECIMALS));
coll.Add("floorplane_b", Math.Round(s.FloorSlope.y, Sector.SLOPE_DECIMALS)); coll.Add("floorplane_b", Math.Round(s.FloorSlope.y, Sector.SLOPE_DECIMALS));
coll.Add("floorplane_c", Math.Round(s.FloorSlope.z, Sector.SLOPE_DECIMALS)); coll.Add("floorplane_c", Math.Round(s.FloorSlope.z, Sector.SLOPE_DECIMALS));
coll.Add("floorplane_d", coll.Add("floorplane_d",
(double.IsNaN(s.FloorSlopeOffset) ? 0f : Math.Round(s.FloorSlopeOffset, Sector.SLOPE_DECIMALS))); (double.IsNaN(s.FloorSlopeOffset) ? 0f : Math.Round(s.FloorSlopeOffset, Sector.SLOPE_DECIMALS)));
*/
coll.Add("floorplane_a", s.FloorSlope.x);
coll.Add("floorplane_b", s.FloorSlope.y);
coll.Add("floorplane_c", s.FloorSlope.z);
coll.Add("floorplane_d", double.IsNaN(s.FloorSlopeOffset) ? 0.0 : s.FloorSlopeOffset);
} }
if(s.CeilSlope.GetLengthSq() > 0) if (s.CeilSlope.GetLengthSq() > 0)
{ {
coll.Add("ceilingplane_a", Math.Round(s.CeilSlope.x, Sector.SLOPE_DECIMALS)); coll.Add("ceilingplane_a", Math.Round(s.CeilSlope.x, Sector.SLOPE_DECIMALS));
coll.Add("ceilingplane_b", Math.Round(s.CeilSlope.y, Sector.SLOPE_DECIMALS)); coll.Add("ceilingplane_b", Math.Round(s.CeilSlope.y, Sector.SLOPE_DECIMALS));

View file

@ -388,7 +388,7 @@ namespace CodeImp.DoomBuilder.Map
// Recalculate values // Recalculate values
lengthsq = delta.GetLengthSq(); lengthsq = delta.GetLengthSq();
length = (float)Math.Sqrt(lengthsq); length = Math.Sqrt(lengthsq);
if(length > 0f) lengthinv = 1f / length; else lengthinv = 1f / 0.0000000001f; if(length > 0f) lengthinv = 1f / length; else lengthinv = 1f / 0.0000000001f;
if(lengthsq > 0f) lengthsqinv = 1f / lengthsq; else lengthsqinv = 1f / 0.0000000001f; if(lengthsq > 0f) lengthsqinv = 1f / lengthsq; else lengthsqinv = 1f / 0.0000000001f;
angle = delta.GetAngle(); angle = delta.GetAngle();
@ -1046,9 +1046,9 @@ namespace CodeImp.DoomBuilder.Map
} }
// This returns the shortest distance from given coordinates to line // This returns the shortest distance from given coordinates to line
public float SafeDistanceTo(Vector2D p, bool bounded) public double SafeDistanceTo(Vector2D p, bool bounded)
{ {
return (float)Math.Sqrt(SafeDistanceToSq(p, bounded)); return Math.Sqrt(SafeDistanceToSq(p, bounded));
} }
// This returns the shortest distance from given coordinates to line // This returns the shortest distance from given coordinates to line
@ -1074,9 +1074,9 @@ namespace CodeImp.DoomBuilder.Map
} }
// This returns the shortest distance from given coordinates to line // This returns the shortest distance from given coordinates to line
public float DistanceTo(Vector2D p, bool bounded) public double DistanceTo(Vector2D p, bool bounded)
{ {
return (float)Math.Sqrt(DistanceToSq(p, bounded)); return Math.Sqrt(DistanceToSq(p, bounded));
} }
// This tests on which side of the line the given coordinates are // This tests on which side of the line the given coordinates are
@ -1465,13 +1465,13 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Copy UDMF offsets as well //mxd. Copy UDMF offsets as well
if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets) if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
{ {
UniFields.SetFloat(newline.front.Fields, "offsetx_top", oldline.front.Fields.GetValue("offsetx_top", 0f)); UniFields.SetFloat(newline.front.Fields, "offsetx_top", oldline.front.Fields.GetValue("offsetx_top", 0.0));
UniFields.SetFloat(newline.front.Fields, "offsetx_mid", oldline.front.Fields.GetValue("offsetx_mid", 0f)); UniFields.SetFloat(newline.front.Fields, "offsetx_mid", oldline.front.Fields.GetValue("offsetx_mid", 0.0));
UniFields.SetFloat(newline.front.Fields, "offsetx_bottom", oldline.front.Fields.GetValue("offsetx_bottom", 0f)); UniFields.SetFloat(newline.front.Fields, "offsetx_bottom", oldline.front.Fields.GetValue("offsetx_bottom", 0.0));
UniFields.SetFloat(newline.front.Fields, "offsety_top", oldline.front.Fields.GetValue("offsety_top", 0f)); UniFields.SetFloat(newline.front.Fields, "offsety_top", oldline.front.Fields.GetValue("offsety_top", 0.0));
UniFields.SetFloat(newline.front.Fields, "offsety_mid", oldline.front.Fields.GetValue("offsety_mid", 0f)); UniFields.SetFloat(newline.front.Fields, "offsety_mid", oldline.front.Fields.GetValue("offsety_mid", 0.0));
UniFields.SetFloat(newline.front.Fields, "offsety_bottom", oldline.front.Fields.GetValue("offsety_bottom", 0f)); UniFields.SetFloat(newline.front.Fields, "offsety_bottom", oldline.front.Fields.GetValue("offsety_bottom", 0.0));
} }
} }
@ -1483,13 +1483,13 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Copy UDMF offsets as well //mxd. Copy UDMF offsets as well
if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets) if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
{ {
UniFields.SetFloat(newline.back.Fields, "offsetx_top", oldline.back.Fields.GetValue("offsetx_top", 0f)); UniFields.SetFloat(newline.back.Fields, "offsetx_top", oldline.back.Fields.GetValue("offsetx_top", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsetx_mid", oldline.back.Fields.GetValue("offsetx_mid", 0f)); UniFields.SetFloat(newline.back.Fields, "offsetx_mid", oldline.back.Fields.GetValue("offsetx_mid", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsetx_bottom", oldline.back.Fields.GetValue("offsetx_bottom", 0f)); UniFields.SetFloat(newline.back.Fields, "offsetx_bottom", oldline.back.Fields.GetValue("offsetx_bottom", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsety_top", oldline.back.Fields.GetValue("offsety_top", 0f)); UniFields.SetFloat(newline.back.Fields, "offsety_top", oldline.back.Fields.GetValue("offsety_top", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsety_mid", oldline.back.Fields.GetValue("offsety_mid", 0f)); UniFields.SetFloat(newline.back.Fields, "offsety_mid", oldline.back.Fields.GetValue("offsety_mid", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsety_bottom", oldline.back.Fields.GetValue("offsety_bottom", 0f)); UniFields.SetFloat(newline.back.Fields, "offsety_bottom", oldline.back.Fields.GetValue("offsety_bottom", 0.0));
} }
} }
break; break;
@ -1503,9 +1503,9 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Reset UDMF X offset as well //mxd. Reset UDMF X offset as well
if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets) if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
{ {
UniFields.SetFloat(newline.front.Fields, "offsetx_top", 0f); UniFields.SetFloat(newline.front.Fields, "offsetx_top", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsetx_mid", 0f); UniFields.SetFloat(newline.front.Fields, "offsetx_mid", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsetx_bottom", 0f); UniFields.SetFloat(newline.front.Fields, "offsetx_bottom", 0.0);
} }
} }
@ -1517,13 +1517,13 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Reset UDMF X offset and copy Y offset as well //mxd. Reset UDMF X offset and copy Y offset as well
if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets) if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
{ {
UniFields.SetFloat(newline.back.Fields, "offsetx_top", 0f); UniFields.SetFloat(newline.back.Fields, "offsetx_top", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsetx_mid", 0f); UniFields.SetFloat(newline.back.Fields, "offsetx_mid", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsetx_bottom", 0f); UniFields.SetFloat(newline.back.Fields, "offsetx_bottom", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsety_top", oldline.back.Fields.GetValue("offsety_top", 0f)); UniFields.SetFloat(newline.back.Fields, "offsety_top", oldline.back.Fields.GetValue("offsety_top", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsety_mid", oldline.back.Fields.GetValue("offsety_mid", 0f)); UniFields.SetFloat(newline.back.Fields, "offsety_mid", oldline.back.Fields.GetValue("offsety_mid", 0.0));
UniFields.SetFloat(newline.back.Fields, "offsety_bottom", oldline.back.Fields.GetValue("offsety_bottom", 0f)); UniFields.SetFloat(newline.back.Fields, "offsety_bottom", oldline.back.Fields.GetValue("offsety_bottom", 0.0));
} }
} }
break; break;
@ -1536,13 +1536,13 @@ namespace CodeImp.DoomBuilder.Map
if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets) if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
{ {
UniFields.SetFloat(newline.front.Fields, "offsetx_top", 0f); UniFields.SetFloat(newline.front.Fields, "offsetx_top", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsetx_mid", 0f); UniFields.SetFloat(newline.front.Fields, "offsetx_mid", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsetx_bottom", 0f); UniFields.SetFloat(newline.front.Fields, "offsetx_bottom", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsety_top", 0f); UniFields.SetFloat(newline.front.Fields, "offsety_top", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsety_mid", 0f); UniFields.SetFloat(newline.front.Fields, "offsety_mid", 0.0);
UniFields.SetFloat(newline.front.Fields, "offsety_bottom", 0f); UniFields.SetFloat(newline.front.Fields, "offsety_bottom", 0.0);
} }
} }
@ -1553,13 +1553,13 @@ namespace CodeImp.DoomBuilder.Map
if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets) if(General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
{ {
UniFields.SetFloat(newline.back.Fields, "offsetx_top", 0f); UniFields.SetFloat(newline.back.Fields, "offsetx_top", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsetx_mid", 0f); UniFields.SetFloat(newline.back.Fields, "offsetx_mid", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsetx_bottom", 0f); UniFields.SetFloat(newline.back.Fields, "offsetx_bottom", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsety_top", 0f); UniFields.SetFloat(newline.back.Fields, "offsety_top", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsety_mid", 0f); UniFields.SetFloat(newline.back.Fields, "offsety_mid", 0.0);
UniFields.SetFloat(newline.back.Fields, "offsety_bottom", 0f); UniFields.SetFloat(newline.back.Fields, "offsety_bottom", 0.0);
} }
} }
break; break;

View file

@ -3155,8 +3155,8 @@ namespace CodeImp.DoomBuilder.Map
if(!double.IsNaN(intersection.x)) if(!double.IsNaN(intersection.x))
{ {
//mxd. Round to map format precision //mxd. Round to map format precision
intersection.x = (float)Math.Round(intersection.x, General.Map.FormatInterface.VertexDecimals); intersection.x = Math.Round(intersection.x, General.Map.FormatInterface.VertexDecimals);
intersection.y = (float)Math.Round(intersection.y, General.Map.FormatInterface.VertexDecimals); intersection.y = Math.Round(intersection.y, General.Map.FormatInterface.VertexDecimals);
//mxd. Skip when intersection matches start/end position. //mxd. Skip when intersection matches start/end position.
// Otherwise infinite ammount of 0-length lines will be created... // Otherwise infinite ammount of 0-length lines will be created...

View file

@ -827,7 +827,7 @@ namespace CodeImp.DoomBuilder.Map
} }
//mxd. This updates all properties (UDMF version) //mxd. This updates all properties (UDMF version)
public void Update(int hfloor, int hceil, string tfloor, string tceil, int effect, Dictionary<string, bool> flags, List<int> tags, int brightness, float flooroffset, Vector3D floorslope, float ceiloffset, Vector3D ceilslope) public void Update(int hfloor, int hceil, string tfloor, string tceil, int effect, Dictionary<string, bool> flags, List<int> tags, int brightness, double flooroffset, Vector3D floorslope, double ceiloffset, Vector3D ceilslope)
{ {
BeforePropsChange(); BeforePropsChange();

View file

@ -605,10 +605,10 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Also copy UDMF offsets and scale //mxd. Also copy UDMF offsets and scale
if(General.Map.UDMF) if(General.Map.UDMF)
{ {
UniFields.SetFloat(s.Fields, "offsetx_top", Fields.GetValue("offsetx_top", 0f), 0f); UniFields.SetFloat(s.Fields, "offsetx_top", Fields.GetValue("offsetx_top", 0.0), 0.0);
UniFields.SetFloat(s.Fields, "offsety_top", Fields.GetValue("offsety_top", 0f), 0f); UniFields.SetFloat(s.Fields, "offsety_top", Fields.GetValue("offsety_top", 0.0), 0.0);
UniFields.SetFloat(s.Fields, "scalex_top", Fields.GetValue("scalex_top", 1.0f), 1.0f); UniFields.SetFloat(s.Fields, "scalex_top", Fields.GetValue("scalex_top", 1.0), 1.0);
UniFields.SetFloat(s.Fields, "scaley_top", Fields.GetValue("scaley_top", 1.0f), 1.0f); UniFields.SetFloat(s.Fields, "scaley_top", Fields.GetValue("scaley_top", 1.0), 1.0);
} }
} }
@ -625,10 +625,10 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Also copy UDMF offsets and scale //mxd. Also copy UDMF offsets and scale
if(General.Map.UDMF) if(General.Map.UDMF)
{ {
UniFields.SetFloat(s.Fields, "offsetx_mid", Fields.GetValue("offsetx_mid", 0f), 0f); UniFields.SetFloat(s.Fields, "offsetx_mid", Fields.GetValue("offsetx_mid", 0.0), 0.0);
UniFields.SetFloat(s.Fields, "offsety_mid", Fields.GetValue("offsety_mid", 0f), 0f); UniFields.SetFloat(s.Fields, "offsety_mid", Fields.GetValue("offsety_mid", 0.0), 0.0);
UniFields.SetFloat(s.Fields, "scalex_mid", Fields.GetValue("scalex_mid", 1.0f), 1.0f); UniFields.SetFloat(s.Fields, "scalex_mid", Fields.GetValue("scalex_mid", 1.0), 1.0);
UniFields.SetFloat(s.Fields, "scaley_mid", Fields.GetValue("scaley_mid", 1.0f), 1.0f); UniFields.SetFloat(s.Fields, "scaley_mid", Fields.GetValue("scaley_mid", 1.0), 1.0);
} }
} }
@ -645,10 +645,10 @@ namespace CodeImp.DoomBuilder.Map
//mxd. Also copy UDMF offsets and scale //mxd. Also copy UDMF offsets and scale
if(General.Map.UDMF) if(General.Map.UDMF)
{ {
UniFields.SetFloat(s.Fields, "offsetx_bottom", Fields.GetValue("offsetx_bottom", 0f), 0f); UniFields.SetFloat(s.Fields, "offsetx_bottom", Fields.GetValue("offsetx_bottom", 0.0), 0.0);
UniFields.SetFloat(s.Fields, "offsety_bottom", Fields.GetValue("offsety_bottom", 0f), 0f); UniFields.SetFloat(s.Fields, "offsety_bottom", Fields.GetValue("offsety_bottom", 0.0), 0.0);
UniFields.SetFloat(s.Fields, "scalex_bottom", Fields.GetValue("scalex_bottom", 1.0f), 1.0f); UniFields.SetFloat(s.Fields, "scalex_bottom", Fields.GetValue("scalex_bottom", 1.0), 1.0);
UniFields.SetFloat(s.Fields, "scaley_bottom", Fields.GetValue("scaley_bottom", 1.0f), 1.0f); UniFields.SetFloat(s.Fields, "scaley_bottom", Fields.GetValue("scaley_bottom", 1.0), 1.0);
} }
} }
@ -752,10 +752,10 @@ namespace CodeImp.DoomBuilder.Map
if(longtexnamehigh != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamehigh)) if(longtexnamehigh != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamehigh))
{ {
ImageData texture = General.Map.Data.GetTextureImage(texnamehigh); ImageData texture = General.Map.Data.GetTextureImage(texnamehigh);
float scaleTop = Fields.GetValue("scalex_top", 1.0f); double scaleTop = Fields.GetValue("scalex_top", 1.0);
float value = Fields.GetValue("offsetx_top", 0f); double value = Fields.GetValue("offsetx_top", 0.0);
float result = (float)(Math.Round(value + offset * scaleTop)); double result = Math.Round(value + offset * scaleTop);
if(texture.IsImageLoaded) result %= texture.Width; if(texture.IsImageLoaded) result %= texture.Width;
UniFields.SetFloat(Fields, "offsetx_top", result); UniFields.SetFloat(Fields, "offsetx_top", result);
} }
@ -764,10 +764,10 @@ namespace CodeImp.DoomBuilder.Map
if(longtexnamemid != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamemid)) if(longtexnamemid != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamemid))
{ {
ImageData texture = General.Map.Data.GetTextureImage(texnamemid); ImageData texture = General.Map.Data.GetTextureImage(texnamemid);
float scaleMid = Fields.GetValue("scalex_mid", 1.0f); double scaleMid = Fields.GetValue("scalex_mid", 1.0);
float value = Fields.GetValue("offsetx_mid", 0f); double value = Fields.GetValue("offsetx_mid", 0.0);
float result = (float)(Math.Round(value + offset * scaleMid)); double result = Math.Round(value + offset * scaleMid);
if(texture.IsImageLoaded) result %= texture.Width; if(texture.IsImageLoaded) result %= texture.Width;
UniFields.SetFloat(Fields, "offsetx_mid", result); UniFields.SetFloat(Fields, "offsetx_mid", result);
} }
@ -776,10 +776,10 @@ namespace CodeImp.DoomBuilder.Map
if(longtexnamelow != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamelow)) if(longtexnamelow != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(texnamelow))
{ {
ImageData texture = General.Map.Data.GetTextureImage(texnamelow); ImageData texture = General.Map.Data.GetTextureImage(texnamelow);
float scaleLow = Fields.GetValue("scalex_bottom", 1.0f); double scaleLow = Fields.GetValue("scalex_bottom", 1.0);
float value = Fields.GetValue("offsetx_bottom", 0f); double value = Fields.GetValue("offsetx_bottom", 0.0);
float result = (float)(Math.Round(value + offset * scaleLow)); double result = Math.Round(value + offset * scaleLow);
if(texture.IsImageLoaded) result %= texture.Width; if(texture.IsImageLoaded) result %= texture.Width;
UniFields.SetFloat(Fields, "offsetx_bottom", result); UniFields.SetFloat(Fields, "offsetx_bottom", result);
} }

View file

@ -494,7 +494,7 @@ namespace CodeImp.DoomBuilder.Map
// This updates all properties // This updates all properties
// NOTE: This does not update sector! (call DetermineSector) // NOTE: This does not update sector! (call DetermineSector)
public void Update(int type, float x, float y, float zoffset, int angle, int pitch, int roll, float scaleX, float scaleY, public void Update(int type, double x, double y, double zoffset, int angle, int pitch, int roll, double scaleX, double scaleY,
Dictionary<string, bool> flags, int tag, int action, int[] args) Dictionary<string, bool> flags, int tag, int action, int[] args)
{ {
// Apply changes // Apply changes
@ -673,9 +673,9 @@ namespace CodeImp.DoomBuilder.Map
public void SnapToAccuracy(bool usepreciseposition) public void SnapToAccuracy(bool usepreciseposition)
{ {
// Round the coordinates // Round the coordinates
Vector3D newpos = new Vector3D((float)Math.Round(pos.x, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)), Vector3D newpos = new Vector3D(Math.Round(pos.x, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)),
(float)Math.Round(pos.y, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)), Math.Round(pos.y, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)),
(float)Math.Round(pos.z, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0))); Math.Round(pos.z, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)));
this.Move(newpos); this.Move(newpos);
} }

View file

@ -116,7 +116,7 @@ namespace CodeImp.DoomBuilder.Map
} }
} }
public static double GetFloat(UniFields fields, string key) { return GetFloat(fields, key, 0f); } public static double GetFloat(UniFields fields, string key) { return GetFloat(fields, key, 0.0); }
public static double GetFloat(UniFields fields, string key, double defaultvalue) public static double GetFloat(UniFields fields, string key, double defaultvalue)
{ {
if(fields == null) return defaultvalue; if(fields == null) return defaultvalue;

View file

@ -52,8 +52,8 @@ namespace CodeImp.DoomBuilder.Map
set set
{ {
// Value may only be a primitive type // Value may only be a primitive type
if((!(value is int) && !(value is float) && !(value is string) && !(value is bool)) || (value == null)) if((!(value is int) && !(value is double) && !(value is string) && !(value is bool)) || (value == null))
throw new ArgumentException("Universal field values can only be of type int, float, string or bool."); throw new ArgumentException("Universal field values can only be of type int, double, string or bool.");
this.value = value; this.value = value;
} }

View file

@ -290,8 +290,8 @@ namespace CodeImp.DoomBuilder.Map
public void SnapToAccuracy(bool usepreciseposition) public void SnapToAccuracy(bool usepreciseposition)
{ {
// Round the coordinates // Round the coordinates
Vector2D newpos = new Vector2D((float)Math.Round(pos.x, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)), Vector2D newpos = new Vector2D(Math.Round(pos.x, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)),
(float)Math.Round(pos.y, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0))); Math.Round(pos.y, (usepreciseposition ? General.Map.FormatInterface.VertexDecimals : 0)));
this.Move(newpos); this.Move(newpos);
} }

View file

@ -29,7 +29,7 @@ namespace CodeImp.DoomBuilder.VisualModes
private Vector3D movemultiplier; private Vector3D movemultiplier;
private double anglexy, anglez; private double anglexy, anglez;
private Sector sector; private Sector sector;
private float gravity = 1.0f; //mxd private double gravity = 1.0; //mxd
#endregion #endregion
@ -41,7 +41,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public double AngleZ { get { return anglez; } set { anglez = value; } } public double AngleZ { get { return anglez; } set { anglez = value; } }
public Sector Sector { get { return sector; } internal set { sector = value; UpdateGravity(); } } //mxd public Sector Sector { get { return sector; } internal set { sector = value; UpdateGravity(); } } //mxd
public Vector3D MoveMultiplier { get { return movemultiplier; } set { movemultiplier = value; } } public Vector3D MoveMultiplier { get { return movemultiplier; } set { movemultiplier = value; } }
public float Gravity { get { return gravity; } } //mxd public double Gravity { get { return gravity; } } //mxd
#endregion #endregion
@ -173,7 +173,7 @@ namespace CodeImp.DoomBuilder.VisualModes
private void UpdateGravity() private void UpdateGravity()
{ {
if(!General.Map.UDMF || sector == null) return; if(!General.Map.UDMF || sector == null) return;
gravity = sector.Fields.GetValue("gravity", 1.0f); gravity = sector.Fields.GetValue("gravity", 1.0);
} }
#endregion #endregion

View file

@ -289,7 +289,7 @@ namespace CodeImp.DoomBuilder.Windows
fieldslist.SetValues(fl.Fields, true); // Custom fields fieldslist.SetValues(fl.Fields, true); // Custom fields
commenteditor.SetValues(fl.Fields, true); //mxd. Comments commenteditor.SetValues(fl.Fields, true); //mxd. Comments
renderStyle.SelectedIndex = Array.IndexOf(renderstyles, fl.Fields.GetValue("renderstyle", "translucent")); renderStyle.SelectedIndex = Array.IndexOf(renderstyles, fl.Fields.GetValue("renderstyle", "translucent"));
alpha.Text = General.Clamp(fl.Fields.GetValue("alpha", 1.0f), 0f, 1f).ToString(); alpha.Text = General.Clamp(fl.Fields.GetValue("alpha", 1.0), 0.0, 1.0).ToString();
// Locknumber // Locknumber
int locknumber = fl.Fields.GetValue("locknumber", 0); int locknumber = fl.Fields.GetValue("locknumber", 0);
@ -394,7 +394,7 @@ namespace CodeImp.DoomBuilder.Windows
renderStyle.SelectedIndex = -1; renderStyle.SelectedIndex = -1;
// Alpha // Alpha
if(!string.IsNullOrEmpty(alpha.Text) && General.Clamp(alpha.GetResultFloat(1.0f), 0f, 1f) != l.Fields.GetValue("alpha", 1.0f)) if(!string.IsNullOrEmpty(alpha.Text) && General.Clamp(alpha.GetResultFloat(1.0), 0.0, 1.0) != l.Fields.GetValue("alpha", 1.0))
alpha.Text = string.Empty; alpha.Text = string.Empty;
// Locknumber // Locknumber
@ -861,18 +861,18 @@ namespace CodeImp.DoomBuilder.Windows
if(string.IsNullOrEmpty(alpha.Text)) if(string.IsNullOrEmpty(alpha.Text))
{ {
foreach(Linedef l in lines) foreach(Linedef l in lines)
UniFields.SetFloat(l.Fields, "alpha", linedefprops[i++].Alpha, 1.0f); UniFields.SetFloat(l.Fields, "alpha", linedefprops[i++].Alpha, 1.0);
} }
else //update values else //update values
{ {
foreach(Linedef l in lines) foreach(Linedef l in lines)
{ {
double value = General.Clamp(alpha.GetResultFloat(l.Fields.GetValue("alpha", 1.0f)), 0f, 1.0f); double value = General.Clamp(alpha.GetResultFloat(l.Fields.GetValue("alpha", 1.0)), 0.0, 1.0);
UniFields.SetFloat(l.Fields, "alpha", value, 1.0f); UniFields.SetFloat(l.Fields, "alpha", value, 1.0);
} }
} }
resetalpha.Visible = (alpha.GetResultFloat(1.0f) != 1.0f); resetalpha.Visible = (alpha.GetResultFloat(1.0) != 1.0);
General.Map.IsChanged = true; General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);

View file

@ -116,28 +116,28 @@ namespace CodeImp.DoomBuilder.Windows
FogDensity = UniFields.GetInteger(s.Fields, "fogdensity", 0); FogDensity = UniFields.GetInteger(s.Fields, "fogdensity", 0);
//UDMF Ceiling //UDMF Ceiling
CeilOffsetX = UniFields.GetFloat(s.Fields, "xpanningceiling", 0f); CeilOffsetX = UniFields.GetFloat(s.Fields, "xpanningceiling", 0.0);
CeilOffsetY = UniFields.GetFloat(s.Fields, "ypanningceiling", 0f); CeilOffsetY = UniFields.GetFloat(s.Fields, "ypanningceiling", 0.0);
CeilScaleX = UniFields.GetFloat(s.Fields, "xscaleceiling", 1.0f); CeilScaleX = UniFields.GetFloat(s.Fields, "xscaleceiling", 1.0);
CeilScaleY = UniFields.GetFloat(s.Fields, "yscaleceiling", 1.0f); CeilScaleY = UniFields.GetFloat(s.Fields, "yscaleceiling", 1.0);
//CeilAlpha = UniFields.GetFloat(s.Fields, "alphaceiling", 1.0f); //CeilAlpha = UniFields.GetFloat(s.Fields, "alphaceiling", 1.0f);
CeilRotation = s.Fields.GetValue("rotationceiling", 0.0f); CeilRotation = s.Fields.GetValue("rotationceiling", 0.0);
CeilBrightness = s.Fields.GetValue("lightceiling", 0); CeilBrightness = s.Fields.GetValue("lightceiling", 0);
CeilLightAbsoulte = s.Fields.GetValue("lightceilingabsolute", false); CeilLightAbsoulte = s.Fields.GetValue("lightceilingabsolute", false);
CeilGlowColor = s.Fields.GetValue("ceilingglowcolor", 0); CeilGlowColor = s.Fields.GetValue("ceilingglowcolor", 0);
CeilGlowHeight = s.Fields.GetValue("ceilingglowheight", 0f); CeilGlowHeight = s.Fields.GetValue("ceilingglowheight", 0.0);
//UDMF Floor //UDMF Floor
FloorOffsetX = UniFields.GetFloat(s.Fields, "xpanningfloor", 0f); FloorOffsetX = UniFields.GetFloat(s.Fields, "xpanningfloor", 0.0);
FloorOffsetY = UniFields.GetFloat(s.Fields, "ypanningfloor", 0f); FloorOffsetY = UniFields.GetFloat(s.Fields, "ypanningfloor", 0.0);
FloorScaleX = UniFields.GetFloat(s.Fields, "xscalefloor", 1.0f); FloorScaleX = UniFields.GetFloat(s.Fields, "xscalefloor", 1.0);
FloorScaleY = UniFields.GetFloat(s.Fields, "yscalefloor", 1.0f); FloorScaleY = UniFields.GetFloat(s.Fields, "yscalefloor", 1.0);
//FloorAlpha = UniFields.GetFloat(s.Fields, "alphafloor", 1.0f); //FloorAlpha = UniFields.GetFloat(s.Fields, "alphafloor", 1.0f);
FloorRotation = s.Fields.GetValue("rotationfloor", 0.0f); FloorRotation = s.Fields.GetValue("rotationfloor", 0.0);
FloorBrightness = s.Fields.GetValue("lightfloor", 0); FloorBrightness = s.Fields.GetValue("lightfloor", 0);
FloorLightAbsoulte = s.Fields.GetValue("lightfloorabsolute", false); FloorLightAbsoulte = s.Fields.GetValue("lightfloorabsolute", false);
FloorGlowColor = s.Fields.GetValue("floorglowcolor", 0); FloorGlowColor = s.Fields.GetValue("floorglowcolor", 0);
FloorGlowHeight = s.Fields.GetValue("floorglowheight", 0f); FloorGlowHeight = s.Fields.GetValue("floorglowheight", 0.0);
//UDMF slopes //UDMF slopes
if(s.FloorSlope.GetLengthSq() > 0) if(s.FloorSlope.GetLengthSq() > 0)
@ -354,8 +354,8 @@ namespace CodeImp.DoomBuilder.Windows
floorScale.SetValuesFrom(sc.Fields, true); floorScale.SetValuesFrom(sc.Fields, true);
// Texture rotation // Texture rotation
float ceilAngle = sc.Fields.GetValue("rotationceiling", 0.0f); double ceilAngle = sc.Fields.GetValue("rotationceiling", 0.0);
float floorAngle = sc.Fields.GetValue("rotationfloor", 0.0f); double floorAngle = sc.Fields.GetValue("rotationfloor", 0.0);
ceilRotation.Text = ceilAngle.ToString(); ceilRotation.Text = ceilAngle.ToString();
floorRotation.Text = floorAngle.ToString(); floorRotation.Text = floorAngle.ToString();
@ -370,12 +370,12 @@ namespace CodeImp.DoomBuilder.Windows
floorLightAbsolute.Checked = sc.Fields.GetValue("lightfloorabsolute", false); floorLightAbsolute.Checked = sc.Fields.GetValue("lightfloorabsolute", false);
// Portal alpha // Portal alpha
alphaceiling.Text = General.Clamp(sc.Fields.GetValue("alphaceiling", 1f), 0f, 1f).ToString(); alphaceiling.Text = General.Clamp(sc.Fields.GetValue("alphaceiling", 1.0), 0.0, 1.0).ToString();
alphafloor.Text = General.Clamp(sc.Fields.GetValue("alphafloor", 1f), 0f, 1f).ToString(); alphafloor.Text = General.Clamp(sc.Fields.GetValue("alphafloor", 1.0), 0.0, 1.0).ToString();
// Reflectivity // Reflectivity
ceiling_reflect.Text = General.Clamp(sc.Fields.GetValue("ceiling_reflect", 0f), 0f, 1f).ToString(); ceiling_reflect.Text = General.Clamp(sc.Fields.GetValue("ceiling_reflect", 0.0), 0.0, 1.0).ToString();
floor_reflect.Text = General.Clamp(sc.Fields.GetValue("floor_reflect", 0f), 0f, 1f).ToString(); floor_reflect.Text = General.Clamp(sc.Fields.GetValue("floor_reflect", 0.0), 0.0, 1.0).ToString();
// Fog density // Fog density
fogdensity.Text = General.Clamp(sc.Fields.GetValue("fogdensity", 0), 0, 510).ToString(); fogdensity.Text = General.Clamp(sc.Fields.GetValue("fogdensity", 0), 0, 510).ToString();
@ -387,8 +387,8 @@ namespace CodeImp.DoomBuilder.Windows
floorglowcolor.SetValueFrom(sc.Fields, true); floorglowcolor.SetValueFrom(sc.Fields, true);
// Floor/ceiling glow height // Floor/ceiling glow height
ceilingglowheight.Text = sc.Fields.GetValue("ceilingglowheight", 0f).ToString(); ceilingglowheight.Text = sc.Fields.GetValue("ceilingglowheight", 0.0).ToString();
floorglowheight.Text = sc.Fields.GetValue("floorglowheight", 0f).ToString(); floorglowheight.Text = sc.Fields.GetValue("floorglowheight", 0.0).ToString();
// Render style // Render style
ceilRenderStyle.SelectedIndex = renderstyles.IndexOf(sc.Fields.GetValue("renderstyleceiling", "translucent")); ceilRenderStyle.SelectedIndex = renderstyles.IndexOf(sc.Fields.GetValue("renderstyleceiling", "translucent"));
@ -410,8 +410,8 @@ namespace CodeImp.DoomBuilder.Windows
// Misc // Misc
soundsequence.Text = sc.Fields.GetValue("soundsequence", NO_SOUND_SEQUENCE); soundsequence.Text = sc.Fields.GetValue("soundsequence", NO_SOUND_SEQUENCE);
gravity.Text = sc.Fields.GetValue("gravity", 1.0f).ToString(); gravity.Text = sc.Fields.GetValue("gravity", 1.0).ToString();
desaturation.Text = General.Clamp(sc.Fields.GetValue("desaturation", 0.0f), 0f, 1f).ToString(); desaturation.Text = General.Clamp(sc.Fields.GetValue("desaturation", 0.0), 0.0, 1.0).ToString();
// Sector colors // Sector colors
fadeColor.SetValueFrom(sc.Fields, true); fadeColor.SetValueFrom(sc.Fields, true);
@ -476,12 +476,12 @@ namespace CodeImp.DoomBuilder.Windows
floorScale.SetValuesFrom(s.Fields, false); floorScale.SetValuesFrom(s.Fields, false);
// Texture rotation // Texture rotation
if(s.Fields.GetValue("rotationceiling", 0.0f).ToString() != ceilRotation.Text) if(s.Fields.GetValue("rotationceiling", 0.0).ToString() != ceilRotation.Text)
{ {
ceilRotation.Text = ""; ceilRotation.Text = "";
ceilAngleControl.Angle = AngleControlEx.NO_ANGLE; ceilAngleControl.Angle = AngleControlEx.NO_ANGLE;
} }
if(s.Fields.GetValue("rotationfloor", 0.0f).ToString() != floorRotation.Text) if(s.Fields.GetValue("rotationfloor", 0.0).ToString() != floorRotation.Text)
{ {
floorRotation.Text = ""; floorRotation.Text = "";
floorAngleControl.Angle = AngleControlEx.NO_ANGLE; floorAngleControl.Angle = AngleControlEx.NO_ANGLE;
@ -503,12 +503,12 @@ namespace CodeImp.DoomBuilder.Windows
} }
// Portal alpha // Portal alpha
if(s.Fields.GetValue("alphaceiling", 1.0f).ToString() != alphaceiling.Text) alphaceiling.Text = ""; if(s.Fields.GetValue("alphaceiling", 1.0).ToString() != alphaceiling.Text) alphaceiling.Text = "";
if(s.Fields.GetValue("alphafloor", 1.0f).ToString() != alphafloor.Text) alphafloor.Text = ""; if(s.Fields.GetValue("alphafloor", 1.0).ToString() != alphafloor.Text) alphafloor.Text = "";
// Reflectivity // Reflectivity
if(s.Fields.GetValue("ceiling_reflect", 0f).ToString() != ceiling_reflect.Text) ceiling_reflect.Text = ""; if(s.Fields.GetValue("ceiling_reflect", 0.0).ToString() != ceiling_reflect.Text) ceiling_reflect.Text = "";
if(s.Fields.GetValue("floor_reflect", 0f).ToString() != floor_reflect.Text) floor_reflect.Text = ""; if(s.Fields.GetValue("floor_reflect", 0.0).ToString() != floor_reflect.Text) floor_reflect.Text = "";
// Fog density // Fog density
if(s.Fields.GetValue("fogdensity", 0).ToString() != fogdensity.Text) fogdensity.Text = ""; if(s.Fields.GetValue("fogdensity", 0).ToString() != fogdensity.Text) fogdensity.Text = "";
@ -520,8 +520,8 @@ namespace CodeImp.DoomBuilder.Windows
floorglowcolor.SetValueFrom(s.Fields, false); floorglowcolor.SetValueFrom(s.Fields, false);
// Floor/ceiling glow height // Floor/ceiling glow height
if(s.Fields.GetValue("ceilingglowheight", 0f).ToString() != ceilingglowheight.Text) ceilingglowheight.Text = ""; if(s.Fields.GetValue("ceilingglowheight", 0.0).ToString() != ceilingglowheight.Text) ceilingglowheight.Text = "";
if(s.Fields.GetValue("floorglowheight", 0f).ToString() != floorglowheight.Text) floorglowheight.Text = ""; if(s.Fields.GetValue("floorglowheight", 0.0).ToString() != floorglowheight.Text) floorglowheight.Text = "";
// Render style // Render style
if(ceilRenderStyle.SelectedIndex > -1 && ceilRenderStyle.SelectedIndex != renderstyles.IndexOf(s.Fields.GetValue("renderstyleceiling", "translucent"))) if(ceilRenderStyle.SelectedIndex > -1 && ceilRenderStyle.SelectedIndex != renderstyles.IndexOf(s.Fields.GetValue("renderstyleceiling", "translucent")))
@ -551,8 +551,8 @@ namespace CodeImp.DoomBuilder.Windows
// Misc // Misc
if(soundsequence.SelectedIndex > -1 && s.Fields.GetValue("soundsequence", NO_SOUND_SEQUENCE) != soundsequence.Text) if(soundsequence.SelectedIndex > -1 && s.Fields.GetValue("soundsequence", NO_SOUND_SEQUENCE) != soundsequence.Text)
soundsequence.SelectedIndex = -1; soundsequence.SelectedIndex = -1;
if(s.Fields.GetValue("gravity", 1.0f).ToString() != gravity.Text) gravity.Text = ""; if(s.Fields.GetValue("gravity", 1.0).ToString() != gravity.Text) gravity.Text = "";
if(s.Fields.GetValue("desaturation", 0.0f).ToString() != desaturation.Text) desaturation.Text = ""; if(s.Fields.GetValue("desaturation", 0.0).ToString() != desaturation.Text) desaturation.Text = "";
// Sector colors // Sector colors
fadeColor.SetValueFrom(s.Fields, false); fadeColor.SetValueFrom(s.Fields, false);
@ -664,7 +664,7 @@ namespace CodeImp.DoomBuilder.Windows
{ {
if(!string.IsNullOrEmpty(control.Text)) if(!string.IsNullOrEmpty(control.Text))
{ {
double ceilAlphaVal = General.Clamp(control.GetResultFloat(s.Fields.GetValue(control.Name, defaultvalue)), 0f, 1f); double ceilAlphaVal = General.Clamp(control.GetResultFloat(s.Fields.GetValue(control.Name, defaultvalue)), 0.0, 1.0);
UniFields.SetFloat(s.Fields, control.Name, ceilAlphaVal, defaultvalue); UniFields.SetFloat(s.Fields, control.Name, ceilAlphaVal, defaultvalue);
} }
} }
@ -898,11 +898,11 @@ namespace CodeImp.DoomBuilder.Windows
if(!string.IsNullOrEmpty(soundsequence.Text)) if(!string.IsNullOrEmpty(soundsequence.Text))
UniFields.SetString(s.Fields, "soundsequence", soundsequence.Text, NO_SOUND_SEQUENCE); UniFields.SetString(s.Fields, "soundsequence", soundsequence.Text, NO_SOUND_SEQUENCE);
if(!string.IsNullOrEmpty(gravity.Text)) if(!string.IsNullOrEmpty(gravity.Text))
UniFields.SetFloat(s.Fields, "gravity", gravity.GetResultFloat(s.Fields.GetValue("gravity", 1.0f)), 1.0f); UniFields.SetFloat(s.Fields, "gravity", gravity.GetResultFloat(s.Fields.GetValue("gravity", 1.0)), 1.0);
if(!string.IsNullOrEmpty(desaturation.Text)) if(!string.IsNullOrEmpty(desaturation.Text))
{ {
double val = General.Clamp(desaturation.GetResultFloat(s.Fields.GetValue("desaturation", 0f)), 0f, 1f); double val = General.Clamp(desaturation.GetResultFloat(s.Fields.GetValue("desaturation", 0.0)), 0.0, 1.0);
UniFields.SetFloat(s.Fields, "desaturation", val, 0f); UniFields.SetFloat(s.Fields, "desaturation", val, 0.0);
} }
// Clear horizontal slopes // Clear horizontal slopes

View file

@ -214,10 +214,10 @@ namespace CodeImp.DoomBuilder.Windows
commenteditor.SetValues(ft.Fields, true); commenteditor.SetValues(ft.Fields, true);
conversationID.Text = ft.Fields.GetValue("conversation", 0).ToString(); conversationID.Text = ft.Fields.GetValue("conversation", 0).ToString();
floatbobphase.Text = ft.Fields.GetValue("floatbobphase", -1).ToString(); floatbobphase.Text = ft.Fields.GetValue("floatbobphase", -1).ToString();
gravity.Text = ft.Fields.GetValue("gravity", 1.0f).ToString(); gravity.Text = ft.Fields.GetValue("gravity", 1.0).ToString();
score.Text = ft.Fields.GetValue("score", 0).ToString(); score.Text = ft.Fields.GetValue("score", 0).ToString();
health.Text = ft.Fields.GetValue("health", 1).ToString(); health.Text = ft.Fields.GetValue("health", 1).ToString();
alpha.Text = ft.Fields.GetValue("alpha", 1.0f).ToString(); alpha.Text = ft.Fields.GetValue("alpha", 1.0).ToString();
color.SetValueFrom(ft.Fields, true); color.SetValueFrom(ft.Fields, true);
scale.SetValues(ft.ScaleX, ft.ScaleY, true); scale.SetValues(ft.ScaleX, ft.ScaleY, true);
pitch.Text = ft.Pitch.ToString(); pitch.Text = ft.Pitch.ToString();
@ -296,10 +296,10 @@ namespace CodeImp.DoomBuilder.Windows
commenteditor.SetValues(t.Fields, false); //mxd. Comments commenteditor.SetValues(t.Fields, false); //mxd. Comments
if(t.Fields.GetValue("conversation", 0).ToString() != conversationID.Text) conversationID.Text = ""; if(t.Fields.GetValue("conversation", 0).ToString() != conversationID.Text) conversationID.Text = "";
if(t.Fields.GetValue("floatbobphase", -1).ToString() != floatbobphase.Text) floatbobphase.Text = ""; if(t.Fields.GetValue("floatbobphase", -1).ToString() != floatbobphase.Text) floatbobphase.Text = "";
if(t.Fields.GetValue("gravity", 1.0f).ToString() != gravity.Text) gravity.Text = ""; if(t.Fields.GetValue("gravity", 1.0).ToString() != gravity.Text) gravity.Text = "";
if(t.Fields.GetValue("score", 0).ToString() != score.Text) score.Text = ""; if(t.Fields.GetValue("score", 0).ToString() != score.Text) score.Text = "";
if(t.Fields.GetValue("health", 1).ToString() != health.Text) health.Text = ""; if(t.Fields.GetValue("health", 1).ToString() != health.Text) health.Text = "";
if(t.Fields.GetValue("alpha", 1.0f).ToString() != alpha.Text) alpha.Text = ""; if(t.Fields.GetValue("alpha", 1.0).ToString() != alpha.Text) alpha.Text = "";
scale.SetValues(t.ScaleX, t.ScaleY, false); scale.SetValues(t.ScaleX, t.ScaleY, false);
color.SetValueFrom(t.Fields, false); color.SetValueFrom(t.Fields, false);
@ -546,7 +546,7 @@ namespace CodeImp.DoomBuilder.Windows
if(!string.IsNullOrEmpty(floatbobphase.Text)) if(!string.IsNullOrEmpty(floatbobphase.Text))
UniFields.SetInteger(t.Fields, "floatbobphase", General.Clamp(floatbobphase.GetResult(t.Fields.GetValue("floatbobphase", -1)), -1, 63), -1); UniFields.SetInteger(t.Fields, "floatbobphase", General.Clamp(floatbobphase.GetResult(t.Fields.GetValue("floatbobphase", -1)), -1, 63), -1);
if(!string.IsNullOrEmpty(gravity.Text)) if(!string.IsNullOrEmpty(gravity.Text))
UniFields.SetFloat(t.Fields, "gravity", gravity.GetResultFloat(t.Fields.GetValue("gravity", 1.0f)), 1.0f); UniFields.SetFloat(t.Fields, "gravity", gravity.GetResultFloat(t.Fields.GetValue("gravity", 1.0)), 1.0);
if(!string.IsNullOrEmpty(health.Text)) if(!string.IsNullOrEmpty(health.Text))
UniFields.SetInteger(t.Fields, "health", health.GetResult(t.Fields.GetValue("health", 1)), 1); UniFields.SetInteger(t.Fields, "health", health.GetResult(t.Fields.GetValue("health", 1)), 1);
if(!string.IsNullOrEmpty(score.Text)) if(!string.IsNullOrEmpty(score.Text))
@ -948,18 +948,18 @@ namespace CodeImp.DoomBuilder.Windows
//restore values //restore values
if(string.IsNullOrEmpty(alpha.Text)) if(string.IsNullOrEmpty(alpha.Text))
{ {
foreach(Thing t in things) UniFields.SetFloat(t.Fields, "alpha", thingprops[i++].Alpha, 1.0f); foreach(Thing t in things) UniFields.SetFloat(t.Fields, "alpha", thingprops[i++].Alpha, 1.0);
} }
else //update values else //update values
{ {
foreach(Thing t in things) foreach(Thing t in things)
{ {
double value = General.Clamp(alpha.GetResultFloat(t.Fields.GetValue("alpha", 1.0f)), 0f, 1.0f); double value = General.Clamp(alpha.GetResultFloat(t.Fields.GetValue("alpha", 1.0)), 0.0, 1.0);
UniFields.SetFloat(t.Fields, "alpha", value, 1.0f); UniFields.SetFloat(t.Fields, "alpha", value, 1.0);
} }
} }
resetalpha.Visible = (alpha.GetResultFloat(1.0f) != 1.0f); resetalpha.Visible = (alpha.GetResultFloat(1.0) != 1.0);
General.Map.IsChanged = true; General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);

View file

@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
identifier = String.Format("user_svg{0}_v{1}_{2}", svgid, vertexid, str); identifier = String.Format("user_svg{0}_v{1}_{2}", svgid, vertexid, str);
// Use reflection to set the variable to the value // Use reflection to set the variable to the value
type.GetField(str, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, sector.Fields.GetValue(identifier, 0.0f)); type.GetField(str, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, sector.Fields.GetValue(identifier, 0.0));
} }
} }

View file

@ -472,23 +472,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (texture != null) if (texture != null)
{ {
float scalex = s.Fields.GetValue("xscaleceiling", 1.0f); double scalex = s.Fields.GetValue("xscaleceiling", 1.0);
float scaley = s.Fields.GetValue("yscaleceiling", 1.0f); double scaley = s.Fields.GetValue("yscaleceiling", 1.0);
if (scalex != 0 && scaley != 0) if (scalex != 0 && scaley != 0)
{ {
Vector2D ceiloffset = new Vector2D(-offset.x, offset.y).GetRotated(-Angle2D.DegToRad((int)s.Fields.GetValue("rotationceiling", 0f))); Vector2D ceiloffset = new Vector2D(-offset.x, offset.y).GetRotated(-Angle2D.DegToRad((int)s.Fields.GetValue("rotationceiling", 0.0)));
ceiloffset.x += s.Fields.GetValue("xpanningceiling", 0f); ceiloffset.x += s.Fields.GetValue("xpanningceiling", 0.0);
ceiloffset.y += s.Fields.GetValue("ypanningceiling", 0f); ceiloffset.y += s.Fields.GetValue("ypanningceiling", 0.0);
int texturewidth = (int)Math.Round(texture.Width / scalex); int texturewidth = (int)Math.Round(texture.Width / scalex);
int textureheight = (int)Math.Round(texture.Height / scaley); int textureheight = (int)Math.Round(texture.Height / scaley);
if (!s.Fields.ContainsKey("xpanningceiling")) s.Fields.Add("xpanningceiling", new UniValue(UniversalType.Float, (float)Math.Round(ceiloffset.x % texturewidth))); if (!s.Fields.ContainsKey("xpanningceiling")) s.Fields.Add("xpanningceiling", new UniValue(UniversalType.Float, Math.Round(ceiloffset.x % texturewidth)));
else s.Fields["xpanningceiling"].Value = (float)Math.Round(ceiloffset.x % texturewidth); else s.Fields["xpanningceiling"].Value = Math.Round(ceiloffset.x % texturewidth);
if (!s.Fields.ContainsKey("ypanningceiling")) s.Fields.Add("ypanningceiling", new UniValue(UniversalType.Float, (float)Math.Round(ceiloffset.y % textureheight))); if (!s.Fields.ContainsKey("ypanningceiling")) s.Fields.Add("ypanningceiling", new UniValue(UniversalType.Float, Math.Round(ceiloffset.y % textureheight)));
else s.Fields["ypanningceiling"].Value = (float)Math.Round(ceiloffset.y % textureheight); else s.Fields["ypanningceiling"].Value = Math.Round(ceiloffset.y % textureheight);
} }
} }
} }
@ -499,23 +499,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
ImageData texture = General.Map.Data.GetFlatImage(s.FloorTexture); ImageData texture = General.Map.Data.GetFlatImage(s.FloorTexture);
if (texture != null) if (texture != null)
{ {
float scalex = s.Fields.GetValue("xscalefloor", 1.0f); double scalex = s.Fields.GetValue("xscalefloor", 1.0);
float scaley = s.Fields.GetValue("yscalefloor", 1.0f); double scaley = s.Fields.GetValue("yscalefloor", 1.0);
if (scalex != 0 && scaley != 0) if (scalex != 0 && scaley != 0)
{ {
Vector2D flooroffset = new Vector2D(-offset.x, offset.y).GetRotated(-Angle2D.DegToRad((int)s.Fields.GetValue("rotationfloor", 0f))); Vector2D flooroffset = new Vector2D(-offset.x, offset.y).GetRotated(-Angle2D.DegToRad((int)s.Fields.GetValue("rotationfloor", 0.0)));
flooroffset.x += s.Fields.GetValue("xpanningfloor", 0f); flooroffset.x += s.Fields.GetValue("xpanningfloor", 0.0);
flooroffset.y += s.Fields.GetValue("ypanningfloor", 0f); flooroffset.y += s.Fields.GetValue("ypanningfloor", 0.0);
int texturewidth = (int)Math.Round(texture.Width / scalex); int texturewidth = (int)Math.Round(texture.Width / scalex);
int textureheight = (int)Math.Round(texture.Height / scaley); int textureheight = (int)Math.Round(texture.Height / scaley);
if (!s.Fields.ContainsKey("xpanningfloor")) s.Fields.Add("xpanningfloor", new UniValue(UniversalType.Float, (float)Math.Round(flooroffset.x % texturewidth))); if (!s.Fields.ContainsKey("xpanningfloor")) s.Fields.Add("xpanningfloor", new UniValue(UniversalType.Float, Math.Round(flooroffset.x % texturewidth)));
else s.Fields["xpanningfloor"].Value = (float)Math.Round(flooroffset.x % texturewidth); else s.Fields["xpanningfloor"].Value = Math.Round(flooroffset.x % texturewidth);
if (!s.Fields.ContainsKey("ypanningfloor")) s.Fields.Add("ypanningfloor", new UniValue(UniversalType.Float, (float)Math.Round(flooroffset.y % textureheight))); if (!s.Fields.ContainsKey("ypanningfloor")) s.Fields.Add("ypanningfloor", new UniValue(UniversalType.Float, Math.Round(flooroffset.y % textureheight)));
else s.Fields["ypanningfloor"].Value = (float)Math.Round(flooroffset.y % textureheight); else s.Fields["ypanningfloor"].Value = Math.Round(flooroffset.y % textureheight);
} }
} }
} }

View file

@ -90,12 +90,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
public SectorTextureInfo(Sector s) public SectorTextureInfo(Sector s)
{ {
// Get transform properties // Get transform properties
Floor.Offset = new Vector2D(UniFields.GetFloat(s.Fields, "xpanningfloor", 0f), UniFields.GetFloat(s.Fields, "ypanningfloor", 0f)); Floor.Offset = new Vector2D(UniFields.GetFloat(s.Fields, "xpanningfloor", 0.0), UniFields.GetFloat(s.Fields, "ypanningfloor", 0.0));
Ceiling.Offset = new Vector2D(UniFields.GetFloat(s.Fields, "xpanningceiling", 0f), UniFields.GetFloat(s.Fields, "ypanningceiling", 0f)); Ceiling.Offset = new Vector2D(UniFields.GetFloat(s.Fields, "xpanningceiling", 0.0), UniFields.GetFloat(s.Fields, "ypanningceiling", 0.0));
Floor.Scale = new Vector2D(UniFields.GetFloat(s.Fields, "xscalefloor", 1.0f), -UniFields.GetFloat(s.Fields, "yscalefloor", 1.0f)); Floor.Scale = new Vector2D(UniFields.GetFloat(s.Fields, "xscalefloor", 1.0), -UniFields.GetFloat(s.Fields, "yscalefloor", 1.0));
Ceiling.Scale = new Vector2D(UniFields.GetFloat(s.Fields, "xscaleceiling", 1.0f), -UniFields.GetFloat(s.Fields, "yscaleceiling", 1.0f)); Ceiling.Scale = new Vector2D(UniFields.GetFloat(s.Fields, "xscaleceiling", 1.0), -UniFields.GetFloat(s.Fields, "yscaleceiling", 1.0));
Floor.Rotation = Angle2D.DegToRad(UniFields.GetFloat(s.Fields, "rotationfloor", 0f)); Floor.Rotation = Angle2D.DegToRad(UniFields.GetFloat(s.Fields, "rotationfloor", 0.0));
Ceiling.Rotation = Angle2D.DegToRad(UniFields.GetFloat(s.Fields, "rotationceiling", 0f)); Ceiling.Rotation = Angle2D.DegToRad(UniFields.GetFloat(s.Fields, "rotationceiling", 0.0));
// Get texture sizes // Get texture sizes
Floor.TextureSize = GetTextureSize(s.LongFloorTexture); Floor.TextureSize = GetTextureSize(s.LongFloorTexture);

View file

@ -623,11 +623,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(Sector s in selection) foreach(Sector s in selection)
{ {
SectorInfo si; SectorInfo si;
si.rotation = Angle2D.DegToRad(s.Fields.GetValue(RotationName, 0.0f)); si.rotation = Angle2D.DegToRad(s.Fields.GetValue(RotationName, 0.0));
si.scale.x = s.Fields.GetValue(XScaleName, 1.0f); si.scale.x = s.Fields.GetValue(XScaleName, 1.0);
si.scale.y = s.Fields.GetValue(YScaleName, 1.0f); si.scale.y = s.Fields.GetValue(YScaleName, 1.0);
si.offset.x = s.Fields.GetValue(XOffsetName, 0.0f); si.offset.x = s.Fields.GetValue(XOffsetName, 0.0);
si.offset.y = -s.Fields.GetValue(YOffsetName, 0.0f); si.offset.y = -s.Fields.GetValue(YOffsetName, 0.0);
sectorinfo.Add(si); sectorinfo.Add(si);
} }

View file

@ -307,12 +307,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
else else
{ {
offset.x %= texture.Width / s.Fields.GetValue((alignFloors ? "xscalefloor" : "xscaleceiling"), 1.0f); offset.x %= texture.Width / s.Fields.GetValue((alignFloors ? "xscalefloor" : "xscaleceiling"), 1.0);
offset.y %= texture.Height / s.Fields.GetValue((alignFloors ? "yscalefloor" : "yscaleceiling"), 1.0f); offset.y %= texture.Height / s.Fields.GetValue((alignFloors ? "yscalefloor" : "yscaleceiling"), 1.0);
} }
UniFields.SetFloat(s.Fields, (alignFloors ? "xpanningfloor" : "xpanningceiling"), (float)Math.Round(-offset.x), 0f); UniFields.SetFloat(s.Fields, (alignFloors ? "xpanningfloor" : "xpanningceiling"), Math.Round(-offset.x), 0.0);
UniFields.SetFloat(s.Fields, (alignFloors ? "ypanningfloor" : "ypanningceiling"), (float)Math.Round(offset.y), 0f); UniFields.SetFloat(s.Fields, (alignFloors ? "ypanningfloor" : "ypanningceiling"), Math.Round(offset.y), 0.0);
//update //update
s.UpdateNeeded = true; s.UpdateNeeded = true;

View file

@ -110,11 +110,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(!sidedef.HighRequired() || sidedef.LongHighTexture == MapSet.EmptyLongName) return; if(!sidedef.HighRequired() || sidedef.LongHighTexture == MapSet.EmptyLongName) return;
float scaleX = sidedef.Fields.GetValue("scalex_top", 1.0f); double scaleX = sidedef.Fields.GetValue("scalex_top", 1.0);
float scaleY = sidedef.Fields.GetValue("scaley_top", 1.0f); double scaleY = sidedef.Fields.GetValue("scaley_top", 1.0);
int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_top", 0.0f)); int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_top", 0.0));
int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_top", 0.0f)); int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_top", 0.0));
int y = (int)Tools.GetSidedefTopOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false); int y = (int)Tools.GetSidedefTopOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false);
CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_UPPER, sidedef.HighTexture); CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_UPPER, sidedef.HighTexture);
} }
@ -123,11 +123,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(!sidedef.MiddleRequired() || sidedef.LongMiddleTexture == MapSet.EmptyLongName) return; if(!sidedef.MiddleRequired() || sidedef.LongMiddleTexture == MapSet.EmptyLongName) return;
float scaleX = sidedef.Fields.GetValue("scalex_mid", 1.0f); double scaleX = sidedef.Fields.GetValue("scalex_mid", 1.0);
float scaleY = sidedef.Fields.GetValue("scaley_mid", 1.0f); double scaleY = sidedef.Fields.GetValue("scaley_mid", 1.0);
int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_mid", 0.0f)); int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_mid", 0.0));
int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_mid", 0.0f)); int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_mid", 0.0));
int y = (int)Tools.GetSidedefMiddleOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false); int y = (int)Tools.GetSidedefMiddleOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false);
CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_MIDDLE, sidedef.MiddleTexture); CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_MIDDLE, sidedef.MiddleTexture);
} }
@ -136,11 +136,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(!sidedef.LowRequired() || sidedef.LongLowTexture == MapSet.EmptyLongName) return; if(!sidedef.LowRequired() || sidedef.LongLowTexture == MapSet.EmptyLongName) return;
float scaleX = sidedef.Fields.GetValue("scalex_bottom", 1.0f); double scaleX = sidedef.Fields.GetValue("scalex_bottom", 1.0);
float scaleY = sidedef.Fields.GetValue("scaley_bottom", 1.0f); double scaleY = sidedef.Fields.GetValue("scaley_bottom", 1.0);
int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_bottom", 0.0f)); int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_bottom", 0.0));
int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_bottom", 0.0f)); int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_bottom", 0.0));
int y = (int)Tools.GetSidedefBottomOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false); int y = (int)Tools.GetSidedefBottomOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false);
CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_LOWER, sidedef.LowTexture); CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_LOWER, sidedef.LowTexture);
} }

View file

@ -349,11 +349,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Map.UDMF) if(General.Map.UDMF)
{ {
// Fetch ZDoom fields // Fetch ZDoom fields
Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0f), Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0),
s.Fields.GetValue("ypanningfloor", 0.0f)); s.Fields.GetValue("ypanningfloor", 0.0));
Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0f), Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0),
s.Fields.GetValue("yscalefloor", 1.0f)); s.Fields.GetValue("yscalefloor", 1.0));
float rotate = s.Fields.GetValue("rotationfloor", 0.0f); double rotate = s.Fields.GetValue("rotationfloor", 0.0);
int color, light; int color, light;
bool absolute; bool absolute;
@ -409,11 +409,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Map.UDMF) if(General.Map.UDMF)
{ {
// Fetch ZDoom fields // Fetch ZDoom fields
Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0f), Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0),
s.Fields.GetValue("ypanningceiling", 0.0f)); s.Fields.GetValue("ypanningceiling", 0.0));
Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0f), Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0),
s.Fields.GetValue("yscaleceiling", 1.0f)); s.Fields.GetValue("yscaleceiling", 1.0));
float rotate = s.Fields.GetValue("rotationceiling", 0.0f); double rotate = s.Fields.GetValue("rotationceiling", 0.0);
int color, light; int color, light;
bool absolute; bool absolute;

View file

@ -173,9 +173,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
double angle; double angle;
if(GeometryType == VisualGeometryType.CEILING) if(GeometryType == VisualGeometryType.CEILING)
angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0f)); angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0.0));
else else
angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0f)); angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0.0));
Vector2D v = new Vector2D(offsetx, offsety).GetRotated(angle); Vector2D v = new Vector2D(offsetx, offsety).GetRotated(angle);
@ -255,8 +255,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Check texture // Check texture
if(target.FloorTexture != (isFloor ? Sector.Sector.FloorTexture : Sector.Sector.CeilTexture)) return; if(target.FloorTexture != (isFloor ? Sector.Sector.FloorTexture : Sector.Sector.CeilTexture)) return;
scaleX = target.Fields.GetValue("xscalefloor", 1.0f); scaleX = target.Fields.GetValue("xscalefloor", 1.0);
scaleY = target.Fields.GetValue("yscalefloor", 1.0f); scaleY = target.Fields.GetValue("yscalefloor", 1.0);
} }
else else
{ {
@ -272,8 +272,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Check texture // Check texture
if(target.CeilTexture != (isFloor ? Sector.Sector.FloorTexture : Sector.Sector.CeilTexture)) return; if(target.CeilTexture != (isFloor ? Sector.Sector.FloorTexture : Sector.Sector.CeilTexture)) return;
scaleX = target.Fields.GetValue("xscaleceiling", 1.0f); scaleX = target.Fields.GetValue("xscaleceiling", 1.0);
scaleY = target.Fields.GetValue("yscaleceiling", 1.0f); scaleY = target.Fields.GetValue("yscaleceiling", 1.0);
} }
//find a linedef to align to //find a linedef to align to
@ -336,13 +336,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(alignx) if(alignx)
{ {
if(Texture != null && Texture.IsImageLoaded) offset.x %= Texture.Width / scaleX; if(Texture != null && Texture.IsImageLoaded) offset.x %= Texture.Width / scaleX;
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "xpanningfloor" : "xpanningceiling"), (float)Math.Round(-offset.x), 0f); UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "xpanningfloor" : "xpanningceiling"), Math.Round(-offset.x), 0.0);
} }
if(aligny) if(aligny)
{ {
if(Texture != null && Texture.IsImageLoaded) offset.y %= Texture.Height / scaleY; if(Texture != null && Texture.IsImageLoaded) offset.y %= Texture.Height / scaleY;
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "ypanningfloor" : "ypanningceiling"), (float)Math.Round(offset.y), 0f); UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "ypanningfloor" : "ypanningceiling"), Math.Round(offset.y), 0.0);
} }
//update geometry //update geometry
@ -866,9 +866,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
Point p = new Point(horizontal, vertical); Point p = new Point(horizontal, vertical);
double angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY); double angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
if(GeometryType == VisualGeometryType.CEILING) if(GeometryType == VisualGeometryType.CEILING)
angle += level.sector.Fields.GetValue("rotationceiling", 0f); angle += level.sector.Fields.GetValue("rotationceiling", 0.0);
else else
angle += level.sector.Fields.GetValue("rotationfloor", 0f); angle += level.sector.Fields.GetValue("rotationfloor", 0.0);
angle = General.ClampAngle(angle); angle = General.ClampAngle(angle);
@ -912,7 +912,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd //mxd
public virtual void OnChangeTextureRotation(float angle) public virtual void OnChangeTextureRotation(double angle)
{ {
if(!General.Map.UDMF) return; if(!General.Map.UDMF) return;
@ -957,8 +957,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Adjust to camera view // Adjust to camera view
double angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY); double angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
if(GeometryType == VisualGeometryType.CEILING) angle += level.sector.Fields.GetValue("rotationceiling", 0f); if(GeometryType == VisualGeometryType.CEILING) angle += level.sector.Fields.GetValue("rotationceiling", 0.0);
else angle += level.sector.Fields.GetValue("rotationfloor", 0f); else angle += level.sector.Fields.GetValue("rotationfloor", 0.0);
angle = General.ClampAngle(angle); angle = General.ClampAngle(angle);
if(angle > 315 || angle < 46) if(angle > 315 || angle < 46)

View file

@ -139,7 +139,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// From UDMF field // From UDMF field
else else
{ {
alpha = (byte)(Sidedef.Line.Fields.GetValue("alpha", 1.0f) * 255.0f); alpha = (byte)(Sidedef.Line.Fields.GetValue("alpha", 1.0) * 255.0);
if(alpha == 255 && Sidedef.Line.IsFlagSet("transparent")) alpha = 64; //mxd if(alpha == 255 && Sidedef.Line.IsFlagSet("transparent")) alpha = 64; //mxd
if(canhavealpha && Sidedef.Line.Fields.GetValue("renderstyle", "translucent") == "add") if(canhavealpha && Sidedef.Line.Fields.GetValue("renderstyle", "translucent") == "add")
@ -530,17 +530,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// biwa // biwa
protected static float GetNewTexutreOffset(float oldValue, float offset, float textureSize) protected static double GetNewTexutreOffset(double oldValue, double offset, double textureSize)
{ {
return GetRoundedTextureOffset(oldValue, offset, 1.0f, textureSize); return GetRoundedTextureOffset(oldValue, offset, 1.0f, textureSize);
} }
//mxd //mxd
protected static float GetRoundedTextureOffset(float oldValue, float offset, float scale, float textureSize) protected static double GetRoundedTextureOffset(double oldValue, double offset, double scale, double textureSize)
{ {
if(offset == 0f) return oldValue; if(offset == 0f) return oldValue;
float scaledOffset = offset * Math.Abs(scale); double scaledOffset = offset * Math.Abs(scale);
float result = (float)Math.Round(oldValue + scaledOffset); double result = Math.Round(oldValue + scaledOffset);
if(textureSize > 0) result %= textureSize; if(textureSize > 0) result %= textureSize;
if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1); if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1);
return result; return result;
@ -1677,25 +1677,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
throw new Exception("OnChangeTextureScale(): Got unknown GeometryType: " + GeometryType); throw new Exception("OnChangeTextureScale(): Got unknown GeometryType: " + GeometryType);
} }
float scaleX = Sidedef.Fields.GetValue(keyX, 1.0f); double scaleX = Sidedef.Fields.GetValue(keyX, 1.0);
float scaleY = Sidedef.Fields.GetValue(keyY, 1.0f); double scaleY = Sidedef.Fields.GetValue(keyY, 1.0);
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
if(incrementX != 0) if(incrementX != 0)
{ {
float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; double pix = (int)Math.Round(Texture.Width * scaleX) - incrementX;
float newscaleX = (float)Math.Round(pix / Texture.Width, 3); double newscaleX = Math.Round(pix / Texture.Width, 3);
scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX);
UniFields.SetFloat(Sidedef.Fields, keyX, scaleX, 1.0f); UniFields.SetFloat(Sidedef.Fields, keyX, scaleX, 1.0);
} }
if(incrementY != 0) if(incrementY != 0)
{ {
float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; double pix = (int)Math.Round(Texture.Height * scaleY) - incrementY;
float newscaleY = (float)Math.Round(pix / Texture.Height, 3); double newscaleY = Math.Round(pix / Texture.Height, 3);
scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY);
UniFields.SetFloat(Sidedef.Fields, keyY, scaleY, 1.0f); UniFields.SetFloat(Sidedef.Fields, keyY, scaleY, 1.0);
} }
// Update geometry // Update geometry

View file

@ -3669,12 +3669,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(obj is VisualFloor) else if(obj is VisualFloor)
{ {
VisualFloor vf = (VisualFloor)obj; VisualFloor vf = (VisualFloor)obj;
vf.OnChangeTextureRotation(General.ClampAngle(vf.GetControlSector().Fields.GetValue("rotationfloor", 0.0f) + textureangleincrement)); vf.OnChangeTextureRotation(General.ClampAngle(vf.GetControlSector().Fields.GetValue("rotationfloor", 0.0) + textureangleincrement));
} }
else if(obj is VisualCeiling) else if(obj is VisualCeiling)
{ {
VisualCeiling vc = (VisualCeiling)obj; VisualCeiling vc = (VisualCeiling)obj;
vc.OnChangeTextureRotation(General.ClampAngle(vc.GetControlSector().Fields.GetValue("rotationceiling", 0.0f) + textureangleincrement)); vc.OnChangeTextureRotation(General.ClampAngle(vc.GetControlSector().Fields.GetValue("rotationceiling", 0.0) + textureangleincrement));
} }
} }
@ -4373,17 +4373,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
switch(start.GeometryType) switch(start.GeometryType)
{ {
case VisualGeometryType.WALL_UPPER: case VisualGeometryType.WALL_UPPER:
first.scaleX = start.Sidedef.Fields.GetValue("scalex_top", 1.0f); first.scaleX = start.Sidedef.Fields.GetValue("scalex_top", 1.0);
first.scaleY = start.Sidedef.Fields.GetValue("scaley_top", 1.0f); first.scaleY = start.Sidedef.Fields.GetValue("scaley_top", 1.0);
break; break;
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
case VisualGeometryType.WALL_MIDDLE_3D: case VisualGeometryType.WALL_MIDDLE_3D:
first.scaleX = first.controlSide.Fields.GetValue("scalex_mid", 1.0f); first.scaleX = first.controlSide.Fields.GetValue("scalex_mid", 1.0);
first.scaleY = first.controlSide.Fields.GetValue("scaley_mid", 1.0f); first.scaleY = first.controlSide.Fields.GetValue("scaley_mid", 1.0);
break; break;
case VisualGeometryType.WALL_LOWER: case VisualGeometryType.WALL_LOWER:
first.scaleX = start.Sidedef.Fields.GetValue("scalex_bottom", 1.0f); first.scaleX = start.Sidedef.Fields.GetValue("scalex_bottom", 1.0);
first.scaleY = start.Sidedef.Fields.GetValue("scaley_bottom", 1.0f); first.scaleY = start.Sidedef.Fields.GetValue("scaley_bottom", 1.0);
break; break;
} }
@ -4396,18 +4396,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
switch(start.GeometryType) switch(start.GeometryType)
{ {
case VisualGeometryType.WALL_UPPER: case VisualGeometryType.WALL_UPPER:
ystartalign += Tools.GetSidedefTopOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_top", 0.0f), worldpanning ? 1.0f : first.scaleY / scaley, false);//mxd ystartalign += Tools.GetSidedefTopOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_top", 0.0), worldpanning ? 1.0 : first.scaleY / scaley, false);//mxd
break; break;
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
ystartalign += Tools.GetSidedefMiddleOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_mid", 0.0f), worldpanning ? 1.0f : first.scaleY / scaley, false);//mxd ystartalign += Tools.GetSidedefMiddleOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_mid", 0.0), worldpanning ? 1.0 : first.scaleY / scaley, false);//mxd
break; break;
case VisualGeometryType.WALL_MIDDLE_3D: //mxd. 3d-floors are not affected by Lower/Upper unpegged flags case VisualGeometryType.WALL_MIDDLE_3D: //mxd. 3d-floors are not affected by Lower/Upper unpegged flags
ystartalign += first.controlSide.OffsetY - (start.Sidedef.Sector.CeilHeight - first.ceilingHeight); ystartalign += first.controlSide.OffsetY - (start.Sidedef.Sector.CeilHeight - first.ceilingHeight);
ystartalign += start.Sidedef.Fields.GetValue("offsety_mid", 0.0f); ystartalign += start.Sidedef.Fields.GetValue("offsety_mid", 0.0);
ystartalign += first.controlSide.Fields.GetValue("offsety_mid", 0.0f); ystartalign += first.controlSide.Fields.GetValue("offsety_mid", 0.0);
break; break;
case VisualGeometryType.WALL_LOWER: case VisualGeometryType.WALL_LOWER:
ystartalign += Tools.GetSidedefBottomOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_bottom", 0.0f), worldpanning ? 1.0f : first.scaleY / scaley, false);//mxd ystartalign += Tools.GetSidedefBottomOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_bottom", 0.0), worldpanning ? 1.0 : first.scaleY / scaley, false);//mxd
break; break;
} }
@ -4415,18 +4415,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
switch(start.GeometryType) switch(start.GeometryType)
{ {
case VisualGeometryType.WALL_UPPER: case VisualGeometryType.WALL_UPPER:
first.offsetx += start.Sidedef.Fields.GetValue("offsetx_top", 0.0f); first.offsetx += start.Sidedef.Fields.GetValue("offsetx_top", 0.0);
break; break;
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
first.offsetx += start.Sidedef.Fields.GetValue("offsetx_mid", 0.0f); first.offsetx += start.Sidedef.Fields.GetValue("offsetx_mid", 0.0);
break; break;
case VisualGeometryType.WALL_MIDDLE_3D: //mxd. Yup, 4 sets of texture offsets are used case VisualGeometryType.WALL_MIDDLE_3D: //mxd. Yup, 4 sets of texture offsets are used
first.offsetx += start.Sidedef.Fields.GetValue("offsetx_mid", 0.0f); first.offsetx += start.Sidedef.Fields.GetValue("offsetx_mid", 0.0);
first.offsetx += first.controlSide.OffsetX; first.offsetx += first.controlSide.OffsetX;
first.offsetx += first.controlSide.Fields.GetValue("offsetx_mid", 0.0f); first.offsetx += first.controlSide.Fields.GetValue("offsetx_mid", 0.0);
break; break;
case VisualGeometryType.WALL_LOWER: case VisualGeometryType.WALL_LOWER:
first.offsetx += start.Sidedef.Fields.GetValue("offsetx_bottom", 0.0f); first.offsetx += start.Sidedef.Fields.GetValue("offsetx_bottom", 0.0);
break; break;
} }
first.forward = true; first.forward = true;
@ -4513,25 +4513,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongHighTexture); ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongHighTexture);
int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1; int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1;
j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, (float)Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals)); j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals));
} }
if(matchbottom) if(matchbottom)
{ {
ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongLowTexture); ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongLowTexture);
int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1; int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1;
j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, (float)Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals)); j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals));
} }
if(matchmid) if(matchmid)
{ {
if(j.sidedef.Index != j.controlSide.Index) //mxd. if it's a part of 3d-floor if(j.sidedef.Index != j.controlSide.Index) //mxd. if it's a part of 3d-floor
{ {
offset -= j.controlSide.OffsetX; offset -= j.controlSide.OffsetX;
offset -= j.controlSide.Fields.GetValue("offsetx_mid", 0.0f); offset -= j.controlSide.Fields.GetValue("offsetx_mid", 0.0);
} }
ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture); ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture);
int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1; int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1;
j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, (float)Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals)); j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals));
} }
} }
@ -4551,7 +4551,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
double scale = !worldpanning ? j.scaleY / scaley : 1.0f; double scale = !worldpanning ? j.scaleY / scaley : 1.0f;
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float,
(float)Math.Round(Tools.GetSidedefTopOffsetY(j.sidedef, offset, scale, true) % vheight, General.Map.FormatInterface.VertexDecimals)); //mxd Math.Round(Tools.GetSidedefTopOffsetY(j.sidedef, offset, scale, true) % vheight, General.Map.FormatInterface.VertexDecimals)); //mxd
} }
if (matchbottom) if (matchbottom)
@ -4561,7 +4561,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
double scale = !worldpanning ? j.scaleY / scaley : 1.0f; double scale = !worldpanning ? j.scaleY / scaley : 1.0f;
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float,
(float)Math.Round(Tools.GetSidedefBottomOffsetY(j.sidedef, offset, scale, true) % vheight, General.Map.FormatInterface.VertexDecimals)); //mxd Math.Round(Tools.GetSidedefBottomOffsetY(j.sidedef, offset, scale, true) % vheight, General.Map.FormatInterface.VertexDecimals)); //mxd
} }
if(matchmid) if(matchmid)
{ {
@ -4569,12 +4569,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(j.sidedef.Index != j.controlSide.Index) if(j.sidedef.Index != j.controlSide.Index)
{ {
offset -= j.controlSide.OffsetY; offset -= j.controlSide.OffsetY;
offset -= j.controlSide.Fields.GetValue("offsety_mid", 0.0f); offset -= j.controlSide.Fields.GetValue("offsety_mid", 0.0);
ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture); ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture);
int texheight = (tex != null && tex.IsImageLoaded) ? tex.Height : 1; int texheight = (tex != null && tex.IsImageLoaded) ? tex.Height : 1;
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float,
(float)Math.Round(offset % vheight, General.Map.FormatInterface.VertexDecimals)); Math.Round(offset % vheight, General.Map.FormatInterface.VertexDecimals));
} }
else else
{ {
@ -4594,7 +4594,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
//mxd. This should be doublesided non-wrapped line. Find the nearset aligned position //mxd. This should be doublesided non-wrapped line. Find the nearset aligned position
double curoffset = UniFields.GetFloat(j.sidedef.Fields, "offsety_mid") + j.sidedef.OffsetY; double curoffset = UniFields.GetFloat(j.sidedef.Fields, "offsety_mid") + j.sidedef.OffsetY;
offset += vheight * (float)Math.Round(curoffset / vheight - 0.5f * Math.Sign(j.scaleY)); offset += vheight * Math.Round(curoffset / vheight - 0.5f * Math.Sign(j.scaleY));
// Make sure the surface stays between floor and ceiling // Make sure the surface stays between floor and ceiling
if(j.sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || Math.Sign(j.scaleY) == -1) if(j.sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || Math.Sign(j.scaleY) == -1)
@ -4650,7 +4650,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply alignment // Apply alignment
if(alignx) if(alignx)
{ {
float offset; double offset;
if(!worldpanning) if(!worldpanning)
{ {
@ -4668,27 +4668,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongHighTexture); ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongHighTexture);
int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1; int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1;
j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float,
(float)Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals)); Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals));
} }
if(matchbottom) if(matchbottom)
{ {
ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongLowTexture); ImageData tex = General.Map.Data.GetTextureImage(j.sidedef.LongLowTexture);
int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1; int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1;
j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float,
(float)Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals)); Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals));
} }
if(matchmid) if(matchmid)
{ {
if(j.sidedef.Index != j.controlSide.Index) //mxd if(j.sidedef.Index != j.controlSide.Index) //mxd
{ {
offset -= j.controlSide.OffsetX; offset -= j.controlSide.OffsetX;
offset -= j.controlSide.Fields.GetValue("offsetx_mid", 0.0f); offset -= j.controlSide.Fields.GetValue("offsetx_mid", 0.0);
} }
ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture); ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture);
int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1; int texwidth = (tex != null && tex.IsImageLoaded) ? tex.Width : 1;
j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float,
(float)Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals)); Math.Round(offset % vwidth, General.Map.FormatInterface.VertexDecimals));
} }
} }
@ -4721,7 +4721,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(j.sidedef.Index != j.controlSide.Index) if(j.sidedef.Index != j.controlSide.Index)
{ {
offset -= j.controlSide.OffsetY; offset -= j.controlSide.OffsetY;
offset -= j.controlSide.Fields.GetValue("offsety_mid", 0.0f); offset -= j.controlSide.Fields.GetValue("offsety_mid", 0.0);
ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture); ImageData tex = General.Map.Data.GetTextureImage(j.controlSide.LongMiddleTexture);
int texheight = (tex != null && tex.IsImageLoaded) ? tex.Height : 1; int texheight = (tex != null && tex.IsImageLoaded) ? tex.Height : 1;

View file

@ -127,7 +127,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if((renderstyle == "add" || renderstyle == "translucent" || renderstyle == "subtract" || renderstyle.EndsWith("stencil")) if((renderstyle == "add" || renderstyle == "translucent" || renderstyle == "subtract" || renderstyle.EndsWith("stencil"))
&& Thing.Fields.ContainsKey("alpha")) && Thing.Fields.ContainsKey("alpha"))
{ {
alpha = (byte)(General.Clamp(Thing.Fields.GetValue("alpha", info.Alpha), 0f, 1f) * 255); alpha = (byte)(General.Clamp(Thing.Fields.GetValue("alpha", info.Alpha), 0.0, 1.0) * 255.0);
} }
if (renderstyle.EndsWith("stencil")) if (renderstyle.EndsWith("stencil"))

View file

@ -84,7 +84,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Avoid black glows // Avoid black glows
if(glowcolor > 0) if(glowcolor > 0)
{ {
float glowheight = data.Sector.Fields.GetValue((floor ? "floorglowheight" : "ceilingglowheight"), 0f); double glowheight = data.Sector.Fields.GetValue((floor ? "floorglowheight" : "ceilingglowheight"), 0.0);
if(glowheight > 0f) if(glowheight > 0f)
{ {
// Create glow data // Create glow data

View file

@ -78,11 +78,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.Setup(level, extrafloor); base.Setup(level, extrafloor);
// Fetch ZDoom fields // Fetch ZDoom fields
double rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationceiling", 0.0f)); double rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationceiling", 0.0));
Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0f), Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0),
s.Fields.GetValue("ypanningceiling", 0.0f)); s.Fields.GetValue("ypanningceiling", 0.0));
Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0f), Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0),
s.Fields.GetValue("yscaleceiling", 1.0f)); s.Fields.GetValue("yscaleceiling", 1.0));
//Load ceiling texture //Load ceiling texture
if(s.LongCeilTexture != MapSet.EmptyLongName) if(s.LongCeilTexture != MapSet.EmptyLongName)
@ -253,7 +253,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd //mxd
public override void OnChangeTextureRotation(float angle) public override void OnChangeTextureRotation(double angle)
{ {
// Only do this when not done yet in this call // Only do this when not done yet in this call
// Because we may be able to select the same 3D floor multiple times through multiple sectors // Because we may be able to select the same 3D floor multiple times through multiple sectors
@ -268,8 +268,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Return texture coordinates // Return texture coordinates
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
return new Point { X = (int)Sector.Sector.Fields.GetValue("xpanningceiling", 0.0f), return new Point { X = (int)Sector.Sector.Fields.GetValue("xpanningceiling", 0.0),
Y = (int)Sector.Sector.Fields.GetValue("ypanningceiling", 0.0f) }; Y = (int)Sector.Sector.Fields.GetValue("ypanningceiling", 0.0) };
} }
//mxd //mxd
@ -291,8 +291,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
Sector s = GetControlSector(); Sector s = GetControlSector();
s.Fields.BeforeFieldsChange(); s.Fields.BeforeFieldsChange();
float nx = (s.Fields.GetValue("xpanningceiling", 0.0f) + offsetx) % (Texture.ScaledWidth / s.Fields.GetValue("xscaleceiling", 1.0f)); double nx = (s.Fields.GetValue("xpanningceiling", 0.0) + offsetx) % (Texture.ScaledWidth / s.Fields.GetValue("xscaleceiling", 1.0));
float ny = (s.Fields.GetValue("ypanningceiling", 0.0f) + offsety) % (Texture.ScaledHeight / s.Fields.GetValue("yscaleceiling", 1.0f)); double ny = (s.Fields.GetValue("ypanningceiling", 0.0) + offsety) % (Texture.ScaledHeight / s.Fields.GetValue("yscaleceiling", 1.0));
s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, nx); s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, nx);
s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, ny); s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, ny);
s.UpdateNeeded = true; s.UpdateNeeded = true;
@ -305,23 +305,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(Texture == null || !Texture.IsImageLoaded) return; if(Texture == null || !Texture.IsImageLoaded) return;
Sector s = GetControlSector(); Sector s = GetControlSector();
float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f); double scaleX = s.Fields.GetValue("xscaleceiling", 1.0);
float scaleY = s.Fields.GetValue("yscaleceiling", 1.0f); double scaleY = s.Fields.GetValue("yscaleceiling", 1.0);
s.Fields.BeforeFieldsChange(); s.Fields.BeforeFieldsChange();
if(incrementX != 0) if(incrementX != 0)
{ {
float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; double pix = (int)Math.Round(Texture.Width * scaleX) - incrementX;
float newscaleX = (float)Math.Round(pix / Texture.Width, 3); double newscaleX = Math.Round(pix / Texture.Width, 3);
scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX);
UniFields.SetFloat(s.Fields, "xscaleceiling", scaleX, 1.0f); UniFields.SetFloat(s.Fields, "xscaleceiling", scaleX, 1.0f);
} }
if(incrementY != 0) if(incrementY != 0)
{ {
float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; double pix = (int)Math.Round(Texture.Height * scaleY) - incrementY;
float newscaleY = (float)Math.Round(pix / Texture.Height, 3); double newscaleY = Math.Round(pix / Texture.Height, 3);
scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY);
UniFields.SetFloat(s.Fields, "yscaleceiling", scaleY, 1.0f); UniFields.SetFloat(s.Fields, "yscaleceiling", scaleY, 1.0f);
} }
@ -520,9 +520,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
int imageHeight = Texture.GetAlphaTestHeight(); int imageHeight = Texture.GetAlphaTestHeight();
// Fetch ZDoom fields // Fetch ZDoom fields
double rotate = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0.0f)); double rotate = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0.0));
Vector2D offset = new Vector2D(level.sector.Fields.GetValue("xpanningceiling", 0.0f), level.sector.Fields.GetValue("ypanningceiling", 0.0f)); Vector2D offset = new Vector2D(level.sector.Fields.GetValue("xpanningceiling", 0.0), level.sector.Fields.GetValue("ypanningceiling", 0.0));
Vector2D scale = new Vector2D(level.sector.Fields.GetValue("xscaleceiling", 1.0f), level.sector.Fields.GetValue("yscaleceiling", 1.0f)); Vector2D scale = new Vector2D(level.sector.Fields.GetValue("xscaleceiling", 1.0), level.sector.Fields.GetValue("yscaleceiling", 1.0));
Vector2D texscale = new Vector2D(1.0f / Texture.ScaledWidth, 1.0f / Texture.ScaledHeight); Vector2D texscale = new Vector2D(1.0f / Texture.ScaledWidth, 1.0f / Texture.ScaledHeight);
// Texture coordinates // Texture coordinates

View file

@ -78,11 +78,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.Setup(level, extrafloor); base.Setup(level, extrafloor);
// Fetch ZDoom fields // Fetch ZDoom fields
double rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationfloor", 0.0f)); double rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationfloor", 0.0));
Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0f), Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0),
s.Fields.GetValue("ypanningfloor", 0.0f)); s.Fields.GetValue("ypanningfloor", 0.0));
Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0f), Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0),
s.Fields.GetValue("yscalefloor", 1.0f)); s.Fields.GetValue("yscalefloor", 1.0));
//Load floor texture //Load floor texture
if(s.LongFloorTexture != MapSet.EmptyLongName) if(s.LongFloorTexture != MapSet.EmptyLongName)
@ -213,7 +213,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd //mxd
public override void OnChangeTextureRotation(float angle) public override void OnChangeTextureRotation(double angle)
{ {
// Only do this when not done yet in this call // Only do this when not done yet in this call
// Because we may be able to select the same 3D floor multiple times through multiple sectors // Because we may be able to select the same 3D floor multiple times through multiple sectors
@ -228,8 +228,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Return texture coordinates // Return texture coordinates
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
return new Point { X = (int)Sector.Sector.Fields.GetValue("xpanningfloor", 0.0f), return new Point { X = (int)Sector.Sector.Fields.GetValue("xpanningfloor", 0.0),
Y = (int)Sector.Sector.Fields.GetValue("ypanningfloor", 0.0f) }; Y = (int)Sector.Sector.Fields.GetValue("ypanningfloor", 0.0) };
} }
//mxd //mxd
@ -251,8 +251,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
Sector s = GetControlSector(); Sector s = GetControlSector();
s.Fields.BeforeFieldsChange(); s.Fields.BeforeFieldsChange();
float nx = (s.Fields.GetValue("xpanningfloor", 0.0f) + offsetx) % (Texture.ScaledWidth / s.Fields.GetValue("xscalefloor", 1.0f)); double nx = (s.Fields.GetValue("xpanningfloor", 0.0) + offsetx) % (Texture.ScaledWidth / s.Fields.GetValue("xscalefloor", 1.0));
float ny = (s.Fields.GetValue("ypanningfloor", 0.0f) + offsety) % (Texture.ScaledHeight / s.Fields.GetValue("yscalefloor", 1.0f)); double ny = (s.Fields.GetValue("ypanningfloor", 0.0) + offsety) % (Texture.ScaledHeight / s.Fields.GetValue("yscalefloor", 1.0));
s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, nx); s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, nx);
s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, ny); s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, ny);
s.UpdateNeeded = true; s.UpdateNeeded = true;
@ -265,25 +265,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(Texture == null || !Texture.IsImageLoaded) return; if(Texture == null || !Texture.IsImageLoaded) return;
Sector s = GetControlSector(); Sector s = GetControlSector();
float scaleX = s.Fields.GetValue("xscalefloor", 1.0f); double scaleX = s.Fields.GetValue("xscalefloor", 1.0);
float scaleY = s.Fields.GetValue("yscalefloor", 1.0f); double scaleY = s.Fields.GetValue("yscalefloor", 1.0);
s.Fields.BeforeFieldsChange(); s.Fields.BeforeFieldsChange();
if(incrementX != 0) if(incrementX != 0)
{ {
float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; double pix = (int)Math.Round(Texture.Width * scaleX) - incrementX;
float newscaleX = (float)Math.Round(pix / Texture.Width, 3); double newscaleX = (float)Math.Round(pix / Texture.Width, 3);
scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX);
UniFields.SetFloat(s.Fields, "xscalefloor", scaleX, 1.0f); UniFields.SetFloat(s.Fields, "xscalefloor", scaleX, 1.0);
} }
if(incrementY != 0) if(incrementY != 0)
{ {
float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; double pix = (int)Math.Round(Texture.Height * scaleY) - incrementY;
float newscaleY = (float)Math.Round(pix / Texture.Height, 3); double newscaleY = (float)Math.Round(pix / Texture.Height, 3);
scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY);
UniFields.SetFloat(s.Fields, "yscalefloor", scaleY, 1.0f); UniFields.SetFloat(s.Fields, "yscalefloor", scaleY, 1.0);
} }
mode.SetActionResult("Floor scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ")."); mode.SetActionResult("Floor scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ").");
@ -452,10 +452,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
int imageHeight = Texture.GetAlphaTestHeight(); int imageHeight = Texture.GetAlphaTestHeight();
// Fetch ZDoom fields // Fetch ZDoom fields
double rotate = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0.0f)); double rotate = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0.0));
Vector2D offset = new Vector2D(level.sector.Fields.GetValue("xpanningfloor", 0.0f), level.sector.Fields.GetValue("ypanningfloor", 0.0f)); Vector2D offset = new Vector2D(level.sector.Fields.GetValue("xpanningfloor", 0.0), level.sector.Fields.GetValue("ypanningfloor", 0.0));
Vector2D scale = new Vector2D(level.sector.Fields.GetValue("xscalefloor", 1.0f), level.sector.Fields.GetValue("yscalefloor", 1.0f)); Vector2D scale = new Vector2D(level.sector.Fields.GetValue("xscalefloor", 1.0), level.sector.Fields.GetValue("yscalefloor", 1.0));
Vector2D texscale = new Vector2D(1.0f / Texture.ScaledWidth, 1.0f / Texture.ScaledHeight); Vector2D texscale = new Vector2D(1.0 / Texture.ScaledWidth, 1.0 / Texture.ScaledHeight);
// Texture coordinates // Texture coordinates
Vector2D o = pickintersect; Vector2D o = pickintersect;

View file

@ -97,11 +97,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool lightabsolute; bool lightabsolute;
GetLightValue(out lightvalue, out lightabsolute); GetLightValue(out lightvalue, out lightabsolute);
Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_bottom", 1.0f), Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_bottom", 1.0),
Sidedef.Fields.GetValue("scaley_bottom", 1.0f)); Sidedef.Fields.GetValue("scaley_bottom", 1.0));
Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y));
Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_bottom", 0.0f), Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_bottom", 0.0),
Sidedef.Fields.GetValue("offsety_bottom", 0.0f)); Sidedef.Fields.GetValue("offsety_bottom", 0.0));
// Texture given? // Texture given?
if(Sidedef.LongLowTexture != MapSet.EmptyLongName) if(Sidedef.LongLowTexture != MapSet.EmptyLongName)
@ -271,13 +271,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning; bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning;
float oldx = Sidedef.Fields.GetValue("offsetx_bottom", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_bottom", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_bottom", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_bottom", 0.0);
float scalex = Sidedef.Fields.GetValue("scalex_bottom", 1.0f); double scalex = Sidedef.Fields.GetValue("scalex_bottom", 1.0);
float scaley = Sidedef.Fields.GetValue("scaley_bottom", 1.0f); double scaley = Sidedef.Fields.GetValue("scaley_bottom", 1.0);
bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd
float width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa double width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa
float height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa double height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa
Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa
@ -285,8 +285,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
float oldx = Sidedef.Fields.GetValue("offsetx_bottom", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_bottom", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_bottom", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_bottom", 0.0);
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }

View file

@ -81,13 +81,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool lightabsolute; bool lightabsolute;
GetLightValue(out lightvalue, out lightabsolute); GetLightValue(out lightvalue, out lightabsolute);
Vector2D tscale = new Vector2D(sourceside.Fields.GetValue("scalex_mid", 1.0f), Vector2D tscale = new Vector2D(sourceside.Fields.GetValue("scalex_mid", 1.0),
sourceside.Fields.GetValue("scaley_mid", 1.0f)); sourceside.Fields.GetValue("scaley_mid", 1.0));
Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y));
Vector2D toffset1 = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), Vector2D toffset1 = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0),
Sidedef.Fields.GetValue("offsety_mid", 0.0f)); Sidedef.Fields.GetValue("offsety_mid", 0.0));
Vector2D toffset2 = new Vector2D(sourceside.Fields.GetValue("offsetx_mid", 0.0f), Vector2D toffset2 = new Vector2D(sourceside.Fields.GetValue("offsetx_mid", 0.0),
sourceside.Fields.GetValue("offsety_mid", 0.0f)); sourceside.Fields.GetValue("offsety_mid", 0.0));
// Left and right vertices for this sidedef // Left and right vertices for this sidedef
if(Sidedef.IsFront) if(Sidedef.IsFront)
@ -415,13 +415,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning; bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning;
float oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0);
float scalex = extrafloor.Linedef.Front.Fields.GetValue("scalex_mid", 1.0f); double scalex = extrafloor.Linedef.Front.Fields.GetValue("scalex_mid", 1.0);
float scaley = extrafloor.Linedef.Front.Fields.GetValue("scaley_mid", 1.0f); double scaley = extrafloor.Linedef.Front.Fields.GetValue("scaley_mid", 1.0);
bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd
float width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa double width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa
float height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa double height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa
@ -429,8 +429,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
float oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0);
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }
@ -462,25 +462,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef target = extrafloor.Linedef.Front; Sidedef target = extrafloor.Linedef.Front;
if(target == null) return; if(target == null) return;
float scaleX = target.Fields.GetValue("scalex_mid", 1.0f); double scaleX = target.Fields.GetValue("scalex_mid", 1.0);
float scaleY = target.Fields.GetValue("scaley_mid", 1.0f); double scaleY = target.Fields.GetValue("scaley_mid", 1.0);
target.Fields.BeforeFieldsChange(); target.Fields.BeforeFieldsChange();
if(incrementX != 0) if(incrementX != 0)
{ {
float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; double pix = (int)Math.Round(Texture.Width * scaleX) - incrementX;
float newscaleX = (float)Math.Round(pix / Texture.Width, 3); double newscaleX = Math.Round(pix / Texture.Width, 3);
scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX);
UniFields.SetFloat(target.Fields, "scalex_mid", scaleX, 1.0f); UniFields.SetFloat(target.Fields, "scalex_mid", scaleX, 1.0);
} }
if(incrementY != 0) if(incrementY != 0)
{ {
float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; double pix = (int)Math.Round(Texture.Height * scaleY) - incrementY;
float newscaleY = (float)Math.Round(pix / Texture.Height, 3); double newscaleY = Math.Round(pix / Texture.Height, 3);
scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY);
UniFields.SetFloat(target.Fields, "scaley_mid", scaleY, 1.0f); UniFields.SetFloat(target.Fields, "scaley_mid", scaleY, 1.0);
} }
// Update the model sector to update all 3d floors // Update the model sector to update all 3d floors

View file

@ -37,13 +37,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool lightabsolute; bool lightabsolute;
GetLightValue(out lightvalue, out lightabsolute); GetLightValue(out lightvalue, out lightabsolute);
Vector2D tscale = new Vector2D(sourceside.Fields.GetValue("scalex_mid", 1.0f), Vector2D tscale = new Vector2D(sourceside.Fields.GetValue("scalex_mid", 1.0),
sourceside.Fields.GetValue("scaley_mid", 1.0f)); sourceside.Fields.GetValue("scaley_mid", 1.0));
Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y));
Vector2D toffset1 = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), Vector2D toffset1 = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0),
Sidedef.Fields.GetValue("offsety_mid", 0.0f)); Sidedef.Fields.GetValue("offsety_mid", 0.0));
Vector2D toffset2 = new Vector2D(sourceside.Fields.GetValue("offsetx_mid", 0.0f), Vector2D toffset2 = new Vector2D(sourceside.Fields.GetValue("offsetx_mid", 0.0),
sourceside.Fields.GetValue("offsety_mid", 0.0f)); sourceside.Fields.GetValue("offsety_mid", 0.0));
// Left and right vertices for this sidedef // Left and right vertices for this sidedef
if(Sidedef.IsFront) if(Sidedef.IsFront)

View file

@ -81,11 +81,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool lightabsolute; bool lightabsolute;
GetLightValue(out lightvalue, out lightabsolute); GetLightValue(out lightvalue, out lightabsolute);
Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_mid", 1.0f), Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_mid", 1.0),
Sidedef.Fields.GetValue("scaley_mid", 1.0f)); Sidedef.Fields.GetValue("scaley_mid", 1.0));
Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y));
Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0),
Sidedef.Fields.GetValue("offsety_mid", 0.0f)); Sidedef.Fields.GetValue("offsety_mid", 0.0));
// Left and right vertices for this sidedef // Left and right vertices for this sidedef
if(Sidedef.IsFront) if(Sidedef.IsFront)
@ -367,13 +367,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning; bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning;
float oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0);
float scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0f); double scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0);
float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f); double scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0);
bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd
float width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa double width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa
float height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa double height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa
@ -384,8 +384,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
float oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0);
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }

View file

@ -67,11 +67,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool lightabsolute; bool lightabsolute;
GetLightValue(out lightvalue, out lightabsolute); GetLightValue(out lightvalue, out lightabsolute);
Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_mid", 1.0f), Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_mid", 1.0),
Sidedef.Fields.GetValue("scaley_mid", 1.0f)); Sidedef.Fields.GetValue("scaley_mid", 1.0));
Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y));
Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0),
Sidedef.Fields.GetValue("offsety_mid", 0.0f)); Sidedef.Fields.GetValue("offsety_mid", 0.0));
// Left and right vertices for this sidedef // Left and right vertices for this sidedef
if(Sidedef.IsFront) if(Sidedef.IsFront)
@ -233,26 +233,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override void SetTextureOffsetX(int x) protected override void SetTextureOffsetX(int x)
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, (float)x); Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, (double)x);
} }
protected override void SetTextureOffsetY(int y) protected override void SetTextureOffsetY(int y)
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, (float)y); Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, (double)y);
} }
protected override void MoveTextureOffset(int offsetx, int offsety) protected override void MoveTextureOffset(int offsetx, int offsety)
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning; bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning;
float oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0);
float scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0f); double scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0);
float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f); double scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0);
bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd
float width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa double width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa
float height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa double height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa
@ -260,8 +260,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
float oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_mid", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0);
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }

View file

@ -313,9 +313,9 @@ namespace CodeImp.DoomBuilder.VisualModes
Plane pivotplane = ((VisualSidedefSlope)pivothandle).Level.plane; Plane pivotplane = ((VisualSidedefSlope)pivothandle).Level.plane;
// Build a new plane. p1 and p2 are the points of the slope handle that is modified, p3 is on the line of the pivot handle // Build a new plane. p1 and p2 are the points of the slope handle that is modified, p3 is on the line of the pivot handle
Vector3D p1 = new Vector3D(sidedef.Line.Start.Position, (float)Math.Round(originalplane.GetZ(sidedef.Line.Start.Position))); Vector3D p1 = new Vector3D(sidedef.Line.Start.Position, Math.Round(originalplane.GetZ(sidedef.Line.Start.Position)));
Vector3D p2 = new Vector3D(sidedef.Line.End.Position, (float)Math.Round(originalplane.GetZ(sidedef.Line.End.Position))); Vector3D p2 = new Vector3D(sidedef.Line.End.Position, Math.Round(originalplane.GetZ(sidedef.Line.End.Position)));
Vector3D p3 = new Vector3D(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f), (float)Math.Round(pivotplane.GetZ(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f)))); Vector3D p3 = new Vector3D(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f), Math.Round(pivotplane.GetZ(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f))));
// Move the points of the handle up/down // Move the points of the handle up/down
p1 += new Vector3D(0f, 0f, amount); p1 += new Vector3D(0f, 0f, amount);

View file

@ -98,11 +98,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool lightabsolute; bool lightabsolute;
GetLightValue(out lightvalue, out lightabsolute); GetLightValue(out lightvalue, out lightabsolute);
Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_top", 1.0f), Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_top", 1.0),
Sidedef.Fields.GetValue("scaley_top", 1.0f)); Sidedef.Fields.GetValue("scaley_top", 1.0));
Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y));
Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_top", 0.0f), Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_top", 0.0),
Sidedef.Fields.GetValue("offsety_top", 0.0f)); Sidedef.Fields.GetValue("offsety_top", 0.0));
// Texture given? // Texture given?
if((Sidedef.LongHighTexture != MapSet.EmptyLongName)) if((Sidedef.LongHighTexture != MapSet.EmptyLongName))
@ -268,13 +268,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning; bool worldpanning = this.Texture.WorldPanning || General.Map.Data.MapInfo.ForceWorldPanning;
float oldx = Sidedef.Fields.GetValue("offsetx_top", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_top", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_top", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_top", 0.0);
float scalex = Sidedef.Fields.GetValue("scalex_top", 1.0f); double scalex = Sidedef.Fields.GetValue("scalex_top", 1.0);
float scaley = Sidedef.Fields.GetValue("scaley_top", 1.0f); double scaley = Sidedef.Fields.GetValue("scaley_top", 1.0);
bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd bool textureloaded = (Texture != null && Texture.IsImageLoaded); //mxd
float width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa double width = textureloaded ? (worldpanning ? this.Texture.ScaledWidth / scalex : this.Texture.Width) : -1; // biwa
float height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa double height = textureloaded ? (worldpanning ? this.Texture.ScaledHeight / scaley : this.Texture.Height) : -1; // biwa
Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldx, offsetx, width)); //mxd // biwa
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetNewTexutreOffset(oldy, offsety, height)); //mxd // biwa
@ -282,8 +282,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override Point GetTextureOffset() protected override Point GetTextureOffset()
{ {
float oldx = Sidedef.Fields.GetValue("offsetx_top", 0.0f); double oldx = Sidedef.Fields.GetValue("offsetx_top", 0.0);
float oldy = Sidedef.Fields.GetValue("offsety_top", 0.0f); double oldy = Sidedef.Fields.GetValue("offsety_top", 0.0);
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }