diff --git a/Subsurface/Source/Camera.cs b/Subsurface/Source/Camera.cs index 2102d9cad..021093842 100644 --- a/Subsurface/Source/Camera.cs +++ b/Subsurface/Source/Camera.cs @@ -119,8 +119,6 @@ namespace Barotrauma get { return targetPos; } set { targetPos = value; - System.Diagnostics.Debug.WriteLine(value); - } } diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index d84544a22..78b0b2a7a 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -198,8 +198,15 @@ namespace Barotrauma.Items.Components if (pointDist > radius) continue; if (pointDist > prevPingRadius && pointDist < pingRadius) { - var blip = new RadarBlip(limb.WorldPosition, 1.0f); - radarBlips.Add(blip); + float limbSize = limb.Mass; + + for (int i = 0; i<=limb.Mass/100.0f; i++) + { + var blip = new RadarBlip(limb.WorldPosition+Rand.Vector(limb.Mass/10.0f), 1.0f); + radarBlips.Add(blip); + } + + } } } diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index 05ee49509..0e172816a 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -151,6 +151,9 @@ namespace Barotrauma { if (WallVertices == null || WallVertices.Length <= 0) return; + Stopwatch sw = new Stopwatch(); + sw.Start(); + basicEffect.World = cam.ShaderTransform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; @@ -194,6 +197,10 @@ namespace Barotrauma } } + + sw.Stop(); + + Debug.WriteLine("level render: "+sw.ElapsedTicks); } } diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index fe5db85c5..47777e927 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace Barotrauma.Lights @@ -38,6 +39,8 @@ namespace Barotrauma.Lights private VertexPositionColor[] shadowVertices; private VertexPositionTexture[] penumbraVertices; + int shadowVertexCount; + private Entity parentEntity; private Rectangle boundingBox; @@ -73,6 +76,10 @@ namespace Barotrauma.Lights cachedShadows = new Dictionary(); + shadowVertices = new VertexPositionColor[6 * 2]; + penumbraVertices = new VertexPositionTexture[6]; + + vertices = points; primitiveCount = vertices.Length; @@ -139,6 +146,8 @@ namespace Barotrauma.Lights private void CalculateShadowVertices(Vector2 lightSourcePos, bool los = true) { + shadowVertexCount = 0; + //compute facing of each edge, using N*L for (int i = 0; i < primitiveCount; i++) { @@ -172,15 +181,13 @@ namespace Barotrauma.Lights startingIndex = nextEdge; } - int shadowVertexCount; - //nr of vertices that are in the shadow if (endingIndex > startingIndex) shadowVertexCount = endingIndex - startingIndex + 1; else shadowVertexCount = primitiveCount + 1 - startingIndex + endingIndex; - shadowVertices = new VertexPositionColor[shadowVertexCount * 2]; + //shadowVertices = new VertexPositionColor[shadowVertexCount * 2]; //create a triangle strip that has the shape of the shadow int currentIndex = startingIndex; @@ -213,8 +220,6 @@ namespace Barotrauma.Lights private void CalculatePenumbraVertices(int startingIndex, int endingIndex, Vector2 lightSourcePos, bool los) { - penumbraVertices = new VertexPositionTexture[6]; - for (int n = 0; n < 4; n += 3) { Vector3 penumbraStart = new Vector3((n == 0) ? vertices[startingIndex] : vertices[endingIndex], 0.0f); @@ -309,18 +314,23 @@ namespace Barotrauma.Lights private void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Matrix transform, bool los = true) { + Vector3 offset = Vector3.Zero; if (parentEntity != null && parentEntity.Submarine != null) { offset = new Vector3(parentEntity.Submarine.DrawPosition.X, parentEntity.Submarine.DrawPosition.Y, 0.0f); } + if (shadowVertexCount>0) + { + shadowEffect.World = Matrix.CreateTranslation(offset) * transform; + shadowEffect.CurrentTechnique.Passes[0].Apply(); - shadowEffect.World = Matrix.CreateTranslation(offset) * transform; - shadowEffect.CurrentTechnique.Passes[0].Apply(); - - graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertices.Length - 2); + graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount*2 - 2); + } + + if (los) { penumbraEffect.World = shadowEffect.World; @@ -330,6 +340,7 @@ namespace Barotrauma.Lights graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration); #endif } + } public void Remove() diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index f8e5d554d..5dd00f0ce 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -60,6 +60,10 @@ namespace Barotrauma.Lights public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 pos) { + + Stopwatch sw = new Stopwatch(); + sw.Start(); + if (!LosEnabled) return; Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height); @@ -75,6 +79,9 @@ namespace Barotrauma.Lights convexHull.DrawShadows(graphics, cam, pos, shadowTransform); } + sw.Stop(); + + Debug.WriteLine("drawlos: " + sw.ElapsedTicks + " (" + sw.ElapsedMilliseconds + ")"); if (!ObstructVision) return; spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative); @@ -82,6 +89,7 @@ namespace Barotrauma.Lights spriteBatch.End(); ObstructVision = false; + } public void OnMapLoaded() @@ -94,6 +102,10 @@ namespace Barotrauma.Lights public void UpdateLightMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam) { + + Stopwatch sw = new Stopwatch(); + sw.Start(); + if (!LightingEnabled) return; Matrix shadowTransform = cam.ShaderTransform @@ -152,6 +164,10 @@ namespace Barotrauma.Lights graphics.SetRenderTarget(null); + Debug.WriteLine("lights: " + sw.ElapsedTicks + " (" + sw.ElapsedMilliseconds + ")"); + if (!ObstructVision) return; + + } public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 lookAtPosition) diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 3ef76c980..2539b262f 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ