Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions Robust.Client/Graphics/ClientEye/EyeManager.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Globalization;
using System.Numerics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
Expand All @@ -15,12 +17,36 @@ namespace Robust.Client.Graphics
/// <inheritdoc />
public sealed partial class EyeManager : IEyeManager
{
// If you modify this make sure to edit the value in the Robust.Shared.Audio.AudioParams struct default too!
// No I can't be bothered to make this a shared constant.
/// <summary>
/// Default scaling for the projection matrix.
/// Default scaling for the projection matrix: how many texture pixels map to one world meter (tile).
/// </summary>
public const int PixelsPerMeter = 32;
/// <remarks>
/// Defaults to 32. It can be overridden once, at process startup, via the
/// <c>ROBUST_PIXELS_PER_METER</c> environment variable. This is fixed for the lifetime of the
/// process and is NOT safe to change at runtime.
/// </remarks>
public static readonly int PixelsPerMeter = ReadPixelsPerMeter();

/// <summary>
/// Environment variable used to override <see cref="PixelsPerMeter"/> at startup.
/// </summary>
public const string PixelsPerMeterEnvVar = "ROBUST_PIXELS_PER_METER";

private const int DefaultPixelsPerMeter = 32;

private static int ReadPixelsPerMeter()
{
var raw = Environment.GetEnvironmentVariable(PixelsPerMeterEnvVar);
Comment on lines +37 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is content supposed to change this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just set the envvar when you run it 🤷
I could instead make it something you can change in a props file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's going to be set globally for every game unless I'm a dumbass?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yo im stupid i forgot i was in client not server

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CVar would be better for it, static readonly is fine but maybe if a server is running multiple gamesTM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if (!string.IsNullOrWhiteSpace(raw)
&& int.TryParse(raw, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value)
&& value > 0)
{
return value;
}

return DefaultPixelsPerMeter;
}

[Dependency] private IClyde _displayManager = default!;
[Dependency] private IEntityManager _entityManager = default!;
Expand Down
2 changes: 1 addition & 1 deletion Robust.Client/Graphics/Drawing/DrawingHandleWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protected DrawingHandleWorld(Texture white) : base(white)
{
}

private const int Ppm = EyeManager.PixelsPerMeter;
private static readonly int Ppm = EyeManager.PixelsPerMeter;

/// <summary>
/// Draws an untextured colored rectangle to the world.The coordinate system is right handed.
Expand Down
2 changes: 1 addition & 1 deletion Robust.Client/Map/ClydeTileDefinitionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal void _genTextureAtlas()
if (defList.Count <= 0)
return;

const int tileSize = EyeManager.PixelsPerMeter;
var tileSize = EyeManager.PixelsPerMeter;

var tileCount = defList.Select(x => x.Variants + x.EdgeSprites.Count).Sum() + 1;

Expand Down
Loading