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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
use *;
// ===========================================================================
// Construction PLANES as ordinary pick candidates.
//
// A construction plane / DATUM base plane is drawn by the datum WIDGET, not by
// the scene, so `pick::pick` — which walks the render scene's solids — can never
// see one. Before this module a plane was reachable only through the independent
// `datum_pick` widget path, and ONLY when the geometry pick missed: any face,
// edge or vertex under the pointer won outright and the plane was unreachable
// (the reported "I can't select a plane if there is any other geometry under the
// pointer"). Here the plane cards are turned into ordinary
// [`pick::PickCandidate`]s and merged into the SAME ranked list every selection
// path consumes, so a plane competes for a pick like any other entity and shows
// up in the pick-list popup like any face.
//
// HOW A PLANE COMPETES — by KIND, not by depth. The candidate list is sorted
// category-major in the pick-list order
//
// VERTEX > EDGE > FACE > PLANE > SOLID > COMPONENT
//
// (the `PickKind` discriminant order), nearest-first within a category. So a
// plane ranks straight after faces: any face under the cursor still out-priorities
// it, and the plane cannot swallow a click meant for the model — while it is
// nonetheless IN the list, one row down, reachable through anything. Pure depth
// ordering was rejected precisely because it trades one complaint for its mirror
// image: a plane card in front of the model would win every click near it, and a
// plane behind the model would still lose at a grazing angle.
//
// WHAT COUNTS AS "ON" A PLANE — the drawn rectangle. A construction plane is
// mathematically infinite, but only the card the renderer draws is pickable
// ([`crate::widgets::WidgetRegistry::datum_plane_hits`] → `DatumPlane::hit_point`,
// the same live-camera `half()` extent `build_main_overlay` draws with — never a
// bake, so the pickable region tracks the drawn one across a zoom). Either face
// of the card picks: a plane seen from behind is still a legitimate selection.
//
// DATUMS RIDE ALONG. `refresh_construction_datums` feeds D (datum) and P (plane)
// features through the one `{planes:[…]}` channel — a DATUM contributes its three
// base planes (`{id}:XY|XZ|YZ`), a PLANE its single frame (`{id}`) — so both are
// `PickKind::Plane` candidates with no extra machinery. Datum AXES are not fed by
// that path and stay out of the pick list.
// ===========================================================================
/// Does `kinds` LIST `kind`? Case-insensitive, with `DATUM` as an alias of
/// `PLANE`. Kind-only, so it cannot tell a committed-sketch sheet from a real
/// body — [`EngineState::candidate_admitted`] is the candidate-aware wrapper every
/// picking path actually calls. STRICT: an empty list admits nothing (the "empty = any kind"
/// convenience belongs to the single-hit [`EngineState::pick_top_at`] alone — the
/// pick-LIST builder passes an empty list to mean "no sub-entity kind is
/// admitted", e.g. a COMPONENT-only filter).
pub
/// The ONE candidate ordering every pick path shares: category-major in the
/// pick-list order (`PickKind`'s discriminant order IS that order —
/// VERTEX > EDGE > FACE > PLANE > SOLID > COMPONENT), nearest (smallest depth)
/// first within a category, then by screen distance. Stable, so equal-depth
/// entries keep the ray ranker's order.
pub
/// The ONE candidate a hover highlight lights and a plain click takes: the
/// filter-admitted entry FIRST IN THE RAYCAST — nearest the eye — with the
/// shared kind order ([`sort_pick_candidates`]) breaking ties *inside the
/// nearest depth layer*. `candidates` must already be in that shared order
/// (every builder sorts before returning); `band` is the depth window, in world
/// units, that counts as "the same layer".
///
/// Why a LAYER and not the raw minimum depth: an EDGE lies ON the face it bounds
/// and a VERTEX on the edge, so a strict depth comparison between them is a coin
/// toss decided by tessellation noise — edges and vertices would stop being
/// clickable wherever a face happened to round nearer. Inside one layer the
/// established kind order still holds, so small targets keep their priority on
/// the surface the user is actually looking at. What the rule DOES demote is
/// everything BEHIND that surface — the far face of a box, a back edge whose
/// screen projection falls inside the 6 px threshold, a plane card under the
/// model — none of which may outrank the visible surface by kind alone any more.
/// Reaching those is what the pick LIST is for, and the list is unchanged: it
/// still ranks category-major over every candidate.
pub