pvsrange vec2 + eyezoom (#7392)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
/// <summary>
|
||||
/// How far away do we update gas overlays (minimum; due to chunking further away tiles may also be updated).
|
||||
/// </summary>
|
||||
private float _updateRange;
|
||||
private Vector2 _updateRange;
|
||||
|
||||
// Because the gas overlay updates aren't run every tick we need to avoid the pop-in that might occur with
|
||||
// the regular PVS range.
|
||||
@@ -70,7 +70,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
var configManager = IoCManager.Resolve<IConfigurationManager>();
|
||||
configManager.OnValueChanged(CCVars.NetGasOverlayTickRate, value => _updateCooldown = value > 0.0f ? 1 / value : float.MaxValue, true);
|
||||
configManager.OnValueChanged(CVars.NetMaxUpdateRange, value => _updateRange = value + RangeOffset, true);
|
||||
configManager.OnValueChanged(CVars.NetDefaultUpdateRange, value => _updateRange = value + RangeOffset, true);
|
||||
configManager.OnValueChanged(CCVars.GasOverlayThresholds, value => _thresholds = value, true);
|
||||
}
|
||||
|
||||
@@ -193,10 +193,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
var inRange = new List<GasOverlayChunk>();
|
||||
|
||||
// This is the max in any direction that we can get a chunk (e.g. max 2 chunks away of data).
|
||||
var (maxXDiff, maxYDiff) = ((int) (_updateRange / ChunkSize) + 1, (int) (_updateRange / ChunkSize) + 1);
|
||||
var (maxXDiff, maxYDiff) = ((int) (_updateRange.X / ChunkSize) + 1, (int) (_updateRange.Y / ChunkSize) + 1);
|
||||
|
||||
var worldBounds = Box2.CenteredAround(EntityManager.GetComponent<TransformComponent>(entity).WorldPosition,
|
||||
new Vector2(_updateRange, _updateRange));
|
||||
_updateRange);
|
||||
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(EntityManager.GetComponent<TransformComponent>(entity).MapID, worldBounds))
|
||||
{
|
||||
@@ -219,10 +219,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
// (e.g. if we're on the very edge of a chunk we may need more chunks).
|
||||
|
||||
var (xDiff, yDiff) = (chunkIndices.X - entityTile.X, chunkIndices.Y - entityTile.Y);
|
||||
if (xDiff > 0 && xDiff > _updateRange ||
|
||||
yDiff > 0 && yDiff > _updateRange ||
|
||||
xDiff < 0 && Math.Abs(xDiff + ChunkSize) > _updateRange ||
|
||||
yDiff < 0 && Math.Abs(yDiff + ChunkSize) > _updateRange) continue;
|
||||
if (xDiff > 0 && xDiff > _updateRange.X ||
|
||||
yDiff > 0 && yDiff > _updateRange.Y ||
|
||||
xDiff < 0 && Math.Abs(xDiff + ChunkSize) > _updateRange.X ||
|
||||
yDiff < 0 && Math.Abs(yDiff + ChunkSize) > _updateRange.Y) continue;
|
||||
|
||||
inRange.Add(chunk);
|
||||
}
|
||||
|
||||
@@ -18,23 +18,23 @@ namespace Content.Shared.Decals
|
||||
public const int ChunkSize = 32;
|
||||
public static Vector2i GetChunkIndices(Vector2 coordinates) => new ((int) Math.Floor(coordinates.X / ChunkSize), (int) Math.Floor(coordinates.Y / ChunkSize));
|
||||
|
||||
private float _viewSize;
|
||||
private Vector2 _viewSize;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<GridInitializeEvent>(OnGridInitialize);
|
||||
_configurationManager.OnValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged, true);
|
||||
_configurationManager.OnValueChanged(CVars.NetDefaultUpdateRange, OnPvsRangeChanged, true);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_configurationManager.UnsubValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged);
|
||||
_configurationManager.UnsubValueChanged(CVars.NetDefaultUpdateRange, OnPvsRangeChanged);
|
||||
}
|
||||
|
||||
private void OnPvsRangeChanged(float obj)
|
||||
private void OnPvsRangeChanged(Vector2 obj)
|
||||
{
|
||||
_viewSize = obj * 2f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user