Backported vsync changes from new-netcode, WIP hull visibility culling

The hull culling functions are there, they just aren't being used right now because there are some annoying bugs.
This commit is contained in:
juanjp600
2016-10-02 22:24:31 -03:00
parent 75e7b3a94e
commit e1296e4a8e
27 changed files with 316 additions and 99 deletions

View File

@@ -453,13 +453,11 @@ namespace Barotrauma
if (pauseMenuOpen)
{
pauseMenu.Update(0.016f);
pauseMenu.Draw(spriteBatch);
}
if (settingsMenuOpen)
{
GameMain.Config.SettingsFrame.Update(0.016f);
GameMain.Config.SettingsFrame.Draw(spriteBatch);
}
@@ -472,6 +470,16 @@ namespace Barotrauma
public static void Update(float deltaTime)
{
if (pauseMenuOpen)
{
pauseMenu.Update(0.016f);
}
if (settingsMenuOpen)
{
GameMain.Config.SettingsFrame.Update(0.016f);
}
if (GUIMessageBox.MessageBoxes.Count > 0)
{
var messageBox = GUIMessageBox.MessageBoxes.Peek();

View File

@@ -162,38 +162,6 @@ namespace Barotrauma
{
if (!Visible) return;
if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
{
state = ComponentState.Hover;
if (PlayerInput.LeftButtonHeld())
{
if (OnPressed != null)
{
if (OnPressed()) state = ComponentState.Selected;
}
}
else if (PlayerInput.LeftButtonClicked())
{
GUI.PlayUISound(GUISoundType.Click);
if (OnClicked != null)
{
if (OnClicked(this, UserData) && CanBeSelected) state = ComponentState.Selected;
}
else
{
Selected = !Selected;
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
}
}
}
else
{
state = Selected ? ComponentState.Selected : ComponentState.None;
}
frame.State = state;
//Color currColor = color;
//if (state == ComponentState.Hover) currColor = hoverColor;
//if (state == ComponentState.Selected) currColor = selectedColor;
@@ -208,5 +176,40 @@ namespace Barotrauma
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
}
public override void Update(float deltaTime)
{
if (!Visible) return;
base.Update(deltaTime);
if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
{
state = ComponentState.Hover;
if (PlayerInput.LeftButtonHeld())
{
if (OnPressed != null)
{
if (OnPressed()) state = ComponentState.Selected;
}
}
else if (PlayerInput.LeftButtonClicked())
{
GUI.PlayUISound(GUISoundType.Click);
if (OnClicked != null)
{
if (OnClicked(this, UserData) && CanBeSelected) state = ComponentState.Selected;
}
else
{
Selected = !Selected;
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
}
}
}
else
{
state = Selected ? ComponentState.Selected : ComponentState.None;
}
frame.State = state;
}
}
}

View File

@@ -317,10 +317,13 @@ namespace Barotrauma
}
for (int i = 0; i < children.Count; i++)
//use a fixed list since children can change their order in the main children list
//TODO: maybe find a more efficient way of handling changes in list order
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
foreach (GUIComponent c in fixedChildren)
{
if (!children[i].Visible) continue;
children[i].Update(deltaTime);
if (!c.Visible) continue;
c.Update(deltaTime);
}
}

View File

@@ -101,6 +101,7 @@ namespace Barotrauma
if (Hull.renderer != null)
{
Hull.renderer.ScrollWater(deltaTime);
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
}