1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! The f32-collapse degenerate-triangle backstop: the env switch that disables
//! it, the drop itself, and the per-element tally of what it removed.
//!
//! Split out of the parent `element` module (whose child it is) because the
//! tally stopped being a pure diagnostic. It is now load-bearing for the #1891
//! closure verdict: the backstop is the ONE step of the per-`MeshData` funnel
//! that changes a mesh's topology, and it runs AFTER
//! `orient_mesh_outward_verdict` has already handed the hasher its verdict. A
//! dropped triangle takes its three welded edges with it, opening every
//! neighbour along them, so an element that drops anything can no longer be
//! certified closed — see
//! `GeometryHasher::retract_closure_if_mesh_edited`, which
//! `produce_element_meshes` feeds [`dropped_this_element`] into before reading
//! the verdict out.
use Mesh;
use Cell;
thread_local!
/// Whether the backstop is disabled.
///
/// On by default. Set `IFC_LITE_DISABLE_DEGENERATE_BACKSTOP=1` to keep the raw
/// (possibly fan-corrupted) triangles — an escape hatch for debugging the
/// heuristic or measuring exactly what it removes. Read once and cached.
/// Open one element's tally scope (same begin/drain shape as the kernel's
/// per-element CSG budget).
pub
/// Drop this mesh's collapsed triangles, tallying how many went.
///
/// At building-scale world coordinates an f32 mantissa can't separate
/// sub-15 µm-apart vertices, so triangles collapse into zero-area / long-thin
/// "fan" slivers that visibly span large georeferenced models. This drops the
/// unambiguously-degenerate ones at the single per-element `MeshData` funnel.
/// With local-frame precision on, the mesh is stored relative to `origin` (small
/// coords) so collapse is PREVENTED upstream and this drops nothing; it stays as
/// the defence-in-depth safety net for any element still too large for its frame.
pub
/// Triangles dropped since [`begin_element`], across every mesh of this element.
pub