Revert "Add heat distortion shader for hot gases" (#40352)

This commit is contained in:
slarticodefast
2025-09-14 20:48:24 +02:00
committed by GitHub
parent b9ddcc9e9f
commit a38c6c1aca
7 changed files with 14 additions and 443 deletions

View File

@@ -1,4 +1,6 @@
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
@@ -11,6 +13,7 @@ using JetBrains.Annotations;
using Microsoft.Extensions.ObjectPool;
using Robust.Server.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
@@ -29,6 +32,7 @@ namespace Content.Server.Atmos.EntitySystems
[Robust.Shared.IoC.Dependency] private readonly IGameTiming _gameTiming = default!;
[Robust.Shared.IoC.Dependency] private readonly IPlayerManager _playerManager = default!;
[Robust.Shared.IoC.Dependency] private readonly IMapManager _mapManager = default!;
[Robust.Shared.IoC.Dependency] private readonly IConfigurationManager _confMan = default!;
[Robust.Shared.IoC.Dependency] private readonly IParallelManager _parMan = default!;
[Robust.Shared.IoC.Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Robust.Shared.IoC.Dependency] private readonly ChunkingSystem _chunkingSys = default!;
@@ -60,12 +64,6 @@ namespace Content.Server.Atmos.EntitySystems
private EntityQuery<MapGridComponent> _gridQuery;
private EntityQuery<GasTileOverlayComponent> _query;
/// <summary>
/// How much the distortion strength should change for the temperature of a tile to be dirtied.
/// The strength goes from 0.0f to 1.0f, so 0.05f gives it essentially 20 "steps"
/// </summary>
private float _heatDistortionStrengthChangeTolerance;
public override void Initialize()
{
base.Initialize();
@@ -87,10 +85,9 @@ namespace Content.Server.Atmos.EntitySystems
};
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
Subs.CVar(ConfMan, CCVars.NetGasOverlayTickRate, UpdateTickRate, true);
Subs.CVar(ConfMan, CCVars.GasOverlayThresholds, UpdateThresholds, true);
Subs.CVar(ConfMan, CVars.NetPVS, OnPvsToggle, true);
Subs.CVar(ConfMan, CCVars.GasOverlayHeatThreshold, UpdateHeatThresholds, true);
Subs.CVar(_confMan, CCVars.NetGasOverlayTickRate, UpdateTickRate, true);
Subs.CVar(_confMan, CCVars.GasOverlayThresholds, UpdateThresholds, true);
Subs.CVar(_confMan, CVars.NetPVS, OnPvsToggle, true);
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<GasTileOverlayComponent, ComponentStartup>(OnStartup);
@@ -140,7 +137,6 @@ namespace Content.Server.Atmos.EntitySystems
private void UpdateTickRate(float value) => _updateInterval = value > 0.0f ? 1 / value : float.MaxValue;
private void UpdateThresholds(int value) => _thresholds = value;
private void UpdateHeatThresholds(float v) => _heatDistortionStrengthChangeTolerance = MathHelper.Clamp01(v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Invalidate(Entity<GasTileOverlayComponent?> grid, Vector2i index)
@@ -179,9 +175,7 @@ namespace Content.Server.Atmos.EntitySystems
public GasOverlayData GetOverlayData(GasMixture? mixture)
{
var data = new GasOverlayData(0,
new byte[VisibleGasId.Length],
mixture?.Temperature ?? Atmospherics.TCMB);
var data = new GasOverlayData(0, new byte[VisibleGasId.Length]);
for (var i = 0; i < VisibleGasId.Length; i++)
{
@@ -221,17 +215,15 @@ namespace Content.Server.Atmos.EntitySystems
}
var changed = false;
var temp = tile.Hotspot.Valid ? tile.Hotspot.Temperature : tile.Air?.Temperature ?? Atmospherics.TCMB;
if (oldData.Equals(default))
{
changed = true;
oldData = new GasOverlayData(tile.Hotspot.State, new byte[VisibleGasId.Length], temp);
oldData = new GasOverlayData(tile.Hotspot.State, new byte[VisibleGasId.Length]);
}
else if (oldData.FireState != tile.Hotspot.State ||
CheckTemperatureTolerance(oldData.Temperature, temp, _heatDistortionStrengthChangeTolerance))
else if (oldData.FireState != tile.Hotspot.State)
{
changed = true;
oldData = new GasOverlayData(tile.Hotspot.State, oldData.Opacity, temp);
oldData = new GasOverlayData(tile.Hotspot.State, oldData.Opacity);
}
if (tile is {Air: not null, NoGridTile: false})
@@ -279,20 +271,6 @@ namespace Content.Server.Atmos.EntitySystems
return true;
}
/// <summary>
/// This function determines whether the change in temperature is significant enough to warrant dirtying the tile data.
/// </summary>
private bool CheckTemperatureTolerance(float tempA, float tempB, float tolerance)
{
var (strengthA, strengthB) = (GetHeatDistortionStrength(tempA), GetHeatDistortionStrength(tempB));
return (strengthA <= 0f && strengthB > 0f) || // change to or from 0
(strengthB <= 0f && strengthA > 0f) ||
(strengthA >= 1f && strengthB < 1f) || // change to or from 1
(strengthB >= 1f && strengthA < 1f) ||
Math.Abs(strengthA - strengthB) > tolerance; // other change within tolerance
}
private void UpdateOverlayData()
{
// TODO parallelize?