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
+17 -1
View File
@@ -117,6 +117,10 @@ var _field_material: ShaderMaterial
# Cached active camera for _process(), mirroring ship_camera.gd's _get_ball()
# pattern so the viewport lookup isn't repeated every frame.
var _camera: Camera3D
var _last_camera_local_pos := Vector3.INF
# Below this, the shader's per-pixel facing test can't produce a visibly
# different result — skip the to_local()/set_shader_parameter() call.
const CAMERA_UNIFORM_UPDATE_THRESHOLD := 0.05
# Group every generated collider is tagged with. A CollisionShape3D only
# registers a shape with a CollisionObject3D that is its DIRECT parent — an
@@ -184,6 +188,14 @@ func get_surface_pull(
global_pos: Vector3, wall_strength: float, wall_range: float,
ceiling_strength: float, ceiling_range: float
) -> Vector3:
# Early-out: every dynamic body pays to_local() plus five _falloff calls
# every tick even mid-arena, where every term is exactly zero. Compared
# directly against global_pos, matching the same identity-transform
# assumption GameMode._is_escaped already makes against these constants.
if absf(global_pos.x) < INNER_HALF_X - wall_range \
and absf(global_pos.z) < INNER_HALF_Z - wall_range \
and global_pos.y < INNER_HEIGHT - ceiling_range:
return Vector3.ZERO
var p := to_local(global_pos)
var pull := Vector3.ZERO
pull += Vector3(1, 0, 0) * _falloff(INNER_HALF_X - p.x, wall_range) * wall_strength
@@ -214,7 +226,11 @@ func _process(_delta: float) -> void:
var camera := _get_camera()
if camera == null:
return # headless (RL/CI) has no camera
_field_material.set_shader_parameter("camera_local_pos", to_local(camera.global_position))
var local_pos := to_local(camera.global_position)
if local_pos.distance_to(_last_camera_local_pos) < CAMERA_UNIFORM_UPDATE_THRESHOLD:
return
_last_camera_local_pos = local_pos
_field_material.set_shader_parameter("camera_local_pos", local_pos)
# Caches the viewport's active camera; a plain is_instance_valid revalidation