Add configurable cursor deadzone (0-15 degrees)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVREx3uo7nz1FEhzveWTUh
This commit is contained in:
2 files changed
+12
No files matched your search
@@ -8,6 +8,7 @@ public final class CursorAimConfig {
|
|||||||
|
|
||||||
public static final ForgeConfigSpec.BooleanValue ENABLED;
|
public static final ForgeConfigSpec.BooleanValue ENABLED;
|
||||||
public static final ForgeConfigSpec.DoubleValue FULL_DEFLECTION_DEGREES;
|
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_TURN_RATE_DEGREES;
|
||||||
public static final ForgeConfigSpec.DoubleValue MAX_ROLL_RATE_DEGREES;
|
public static final ForgeConfigSpec.DoubleValue MAX_ROLL_RATE_DEGREES;
|
||||||
public static final ForgeConfigSpec.DoubleValue MAX_BANK_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",
|
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")
|
"sideways, the full pitch rate up or down")
|
||||||
.defineInRange("fullDeflectionDegrees", 30.0, 5.0, 90.0);
|
.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")
|
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);
|
.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")
|
MAX_ROLL_RATE_DEGREES = builder.comment("Fastest roll in degrees per second the pilot asks for when it rolls to a bank angle")
|
||||||
|
|||||||
@@ -53,6 +53,14 @@ final class CursorPilot {
|
|||||||
// Cursor as angles from the reticle: sideways (positive right) and up, both through any 270 degree cone
|
// 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 sideways = Math.atan2(aim.cr(), aim.cf());
|
||||||
double vertical = Math.atan2(aim.cu(), Math.hypot(aim.cf(), aim.cr()));
|
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 lateral = saturate(sideways / fullAngle);
|
||||||
double blend = smoothstep(Math.abs(sideways), FINE_START, FINE_END);
|
double blend = smoothstep(Math.abs(sideways), FINE_START, FINE_END);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user