-
Notifications
You must be signed in to change notification settings - Fork 71
/
jolt_physics_server_3d.hpp
588 lines (378 loc) · 17.5 KB
/
jolt_physics_server_3d.hpp
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#pragma once
class JoltAreaImpl3D;
class JoltBodyImpl3D;
class JoltJobSystem;
class JoltJointImpl3D;
class JoltShapeImpl3D;
class JoltSpace3D;
class JoltPhysicsServer3D final : public PhysicsServer3DExtension {
GDCLASS_NO_WARN(JoltPhysicsServer3D, PhysicsServer3DExtension)
private:
// NOLINTNEXTLINE(readability-identifier-naming)
static void _bind_methods() { }
public:
RID _world_boundary_shape_create() override;
RID _separation_ray_shape_create() override;
RID _sphere_shape_create() override;
RID _box_shape_create() override;
RID _capsule_shape_create() override;
RID _cylinder_shape_create() override;
RID _convex_polygon_shape_create() override;
RID _concave_polygon_shape_create() override;
RID _heightmap_shape_create() override;
RID _custom_shape_create() override;
void _shape_set_data(const RID& p_shape, const Variant& p_data) override;
void _shape_set_custom_solver_bias(const RID& p_shape, double p_bias) override;
void _shape_set_margin(const RID& p_shape, double p_margin) override;
double _shape_get_margin(const RID& p_shape) const override;
PhysicsServer3D::ShapeType _shape_get_type(const RID& p_shape) const override;
Variant _shape_get_data(const RID& p_shape) const override;
double _shape_get_custom_solver_bias(const RID& p_shape) const override;
RID _space_create() override;
void _space_set_active(const RID& p_space, bool p_active) override;
bool _space_is_active(const RID& p_space) const override;
void _space_set_param(
const RID& p_space,
PhysicsServer3D::SpaceParameter p_param,
double p_value
) override;
double _space_get_param(const RID& p_space, PhysicsServer3D::SpaceParameter p_param)
const override;
PhysicsDirectSpaceState3D* _space_get_direct_state(const RID& p_space) override;
void _space_set_debug_contacts(const RID& p_space, int32_t p_max_contacts) override;
PackedVector3Array _space_get_contacts(const RID& p_space) const override;
int32_t _space_get_contact_count(const RID& p_space) const override;
RID _area_create() override;
void _area_set_space(const RID& p_area, const RID& p_space) override;
RID _area_get_space(const RID& p_area) const override;
void _area_add_shape(
const RID& p_area,
const RID& p_shape,
const Transform3D& p_transform,
bool p_disabled
) override;
void _area_set_shape(const RID& p_area, int32_t p_shape_idx, const RID& p_shape) override;
void _area_set_shape_transform(
const RID& p_area,
int32_t p_shape_idx,
const Transform3D& p_transform
) override;
void _area_set_shape_disabled(const RID& p_area, int32_t p_shape_idx, bool p_disabled) override;
int32_t _area_get_shape_count(const RID& p_area) const override;
RID _area_get_shape(const RID& p_area, int32_t p_shape_idx) const override;
Transform3D _area_get_shape_transform(const RID& p_area, int32_t p_shape_idx) const override;
void _area_remove_shape(const RID& p_area, int32_t p_shape_idx) override;
void _area_clear_shapes(const RID& p_area) override;
void _area_attach_object_instance_id(const RID& p_area, uint64_t p_id) override;
uint64_t _area_get_object_instance_id(const RID& p_area) const override;
void _area_set_param(
const RID& p_area,
PhysicsServer3D::AreaParameter p_param,
const Variant& p_value
) override;
void _area_set_transform(const RID& p_area, const Transform3D& p_transform) override;
Variant _area_get_param(const RID& p_area, PhysicsServer3D::AreaParameter p_param)
const override;
Transform3D _area_get_transform(const RID& p_area) const override;
void _area_set_collision_layer(const RID& p_area, uint32_t p_layer) override;
uint32_t _area_get_collision_layer(const RID& p_area) const override;
void _area_set_collision_mask(const RID& p_area, uint32_t p_mask) override;
uint32_t _area_get_collision_mask(const RID& p_area) const override;
void _area_set_monitorable(const RID& p_area, bool p_monitorable) override;
void _area_set_ray_pickable(const RID& p_area, bool p_enable) override;
void _area_set_monitor_callback(const RID& p_area, const Callable& p_callback) override;
void _area_set_area_monitor_callback(const RID& p_area, const Callable& p_callback) override;
RID _body_create() override;
void _body_set_space(const RID& p_body, const RID& p_space) override;
RID _body_get_space(const RID& p_body) const override;
void _body_set_mode(const RID& p_body, PhysicsServer3D::BodyMode p_mode) override;
PhysicsServer3D::BodyMode _body_get_mode(const RID& p_body) const override;
void _body_add_shape(
const RID& p_body,
const RID& p_shape,
const Transform3D& p_transform,
bool p_disabled
) override;
void _body_set_shape(const RID& p_body, int32_t p_shape_idx, const RID& p_shape) override;
void _body_set_shape_transform(
const RID& p_body,
int32_t p_shape_idx,
const Transform3D& p_transform
) override;
void _body_set_shape_disabled(const RID& p_body, int32_t p_shape_idx, bool p_disabled) override;
int32_t _body_get_shape_count(const RID& p_body) const override;
RID _body_get_shape(const RID& p_body, int32_t p_shape_idx) const override;
Transform3D _body_get_shape_transform(const RID& p_body, int32_t p_shape_idx) const override;
void _body_remove_shape(const RID& p_body, int32_t p_shape_idx) override;
void _body_clear_shapes(const RID& p_body) override;
void _body_attach_object_instance_id(const RID& p_body, uint64_t p_id) override;
uint64_t _body_get_object_instance_id(const RID& p_body) const override;
void _body_set_enable_continuous_collision_detection(const RID& p_body, bool p_enable) override;
bool _body_is_continuous_collision_detection_enabled(const RID& p_body) const override;
void _body_set_collision_layer(const RID& p_body, uint32_t p_layer) override;
uint32_t _body_get_collision_layer(const RID& p_body) const override;
void _body_set_collision_mask(const RID& p_body, uint32_t p_mask) override;
uint32_t _body_get_collision_mask(const RID& p_body) const override;
void _body_set_collision_priority(const RID& p_body, double p_priority) override;
double _body_get_collision_priority(const RID& p_body) const override;
void _body_set_user_flags(const RID& p_body, uint32_t p_flags) override;
uint32_t _body_get_user_flags(const RID& p_body) const override;
void _body_set_param(
const RID& p_body,
PhysicsServer3D::BodyParameter p_param,
const Variant& p_value
) override;
Variant _body_get_param(const RID& p_body, PhysicsServer3D::BodyParameter p_param)
const override;
void _body_reset_mass_properties(const RID& p_body) override;
void _body_set_state(
const RID& p_body,
PhysicsServer3D::BodyState p_state,
const Variant& p_value
) override;
Variant _body_get_state(const RID& p_body, PhysicsServer3D::BodyState p_state) const override;
void _body_apply_central_impulse(const RID& p_body, const Vector3& p_impulse) override;
void _body_apply_impulse(const RID& p_body, const Vector3& p_impulse, const Vector3& p_position)
override;
void _body_apply_torque_impulse(const RID& p_body, const Vector3& p_impulse) override;
void _body_apply_central_force(const RID& p_body, const Vector3& p_force) override;
void _body_apply_force(const RID& p_body, const Vector3& p_force, const Vector3& p_position)
override;
void _body_apply_torque(const RID& p_body, const Vector3& p_torque) override;
void _body_add_constant_central_force(const RID& p_body, const Vector3& p_force) override;
void _body_add_constant_force(
const RID& p_body,
const Vector3& p_force,
const Vector3& p_position
) override;
void _body_add_constant_torque(const RID& p_body, const Vector3& p_torque) override;
void _body_set_constant_force(const RID& p_body, const Vector3& p_force) override;
Vector3 _body_get_constant_force(const RID& p_body) const override;
void _body_set_constant_torque(const RID& p_body, const Vector3& p_torque) override;
Vector3 _body_get_constant_torque(const RID& p_body) const override;
void _body_set_axis_velocity(const RID& p_body, const Vector3& p_axis_velocity) override;
void _body_set_axis_lock(const RID& p_body, PhysicsServer3D::BodyAxis p_axis, bool p_lock)
override;
bool _body_is_axis_locked(const RID& p_body, PhysicsServer3D::BodyAxis p_axis) const override;
void _body_add_collision_exception(const RID& p_body, const RID& p_excepted_body) override;
void _body_remove_collision_exception(const RID& p_body, const RID& p_excepted_body) override;
TypedArray<RID> _body_get_collision_exceptions(const RID& p_body) const override;
void _body_set_max_contacts_reported(const RID& p_body, int32_t p_amount) override;
int32_t _body_get_max_contacts_reported(const RID& p_body) const override;
void _body_set_contacts_reported_depth_threshold(const RID& p_body, double p_threshold)
override;
double _body_get_contacts_reported_depth_threshold(const RID& p_body) const override;
void _body_set_omit_force_integration(const RID& p_body, bool p_enable) override;
bool _body_is_omitting_force_integration(const RID& p_body) const override;
void _body_set_state_sync_callback(const RID& p_body, const Callable& p_callable) override;
void _body_set_force_integration_callback(
const RID& p_body,
const Callable& p_callable,
const Variant& p_userdata
) override;
void _body_set_ray_pickable(const RID& p_body, bool p_enable) override;
bool _body_test_motion(
const RID& p_body,
const Transform3D& p_from,
const Vector3& p_motion,
double p_margin,
int32_t p_max_collisions,
bool p_collide_separation_ray,
PhysicsServer3DExtensionMotionResult* p_result
) const override;
PhysicsDirectBodyState3D* _body_get_direct_state(const RID& p_body) override;
RID _soft_body_create() override;
void _soft_body_update_rendering_server(
const RID& p_body,
PhysicsServer3DRenderingServerHandler* p_rendering_server_handler
) override;
void _soft_body_set_space(const RID& p_body, const RID& p_space) override;
RID _soft_body_get_space(const RID& p_body) const override;
void _soft_body_set_ray_pickable(const RID& p_body, bool p_enable) override;
void _soft_body_set_collision_layer(const RID& p_body, uint32_t p_layer) override;
uint32_t _soft_body_get_collision_layer(const RID& p_body) const override;
void _soft_body_set_collision_mask(const RID& p_body, uint32_t p_mask) override;
uint32_t _soft_body_get_collision_mask(const RID& p_body) const override;
void _soft_body_add_collision_exception(const RID& p_body, const RID& p_body_b) override;
void _soft_body_remove_collision_exception(const RID& p_body, const RID& p_body_b) override;
TypedArray<RID> _soft_body_get_collision_exceptions(const RID& p_body) const override;
void _soft_body_set_state(
const RID& p_body,
PhysicsServer3D::BodyState p_state,
const Variant& p_variant
) override;
Variant _soft_body_get_state(const RID& p_body, PhysicsServer3D::BodyState p_state)
const override;
void _soft_body_set_transform(const RID& p_body, const Transform3D& p_transform) override;
void _soft_body_set_simulation_precision(const RID& p_body, int32_t p_simulation_precision)
override;
int32_t _soft_body_get_simulation_precision(const RID& p_body) const override;
void _soft_body_set_total_mass(const RID& p_body, double p_total_mass) override;
double _soft_body_get_total_mass(const RID& p_body) const override;
void _soft_body_set_linear_stiffness(const RID& p_body, double p_linear_stiffness) override;
double _soft_body_get_linear_stiffness(const RID& p_body) const override;
void _soft_body_set_pressure_coefficient(const RID& p_body, double p_pressure_coefficient)
override;
double _soft_body_get_pressure_coefficient(const RID& p_body) const override;
void _soft_body_set_damping_coefficient(const RID& p_body, double p_damping_coefficient)
override;
double _soft_body_get_damping_coefficient(const RID& p_body) const override;
void _soft_body_set_drag_coefficient(const RID& p_body, double p_drag_coefficient) override;
double _soft_body_get_drag_coefficient(const RID& p_body) const override;
void _soft_body_set_mesh(const RID& p_body, const RID& p_mesh) override;
AABB _soft_body_get_bounds(const RID& p_body) const override;
void _soft_body_move_point(
const RID& p_body,
int32_t p_point_index,
const Vector3& p_global_position
) override;
Vector3 _soft_body_get_point_global_position(const RID& p_body, int32_t p_point_index)
const override;
void _soft_body_remove_all_pinned_points(const RID& p_body) override;
void _soft_body_pin_point(const RID& p_body, int32_t p_point_index, bool p_pin) override;
bool _soft_body_is_point_pinned(const RID& p_body, int32_t p_point_index) const override;
RID _joint_create() override;
void _joint_clear(const RID& p_joint) override;
void _joint_make_pin(
const RID& p_joint,
const RID& p_body_a,
const Vector3& p_local_a,
const RID& p_body_b,
const Vector3& p_local_b
) override;
void _pin_joint_set_param(
const RID& p_joint,
PhysicsServer3D::PinJointParam p_param,
double p_value
) override;
double _pin_joint_get_param(const RID& p_joint, PhysicsServer3D::PinJointParam p_param)
const override;
void _pin_joint_set_local_a(const RID& p_joint, const Vector3& p_local_a) override;
Vector3 _pin_joint_get_local_a(const RID& p_joint) const override;
void _pin_joint_set_local_b(const RID& p_joint, const Vector3& p_local_b) override;
Vector3 _pin_joint_get_local_b(const RID& p_joint) const override;
void _joint_make_hinge(
const RID& p_joint,
const RID& p_body_a,
const Transform3D& p_hinge_a,
const RID& p_body_b,
const Transform3D& p_hinge_b
) override;
void _joint_make_hinge_simple(
const RID& p_joint,
const RID& p_body_a,
const Vector3& p_pivot_a,
const Vector3& p_axis_a,
const RID& p_body_b,
const Vector3& p_pivot_b,
const Vector3& p_axis_b
) override;
void _hinge_joint_set_param(
const RID& p_joint,
PhysicsServer3D::HingeJointParam p_param,
double p_value
) override;
double _hinge_joint_get_param(const RID& p_joint, PhysicsServer3D::HingeJointParam p_param)
const override;
void _hinge_joint_set_flag(
const RID& p_joint,
PhysicsServer3D::HingeJointFlag p_flag,
bool p_enabled
) override;
bool _hinge_joint_get_flag(const RID& p_joint, PhysicsServer3D::HingeJointFlag p_flag)
const override;
void _joint_make_slider(
const RID& p_joint,
const RID& p_body_a,
const Transform3D& p_local_ref_a,
const RID& p_body_b,
const Transform3D& p_local_ref_b
) override;
void _slider_joint_set_param(
const RID& p_joint,
PhysicsServer3D::SliderJointParam p_param,
double p_value
) override;
double _slider_joint_get_param(const RID& p_joint, PhysicsServer3D::SliderJointParam p_param)
const override;
void _joint_make_cone_twist(
const RID& p_joint,
const RID& p_body_a,
const Transform3D& p_local_ref_a,
const RID& p_body_b,
const Transform3D& p_local_ref_b
) override;
void _cone_twist_joint_set_param(
const RID& p_joint,
PhysicsServer3D::ConeTwistJointParam p_param,
double p_value
) override;
double _cone_twist_joint_get_param(
const RID& p_joint,
PhysicsServer3D::ConeTwistJointParam p_param
) const override;
void _joint_make_generic_6dof(
const RID& p_joint,
const RID& p_body_a,
const Transform3D& p_local_ref_a,
const RID& p_body_b,
const Transform3D& p_local_ref_b
) override;
void _generic_6dof_joint_set_param(
const RID& p_joint,
Vector3::Axis p_axis,
PhysicsServer3D::G6DOFJointAxisParam p_param,
double p_value
) override;
double _generic_6dof_joint_get_param(
const RID& p_joint,
Vector3::Axis p_axis,
PhysicsServer3D::G6DOFJointAxisParam p_param
) const override;
void _generic_6dof_joint_set_flag(
const RID& p_joint,
Vector3::Axis p_axis,
PhysicsServer3D::G6DOFJointAxisFlag p_flag,
bool p_enable
) override;
bool _generic_6dof_joint_get_flag(
const RID& p_joint,
Vector3::Axis p_axis,
PhysicsServer3D::G6DOFJointAxisFlag p_flag
) const override;
PhysicsServer3D::JointType _joint_get_type(const RID& p_joint) const override;
void _joint_set_solver_priority(const RID& p_joint, int32_t p_priority) override;
int32_t _joint_get_solver_priority(const RID& p_joint) const override;
void _joint_disable_collisions_between_bodies(const RID& p_joint, bool p_disable) override;
bool _joint_is_disabled_collisions_between_bodies(const RID& p_joint) const override;
void _free_rid(const RID& p_rid) override;
void _set_active(bool p_active) override;
void _init() override;
void _step(double p_step) override;
void _sync() override { }
void _flush_queries() override;
void _end_sync() override { }
void _finish() override;
bool _is_flushing_queries() const override;
int32_t _get_process_info(PhysicsServer3D::ProcessInfo p_process_info) override;
void free_space(JoltSpace3D* p_space);
void free_area(JoltAreaImpl3D* p_area);
void free_body(JoltBodyImpl3D* p_body);
void free_shape(JoltShapeImpl3D* p_shape);
void free_joint(JoltJointImpl3D* p_joint);
JoltSpace3D* get_space(const RID& p_rid) const { return space_owner.get_or_null(p_rid); }
JoltAreaImpl3D* get_area(const RID& p_rid) const { return area_owner.get_or_null(p_rid); }
JoltBodyImpl3D* get_body(const RID& p_rid) const { return body_owner.get_or_null(p_rid); }
JoltShapeImpl3D* get_shape(const RID& p_rid) const { return shape_owner.get_or_null(p_rid); }
JoltJointImpl3D* get_joint(const RID& p_rid) const { return joint_owner.get_or_null(p_rid); }
private:
mutable RID_PtrOwner<JoltSpace3D> space_owner;
mutable RID_PtrOwner<JoltAreaImpl3D> area_owner;
mutable RID_PtrOwner<JoltBodyImpl3D> body_owner;
mutable RID_PtrOwner<JoltShapeImpl3D> shape_owner;
mutable RID_PtrOwner<JoltJointImpl3D> joint_owner;
HashSet<JoltSpace3D*> active_spaces;
JoltJobSystem* job_system = nullptr;
bool active = true;
bool flushing_queries = false;
};