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
pub use self::collider::*;
pub use self::shape_views::ColliderView;
pub use rapier::geometry::InteractionGroups;
pub use rapier::geometry::SolverFlags;
pub use rapier::parry::query::TOIStatus;
pub use rapier::parry::shape::TriMeshFlags;
pub use rapier::parry::transformation::{vhacd::VHACDParameters, voxelization::FillMode};
use crate::math::{Real, Vect};
use rapier::prelude::FeatureId;
mod collider;
mod collider_impl;
pub mod shape_views;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct PointProjection {
pub is_inside: bool,
pub point: Vect,
}
impl PointProjection {
pub(crate) fn from_rapier(
physics_scale: Real,
raw: rapier::parry::query::PointProjection,
) -> Self {
Self {
is_inside: raw.is_inside,
point: (raw.point * physics_scale).into(),
}
}
}
impl From<rapier::parry::query::PointProjection> for PointProjection {
fn from(projection: rapier::parry::query::PointProjection) -> PointProjection {
PointProjection {
is_inside: projection.is_inside,
point: projection.point.into(),
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct RayIntersection {
pub toi: Real,
pub point: Vect,
pub normal: Vect,
pub feature: FeatureId,
}
impl RayIntersection {
pub(crate) fn from_rapier(
inter: rapier::parry::query::RayIntersection,
unscaled_origin: Vect,
unscaled_dir: Vect,
) -> Self {
Self {
toi: inter.toi,
point: unscaled_origin + unscaled_dir * inter.toi,
normal: inter.normal.into(),
feature: inter.feature,
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct Toi {
pub toi: Real,
pub witness1: Vect,
pub witness2: Vect,
pub normal1: Vect,
pub normal2: Vect,
pub status: TOIStatus,
}
impl Toi {
pub(crate) fn from_rapier(physics_scale: Real, toi: rapier::parry::query::TOI) -> Self {
Self {
toi: toi.toi,
witness1: (toi.witness1 * physics_scale).into(),
witness2: (toi.witness2 * physics_scale).into(),
normal1: toi.normal1.into(),
normal2: toi.normal2.into(),
status: toi.status,
}
}
}