From 3a674189856a37ae516d0d11ee9ee6bc4800b15a Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Wed, 11 Oct 2017 22:52:13 -0300 Subject: [PATCH] Minor optimizations + Potential bugfixes --- .../BarotraumaClient/Source/GameMain.cs | 4 ++++ .../Source/Particles/Particle.cs | 21 +++++++++++++++++-- .../BarotraumaShared/Content/Content.mgcb | 2 +- .../BarotraumaShared/Content/watershader.fx | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index a31dc8cf6..a9982d023 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -111,6 +111,7 @@ namespace Barotrauma public GameMain() { GraphicsDeviceManager = new GraphicsDeviceManager(this); + Window.Title = "Barotrauma"; Instance = this; @@ -145,6 +146,9 @@ namespace Barotrauma { GraphicsWidth = Config.GraphicsWidth; GraphicsHeight = Config.GraphicsHeight; + GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.HiDef; + GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Bgra32; + GraphicsDeviceManager.PreferMultiSampling = false; GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled; if (Config.WindowMode == WindowMode.Windowed) diff --git a/Barotrauma/BarotraumaClient/Source/Particles/Particle.cs b/Barotrauma/BarotraumaClient/Source/Particles/Particle.cs index 5bed056b8..a8b5e36f1 100644 --- a/Barotrauma/BarotraumaClient/Source/Particles/Particle.cs +++ b/Barotrauma/BarotraumaClient/Source/Particles/Particle.cs @@ -23,6 +23,9 @@ namespace Barotrauma.Particles private float angularVelocity; + private Vector2 dragVec = Vector2.Zero; + private int dragWait = 0; + private Vector2 size; private Vector2 sizeChange; @@ -271,10 +274,24 @@ namespace Barotrauma.Particles private void ApplyDrag(float dragCoefficient, float deltaTime) { + if (velocity.LengthSquared() < dragVec.LengthSquared()) + { + velocity = Vector2.Zero; + return; + } if (Math.Abs(velocity.X) < 0.0001f && Math.Abs(velocity.Y) < 0.0001f) return; - float speed = velocity.Length(); - velocity -= (velocity / speed) * Math.Min(speed * speed * dragCoefficient * deltaTime, 1.0f); + dragWait--; + if (dragWait<=0) + { + dragWait = 30; + + float speed = velocity.Length(); + + dragVec = (velocity / speed) * Math.Min(speed * speed * dragCoefficient * deltaTime, 1.0f); + } + + velocity -= dragVec; } private void OnWallCollisionInside(Hull prevHull, Vector2 collisionNormal) diff --git a/Barotrauma/BarotraumaShared/Content/Content.mgcb b/Barotrauma/BarotraumaShared/Content/Content.mgcb index 9cf60ed0f..65666e6c8 100644 --- a/Barotrauma/BarotraumaShared/Content/Content.mgcb +++ b/Barotrauma/BarotraumaShared/Content/Content.mgcb @@ -5,7 +5,7 @@ /intermediateDir:obj/$(Platform) /platform:Windows /config: -/profile:Reach +/profile:HiDef /compress:False #-------------------------------- References --------------------------------# diff --git a/Barotrauma/BarotraumaShared/Content/watershader.fx b/Barotrauma/BarotraumaShared/Content/watershader.fx index 2b9467064..2412c3df6 100644 --- a/Barotrauma/BarotraumaShared/Content/watershader.fx +++ b/Barotrauma/BarotraumaShared/Content/watershader.fx @@ -27,7 +27,7 @@ float2 xBumpPos; float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0 { float4 bumpColor = tex2D(WaterBumpSampler, texCoord+xWavePos+xBumpPos); - bumpColor = (bumpColor + tex2D(WaterBumpSampler, texCoord-xWavePos*2.0f+xBumpPos))/2.0f; + bumpColor = (bumpColor + tex2D(WaterBumpSampler, texCoord-xWavePos*2.0f+xBumpPos))*0.5f; float2 samplePos = texCoord; @@ -40,7 +40,7 @@ float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoor sample += tex2D( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y-xBlurDistance)); sample += tex2D( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y+xBlurDistance)); - sample = sample / 4; + sample = sample * 0.25; return sample; }