feat: add witnessed knowledge and wind ambience

This commit is contained in:
Rijad Zuzo
2026-07-11 11:27:40 +02:00
parent 2ed93de6d1
commit 81409650df
72 changed files with 3001 additions and 606 deletions
+8 -6
View File
@@ -32,7 +32,9 @@ func _run() -> void:
var bake_aabb: AABB = nav_mesh.filter_baking_aabb
bake_aabb.position += nav_mesh.filter_baking_aabb_offset
var terrain_faces: PackedVector3Array = terrain.generate_nav_mesh_source_geometry(bake_aabb, false)
var terrain_faces: PackedVector3Array = terrain.generate_nav_mesh_source_geometry(
bake_aabb, false
)
if terrain_faces.is_empty():
push_error("Terrain3D produced no navigation source faces")
quit(1)
@@ -54,8 +56,10 @@ func _run() -> void:
return
print(
"[TOOL] Saved %s with %d vertices and %d polygons"
% [OUTPUT_PATH, nav_mesh.get_vertices().size(), nav_mesh.get_polygon_count()]
(
"[TOOL] Saved %s with %d vertices and %d polygons"
% [OUTPUT_PATH, nav_mesh.get_vertices().size(), nav_mesh.get_polygon_count()]
)
)
quit(0)
@@ -68,7 +72,5 @@ func _create_navigation_mesh_template() -> NavigationMesh:
nav_mesh.agent_max_slope = 35.0
nav_mesh.cell_size = 0.25
nav_mesh.cell_height = 0.1
nav_mesh.filter_baking_aabb = AABB(
Vector3(-36.0, -8.0, -36.0), Vector3(72.0, 32.0, 72.0)
)
nav_mesh.filter_baking_aabb = AABB(Vector3(-36.0, -8.0, -36.0), Vector3(72.0, 32.0, 72.0))
return nav_mesh
+17 -5
View File
@@ -41,6 +41,7 @@ func _run() -> void:
if not demo_controller.debug_overlay_visible:
demo_controller.toggle_debug_overlay()
await _stage_wind_gust(main_scene)
var debug_analysis := _capture(DEBUG_OUTPUT_PATH)
if debug_analysis.is_empty():
quit(1)
@@ -48,9 +49,7 @@ func _run() -> void:
if demo_controller.has_method("toggle_debug_overlay") and demo_controller.debug_overlay_visible:
demo_controller.toggle_debug_overlay()
await process_frame
for _frame in 30:
await process_frame
await _stage_wind_gust(main_scene)
var cinematic_analysis := _capture(CINEMATIC_OUTPUT_PATH)
if cinematic_analysis.is_empty():
@@ -58,12 +57,25 @@ func _run() -> void:
return
print(
"[TOOL] Saved Simulation Garden captures | debug %s | cinematic %s"
% [debug_analysis, cinematic_analysis]
(
"[TOOL] Saved Simulation Garden captures | debug %s | cinematic %s"
% [debug_analysis, cinematic_analysis]
)
)
quit(0)
func _stage_wind_gust(main_scene: Node) -> void:
var gust_field := (
main_scene.get_node_or_null("JajceWorld/AtmosphereRoot/WindGustField") as WindGustField
)
if gust_field == null:
return
gust_field.trigger_gust_at(Vector3(1.5, 0.0, -1.0), true, 0.5)
for _frame in 2:
await process_frame
func _capture(output_path: String) -> Dictionary:
var image := root.get_texture().get_image()
if image == null or image.is_empty():
Regular → Executable
+6 -6
View File
@@ -7,20 +7,20 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
# detect gdformat
FMT=""
FMT=()
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then
FMT="$ROOT/.venv/bin/gdformat"
FMT=("$ROOT/.venv/bin/gdformat")
elif command -v gdformat &>/dev/null; then
FMT="gdformat"
FMT=(gdformat)
elif python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then
FMT="python -m gdtoolkit.formatter"
FMT=(python -m gdtoolkit.formatter)
fi
if [[ -z "$FMT" ]]; then
if [[ ${#FMT[@]} -eq 0 ]]; then
echo "ERROR: gdformat not found. Install requirements-dev.txt; see docs/local_quality_gate.md."
exit 1
fi
echo "Formatting all .gd files in $ROOT ..."
$FMT .
"${FMT[@]}" player simulation tests tools world
echo "Done."
+41 -7
View File
@@ -86,6 +86,8 @@ function Test-GdLint {
return $false
}
$script:GdToolExitCode = 0
function Invoke-GdFormat {
$args = $args
$localTool = "$ROOT/.venv/Scripts/gdformat.exe"
@@ -96,6 +98,7 @@ function Invoke-GdFormat {
} else {
& python -m gdtoolkit.formatter @args 2>&1
}
$script:GdToolExitCode = $LASTEXITCODE
}
function Invoke-GdLint {
@@ -108,11 +111,13 @@ function Invoke-GdLint {
} else {
& python -m gdtoolkit.linter @args 2>&1
}
$script:GdToolExitCode = $LASTEXITCODE
}
function Get-ChangedGd {
$f = git diff --name-only HEAD -- '*.gd' 2>$null
return @($f | Where-Object { $_ -ne '' })
$changed = @(git diff --name-only HEAD -- '*.gd' 2>$null)
$untracked = @(git ls-files --others --exclude-standard -- '*.gd' 2>$null)
return @((@($changed) + @($untracked)) | Where-Object { $_ -ne '' } | Sort-Object -Unique)
}
function To-ResPath($p) {
@@ -171,8 +176,10 @@ $hasProjectClasses = (Test-Path $classCache) -and
(Select-String -Path $classCache -SimpleMatch '"class": &"SimNPC"' -Quiet)
$hasGutClasses = (Test-Path $classCache) -and
(Select-String -Path $classCache -SimpleMatch '"class": &"GutTest"' -Quiet)
$changedGd = @(Get-ChangedGd)
$needsImport = (-not $hasProjectClasses) -or
((Test-Path "addons/gut/gut_cmdln.gd") -and (-not $hasGutClasses))
((Test-Path "addons/gut/gut_cmdln.gd") -and (-not $hasGutClasses)) -or
($changedGd.Count -gt 0)
if ($needsImport) {
$importArgs = "--headless --path `"$ROOT`" --import"
$importOutput, $importExit = Invoke-GodotWithTimeout -ArgumentString $importArgs
@@ -200,6 +207,7 @@ if ($importResult -eq "FAIL") {
# -- 1. gdformat --------------------------------------------------------------
$fmtAvail = Test-GdFormat
$fmtResult = "PASS"
$fmtFailed = $false
Set-Content -Path "$LOG/gdformat.log" -Value "" -Encoding utf8
if (-not $fmtAvail) {
$fmtResult = "SKIPPED"
@@ -215,8 +223,9 @@ if (-not $fmtAvail) {
if (-not (Test-Path $f)) { continue }
$total++
$out = Invoke-GdFormat "--check" $f
$formatExit = $script:GdToolExitCode
$out | Add-Content -Path "$LOG/gdformat.log" -Encoding utf8
if ($LASTEXITCODE -ne 0) { $bad++ }
if ($formatExit -ne 0) { $bad++; $fmtFailed = $true }
}
$msg = "($bad/$total files need formatting)"
Add-Content -Path "$LOG/gdformat.log" -Value $msg -Encoding utf8
@@ -224,12 +233,15 @@ if (-not $fmtAvail) {
} else {
$formatArgs = @("--check") + $OWNED_GDSCRIPT_ROOTS
$out = Invoke-GdFormat @formatArgs
$formatExit = $script:GdToolExitCode
$out | Add-Content -Path "$LOG/gdformat.log" -Encoding utf8
if ($formatExit -ne 0) { $fmtFailed = $true }
}
}
if (Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" -Quiet) {
$fmtResult = "FAIL"
if ($fmtFailed) { $fmtResult = "FAIL" }
$formatDiagnostics = Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" -Quiet
if ($formatDiagnostics) {
$lines = Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" | Select-Object -ExpandProperty Line
foreach ($line in $lines) {
$p = ($line -replace '^would reformat ', '').Trim()
@@ -237,11 +249,15 @@ if (Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" -Quiet
$ERRORS += "$rp needs formatting"
}
$FIXES += "Run gdformat to auto-format files"
} elseif ($fmtFailed) {
$ERRORS += "gdformat: formatter exited non-zero; see $LOG/gdformat.log"
$FIXES += "Fix the gdformat error before continuing"
}
# -- 2. gdlint ----------------------------------------------------------------
$lintAvail = Test-GdLint
$lintResult = "PASS"
$lintFailed = $false
Set-Content -Path "$LOG/gdlint.log" -Value "" -Encoding utf8
if (-not $lintAvail) {
$lintResult = "SKIPPED"
@@ -255,18 +271,22 @@ if (-not $lintAvail) {
foreach ($f in $files) {
if (-not (Test-Path $f)) { continue }
$out = Invoke-GdLint $f
$lintExit = $script:GdToolExitCode
$out | Add-Content -Path "$LOG/gdlint.log" -Encoding utf8
if ($lintExit -ne 0) { $lintFailed = $true }
}
}
} else {
$out = Invoke-GdLint @OWNED_GDSCRIPT_ROOTS
$lintExit = $script:GdToolExitCode
$out | Add-Content -Path "$LOG/gdlint.log" -Encoding utf8
if ($lintExit -ne 0) { $lintFailed = $true }
}
}
if ($lintFailed) { $lintResult = "FAIL" }
$lintLines = Select-String -Pattern '^[^ ]+:\d+:\d+:' -Path "$LOG/gdlint.log" | Select-Object -ExpandProperty Line
if ($lintLines) {
$lintResult = "FAIL"
foreach ($line in $lintLines) {
$parts = $line -split ':', 4
if ($parts.Count -lt 4) { continue }
@@ -280,6 +300,9 @@ if ($lintLines) {
$rule = $parts[3]; $fname = Split-Path -Leaf $parts[0]
$FIXES += "Fix $rule in $fname"
}
} elseif ($lintFailed) {
$ERRORS += "gdlint: linter exited non-zero; see $LOG/gdlint.log"
$FIXES += "Fix the gdlint error before continuing"
}
# -- 3. godot headless check --------------------------------------------------
@@ -300,6 +323,12 @@ if ($godotExit -eq $null) {
}
$FIXES += "Fix Godot parser errors"
}
$godotLoadError = Select-String -Path "$LOG/godot-check.log" -Pattern 'SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
if ($godotLoadError) {
$godotResult = "FAIL"
$ERRORS += "godot: project check reported a script load or parse error"
$FIXES += "Fix Godot parser errors"
}
# -- 4. project scenario tests ------------------------------------------------
$scenarioResult = "PASS"
@@ -315,6 +344,11 @@ foreach ($test in $scenarioTests) {
$ERRORS += "scenario: $($test.Name) failed or timed out"
}
}
$scenarioLoadError = Select-String -Path "$LOG/scenarios.log" -Pattern 'SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
if ($scenarioLoadError) {
$scenarioResult = "FAIL"
$ERRORS += "scenario: Godot reported a script load or parse error"
}
if ($scenarioResult -eq "FAIL") {
$FIXES += "Fix failing project scenario tests"
}
+107 -60
View File
@@ -53,22 +53,43 @@ find_godot() {
return 1
}
find_gdformat() {
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then echo "$ROOT/.venv/bin/gdformat"; return 0; fi
if command -v gdformat &>/dev/null; then echo "gdformat"; return 0; fi
if python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.formatter"; return 0; fi
return 1
has_gdformat() {
[[ -x "$ROOT/.venv/bin/gdformat" ]] && return 0
command -v gdformat &>/dev/null && return 0
python -m gdtoolkit.formatter --help &>/dev/null 2>&1
}
find_gdlint() {
if [[ -x "$ROOT/.venv/bin/gdlint" ]]; then echo "$ROOT/.venv/bin/gdlint"; return 0; fi
if command -v gdlint &>/dev/null; then echo "gdlint"; return 0; fi
if python -m gdtoolkit.linter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.linter"; return 0; fi
return 1
run_gdformat() {
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then
"$ROOT/.venv/bin/gdformat" "$@"
elif command -v gdformat &>/dev/null; then
gdformat "$@"
else
python -m gdtoolkit.formatter "$@"
fi
}
has_gdlint() {
[[ -x "$ROOT/.venv/bin/gdlint" ]] && return 0
command -v gdlint &>/dev/null && return 0
python -m gdtoolkit.linter --help &>/dev/null 2>&1
}
run_gdlint() {
if [[ -x "$ROOT/.venv/bin/gdlint" ]]; then
"$ROOT/.venv/bin/gdlint" "$@"
elif command -v gdlint &>/dev/null; then
gdlint "$@"
else
python -m gdtoolkit.linter "$@"
fi
}
changed_gd() {
git diff --name-only HEAD -- '*.gd' 2>/dev/null || true
{
git diff --name-only HEAD -- '*.gd' 2>/dev/null
git ls-files --others --exclude-standard -- '*.gd' 2>/dev/null
} | sort -u || true
}
res_path() {
@@ -83,8 +104,38 @@ contains_element() {
local e; for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done; return 1
}
need_timeout() {
command -v timeout &>/dev/null
run_with_timeout() {
local seconds="$1"
shift
if command -v timeout &>/dev/null; then
timeout "$seconds" "$@"
return $?
fi
local marker="$LOG/.timeout-$$-${RANDOM}"
: > "$marker"
"$@" &
local command_pid=$!
(
sleep "$seconds"
if kill -0 "$command_pid" 2>/dev/null; then
echo "timeout" > "$marker"
kill "$command_pid" 2>/dev/null || true
sleep 2
kill -KILL "$command_pid" 2>/dev/null || true
fi
) &
local watchdog_pid=$!
wait "$command_pid"
local status=$?
kill "$watchdog_pid" 2>/dev/null || true
wait "$watchdog_pid" 2>/dev/null || true
if [[ -s "$marker" ]]; then
status=124
fi
rm -f "$marker"
return "$status"
}
# -- godot --------------------------------------------------------------------
@@ -104,16 +155,15 @@ needs_import=false
if [[ -f "addons/gut/gut_cmdln.gd" ]] && ! grep -q '"class": &"GutTest"' "$class_cache" 2>/dev/null; then
needs_import=true
fi
[[ -n "$(changed_gd)" ]] && needs_import=true
if $needs_import; then
if need_timeout; then
timeout 60 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
import_exit=$?
else
"${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
import_exit=$?
fi
run_with_timeout 60 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
import_exit=$?
if [[ $import_exit -ne 0 ]]; then
import_result="FAIL"
if [[ $import_exit -eq 124 ]]; then
echo "[timed out after 60s]" >> "$LOG/godot-import.log"
fi
fi
fi
if [[ ! -f "$class_cache" ]] || ! grep -q '"class": &"SimNPC"' "$class_cache"; then
@@ -131,10 +181,10 @@ if [[ "$import_result" == "FAIL" ]]; then
fi
# -- 1. gdformat --------------------------------------------------------------
fmt_tool=$(find_gdformat) || true
fmt_result="PASS"
fmt_failed=false
: > "$LOG/gdformat.log"
if [[ -z "$fmt_tool" ]]; then
if ! has_gdformat; then
fmt_result="SKIPPED"
echo "gdformat not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdformat.log"
else
@@ -147,32 +197,40 @@ else
while IFS= read -r f; do
[[ -f "$f" ]] || continue
total=$((total+1))
if ! $fmt_tool --check "$f" >> "$LOG/gdformat.log" 2>&1; then
if ! run_gdformat --check "$f" >> "$LOG/gdformat.log" 2>&1; then
bad=$((bad+1))
fmt_failed=true
fi
done <<< "$files"
echo "($bad/$total files need formatting)" >> "$LOG/gdformat.log"
fi
else
$fmt_tool --check "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdformat.log" 2>&1 || true
if ! run_gdformat --check "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdformat.log" 2>&1; then
fmt_failed=true
fi
fi
fi
if grep -q "would reformat" "$LOG/gdformat.log" 2>/dev/null; then
if $fmt_failed; then
fmt_result="FAIL"
fi
if grep -q "would reformat" "$LOG/gdformat.log" 2>/dev/null; then
while IFS= read -r line; do
line="${line#would reformat }"
rp=$(res_path "$line")
ERRORS+=("$rp needs formatting")
done < <(grep "would reformat" "$LOG/gdformat.log")
FIXES+=("Run gdformat to auto-format files")
elif $fmt_failed; then
ERRORS+=("gdformat: formatter exited non-zero; see $LOG/gdformat.log")
FIXES+=("Fix the gdformat error before continuing")
fi
# -- 2. gdlint ----------------------------------------------------------------
lint_tool=$(find_gdlint) || true
lint_result="PASS"
lint_failed=false
: > "$LOG/gdlint.log"
if [[ -z "$lint_tool" ]]; then
if ! has_gdlint; then
lint_result="SKIPPED"
echo "gdlint not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdlint.log"
else
@@ -183,16 +241,22 @@ else
else
while IFS= read -r f; do
[[ -f "$f" ]] || continue
$lint_tool "$f" >> "$LOG/gdlint.log" 2>&1 || true
if ! run_gdlint "$f" >> "$LOG/gdlint.log" 2>&1; then
lint_failed=true
fi
done <<< "$files"
fi
else
$lint_tool "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdlint.log" 2>&1 || true
if ! run_gdlint "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdlint.log" 2>&1; then
lint_failed=true
fi
fi
fi
if grep -qE "^[^ ]+:[0-9]+:" "$LOG/gdlint.log" 2>/dev/null; then
if $lint_failed; then
lint_result="FAIL"
fi
if grep -qE "^[^ ]+:[0-9]+:" "$LOG/gdlint.log" 2>/dev/null; then
while IFS= read -r line; do
[[ "$line" =~ ^([^:]+):([0-9]+):([0-9]+):[^:]+:(.*) ]] || continue
file="${BASH_REMATCH[1]}"
@@ -209,28 +273,21 @@ if grep -qE "^[^ ]+:[0-9]+:" "$LOG/gdlint.log" 2>/dev/null; then
fname=$(basename "${BASH_REMATCH[1]}")
FIXES+=("Fix $rule in $fname")
done < <(grep -E "^[^ ]+:[0-9]+:" "$LOG/gdlint.log")
elif $lint_failed; then
ERRORS+=("gdlint: linter exited non-zero; see $LOG/gdlint.log")
FIXES+=("Fix the gdlint error before continuing")
fi
# -- 3. godot headless check --------------------------------------------------
godot_result="PASS"
: > "$LOG/godot-check.log"
if need_timeout; then
if timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
godot_result="PASS"
else
ec=$?
if [[ $ec -eq 124 ]]; then
godot_result="FAIL"
echo "[timed out after 30s — project runs continuously]" >> "$LOG/godot-check.log"
else
godot_result="FAIL"
fi
fi
if run_with_timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
godot_result="PASS"
else
if "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
godot_result="PASS"
else
godot_result="FAIL"
ec=$?
godot_result="FAIL"
if [[ $ec -eq 124 ]]; then
echo "[timed out after 30s]" >> "$LOG/godot-check.log"
fi
fi
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/godot-check.log"; then
@@ -248,14 +305,9 @@ scenario_result="PASS"
: > "$LOG/scenarios.log"
for test in tests/*_test.gd; do
echo "[RUN] $(basename "$test")" >> "$LOG/scenarios.log"
if need_timeout; then
if ! timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
scenario_result="FAIL"
ERRORS+=("scenario: $(basename "$test") failed or timed out")
fi
elif ! "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
if ! run_with_timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
scenario_result="FAIL"
ERRORS+=("scenario: $(basename "$test") failed")
ERRORS+=("scenario: $(basename "$test") failed or timed out")
fi
done
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/scenarios.log"; then
@@ -278,13 +330,8 @@ else
"${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT"
-s addons/gut/gut_cmdln.gd -gexit -gdisable_colors
)
if need_timeout; then
timeout 30 "${gut_command[@]}" >> "$LOG/gut.log" 2>&1
gut_exit=$?
else
"${gut_command[@]}" >> "$LOG/gut.log" 2>&1
gut_exit=$?
fi
run_with_timeout 30 "${gut_command[@]}" >> "$LOG/gut.log" 2>&1
gut_exit=$?
if [[ $gut_exit -eq 0 ]]; then
gut_result="PASS"
else