Removed a redundant DrawRectangle method & redundant sub visibility culling in GameScreen

This commit is contained in:
Regalis
2016-11-12 18:29:39 +02:00
parent 0353732e7e
commit c2098f06f8
5 changed files with 17 additions and 40 deletions
+14 -21
View File
@@ -272,16 +272,6 @@ namespace Barotrauma
} }
} }
public static void DrawRectangle(SpriteBatch sb, Rectangle rect, Color clr, int thickness, float depth = 0.0f)
{
DrawLine(sb, new Vector2(rect.X, rect.Y), new Vector2(rect.Right, rect.Y), clr, depth, thickness);
DrawLine(sb, new Vector2(rect.X, rect.Bottom-thickness), new Vector2(rect.Right, rect.Bottom-thickness), clr, depth, thickness);
DrawLine(sb, new Vector2(rect.X+thickness, rect.Y+thickness), new Vector2(rect.X+thickness, rect.Bottom-thickness), clr, depth, thickness);
DrawLine(sb, new Vector2(rect.Right, rect.Y + thickness), new Vector2(rect.Right, rect.Bottom - thickness), clr, depth, thickness);
}
public static void DrawProgressBar(SpriteBatch sb, Vector2 start, Vector2 size, float progress, Color clr, float depth = 0.0f) public static void DrawProgressBar(SpriteBatch sb, Vector2 start, Vector2 size, float progress, Color clr, float depth = 0.0f)
{ {
DrawProgressBar(sb, start, size, progress, clr, new Color(0.5f, 0.57f, 0.6f, 1.0f), depth); DrawProgressBar(sb, start, size, progress, clr, new Color(0.5f, 0.57f, 0.6f, 1.0f), depth);
@@ -428,27 +418,30 @@ namespace Barotrauma
if (GameMain.DebugDraw) if (GameMain.DebugDraw)
{ {
spriteBatch.DrawString(SmallFont, DrawString(spriteBatch, new Vector2(10, 10),
"FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond, "FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond,
new Vector2(10, 10), Color.White); Color.White, Color.Black * 0.5f, 0, SmallFont);
spriteBatch.DrawString(SmallFont, DrawString(spriteBatch, new Vector2(10, 20),
"Physics: " + GameMain.World.UpdateTime, "Physics: " + GameMain.World.UpdateTime,
new Vector2(10, 20), Color.White); Color.White, Color.Black * 0.5f, 0, SmallFont);
spriteBatch.DrawString(SmallFont, DrawString(spriteBatch, new Vector2(10, 30),
"Bodies: " + GameMain.World.BodyList.Count + " (" + GameMain.World.BodyList.FindAll(b => b.Awake && b.Enabled).Count + " awake)", "Bodies: " + GameMain.World.BodyList.Count + " (" + GameMain.World.BodyList.FindAll(b => b.Awake && b.Enabled).Count + " awake)",
new Vector2(10, 30), Color.White); Color.White, Color.Black * 0.5f, 0, SmallFont);
spriteBatch.DrawString(SmallFont, if (Screen.Selected.Cam != null)
"Camera pos: " + GameMain.GameScreen.Cam.Position.ToPoint(), {
new Vector2(10, 40), Color.White); DrawString(spriteBatch, new Vector2(10, 40),
"Camera pos: " + Screen.Selected.Cam.Position.ToPoint(),
Color.White, Color.Black * 0.5f, 0, SmallFont);
}
if (Submarine.MainSub != null) if (Submarine.MainSub != null)
{ {
spriteBatch.DrawString(SmallFont, DrawString(spriteBatch, new Vector2(10, 50),
"Sub pos: " + Submarine.MainSub.Position.ToPoint(), "Sub pos: " + Submarine.MainSub.Position.ToPoint(),
new Vector2(10, 50), Color.White); Color.White, Color.Black * 0.5f, 0, SmallFont);
} }
for (int i = 1; i < Sounds.SoundManager.DefaultSourceCount; i++) for (int i = 1; i < Sounds.SoundManager.DefaultSourceCount; i++)
@@ -190,7 +190,7 @@ namespace Barotrauma.Items.Components
Color.Black * 0.5f, 2, GUI.SmallFont); Color.Black * 0.5f, 2, GUI.SmallFont);
} }
GUI.DrawRectangle(spriteBatch, hullRect, borderColor, 2); GUI.DrawRectangle(spriteBatch, hullRect, borderColor, false, 0.0f, 2);
} }
} }
+1 -1
View File
@@ -358,7 +358,7 @@ namespace Barotrauma
} }
rect.Inflate(8, 8); rect.Inflate(8, 8);
GUI.DrawRectangle(spriteBatch, rect, Color.Black, 8); GUI.DrawRectangle(spriteBatch, rect, Color.Black, false, 0.0f, 8);
GUI.DrawRectangle(spriteBatch, rect, Color.LightGray); GUI.DrawRectangle(spriteBatch, rect, Color.LightGray);
for (int i = 0; i < locations.Count; i++) for (int i = 0; i < locations.Count; i++)
+1 -1
View File
@@ -352,7 +352,7 @@ namespace Barotrauma
worldBorders.Location += sub.WorldPosition.ToPoint(); worldBorders.Location += sub.WorldPosition.ToPoint();
worldBorders.Y = -worldBorders.Y; worldBorders.Y = -worldBorders.Y;
GUI.DrawRectangle(spriteBatch, worldBorders, Color.White, 5); GUI.DrawRectangle(spriteBatch, worldBorders, Color.White, false, 0, 5);
if (sub.subBody.MemPos.Count < 2) continue; if (sub.subBody.MemPos.Count < 2) continue;
-16
View File
@@ -227,22 +227,6 @@ namespace Barotrauma
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition); GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
} }
List<Submarine> visibleSubs = new List<Submarine>();
foreach (Submarine sub in Submarine.Loaded)
{
Rectangle worldBorders = new Rectangle(
sub.Borders.X + (int)sub.WorldPosition.X - 500,
sub.Borders.Y + (int)sub.WorldPosition.Y + 500,
sub.Borders.Width + 1000,
sub.Borders.Height + 1000);
if (Submarine.RectsOverlap(worldBorders, cam.WorldView))
{
visibleSubs.Add(sub);
}
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
//1. draw the background, characters and the parts of the submarine that are behind them //1. draw the background, characters and the parts of the submarine that are behind them
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------