-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrapier_direct_space_state_3d.rs
192 lines (184 loc) · 5.04 KB
/
rapier_direct_space_state_3d.rs
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
use godot::classes::*;
use godot::prelude::*;
use super::rapier_direct_space_state_impl::RapierDirectSpaceStateImpl;
use crate::servers::rapier_physics_singleton::physics_data;
use crate::types::*;
#[derive(GodotClass)]
#[class(base=PhysicsDirectSpaceState3DExtension,tool)]
/// The physics direct space state singleton implemented for Rapier Physics.
/// For methods exposed see [PhysicsDirectSpaceState3D].
pub struct RapierDirectSpaceState3D {
inner: RapierDirectSpaceStateImpl,
space: Rid,
base: Base<PhysicsDirectSpaceState3DExtension>,
}
impl RapierDirectSpaceState3D {
pub fn set_space(&mut self, space: Rid) {
self.space = space;
self.inner.space = space;
}
}
#[godot_api]
impl IPhysicsDirectSpaceState3DExtension for RapierDirectSpaceState3D {
fn init(base: Base<PhysicsDirectSpaceState3DExtension>) -> Self {
Self {
inner: RapierDirectSpaceStateImpl::default(),
space: Rid::Invalid,
base,
}
}
unsafe fn intersect_ray(
&mut self,
from: Vector,
to: Vector,
collision_mask: u32,
collide_with_bodies: bool,
collide_with_areas: bool,
hit_from_inside: bool,
_hit_back_faces: bool,
_pick_ray: bool,
result: *mut PhysicsServerExtensionRayResult,
) -> bool {
let physics_data = physics_data();
self.inner.intersect_ray(
from,
to,
collision_mask,
collide_with_bodies,
collide_with_areas,
hit_from_inside,
result,
physics_data,
)
}
unsafe fn intersect_point(
&mut self,
position: Vector,
collision_mask: u32,
collide_with_bodies: bool,
collide_with_areas: bool,
results: *mut PhysicsServerExtensionShapeResult,
max_results: i32,
) -> i32 {
let physics_data = physics_data();
self.inner.intersect_point(
position,
0,
collision_mask,
collide_with_bodies,
collide_with_areas,
results,
max_results,
physics_data,
)
}
unsafe fn intersect_shape(
&mut self,
shape_rid: Rid,
transform: Transform,
motion: Vector,
margin: f32,
collision_mask: u32,
collide_with_bodies: bool,
collide_with_areas: bool,
results: *mut PhysicsServerExtensionShapeResult,
max_results: i32,
) -> i32 {
let physics_data = physics_data();
self.inner.intersect_shape(
shape_rid,
transform,
motion,
margin,
collision_mask,
collide_with_bodies,
collide_with_areas,
results,
max_results,
physics_data,
)
}
unsafe fn cast_motion(
&mut self,
shape_rid: Rid,
transform: Transform,
motion: Vector,
margin: f32,
collision_mask: u32,
collide_with_bodies: bool,
collide_with_areas: bool,
closest_safe: *mut f64,
closest_unsafe: *mut f64,
_info: *mut PhysicsServerExtensionShapeRestInfo,
) -> bool {
let physics_data = physics_data();
self.inner.cast_motion(
shape_rid,
transform,
motion,
margin,
collision_mask,
collide_with_bodies,
collide_with_areas,
closest_safe,
closest_unsafe,
physics_data,
)
}
unsafe fn collide_shape(
&mut self,
shape_rid: Rid,
transform: Transform,
motion: Vector,
margin: f32,
collision_mask: u32,
collide_with_bodies: bool,
collide_with_areas: bool,
results: *mut std::ffi::c_void,
max_results: i32,
result_count: *mut i32,
) -> bool {
let physics_data = physics_data();
self.inner.collide_shape(
shape_rid,
transform,
motion,
margin,
collision_mask,
collide_with_bodies,
collide_with_areas,
results,
max_results,
result_count,
physics_data,
)
}
unsafe fn rest_info(
&mut self,
shape_rid: Rid,
transform: Transform,
motion: Vector,
margin: f32,
collision_mask: u32,
collide_with_bodies: bool,
collide_with_areas: bool,
rest_info: *mut PhysicsServerExtensionShapeRestInfo,
) -> bool {
let physics_data = physics_data();
self.inner.rest_info(
shape_rid,
transform,
motion,
margin,
collision_mask,
collide_with_bodies,
collide_with_areas,
rest_info,
physics_data,
)
}
fn get_closest_point_to_object_volume(&self, _object: Rid, _point: Vector3) -> Vector3 {
godot_print!("Not implemented");
Vector::ZERO
}
}