Skip to content

Reject most shadow candidates in double before the exact test - #6596

Merged
meshinspector-agent[bot] merged 2 commits into
alpha-shape-triangle-shadowfrom
agent/mlib-shadow-prefilter-doubles
Aug 16, 2026
Merged

Reject most shadow candidates in double before the exact test#6596
meshinspector-agent[bot] merged 2 commits into
alpha-shape-triangle-shadowfrom
agent/mlib-shadow-prefilter-doubles

Conversation

@meshinspector-agent

Copy link
Copy Markdown
Contributor

Supersedes #6593, which sits on closed #6592's branch and needs toDouble. This one is based on alpha-shape-triangle-shadow and needs nothing new — it recomputes the pre-filter's operands in double instead of converting the exact bignums.

  • The port to FastInt dropped the pre-filter, so every candidate reached the exact path. Restoring it skips 79–91% of them.
  • up/uq are hoisted out of the candidate loop; bp = dot( d, up ), bq = dot( d, uq ), and a negative sign of either rejects the candidate before any bignum work.
  • Why no toDouble. The operands must approximate the value on the integer grid, where the predicates and the SoS ties live. Point differences are below 2^31, so Vector3d of one is exact and pp/qq/pq are ordinary double dot products — 0.7 bits worse than converting the exact bignum (max error 2^10.7 vs 2^10.0 over 200k pairs), against 2^33.3 if taken from the cloud's Vector3f.
  • Error bound: those dot products are below 2^64, the components of up/uq below 2^96, their dot with d below 2^129; each rounding costs 2^-53 of the running magnitude, so the total stays below 2^79 and a double below -2^79 is negative exactly as well. The 2^84 tolerance keeps 32x that margin; candidates in between fall through to the exact path unchanged.
  • Consequence: no dependency on Add toDouble for the FastInt family #6594, so this can land on the branch on its own.

The exact path itself is untouched — this only decides which candidates reach it.

Verification

Built in the ubuntu22 image mirroring build-test-ubuntu-x64.yml: clone_submodules_linux.sh --skip-prebuilt-thirdparty, prebuilt thirdparty linked as lib/include/share, Ninja Release, g++-12, -DMR_CXX_STANDARD=20. MRTest and its dependency graph — 640/640, no new warnings.

MRTest --gtest_filter=*AlphaShape*:*PrecisePredicates*:*InSphere*:*FastInt*16/16 pass.

DISABLED_AlphaShapeBench, pre-filter on:

cloud triangle hash shadowTests exactShadowTests rejected
sphere 40k 17403291826481596167 487416 54994 88.7%
grid 40k 635805191690857954 2058881 186448 90.9%
random 40k 11472133144093973002 54564333 11466269 79.0%

Every hash equals the filter-off baseline, and consideredTris, touchableTris, inBallTests (1461420 / 3055058 / 23736199) and shadowedNeis are unchanged — the pre-filter is output-preserving, as its bound claims. All of those, and all three hashes, are also identical to #6593's toDouble version: on these clouds the cheaper operands decide every candidate exactly the same way.

No timings on purpose — this box is not a GitHub-hosted runner, so its milliseconds are not comparable to the reported set. The counters above are exact and platform-independent; the wall-clock payoff comes from the branch run.

Not exercised: the other MRTest configs (MSVC, arm64, wasm, macOS) — a PR based on alpha-shape-triangle-shadow gets no checks of its own. No UI surface (library-internal predicate, no MCP-exposed tool and no viewer widget), so nothing to drive over MCP and no screenshots; the three structurally different clouds are the state coverage instead.

CI labels: none.

The port to FastInt dropped the floating-point pre-filter because the family
has no conversion to double, so every candidate was evaluated exactly. The
filter's operands are dot products of point differences below 2^31, which
Vector3d represents exactly, so they can be recomputed in double directly
instead of converting the exact bignums - 0.7 bits worse, and no dependency
on a bignum-to-double conversion.
…q prefilter

Brings master's FastInt rework under the double sign rejection so this PR
builds against current master.
@meshinspector-agent
meshinspector-agent Bot merged commit 10ae314 into alpha-shape-triangle-shadow Aug 16, 2026
@meshinspector-agent
meshinspector-agent Bot deleted the agent/mlib-shadow-prefilter-doubles branch August 16, 2026 21:03
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.

0 participants