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
//! A sphere's overlap with one shape, measured: how deep, which way out, and
//! where.
//!
//! [`OverlapHit`] is what the overlap queries answer per collider. Every
//! function here is the push-out the capsule queries already compute
//! ([`Penetration`]), asked for a capsule of no height — which is a sphere —
//! with the contact point added.
//!
//! A turned box and a turned capsule are measured in their own frames, as
//! [`super::sphere_overlaps_box`] tests one, by the forms beside it in
//! [`super::boxes`] and [`super::capsules`]: a sphere is the same in any frame
//! and a rotation keeps lengths, so only the point and the normal are turned
//! back out. A mesh is measured by its own capsule push-out, against the
//! triangle the sphere is deepest in.
//!
//! # A hit is a positive depth, exactly
//!
//! A sphere that only touches a shape is not inside it, and is not a hit: the
//! depth has to be strictly positive in `f64`, with no tolerance either way,
//! the rule [`Penetration`] keeps. Two shapes apart by less than rounding can
//! therefore read either side of the line; nothing here pads it.
//!
//! # The normal where there is no direction to escape along
//!
//! A centre exactly on a sphere's centre, or on a capsule's core, is equally
//! far from every point of the surface. The normal there is `+Y` — the shape's
//! own `+Y` for a turned capsule, its core — which is the fallback the sweeps
//! and the capsule push-out already take for the same case. A centre inside a
//! box leaves through the nearest face, and of faces equally near through the
//! first of `-X`, `+X`, `-Y`, `+Y`, `-Z`, `+Z` in the box's own frame, which is
//! the minimum-penetration rule the capsule push-out uses.
//!
//! "Exactly" is as the arithmetic has it. A centre that is on a capsule's core
//! in exact numbers can land a rounding off it in `f64` — the nearest core
//! point is worked out along the core, and need not come back to the bit —
//! and then leaves along that rounding's direction: deterministic, the same
//! on every run and target, but no more meaningful than which way it rounded.
//! A centre on a mesh's triangle leaves along the triangle's own normal, the
//! side its winding faces.
use DVec3;
use ;
use crate;
/// Where, how deep and which way a query sphere overlaps one collider.
///
/// The overlap queries' answer per collider —
/// [`PhysicsWorld::overlap_sphere`](crate::PhysicsWorld::overlap_sphere) and
/// every form of it. Not a [`ShapeHit`](super::ShapeHit): an overlap has no
/// time of impact, so a ray parameter would be a field with no meaning, and
/// the depth a sweep cannot give is the measurement an overlap exists for.
/// `sphere` as the capsule queries take one: a capsule of no height.
/// How `sphere` overlaps another sphere, or `None` if they are apart or only
/// touch.
/// How `sphere` overlaps an AABB, or `None` if they are apart or only touch.
/// How `sphere` overlaps a Y-aligned capsule, or `None` if they are apart or
/// only touch.