Submarines, items and characters that reach a depth of 300,000 units (~4000 m) are automatically disabled. Avoids the unnecessary cost of updating entities that are way too deep to be reached by anyone.

This commit is contained in:
Joonas Rikkonen
2017-08-13 19:52:56 +03:00
parent 98b4b904d4
commit 4d40f5d483
11 changed files with 83 additions and 25 deletions
+8 -3
View File
@@ -139,12 +139,17 @@ namespace Barotrauma
if (Level.Loaded != null && clampPos)
{
position.Y -= Math.Max(worldView.Y - Level.Loaded.Size.Y, 0.0f);
interpolatedPosition.Y -= Math.Max(worldView.Y - Level.Loaded.Size.Y, 0.0f);
float maxY = Level.Loaded.Size.Y + 100;
worldView.Y = Math.Min((int)Level.Loaded.Size.Y, worldView.Y);
position.Y -= Math.Max(worldView.Y - maxY, 0.0f);
interpolatedPosition.Y -= Math.Max(worldView.Y - maxY, 0.0f);
position.Y = Math.Max(position.Y, (int)Level.MaxCameraDepth);
interpolatedPosition.Y = Math.Max(interpolatedPosition.Y, (int)Level.MaxCameraDepth);
worldView.Y = MathHelper.Clamp(worldView.Y, (int)Level.MaxCameraDepth, (int)maxY);
}
transform = Matrix.CreateTranslation(
new Vector3(-interpolatedPosition.X, interpolatedPosition.Y, 0)) *
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *