chore(multiplayer): Phase 0 refactors + graphics/perf settings groundwork

Lands the non-networked Phase 0 tasks from multiplayer-todo.md (ship/camera/
arena refactors, sim constants, background FPS handling) plus a first pass
at exposing graphics/performance settings (presets, resolution scaling,
vsync, FPS cap, perf overlay) and a GPU profiling harness for the
real-hardware follow-up in task 0.15b.
This commit is contained in:
Josh Creek
2026-08-19 22:37:17 +01:00
parent 88591e031f
commit 04691aaa48
29 changed files with 2212 additions and 134 deletions
+33 -1
View File
@@ -19,6 +19,30 @@ const MAX_SPEED := 32.0
var _boundary: ArenaBoundary
var _trail: GPUParticles3D
var _pending_teleport: Transform3D
var _has_pending_teleport := false
# Queues an authoritative teleport, applied at the top of the next
# _integrate_forces — the only Jolt-safe place to write state.transform
# directly (see GameMode._reset_body / task 0.15) — instead of racing the
# physics step via set_deferred("global_transform", ...).
func queue_teleport(to: Transform3D) -> void:
_pending_teleport = to
_has_pending_teleport = true
# -1 = use the real linear_velocity (default; see _physics_process below).
# A frozen remote ball (Phase 4) holds zero velocity — Godot/Jolt zeroes and
# ignores velocity writes on frozen bodies — so the trail needs a
# presentation-only speed fed in from outside instead of reading physics
# state that will never reflect the ball's true remote motion.
var _visual_speed_override: float = -1.0
func set_visual_speed(speed: float) -> void:
_visual_speed_override = speed
func _ready() -> void:
_boundary = get_tree().get_first_node_in_group("arena_boundary")
@@ -32,7 +56,8 @@ func _ready() -> void:
func _physics_process(_delta: float) -> void:
if _trail:
var speed_ratio := clampf(linear_velocity.length() / MAX_SPEED, 0.0, 1.0)
var speed := _visual_speed_override if _visual_speed_override >= 0.0 else linear_velocity.length()
var speed_ratio := clampf(speed / MAX_SPEED, 0.0, 1.0)
_trail.emitting = speed_ratio > 0.12
_trail.amount_ratio = smoothstep(0.12, 1.0, speed_ratio)
@@ -68,6 +93,13 @@ func _build_trail() -> void:
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
if _has_pending_teleport:
_has_pending_teleport = false
state.transform = _pending_teleport
state.linear_velocity = Vector3.ZERO
state.angular_velocity = Vector3.ZERO
reset_physics_interpolation()
if _boundary:
var pull := _boundary.get_surface_pull(
global_position, wall_pull_strength, wall_pull_range,