Player characters arent AICharacters in multiplayer, lighting optimization

This commit is contained in:
Regalis11
2015-12-13 18:02:43 +02:00
parent 04cfca0ede
commit c74caadc42
9 changed files with 38 additions and 34 deletions

View File

@@ -125,6 +125,18 @@ namespace Barotrauma.Lights
vertices = points;
}
public bool Intersects(Rectangle rect)
{
Rectangle transformedBounds = boundingBox;
if (parentEntity != null && parentEntity.Submarine != null)
{
transformedBounds.X += (int)parentEntity.Submarine.Position.X;
transformedBounds.Y += (int)parentEntity.Submarine.Position.Y;
}
return transformedBounds.Intersects(rect);
}
private void CalculateShadowVertices(Vector2 lightSourcePos, bool los = true)
{
//compute facing of each edge, using N*L

View File

@@ -69,6 +69,7 @@ namespace Barotrauma.Lights
foreach (ConvexHull convexHull in ConvexHull.list)
{
if (!convexHull.Intersects(camView)) continue;
//if (!camView.Intersects(convexHull.BoundingBox)) continue;
convexHull.DrawShadows(graphics, cam, pos, shadowTransform);
@@ -109,7 +110,7 @@ namespace Barotrauma.Lights
foreach (LightSource light in lights)
{
if (light.hullsInRange.Count == 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
//if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue;
if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
//clear alpha to 1
ClearAlphaToOne(graphics, spriteBatch);
@@ -121,7 +122,7 @@ namespace Barotrauma.Lights
foreach (ConvexHull ch in light.hullsInRange)
{
//if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
//draw shadow
ch.DrawShadows(graphics, cam, light, shadowTransform, false);
}