From d66e8a83d21df789a5745c68d8d7b3b1fbdb5f03 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 14:06:27 +0100 Subject: [PATCH] Add configurable cursor deadzone (0-15 degrees) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01YVREx3uo7nz1FEhzveWTUh --- .../improvedAerodynamics/flight/CursorAimConfig.java | 4 ++++ .../lumareth/improvedAerodynamics/flight/CursorPilot.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorAimConfig.java b/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorAimConfig.java index 6478b73..0efd188 100644 --- a/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorAimConfig.java +++ b/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorAimConfig.java @@ -8,6 +8,7 @@ public final class CursorAimConfig { public static final ForgeConfigSpec.BooleanValue ENABLED; public static final ForgeConfigSpec.DoubleValue FULL_DEFLECTION_DEGREES; + public static final ForgeConfigSpec.DoubleValue DEADZONE_DEGREES; public static final ForgeConfigSpec.DoubleValue MAX_TURN_RATE_DEGREES; public static final ForgeConfigSpec.DoubleValue MAX_ROLL_RATE_DEGREES; public static final ForgeConfigSpec.DoubleValue MAX_BANK_DEGREES; @@ -25,6 +26,9 @@ public final class CursorAimConfig { FULL_DEFLECTION_DEGREES = builder.comment("Angle of the cursor from the gun reticle at which the virtual pilot asks for full deflection: the maximum bank", "sideways, the full pitch rate up or down") .defineInRange("fullDeflectionDegrees", 30.0, 5.0, 90.0); + DEADZONE_DEGREES = builder.comment("Radius around the gun reticle in degrees inside which the cursor commands nothing, so the craft flies straight.", + "Outside it the command grows from zero, there is no jump at the edge") + .defineInRange("deadzoneDegrees", 3.0, 0.0, 15.0); MAX_TURN_RATE_DEGREES = builder.comment("Turn rate in degrees per second the pilot asks for at full deflection, both for the turn at maximum bank and for pitching") .defineInRange("maxTurnRateDegrees", 40.0, 5.0, 360.0); MAX_ROLL_RATE_DEGREES = builder.comment("Fastest roll in degrees per second the pilot asks for when it rolls to a bank angle") diff --git a/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorPilot.java b/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorPilot.java index dcf7fb9..89eeb04 100644 --- a/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorPilot.java +++ b/src/main/java/dev/lumareth/improvedAerodynamics/flight/CursorPilot.java @@ -53,6 +53,14 @@ final class CursorPilot { // Cursor as angles from the reticle: sideways (positive right) and up, both through any 270 degree cone double sideways = Math.atan2(aim.cr(), aim.cf()); double vertical = Math.atan2(aim.cu(), Math.hypot(aim.cf(), aim.cr())); + // Deadzone around the reticle: shrink the cursor offset by its radius, direction kept + double offset = Math.hypot(sideways, vertical); + double deadzone = Math.toRadians(CursorAimConfig.DEADZONE_DEGREES.get()); + if (offset > 1.0E-9) { + double scale = Math.max(0.0, offset - deadzone) / offset; + sideways *= scale; + vertical *= scale; + } double lateral = saturate(sideways / fullAngle); double blend = smoothstep(Math.abs(sideways), FINE_START, FINE_END);