Skip to content

Fix the offscreen target indicator flickering when targeting a subsystem on a distant ship - #7792

Open
Goober5000 wants to merge 3 commits into
scp-fs2open:masterfrom
Goober5000:fix/offscreen_indicator
Open

Goober5000 wants to merge 3 commits into
scp-fs2open:masterfrom
Goober5000:fix/offscreen_indicator

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

A bug report described the indicator flickering between different shapes when a subsystem defined by a POF special point was targeted on a far away ship. The cause is in HudGaugeOffscreen::calculatePosition, which could return without writing its outputs: when the eye vertex overflowed, or when the clipped point landed a pixel or two inside the clip rectangle. The caller drew anyway, so the triangle was placed at an uninitialized position with an uninitialized direction, both changing every frame.

The clip against the view frustum should leave the point exactly on a screen edge, and the edge tests allow only about one pixel of slack. Precision degrades with distance because the point is interpolated along a segment tens of kilometres long and ends up near the view apex, so at long range it can drift inside the edge and fall through.

calculatePosition now returns whether it found a position, and both its callers (the gauge and the Lua drawOffscreenIndicator function) skip drawing when it did not. The inside case falls back to the nearest screen edge, since the point is already known to be off screen, so the indicator stays steady rather than blinking.

Two related fixes found along the way:

  • The current target's display list entries stored the hull centre while the projected point was the subsystem, so the offscreen triangle separation was computed for a different point than the one clipped against. They now store the subsystem position.
  • g3_project_vertex used & instead of | when a vertex is at zero depth, so neither PF_OVERFLOW nor PF_PROJECTED was ever set on that path.

The expression used & instead of |, so neither PF_OVERFLOW nor
PF_PROJECTED was ever set on that path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. HUD A feature or issue related to the HUD labels Sep 18, 2026
@Goober5000
Goober5000 force-pushed the fix/offscreen_indicator branch from c81b934 to aeace65 Compare September 18, 2026 04:00
Goober5000 and others added 2 commits September 18, 2026 00:50
… list entries

The projected point was the subsystem but the stored position was the
hull centre, so the offscreen indicator sized its triangles for a
different point than the one it clipped against.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…n and direction

HudGaugeOffscreen::calculatePosition could return without writing its
outputs, either when the eye vertex overflowed or when the clipped
point landed a pixel or two inside the clip rectangle. The caller drew
anyway, so the indicator appeared at a random spot with a random
orientation that changed every frame. This showed up when targeting a
subsystem on a distant ship, where the clip loses enough precision to
hit the second case.

calculatePosition now returns whether it found a position, and both
callers skip drawing when it did not. The inside case falls back to
the nearest screen edge, since the point is already known to be off
screen, so the indicator stays steady instead of blinking.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Goober5000
Goober5000 force-pushed the fix/offscreen_indicator branch from aeace65 to 12323ef Compare September 18, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. HUD A feature or issue related to the HUD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant