Player characters arent AICharacters in multiplayer, lighting optimization
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -507,8 +507,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
for (int i = 0; i<mapEntityList.Count; i++)
|
||||
{
|
||||
MapEntity e = mapEntityList[i];
|
||||
|
||||
e.OnMapLoaded();
|
||||
|
||||
if (e.Submarine != null) e.Move(Submarine.HiddenSubPosition);
|
||||
@@ -516,10 +518,10 @@ namespace Barotrauma
|
||||
|
||||
|
||||
|
||||
mapEntityList.Sort((x, y) =>
|
||||
{
|
||||
return x.Name.CompareTo(y.Name);
|
||||
});
|
||||
//mapEntityList.Sort((x, y) =>
|
||||
//{
|
||||
// return x.Name.CompareTo(y.Name);
|
||||
//});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user