extends SceneTree ## Float calibration: how does this Godot binary compute Vector2 math (float32, FMA or not)? ## Writes inputs and results as raw float32 bits so the C# port can match them exactly. ## Run: godot --headless --path ../saumwacht-godot --script -- func _init() -> void: var out: String = OS.get_cmdline_user_args()[0] if not OS.get_cmdline_user_args().is_empty() else "/tmp/float_probe.json" var state: int = 12345 var rows: Array = [] for i: int in range(4000): var values: Array[float] = [] for k: int in range(5): state = (state * 1103515245 + 12345) % 2147483648 values.append((float(state) / 2147483648.0 - 0.5) * 80.0) var a := Vector2(values[0], values[1]) var b := Vector2(values[2], values[3]) var w: float = absf(values[4]) / 40.0 var s: float = values[4] var f := PackedFloat32Array([a.x, a.y, b.x, b.y, w, s, a.length(), a.length_squared(), a.distance_to(b), a.distance_squared_to(b), a.dot(b), a.normalized().x, a.normalized().y, a.lerp(b, w).x, a.lerp(b, w).y, a.limit_length(0.9).x, a.limit_length(0.9).y, (a * s).x, (a / s).y, (a - b).normalized().x]) var d := PackedFloat64Array([atan2(a.x, a.y), clampf(s, -3.0, 3.0), float(a.x) * s + float(b.y)]) rows.append([f.to_byte_array().hex_encode(), d.to_byte_array().hex_encode()]) var file := FileAccess.open(out, FileAccess.WRITE) file.store_string(JSON.stringify({"engine": Engine.get_version_info().string, "rows": rows})) file.close() print("FLOAT_PROBE ", rows.size(), " -> ", out) quit()