RegEx, FindPickable & DrawShadows optimization

This commit is contained in:
Regalis
2015-09-27 17:02:15 +03:00
parent c8ee9e085f
commit 97c3ac1412
8 changed files with 124 additions and 91 deletions
+2 -3
View File
@@ -111,7 +111,7 @@ namespace Subsurface.Lights
}
}
public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, bool los = true)
public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, Matrix transform, bool los = true)
{
if (!Enabled) return;
@@ -224,8 +224,7 @@ namespace Subsurface.Lights
currentIndex = (currentIndex + 1) % primitiveCount;
}
shadowEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
shadowEffect.World = transform;
shadowEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);
+8 -2
View File
@@ -59,18 +59,24 @@ namespace Subsurface.Lights
{
Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height);
Matrix shadowTransform = cam.ShaderTransform
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
if (!LosEnabled) return;
foreach (ConvexHull convexHull in ConvexHull.list)
{
if (!camView.Intersects(convexHull.BoundingBox)) continue;
convexHull.DrawShadows(graphics, cam, pos);
convexHull.DrawShadows(graphics, cam, pos, shadowTransform);
}
}
public void DrawLightmap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
{
Matrix shadowTransform = cam.ShaderTransform
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
graphics.SetRenderTarget(lightMap);
Rectangle viewRect = cam.WorldView;
@@ -96,7 +102,7 @@ namespace Subsurface.Lights
{
if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
//draw shadow
ch.DrawShadows(graphics, cam, light.Position, false);
ch.DrawShadows(graphics, cam, light.Position, shadowTransform, false);
}
//draw the light shape