use CannyFastMath in various places even where it might not be any different

also update a bunch of packages

clean up redundant YamlDotNet references
This commit is contained in:
Tyler Young
2020-06-13 01:28:28 -04:00
parent 916b9a67d8
commit de274de9e3
25 changed files with 71 additions and 66 deletions

View File

@@ -11,10 +11,10 @@
</PropertyGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
<ItemGroup>
<PackageReference Include="Nett" Version="0.13.0" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0002" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0009" />
<PackageReference Include="YamlDotNet" Version="8.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RobustToolbox\Lidgren.Network\Lidgren.Network.csproj" />

View File

@@ -77,7 +77,7 @@ namespace Content.Client.GameObjects.Components.Power
SolarControlConsoleBoundInterfaceState scc = (SolarControlConsoleBoundInterfaceState) state;
_lastState = scc;
_window.NotARadar.UpdateState(scc);
_window.OutputPower.Text = ((int) Math.Floor(scc.OutputPower)).ToString();
_window.OutputPower.Text = ((int) MathF.Floor(scc.OutputPower)).ToString();
_window.SunAngle.Text = FormatAngle(scc.TowardsSun);
UpdateField(_window.PanelRotation, FormatAngle(scc.Rotation));
UpdateField(_window.PanelVelocity, FormatAngle(scc.AngularVelocity * 60));

View File

@@ -12,6 +12,9 @@ using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using Color = Robust.Shared.Maths.Color;
using CannyFastMath;
using Math = CannyFastMath.Math;
using MathF = CannyFastMath.MathF;
namespace Content.Client.Parallax
{
@@ -78,7 +81,7 @@ namespace Content.Client.Parallax
private readonly NoiseGenerator.NoiseType NoiseType = NoiseGenerator.NoiseType.Fbm;
private readonly uint Seed = 1234;
private readonly float Persistence = 0.5f;
private readonly float Lacunarity = (float) (Math.PI * 2 / 3);
private readonly float Lacunarity = (float) (Math.TAU / 3);
private readonly float Frequency = 1;
private readonly uint Octaves = 3;
private readonly float Threshold;
@@ -179,12 +182,12 @@ namespace Content.Client.Parallax
for (var x = 0; x < bitmap.Width; x++)
{
// Do noise calculations.
var noiseVal = Math.Min(1, Math.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2));
var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2));
// Threshold
noiseVal = Math.Max(0, noiseVal - Threshold);
noiseVal = MathF.Max(0, noiseVal - Threshold);
noiseVal *= threshVal;
noiseVal = (float) Math.Pow(noiseVal, powFactor);
noiseVal = (float) MathF.Pow(noiseVal, powFactor);
// Get colors based on noise values.
var srcColor = Color.InterpolateBetween(OuterColor, InnerColor, noiseVal)
@@ -215,7 +218,7 @@ namespace Content.Client.Parallax
private readonly NoiseGenerator.NoiseType MaskNoiseType = NoiseGenerator.NoiseType.Fbm;
private readonly uint MaskSeed = 1234;
private readonly float MaskPersistence = 0.5f;
private readonly float MaskLacunarity = (float) Math.PI * 2 / 3;
private readonly float MaskLacunarity = (float) (Math.PI * 2 / 3);
private readonly float MaskFrequency = 1;
private readonly uint MaskOctaves = 3;
private readonly float MaskThreshold;
@@ -406,11 +409,11 @@ namespace Content.Client.Parallax
var y = random.Next(0, buffer.Height);
// Grab noise at this point.
var noiseVal = Math.Min(1, Math.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2));
var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2));
// Threshold
noiseVal = Math.Max(0, noiseVal - MaskThreshold);
noiseVal = MathF.Max(0, noiseVal - MaskThreshold);
noiseVal *= threshVal;
noiseVal = (float) Math.Pow(noiseVal, powFactor);
noiseVal = (float) MathF.Pow(noiseVal, powFactor);
var randomThresh = random.NextFloat();
if (randomThresh > noiseVal)

View File

@@ -18,6 +18,9 @@ using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
using CannyFastMath;
using Math = CannyFastMath.Math;
using MathF = CannyFastMath.MathF;
namespace Content.Client.State
{

View File

@@ -6,6 +6,9 @@ using System;
using Robust.Client.Graphics.Shaders;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using CannyFastMath;
using Math = CannyFastMath.Math;
using MathF = CannyFastMath.MathF;
namespace Robust.Client.UserInterface.Controls
{
@@ -33,7 +36,7 @@ namespace Robust.Client.UserInterface.Controls
{
Color color;
var lerp = 1f - Math.Abs(Progress); // for future bikeshedding purposes
var lerp = 1f - MathF.Abs(Progress); // for future bikeshedding purposes
if (Progress >= 0f)
{
@@ -42,7 +45,7 @@ namespace Robust.Client.UserInterface.Controls
}
else
{
var alpha = Math.Clamp(0.5f * lerp, 0f, 0.5f);
var alpha = MathF.Clamp(0.5f * lerp, 0f, 0.5f);
color = new Color(1f, 1f, 1f, alpha);
}