Optimize Player UI updates with threshold-based rendering and add performance profiler autoload: implement UI_UPDATE_THRESHOLD constant to reduce unnecessary label updates, add conditional DEBUG compilation for debug prints, wrap debug output in preprocessor directives, add PerformanceProfiler autoload, switch to JoltPhysics3D engine, enable VSync, configure rendering quality settings (TAA, SSAA, anisotropic filtering, shadow atlas), and update main scene path

This commit is contained in:
William Stuckey
2026-01-03 16:07:49 -06:00
parent 0d69ad30fb
commit 04dcf8d0e6
182 changed files with 9654 additions and 8 deletions

View File

@@ -20,6 +20,11 @@ public partial class Player : FirstPersonController
public Label VelocityVal { get; set; }
private float _lastSpeed = 0f;
private float _lastDisplayedSpeed = 0f;
private Vector3 _lastDisplayedPosition;
private Vector3 _lastDisplayedVelocity;
private string _lastDisplayedState = "";
private const float UI_UPDATE_THRESHOLD = 0.1f;
public override void _Ready()
{
@@ -102,21 +107,25 @@ public partial class Player : FirstPersonController
MouseSensitivity = 0.35f;
EnableDebugOutput = false;
#if DEBUG
GD.Print($"InputManager assigned: {InputManager != null}");
GD.Print($"CameraNode assigned: {CameraNode != null}");
GD.Print($"Config assigned: {Config != null}");
#endif
SubscribeToStateChanges(OnMovementStateChanged);
MovementEvents.PlayerJumped += OnPlayerJumped;
MovementEvents.SpeedChanged += OnSpeedChanged;
#if DEBUG
GD.Print("TestPlayer initialized with all libraries!");
GD.Print("- Movement: Enabled");
GD.Print("- Input: Enabled");
GD.Print("- Events: Enabled");
GD.Print("- StateManagement: Enabled");
GD.Print("- Camera: Enabled");
#endif
}
public override void _Process(double delta)
@@ -128,15 +137,15 @@ public partial class Player : FirstPersonController
private void UpdateUI()
{
if (SpeedVal != null)
if (SpeedVal != null && Mathf.Abs(CurrentSpeed - _lastDisplayedSpeed) > UI_UPDATE_THRESHOLD)
{
SpeedVal.Text = $"{CurrentSpeed:F1} u/s ";
_lastDisplayedSpeed = CurrentSpeed;
}
if (StateVal != null)
{
string state = "Unknown";
// Check crouch first since IsOnFloor() is unreliable when crouched
if (IsCrouching)
{
state = "Crouching";
@@ -153,38 +162,49 @@ public partial class Player : FirstPersonController
state = "Airborne";
}
StateVal.Text = $"{state} ";
if (state != _lastDisplayedState)
{
StateVal.Text = $"{state} ";
_lastDisplayedState = state;
}
}
if (PositionVal != null)
if (PositionVal != null && GlobalPosition.DistanceSquaredTo(_lastDisplayedPosition) > UI_UPDATE_THRESHOLD)
{
PositionVal.Text =
$"({GlobalPosition.X:F1}, {GlobalPosition.Y:F1}, {GlobalPosition.Z:F1}) ";
_lastDisplayedPosition = GlobalPosition;
}
if (VelocityVal != null)
if (VelocityVal != null && Velocity.DistanceSquaredTo(_lastDisplayedVelocity) > UI_UPDATE_THRESHOLD)
{
VelocityVal.Text = $"({Velocity.X:F1}, {Velocity.Y:F1}, {Velocity.Z:F1}) ";
_lastDisplayedVelocity = Velocity;
}
}
private void OnMovementStateChanged(MovementStateChangedEvent evt)
{
#if DEBUG
GD.Print($"[Movement] State changed to: {evt.StateName} (Speed: {evt.Speed:F1})");
#endif
MovementEvents.RaiseStateChanged(evt.StateName);
}
private void OnPlayerJumped()
{
#if DEBUG
GD.Print($"[Event] Player jumped at speed: {CurrentSpeed:F1}");
#endif
}
private void OnSpeedChanged(float speed)
{
if (Mathf.Abs(speed - _lastSpeed) > 50f)
{
#if DEBUG
GD.Print($"[Event] Speed changed significantly: {_lastSpeed:F1} -> {speed:F1}");
#endif
_lastSpeed = speed;
}
}