Skip to content

track: trackback_c uses the volume's Y limits (backward tracking never added particles) - #233

Open
alexlib wants to merge 1 commit into
masterfrom
fix/trackback-volume-y-limits
Open

alexlib wants to merge 1 commit into
masterfrom
fix/trackback-volume-y-limits

Conversation

@alexlib

@alexlib alexlib commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

trackback_c declares Ymin = Ymax = 0 and uses them in the add-particle volume check:

if ( vpar->X_lay[0] < X[3][0] && X[3][0] < vpar->X_lay[1] &&
     Ymin < X[3][1] && X[3][1] < Ymax && ...)

0 < y < 0 is never true, so backward tracking never adds a particle, whatever tpar->add is.

The 3DPTV original declares the same zeros, but then fills them:

double rr, Ymin=0, Ymax=0;                                               /* 3dptv src_c/track.c:753 */
volumedimension (&X_lay[1], &X_lay[0], &Ymax, &Ymin, &Zmax_lay[1], &Zmin_lay[0]);  /* :791 */

That call was lost in the port. tr_new() already computes these limits into run_info->ymin/ymax, which trackcorr_c_loop uses. trackback_c now uses them too.

Note that this changes results: with add = 1, backward tracking will add particles again, as in 3DPTV.

Local run of all check_*.c (minimal stand-in check.h, no libcheck available): 84 ok, the same 3 failures as master. One of those, test_volumedimension, is the flaky test fixed in #232.

Found while porting the same fix to openptv2, which had copied the zeros.

🤖 Generated with Claude Code

trackback_c declared Ymin = Ymax = 0 and used them in the add-particle
volume check, so 0 < y < 0 never passed and backward tracking never added a
particle. The 3DPTV original (track.c, trackback_c) declares the same zeros
but then fills them with volumedimension(); that call was lost in the port.
tr_new() already computes them into run_info->ymin/ymax, which
trackcorr_c_loop uses; trackback_c now does too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The shared Y bounds remain uninitialized in tr_new, and the corrected behavior lacks an effective regression test.

2 open findings
What changed in this PR

Fixes backward tracking so particle addition uses the observed volume’s Y bounds.

Changes:

  • Replaces impossible zero-valued Y bounds with shared tracking-run bounds.
  • Documents the original backward-addition failure.
File Description
liboptv/​src/​track.c Uses calculated Y limits during backward particle addition.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread liboptv/src/track.c
Comment on lines +1096 to +1097
Ymin = run_info->ymin;
Ymax = run_info->ymax;
Comment thread liboptv/src/track.c
tr_new(), as trackcorr_c_loop uses them. Left at 0 here (3DPTV filled
them with volumedimension()), the add-particle volume check
0 < y < 0 never passed and backward tracking never added. */
Ymin = run_info->ymin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants