rnd(M03): add rendered ground query facade

This commit is contained in:
2026-07-16 00:49:28 +04:00
parent 6117e5282e
commit b697a896e8
12 changed files with 416 additions and 158 deletions
@@ -0,0 +1,50 @@
class_name RenderedGroundSample
extends RefCounted
## Immutable result of sampling currently loaded render terrain in Godot world units.
## This diagnostic value is renderer-owned and is not authoritative gameplay collision.
var is_available: bool:
get:
return _is_available
var height_units: float:
get:
return _height_units
var failure_code: StringName:
get:
return _failure_code
var _is_available: bool
var _height_units: float
var _failure_code: StringName
## Creates an available finite rendered-ground sample in Godot world units.
static func available(height_units_value: float) -> RenderedGroundSample:
return RenderedGroundSample.new(true, height_units_value, &"")
## Creates an unavailable rendered-ground sample with a stable failure code.
static func unavailable(failure_code_value: StringName) -> RenderedGroundSample:
return RenderedGroundSample.new(false, 0.0, failure_code_value)
func _init(
is_available_value: bool,
height_units_value: float,
failure_code_value: StringName
) -> void:
_is_available = is_available_value and is_finite(height_units_value)
_height_units = height_units_value if _is_available else 0.0
if _is_available:
_failure_code = &""
elif not is_finite(height_units_value):
_failure_code = &"render_terrain_height_not_finite"
else:
_failure_code = (
failure_code_value
if not failure_code_value.is_empty()
else &"render_terrain_unavailable"
)
@@ -0,0 +1 @@
uid://c744ldnnn87a8
+30
View File
@@ -7,6 +7,7 @@ extends Node
const GODOT_WORLD_POSITION_SCRIPT := preload("res://src/domain/coordinates/godot_world_position.gd")
const STREAMING_FOCUS_SCRIPT := preload("res://src/domain/streaming/streaming_focus.gd")
const RENDERED_GROUND_SAMPLE_SCRIPT := preload("res://src/render/terrain/rendered_ground_sample.gd")
## Internal renderer implementation resolved relative to this node.
## The referenced node remains owned by its scene parent.
@@ -66,6 +67,33 @@ func renderer_metrics_snapshot() -> Dictionary:
return (metrics_variant as Dictionary).duplicate(true)
## Samples the currently loaded render terrain at a typed Godot world position.
## This read-only renderer view is diagnostic and does not replace authoritative
## gameplay collision or the independently composed [TerrainQuery].
func sample_ground_height(godot_world_position: GodotWorldPosition) -> RefCounted:
var loader := _resolve_streaming_world_loader()
if loader == null:
return RENDERED_GROUND_SAMPLE_SCRIPT.unavailable(&"render_facade_unavailable")
var sample_variant = loader.call("sample_rendered_ground_height", godot_world_position)
if sample_variant is RefCounted and sample_variant.get_script() == RENDERED_GROUND_SAMPLE_SCRIPT:
return sample_variant
push_error("WorldRenderFacade received an invalid rendered ground sample.")
return RENDERED_GROUND_SAMPLE_SCRIPT.unavailable(&"render_ground_sample_invalid")
## Returns a detached diagnostic snapshot for one rendered-ground query.
## Mutating the result cannot mutate streamer queues, tile state or resources.
func renderer_ground_query_snapshot(godot_world_position: GodotWorldPosition) -> Dictionary:
var loader := _resolve_streaming_world_loader()
if loader == null:
return {}
var snapshot_variant = loader.call("render_ground_query_snapshot", godot_world_position)
if not (snapshot_variant is Dictionary):
push_error("WorldRenderFacade received a non-Dictionary ground query snapshot.")
return {}
return (snapshot_variant as Dictionary).duplicate(true)
func _capture_streaming_focus_from_source() -> void:
if streaming_focus_source_path == NodePath():
return
@@ -99,6 +127,8 @@ func _resolve_streaming_world_loader() -> Node:
&"set_streaming_focus",
&"refresh_streaming_focus",
&"render_baseline_snapshot",
&"sample_rendered_ground_height",
&"render_ground_query_snapshot",
]:
if not candidate.has_method(required_method):
if not _missing_loader_reported: