diff --git a/Source/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/BuilderModes/VisualModes/BaseVisualThing.cs index 083b4c88..1d747acd 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualThing.cs @@ -93,11 +93,10 @@ namespace CodeImp.DoomBuilder.BuilderModes if(Thing.Sector != null) { // Use sector brightness for color shading - sectorcolor = new PixelColor(255, unchecked((byte)Thing.Sector.Brightness), - unchecked((byte)Thing.Sector.Brightness), - unchecked((byte)Thing.Sector.Brightness)); + byte brightness = (byte)General.Clamp(Thing.Sector.Brightness, 0, 255); + sectorcolor = new PixelColor(255, brightness, brightness, brightness); } - + // Check if the texture is loaded sprite.LoadImage(); isloaded = sprite.IsImageLoaded; diff --git a/Source/BuilderModes/VisualModes/VisualCeiling.cs b/Source/BuilderModes/VisualModes/VisualCeiling.cs index cca35c4d..d39e667b 100644 --- a/Source/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/BuilderModes/VisualModes/VisualCeiling.cs @@ -68,6 +68,7 @@ namespace CodeImp.DoomBuilder.BuilderModes WorldVertex[] verts; WorldVertex v; Sector s = base.Sector.Sector; + byte brightness = (byte)General.Clamp(s.Brightness, 0, 255); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture); @@ -87,9 +88,7 @@ namespace CodeImp.DoomBuilder.BuilderModes for(int i = 0; i < s.Triangles.Vertices.Count; i++) { // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, unchecked((byte)s.Brightness), - unchecked((byte)s.Brightness), - unchecked((byte)s.Brightness)); + PixelColor pc = new PixelColor(255, brightness, brightness, brightness); verts[i].c = pc.ToInt(); //verts[i].c = -1; diff --git a/Source/BuilderModes/VisualModes/VisualFloor.cs b/Source/BuilderModes/VisualModes/VisualFloor.cs index b649bee4..7c330b0b 100644 --- a/Source/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/BuilderModes/VisualModes/VisualFloor.cs @@ -67,6 +67,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { WorldVertex[] verts; Sector s = base.Sector.Sector; + byte brightness = (byte)General.Clamp(s.Brightness, 0, 255); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongFloorTexture); @@ -86,9 +87,7 @@ namespace CodeImp.DoomBuilder.BuilderModes for(int i = 0; i < s.Triangles.Vertices.Count; i++) { // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, unchecked((byte)s.Brightness), - unchecked((byte)s.Brightness), - unchecked((byte)s.Brightness)); + PixelColor pc = new PixelColor(255, brightness, brightness, brightness); verts[i].c = pc.ToInt(); //verts[i].c = -1; diff --git a/Source/BuilderModes/VisualModes/VisualLower.cs b/Source/BuilderModes/VisualModes/VisualLower.cs index 30ec7d7a..949ac9b8 100644 --- a/Source/BuilderModes/VisualModes/VisualLower.cs +++ b/Source/BuilderModes/VisualModes/VisualLower.cs @@ -65,6 +65,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { + byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + // Calculate size of this wall part float geotop = (float)Sidedef.Other.Sector.FloorHeight; float geobottom = (float)Sidedef.Sector.FloorHeight; @@ -133,9 +135,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness)); + PixelColor pc = new PixelColor(255, brightness, brightness, brightness); // Make vertices WorldVertex[] verts = new WorldVertex[6]; diff --git a/Source/BuilderModes/VisualModes/VisualMiddleDouble.cs b/Source/BuilderModes/VisualModes/VisualMiddleDouble.cs index 1d592be5..c1f945cb 100644 --- a/Source/BuilderModes/VisualModes/VisualMiddleDouble.cs +++ b/Source/BuilderModes/VisualModes/VisualMiddleDouble.cs @@ -68,6 +68,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { + byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + // Calculate size of this wall part float geotop = (float)Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight); float geobottom = (float)Math.Max(Sidedef.Sector.FloorHeight, Sidedef.Other.Sector.FloorHeight); @@ -143,9 +145,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness)); + PixelColor pc = new PixelColor(255, brightness, brightness, brightness); // Make vertices WorldVertex[] verts = new WorldVertex[6]; diff --git a/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs b/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs index 624e725b..74455d2e 100644 --- a/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs +++ b/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs @@ -65,6 +65,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { + byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + // Calculate size of this wall part float geotop = (float)Sidedef.Sector.CeilHeight; float geobottom = (float)Sidedef.Sector.FloorHeight; @@ -133,9 +135,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness)); + PixelColor pc = new PixelColor(255, brightness, brightness, brightness); // Make vertices WorldVertex[] verts = new WorldVertex[6]; diff --git a/Source/BuilderModes/VisualModes/VisualUpper.cs b/Source/BuilderModes/VisualModes/VisualUpper.cs index 3a674fea..016847ba 100644 --- a/Source/BuilderModes/VisualModes/VisualUpper.cs +++ b/Source/BuilderModes/VisualModes/VisualUpper.cs @@ -65,6 +65,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // This builds the geometry. Returns false when no geometry created. public override bool Setup() { + byte brightness = (byte)General.Clamp(Sidedef.Sector.Brightness, 0, 255); + // Calculate size of this wall part float geotop = (float)Sidedef.Sector.CeilHeight; float geobottom = (float)Sidedef.Other.Sector.CeilHeight; @@ -133,9 +135,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Use sector brightness for color shading - PixelColor pc = new PixelColor(255, unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness), - unchecked((byte)Sidedef.Sector.Brightness)); + PixelColor pc = new PixelColor(255, brightness, brightness, brightness); // Make vertices WorldVertex[] verts = new WorldVertex[6];