1/**************************************************************************/
2/* physics_server_3d.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef PHYSICS_SERVER_3D_H
32#define PHYSICS_SERVER_3D_H
33
34#include "core/io/resource.h"
35#include "core/object/class_db.h"
36#include "core/object/gdvirtual.gen.inc"
37#include "core/variant/native_ptr.h"
38
39class PhysicsDirectSpaceState3D;
40template <typename T>
41class TypedArray;
42
43class PhysicsDirectBodyState3D : public Object {
44 GDCLASS(PhysicsDirectBodyState3D, Object);
45
46protected:
47 static void _bind_methods();
48
49public:
50 virtual Vector3 get_total_gravity() const = 0;
51 virtual real_t get_total_angular_damp() const = 0;
52 virtual real_t get_total_linear_damp() const = 0;
53
54 virtual Vector3 get_center_of_mass() const = 0;
55 virtual Vector3 get_center_of_mass_local() const = 0;
56 virtual Basis get_principal_inertia_axes() const = 0;
57 virtual real_t get_inverse_mass() const = 0; // get the mass
58 virtual Vector3 get_inverse_inertia() const = 0; // get density of this body space
59 virtual Basis get_inverse_inertia_tensor() const = 0; // get density of this body space
60
61 virtual void set_linear_velocity(const Vector3 &p_velocity) = 0;
62 virtual Vector3 get_linear_velocity() const = 0;
63
64 virtual void set_angular_velocity(const Vector3 &p_velocity) = 0;
65 virtual Vector3 get_angular_velocity() const = 0;
66
67 virtual void set_transform(const Transform3D &p_transform) = 0;
68 virtual Transform3D get_transform() const = 0;
69
70 virtual Vector3 get_velocity_at_local_position(const Vector3 &p_position) const = 0;
71
72 virtual void apply_central_impulse(const Vector3 &p_impulse) = 0;
73 virtual void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0;
74 virtual void apply_torque_impulse(const Vector3 &p_impulse) = 0;
75
76 virtual void apply_central_force(const Vector3 &p_force) = 0;
77 virtual void apply_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
78 virtual void apply_torque(const Vector3 &p_torque) = 0;
79
80 virtual void add_constant_central_force(const Vector3 &p_force) = 0;
81 virtual void add_constant_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
82 virtual void add_constant_torque(const Vector3 &p_torque) = 0;
83
84 virtual void set_constant_force(const Vector3 &p_force) = 0;
85 virtual Vector3 get_constant_force() const = 0;
86
87 virtual void set_constant_torque(const Vector3 &p_torque) = 0;
88 virtual Vector3 get_constant_torque() const = 0;
89
90 virtual void set_sleep_state(bool p_sleep) = 0;
91 virtual bool is_sleeping() const = 0;
92
93 virtual int get_contact_count() const = 0;
94
95 virtual Vector3 get_contact_local_position(int p_contact_idx) const = 0;
96 virtual Vector3 get_contact_local_normal(int p_contact_idx) const = 0;
97 virtual Vector3 get_contact_impulse(int p_contact_idx) const = 0;
98 virtual int get_contact_local_shape(int p_contact_idx) const = 0;
99 virtual Vector3 get_contact_local_velocity_at_position(int p_contact_idx) const = 0;
100
101 virtual RID get_contact_collider(int p_contact_idx) const = 0;
102 virtual Vector3 get_contact_collider_position(int p_contact_idx) const = 0;
103 virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0;
104 virtual Object *get_contact_collider_object(int p_contact_idx) const;
105 virtual int get_contact_collider_shape(int p_contact_idx) const = 0;
106 virtual Vector3 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0;
107
108 virtual real_t get_step() const = 0;
109 virtual void integrate_forces();
110
111 virtual PhysicsDirectSpaceState3D *get_space_state() = 0;
112
113 PhysicsDirectBodyState3D();
114};
115
116class PhysicsRayQueryParameters3D;
117class PhysicsPointQueryParameters3D;
118class PhysicsShapeQueryParameters3D;
119
120class PhysicsDirectSpaceState3D : public Object {
121 GDCLASS(PhysicsDirectSpaceState3D, Object);
122
123private:
124 Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters3D> &p_ray_query);
125 TypedArray<Dictionary> _intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results = 32);
126 TypedArray<Dictionary> _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
127 Vector<real_t> _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
128 TypedArray<Vector3> _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
129 Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
130
131protected:
132 static void _bind_methods();
133
134public:
135 struct RayParameters {
136 Vector3 from;
137 Vector3 to;
138 HashSet<RID> exclude;
139 uint32_t collision_mask = UINT32_MAX;
140
141 bool collide_with_bodies = true;
142 bool collide_with_areas = false;
143
144 bool hit_from_inside = false;
145 bool hit_back_faces = true;
146
147 bool pick_ray = false;
148 };
149
150 struct RayResult {
151 Vector3 position;
152 Vector3 normal;
153 int face_index = -1;
154 RID rid;
155 ObjectID collider_id;
156 Object *collider = nullptr;
157 int shape = 0;
158 };
159
160 virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) = 0;
161
162 struct ShapeResult {
163 RID rid;
164 ObjectID collider_id;
165 Object *collider = nullptr;
166 int shape = 0;
167 };
168
169 struct PointParameters {
170 Vector3 position;
171 HashSet<RID> exclude;
172 uint32_t collision_mask = UINT32_MAX;
173
174 bool collide_with_bodies = true;
175 bool collide_with_areas = false;
176 };
177
178 virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) = 0;
179
180 struct ShapeParameters {
181 RID shape_rid;
182 Transform3D transform;
183 Vector3 motion;
184 real_t margin = 0.0;
185 HashSet<RID> exclude;
186 uint32_t collision_mask = UINT32_MAX;
187
188 bool collide_with_bodies = true;
189 bool collide_with_areas = false;
190 };
191
192 struct ShapeRestInfo {
193 Vector3 point;
194 Vector3 normal;
195 RID rid;
196 ObjectID collider_id;
197 int shape = 0;
198 Vector3 linear_velocity; // Velocity at contact point.
199 };
200
201 virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) = 0;
202 virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info = nullptr) = 0;
203 virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) = 0;
204 virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) = 0;
205
206 virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0;
207
208 PhysicsDirectSpaceState3D();
209};
210
211class PhysicsServer3DRenderingServerHandler : public Object {
212 GDCLASS(PhysicsServer3DRenderingServerHandler, Object)
213protected:
214 GDVIRTUAL2(_set_vertex, int, GDExtensionConstPtr<void>)
215 GDVIRTUAL2(_set_normal, int, GDExtensionConstPtr<void>)
216 GDVIRTUAL1(_set_aabb, const AABB &)
217
218 static void _bind_methods();
219
220public:
221 virtual void set_vertex(int p_vertex_id, const void *p_vector3);
222 virtual void set_normal(int p_vertex_id, const void *p_vector3);
223 virtual void set_aabb(const AABB &p_aabb);
224
225 virtual ~PhysicsServer3DRenderingServerHandler() {}
226};
227
228class PhysicsTestMotionParameters3D;
229class PhysicsTestMotionResult3D;
230
231class PhysicsServer3D : public Object {
232 GDCLASS(PhysicsServer3D, Object);
233
234 static PhysicsServer3D *singleton;
235
236 virtual bool _body_test_motion(RID p_body, const Ref<PhysicsTestMotionParameters3D> &p_parameters, const Ref<PhysicsTestMotionResult3D> &p_result = Ref<PhysicsTestMotionResult3D>());
237
238protected:
239 static void _bind_methods();
240
241public:
242 static PhysicsServer3D *get_singleton();
243
244 enum ShapeType {
245 SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
246 SHAPE_SEPARATION_RAY, ///< float:"length"
247 SHAPE_SPHERE, ///< float:"radius"
248 SHAPE_BOX, ///< vec3:"extents"
249 SHAPE_CAPSULE, ///< dict( float:"radius", float:"height"):capsule
250 SHAPE_CYLINDER, ///< dict( float:"radius", float:"height"):cylinder
251 SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
252 SHAPE_CONCAVE_POLYGON, ///< vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
253 SHAPE_HEIGHTMAP, ///< dict( int:"width", int:"depth",float:"cell_size", float_array:"heights"
254 SHAPE_SOFT_BODY, ///< Used internally, can't be created from the physics server.
255 SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
256 };
257
258 RID shape_create(ShapeType p_shape);
259
260 virtual RID world_boundary_shape_create() = 0;
261 virtual RID separation_ray_shape_create() = 0;
262 virtual RID sphere_shape_create() = 0;
263 virtual RID box_shape_create() = 0;
264 virtual RID capsule_shape_create() = 0;
265 virtual RID cylinder_shape_create() = 0;
266 virtual RID convex_polygon_shape_create() = 0;
267 virtual RID concave_polygon_shape_create() = 0;
268 virtual RID heightmap_shape_create() = 0;
269 virtual RID custom_shape_create() = 0;
270
271 virtual void shape_set_data(RID p_shape, const Variant &p_data) = 0;
272 virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) = 0;
273
274 virtual ShapeType shape_get_type(RID p_shape) const = 0;
275 virtual Variant shape_get_data(RID p_shape) const = 0;
276
277 virtual void shape_set_margin(RID p_shape, real_t p_margin) = 0;
278 virtual real_t shape_get_margin(RID p_shape) const = 0;
279
280 virtual real_t shape_get_custom_solver_bias(RID p_shape) const = 0;
281
282 /* SPACE API */
283
284 virtual RID space_create() = 0;
285 virtual void space_set_active(RID p_space, bool p_active) = 0;
286 virtual bool space_is_active(RID p_space) const = 0;
287
288 enum SpaceParameter {
289 SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
290 SPACE_PARAM_CONTACT_MAX_SEPARATION,
291 SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION,
292 SPACE_PARAM_CONTACT_DEFAULT_BIAS,
293 SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
294 SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
295 SPACE_PARAM_BODY_TIME_TO_SLEEP,
296 SPACE_PARAM_SOLVER_ITERATIONS,
297 };
298
299 virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) = 0;
300 virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0;
301
302 // this function only works on physics process, errors and returns null otherwise
303 virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) = 0;
304
305 virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) = 0;
306 virtual Vector<Vector3> space_get_contacts(RID p_space) const = 0;
307 virtual int space_get_contact_count(RID p_space) const = 0;
308
309 //missing space parameters
310
311 /* AREA API */
312
313 //missing attenuation? missing better override?
314
315 enum AreaParameter {
316 AREA_PARAM_GRAVITY_OVERRIDE_MODE,
317 AREA_PARAM_GRAVITY,
318 AREA_PARAM_GRAVITY_VECTOR,
319 AREA_PARAM_GRAVITY_IS_POINT,
320 AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE,
321 AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
322 AREA_PARAM_LINEAR_DAMP,
323 AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
324 AREA_PARAM_ANGULAR_DAMP,
325 AREA_PARAM_PRIORITY,
326 AREA_PARAM_WIND_FORCE_MAGNITUDE,
327 AREA_PARAM_WIND_SOURCE,
328 AREA_PARAM_WIND_DIRECTION,
329 AREA_PARAM_WIND_ATTENUATION_FACTOR,
330 };
331
332 virtual RID area_create() = 0;
333
334 virtual void area_set_space(RID p_area, RID p_space) = 0;
335 virtual RID area_get_space(RID p_area) const = 0;
336
337 enum AreaSpaceOverrideMode {
338 AREA_SPACE_OVERRIDE_DISABLED,
339 AREA_SPACE_OVERRIDE_COMBINE,
340 AREA_SPACE_OVERRIDE_COMBINE_REPLACE,
341 AREA_SPACE_OVERRIDE_REPLACE,
342 AREA_SPACE_OVERRIDE_REPLACE_COMBINE
343 };
344
345 virtual void area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) = 0;
346 virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0;
347 virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) = 0;
348
349 virtual int area_get_shape_count(RID p_area) const = 0;
350 virtual RID area_get_shape(RID p_area, int p_shape_idx) const = 0;
351 virtual Transform3D area_get_shape_transform(RID p_area, int p_shape_idx) const = 0;
352
353 virtual void area_remove_shape(RID p_area, int p_shape_idx) = 0;
354 virtual void area_clear_shapes(RID p_area) = 0;
355
356 virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) = 0;
357
358 virtual void area_attach_object_instance_id(RID p_area, ObjectID p_id) = 0;
359 virtual ObjectID area_get_object_instance_id(RID p_area) const = 0;
360
361 virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) = 0;
362 virtual void area_set_transform(RID p_area, const Transform3D &p_transform) = 0;
363
364 virtual Variant area_get_param(RID p_parea, AreaParameter p_param) const = 0;
365 virtual Transform3D area_get_transform(RID p_area) const = 0;
366
367 virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) = 0;
368 virtual uint32_t area_get_collision_layer(RID p_area) const = 0;
369
370 virtual void area_set_collision_mask(RID p_area, uint32_t p_mask) = 0;
371 virtual uint32_t area_get_collision_mask(RID p_area) const = 0;
372
373 virtual void area_set_monitorable(RID p_area, bool p_monitorable) = 0;
374
375 virtual void area_set_monitor_callback(RID p_area, const Callable &p_callback) = 0;
376 virtual void area_set_area_monitor_callback(RID p_area, const Callable &p_callback) = 0;
377
378 virtual void area_set_ray_pickable(RID p_area, bool p_enable) = 0;
379
380 /* BODY API */
381
382 //missing ccd?
383
384 enum BodyMode {
385 BODY_MODE_STATIC,
386 BODY_MODE_KINEMATIC,
387 BODY_MODE_RIGID,
388 BODY_MODE_RIGID_LINEAR,
389 };
390
391 enum BodyDampMode {
392 BODY_DAMP_MODE_COMBINE,
393 BODY_DAMP_MODE_REPLACE,
394 };
395
396 virtual RID body_create() = 0;
397
398 virtual void body_set_space(RID p_body, RID p_space) = 0;
399 virtual RID body_get_space(RID p_body) const = 0;
400
401 virtual void body_set_mode(RID p_body, BodyMode p_mode) = 0;
402 virtual BodyMode body_get_mode(RID p_body) const = 0;
403
404 virtual void body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) = 0;
405 virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) = 0;
406 virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform3D &p_transform) = 0;
407
408 virtual int body_get_shape_count(RID p_body) const = 0;
409 virtual RID body_get_shape(RID p_body, int p_shape_idx) const = 0;
410 virtual Transform3D body_get_shape_transform(RID p_body, int p_shape_idx) const = 0;
411
412 virtual void body_remove_shape(RID p_body, int p_shape_idx) = 0;
413 virtual void body_clear_shapes(RID p_body) = 0;
414
415 virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) = 0;
416
417 virtual void body_attach_object_instance_id(RID p_body, ObjectID p_id) = 0;
418 virtual ObjectID body_get_object_instance_id(RID p_body) const = 0;
419
420 virtual void body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) = 0;
421 virtual bool body_is_continuous_collision_detection_enabled(RID p_body) const = 0;
422
423 virtual void body_set_collision_layer(RID p_body, uint32_t p_layer) = 0;
424 virtual uint32_t body_get_collision_layer(RID p_body) const = 0;
425
426 virtual void body_set_collision_mask(RID p_body, uint32_t p_mask) = 0;
427 virtual uint32_t body_get_collision_mask(RID p_body) const = 0;
428
429 virtual void body_set_collision_priority(RID p_body, real_t p_priority) = 0;
430 virtual real_t body_get_collision_priority(RID p_body) const = 0;
431
432 virtual void body_set_user_flags(RID p_body, uint32_t p_flags) = 0;
433 virtual uint32_t body_get_user_flags(RID p_body) const = 0;
434
435 // common body variables
436 enum BodyParameter {
437 BODY_PARAM_BOUNCE,
438 BODY_PARAM_FRICTION,
439 BODY_PARAM_MASS, ///< unused for static, always infinite
440 BODY_PARAM_INERTIA,
441 BODY_PARAM_CENTER_OF_MASS,
442 BODY_PARAM_GRAVITY_SCALE,
443 BODY_PARAM_LINEAR_DAMP_MODE,
444 BODY_PARAM_ANGULAR_DAMP_MODE,
445 BODY_PARAM_LINEAR_DAMP,
446 BODY_PARAM_ANGULAR_DAMP,
447 BODY_PARAM_MAX,
448 };
449
450 virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) = 0;
451 virtual Variant body_get_param(RID p_body, BodyParameter p_param) const = 0;
452
453 virtual void body_reset_mass_properties(RID p_body) = 0;
454
455 //state
456 enum BodyState {
457 BODY_STATE_TRANSFORM,
458 BODY_STATE_LINEAR_VELOCITY,
459 BODY_STATE_ANGULAR_VELOCITY,
460 BODY_STATE_SLEEPING,
461 BODY_STATE_CAN_SLEEP
462 };
463
464 virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0;
465 virtual Variant body_get_state(RID p_body, BodyState p_state) const = 0;
466
467 virtual void body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) = 0;
468 virtual void body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0;
469 virtual void body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) = 0;
470
471 virtual void body_apply_central_force(RID p_body, const Vector3 &p_force) = 0;
472 virtual void body_apply_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
473 virtual void body_apply_torque(RID p_body, const Vector3 &p_torque) = 0;
474
475 virtual void body_add_constant_central_force(RID p_body, const Vector3 &p_force) = 0;
476 virtual void body_add_constant_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
477 virtual void body_add_constant_torque(RID p_body, const Vector3 &p_torque) = 0;
478
479 virtual void body_set_constant_force(RID p_body, const Vector3 &p_force) = 0;
480 virtual Vector3 body_get_constant_force(RID p_body) const = 0;
481
482 virtual void body_set_constant_torque(RID p_body, const Vector3 &p_torque) = 0;
483 virtual Vector3 body_get_constant_torque(RID p_body) const = 0;
484
485 virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) = 0;
486
487 enum BodyAxis {
488 BODY_AXIS_LINEAR_X = 1 << 0,
489 BODY_AXIS_LINEAR_Y = 1 << 1,
490 BODY_AXIS_LINEAR_Z = 1 << 2,
491 BODY_AXIS_ANGULAR_X = 1 << 3,
492 BODY_AXIS_ANGULAR_Y = 1 << 4,
493 BODY_AXIS_ANGULAR_Z = 1 << 5
494 };
495
496 virtual void body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) = 0;
497 virtual bool body_is_axis_locked(RID p_body, BodyAxis p_axis) const = 0;
498
499 //fix
500 virtual void body_add_collision_exception(RID p_body, RID p_body_b) = 0;
501 virtual void body_remove_collision_exception(RID p_body, RID p_body_b) = 0;
502 virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) = 0;
503
504 virtual void body_set_max_contacts_reported(RID p_body, int p_contacts) = 0;
505 virtual int body_get_max_contacts_reported(RID p_body) const = 0;
506
507 //missing remove
508 virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) = 0;
509 virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const = 0;
510
511 virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0;
512 virtual bool body_is_omitting_force_integration(RID p_body) const = 0;
513
514 virtual void body_set_state_sync_callback(RID p_body, const Callable &p_callable) = 0;
515 virtual void body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata = Variant()) = 0;
516
517 virtual void body_set_ray_pickable(RID p_body, bool p_enable) = 0;
518
519 // this function only works on physics process, errors and returns null otherwise
520 virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) = 0;
521
522 struct MotionParameters {
523 Transform3D from;
524 Vector3 motion;
525 real_t margin = 0.001;
526 int max_collisions = 1;
527 bool collide_separation_ray = false;
528 HashSet<RID> exclude_bodies;
529 HashSet<ObjectID> exclude_objects;
530 bool recovery_as_collision = false;
531
532 MotionParameters() {}
533
534 MotionParameters(const Transform3D &p_from, const Vector3 &p_motion, real_t p_margin = 0.001) :
535 from(p_from),
536 motion(p_motion),
537 margin(p_margin) {}
538 };
539
540 struct MotionCollision {
541 Vector3 position;
542 Vector3 normal;
543 Vector3 collider_velocity;
544 Vector3 collider_angular_velocity;
545 real_t depth = 0.0;
546 int local_shape = 0;
547 ObjectID collider_id;
548 RID collider;
549 int collider_shape = 0;
550
551 real_t get_angle(Vector3 p_up_direction) const {
552 return Math::acos(normal.dot(p_up_direction));
553 }
554 };
555
556 struct MotionResult {
557 Vector3 travel;
558 Vector3 remainder;
559 real_t collision_depth = 0.0;
560 real_t collision_safe_fraction = 0.0;
561 real_t collision_unsafe_fraction = 0.0;
562
563 static const int MAX_COLLISIONS = 32;
564 MotionCollision collisions[MAX_COLLISIONS];
565 int collision_count = 0;
566 };
567
568 virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) = 0;
569
570 /* SOFT BODY */
571
572 virtual RID soft_body_create() = 0;
573
574 virtual void soft_body_update_rendering_server(RID p_body, PhysicsServer3DRenderingServerHandler *p_rendering_server_handler) = 0;
575
576 virtual void soft_body_set_space(RID p_body, RID p_space) = 0;
577 virtual RID soft_body_get_space(RID p_body) const = 0;
578
579 virtual void soft_body_set_mesh(RID p_body, RID p_mesh) = 0;
580
581 virtual AABB soft_body_get_bounds(RID p_body) const = 0;
582
583 virtual void soft_body_set_collision_layer(RID p_body, uint32_t p_layer) = 0;
584 virtual uint32_t soft_body_get_collision_layer(RID p_body) const = 0;
585
586 virtual void soft_body_set_collision_mask(RID p_body, uint32_t p_mask) = 0;
587 virtual uint32_t soft_body_get_collision_mask(RID p_body) const = 0;
588
589 virtual void soft_body_add_collision_exception(RID p_body, RID p_body_b) = 0;
590 virtual void soft_body_remove_collision_exception(RID p_body, RID p_body_b) = 0;
591 virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) = 0;
592
593 virtual void soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0;
594 virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const = 0;
595
596 virtual void soft_body_set_transform(RID p_body, const Transform3D &p_transform) = 0;
597
598 virtual void soft_body_set_ray_pickable(RID p_body, bool p_enable) = 0;
599
600 virtual void soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) = 0;
601 virtual int soft_body_get_simulation_precision(RID p_body) const = 0;
602
603 virtual void soft_body_set_total_mass(RID p_body, real_t p_total_mass) = 0;
604 virtual real_t soft_body_get_total_mass(RID p_body) const = 0;
605
606 virtual void soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) = 0;
607 virtual real_t soft_body_get_linear_stiffness(RID p_body) const = 0;
608
609 virtual void soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) = 0;
610 virtual real_t soft_body_get_pressure_coefficient(RID p_body) const = 0;
611
612 virtual void soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) = 0;
613 virtual real_t soft_body_get_damping_coefficient(RID p_body) const = 0;
614
615 virtual void soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) = 0;
616 virtual real_t soft_body_get_drag_coefficient(RID p_body) const = 0;
617
618 virtual void soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) = 0;
619 virtual Vector3 soft_body_get_point_global_position(RID p_body, int p_point_index) const = 0;
620
621 virtual void soft_body_remove_all_pinned_points(RID p_body) = 0;
622 virtual void soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) = 0;
623 virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) const = 0;
624
625 /* JOINT API */
626
627 enum JointType {
628 JOINT_TYPE_PIN,
629 JOINT_TYPE_HINGE,
630 JOINT_TYPE_SLIDER,
631 JOINT_TYPE_CONE_TWIST,
632 JOINT_TYPE_6DOF,
633 JOINT_TYPE_MAX,
634
635 };
636
637 virtual RID joint_create() = 0;
638
639 virtual void joint_clear(RID p_joint) = 0;
640
641 virtual JointType joint_get_type(RID p_joint) const = 0;
642
643 virtual void joint_set_solver_priority(RID p_joint, int p_priority) = 0;
644 virtual int joint_get_solver_priority(RID p_joint) const = 0;
645
646 virtual void joint_disable_collisions_between_bodies(RID p_joint, bool p_disable) = 0;
647 virtual bool joint_is_disabled_collisions_between_bodies(RID p_joint) const = 0;
648
649 virtual void joint_make_pin(RID p_joint, RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) = 0;
650
651 enum PinJointParam {
652 PIN_JOINT_BIAS,
653 PIN_JOINT_DAMPING,
654 PIN_JOINT_IMPULSE_CLAMP
655 };
656
657 virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) = 0;
658 virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
659
660 virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) = 0;
661 virtual Vector3 pin_joint_get_local_a(RID p_joint) const = 0;
662
663 virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) = 0;
664 virtual Vector3 pin_joint_get_local_b(RID p_joint) const = 0;
665
666 enum HingeJointParam {
667 HINGE_JOINT_BIAS,
668 HINGE_JOINT_LIMIT_UPPER,
669 HINGE_JOINT_LIMIT_LOWER,
670 HINGE_JOINT_LIMIT_BIAS,
671 HINGE_JOINT_LIMIT_SOFTNESS,
672 HINGE_JOINT_LIMIT_RELAXATION,
673 HINGE_JOINT_MOTOR_TARGET_VELOCITY,
674 HINGE_JOINT_MOTOR_MAX_IMPULSE,
675 HINGE_JOINT_MAX
676 };
677
678 enum HingeJointFlag {
679 HINGE_JOINT_FLAG_USE_LIMIT,
680 HINGE_JOINT_FLAG_ENABLE_MOTOR,
681 HINGE_JOINT_FLAG_MAX
682 };
683
684 virtual void joint_make_hinge(RID p_joint, RID p_body_A, const Transform3D &p_hinge_A, RID p_body_B, const Transform3D &p_hinge_B) = 0;
685 virtual void joint_make_hinge_simple(RID p_joint, RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) = 0;
686
687 virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) = 0;
688 virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const = 0;
689
690 virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) = 0;
691 virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const = 0;
692
693 enum SliderJointParam {
694 SLIDER_JOINT_LINEAR_LIMIT_UPPER,
695 SLIDER_JOINT_LINEAR_LIMIT_LOWER,
696 SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
697 SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
698 SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
699 SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
700 SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
701 SLIDER_JOINT_LINEAR_MOTION_DAMPING,
702 SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
703 SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
704 SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
705
706 SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
707 SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
708 SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
709 SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
710 SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
711 SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
712 SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
713 SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
714 SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
715 SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
716 SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
717 SLIDER_JOINT_MAX
718
719 };
720
721 virtual void joint_make_slider(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) = 0; //reference frame is A
722
723 virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) = 0;
724 virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const = 0;
725
726 enum ConeTwistJointParam {
727 CONE_TWIST_JOINT_SWING_SPAN,
728 CONE_TWIST_JOINT_TWIST_SPAN,
729 CONE_TWIST_JOINT_BIAS,
730 CONE_TWIST_JOINT_SOFTNESS,
731 CONE_TWIST_JOINT_RELAXATION,
732 CONE_TWIST_MAX
733 };
734
735 virtual void joint_make_cone_twist(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) = 0; //reference frame is A
736
737 virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) = 0;
738 virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const = 0;
739
740 enum G6DOFJointAxisParam {
741 G6DOF_JOINT_LINEAR_LOWER_LIMIT,
742 G6DOF_JOINT_LINEAR_UPPER_LIMIT,
743 G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
744 G6DOF_JOINT_LINEAR_RESTITUTION,
745 G6DOF_JOINT_LINEAR_DAMPING,
746 G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
747 G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
748 G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
749 G6DOF_JOINT_LINEAR_SPRING_DAMPING,
750 G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
751 G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
752 G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
753 G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
754 G6DOF_JOINT_ANGULAR_DAMPING,
755 G6DOF_JOINT_ANGULAR_RESTITUTION,
756 G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
757 G6DOF_JOINT_ANGULAR_ERP,
758 G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
759 G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
760 G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
761 G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
762 G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
763 G6DOF_JOINT_MAX
764 };
765
766 enum G6DOFJointAxisFlag {
767 G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
768 G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
769 G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
770 G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
771 G6DOF_JOINT_FLAG_ENABLE_MOTOR,
772 G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
773 G6DOF_JOINT_FLAG_MAX
774 };
775
776 virtual void joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) = 0; //reference frame is A
777
778 virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) = 0;
779 virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) const = 0;
780
781 virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) = 0;
782 virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) const = 0;
783
784 /* QUERY API */
785
786 enum AreaBodyStatus {
787 AREA_BODY_ADDED,
788 AREA_BODY_REMOVED
789 };
790
791 /* MISC */
792
793 virtual void free(RID p_rid) = 0;
794
795 virtual void set_active(bool p_active) = 0;
796 virtual void init() = 0;
797 virtual void step(real_t p_step) = 0;
798 virtual void sync() = 0;
799 virtual void flush_queries() = 0;
800 virtual void end_sync() = 0;
801 virtual void finish() = 0;
802
803 virtual bool is_flushing_queries() const = 0;
804
805 enum ProcessInfo {
806 INFO_ACTIVE_OBJECTS,
807 INFO_COLLISION_PAIRS,
808 INFO_ISLAND_COUNT
809 };
810
811 virtual int get_process_info(ProcessInfo p_info) = 0;
812
813 PhysicsServer3D();
814 ~PhysicsServer3D();
815};
816
817class PhysicsRayQueryParameters3D : public RefCounted {
818 GDCLASS(PhysicsRayQueryParameters3D, RefCounted);
819
820 PhysicsDirectSpaceState3D::RayParameters parameters;
821
822protected:
823 static void _bind_methods();
824
825public:
826 static Ref<PhysicsRayQueryParameters3D> create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude);
827 const PhysicsDirectSpaceState3D::RayParameters &get_parameters() const { return parameters; }
828
829 void set_from(const Vector3 &p_from) { parameters.from = p_from; }
830 const Vector3 &get_from() const { return parameters.from; }
831
832 void set_to(const Vector3 &p_to) { parameters.to = p_to; }
833 const Vector3 &get_to() const { return parameters.to; }
834
835 void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
836 uint32_t get_collision_mask() const { return parameters.collision_mask; }
837
838 void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
839 bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
840
841 void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
842 bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
843
844 void set_hit_from_inside(bool p_enable) { parameters.hit_from_inside = p_enable; }
845 bool is_hit_from_inside_enabled() const { return parameters.hit_from_inside; }
846
847 void set_hit_back_faces(bool p_enable) { parameters.hit_back_faces = p_enable; }
848 bool is_hit_back_faces_enabled() const { return parameters.hit_back_faces; }
849
850 void set_exclude(const TypedArray<RID> &p_exclude);
851 TypedArray<RID> get_exclude() const;
852};
853
854class PhysicsPointQueryParameters3D : public RefCounted {
855 GDCLASS(PhysicsPointQueryParameters3D, RefCounted);
856
857 PhysicsDirectSpaceState3D::PointParameters parameters;
858
859protected:
860 static void _bind_methods();
861
862public:
863 const PhysicsDirectSpaceState3D::PointParameters &get_parameters() const { return parameters; }
864
865 void set_position(const Vector3 &p_position) { parameters.position = p_position; }
866 const Vector3 &get_position() const { return parameters.position; }
867
868 void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
869 uint32_t get_collision_mask() const { return parameters.collision_mask; }
870
871 void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
872 bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
873
874 void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
875 bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
876
877 void set_exclude(const TypedArray<RID> &p_exclude);
878 TypedArray<RID> get_exclude() const;
879};
880
881class PhysicsShapeQueryParameters3D : public RefCounted {
882 GDCLASS(PhysicsShapeQueryParameters3D, RefCounted);
883
884 PhysicsDirectSpaceState3D::ShapeParameters parameters;
885
886 Ref<Resource> shape_ref;
887
888protected:
889 static void _bind_methods();
890
891public:
892 const PhysicsDirectSpaceState3D::ShapeParameters &get_parameters() const { return parameters; }
893
894 void set_shape(const Ref<Resource> &p_shape_ref);
895 Ref<Resource> get_shape() const { return shape_ref; }
896
897 void set_shape_rid(const RID &p_shape);
898 RID get_shape_rid() const { return parameters.shape_rid; }
899
900 void set_transform(const Transform3D &p_transform) { parameters.transform = p_transform; }
901 const Transform3D &get_transform() const { return parameters.transform; }
902
903 void set_motion(const Vector3 &p_motion) { parameters.motion = p_motion; }
904 const Vector3 &get_motion() const { return parameters.motion; }
905
906 void set_margin(real_t p_margin) { parameters.margin = p_margin; }
907 real_t get_margin() const { return parameters.margin; }
908
909 void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
910 uint32_t get_collision_mask() const { return parameters.collision_mask; }
911
912 void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
913 bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
914
915 void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
916 bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
917
918 void set_exclude(const TypedArray<RID> &p_exclude);
919 TypedArray<RID> get_exclude() const;
920};
921
922class PhysicsTestMotionParameters3D : public RefCounted {
923 GDCLASS(PhysicsTestMotionParameters3D, RefCounted);
924
925 PhysicsServer3D::MotionParameters parameters;
926
927protected:
928 static void _bind_methods();
929
930public:
931 const PhysicsServer3D::MotionParameters &get_parameters() const { return parameters; }
932
933 const Transform3D &get_from() const { return parameters.from; }
934 void set_from(const Transform3D &p_from) { parameters.from = p_from; }
935
936 const Vector3 &get_motion() const { return parameters.motion; }
937 void set_motion(const Vector3 &p_motion) { parameters.motion = p_motion; }
938
939 real_t get_margin() const { return parameters.margin; }
940 void set_margin(real_t p_margin) { parameters.margin = p_margin; }
941
942 int get_max_collisions() const { return parameters.max_collisions; }
943 void set_max_collisions(int p_max_collisions) { parameters.max_collisions = p_max_collisions; }
944
945 bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; }
946 void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; }
947
948 TypedArray<RID> get_exclude_bodies() const;
949 void set_exclude_bodies(const TypedArray<RID> &p_exclude);
950
951 TypedArray<uint64_t> get_exclude_objects() const;
952 void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
953
954 bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
955 void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
956};
957
958class PhysicsTestMotionResult3D : public RefCounted {
959 GDCLASS(PhysicsTestMotionResult3D, RefCounted);
960
961 PhysicsServer3D::MotionResult result;
962
963protected:
964 static void _bind_methods();
965
966public:
967 PhysicsServer3D::MotionResult *get_result_ptr() const { return const_cast<PhysicsServer3D::MotionResult *>(&result); }
968
969 Vector3 get_travel() const;
970 Vector3 get_remainder() const;
971 real_t get_collision_safe_fraction() const;
972 real_t get_collision_unsafe_fraction() const;
973
974 int get_collision_count() const;
975
976 Vector3 get_collision_point(int p_collision_index = 0) const;
977 Vector3 get_collision_normal(int p_collision_index = 0) const;
978 Vector3 get_collider_velocity(int p_collision_index = 0) const;
979 ObjectID get_collider_id(int p_collision_index = 0) const;
980 RID get_collider_rid(int p_collision_index = 0) const;
981 Object *get_collider(int p_collision_index = 0) const;
982 int get_collider_shape(int p_collision_index = 0) const;
983 int get_collision_local_shape(int p_collision_index = 0) const;
984 real_t get_collision_depth(int p_collision_index = 0) const;
985};
986
987class PhysicsServer3DManager : public Object {
988 GDCLASS(PhysicsServer3DManager, Object);
989
990 static PhysicsServer3DManager *singleton;
991
992 struct ClassInfo {
993 String name;
994 Callable create_callback;
995
996 ClassInfo() {}
997
998 ClassInfo(String p_name, Callable p_create_callback) :
999 name(p_name),
1000 create_callback(p_create_callback) {}
1001
1002 ClassInfo(const ClassInfo &p_ci) :
1003 name(p_ci.name),
1004 create_callback(p_ci.create_callback) {}
1005
1006 void operator=(const ClassInfo &p_ci) {
1007 name = p_ci.name;
1008 create_callback = p_ci.create_callback;
1009 }
1010 };
1011
1012 Vector<ClassInfo> physics_servers;
1013 int default_server_id = -1;
1014 int default_server_priority = -1;
1015
1016 void on_servers_changed();
1017
1018protected:
1019 static void _bind_methods();
1020
1021public:
1022 static const String setting_property_name;
1023
1024 static PhysicsServer3DManager *get_singleton();
1025
1026 void register_server(const String &p_name, const Callable &p_create_callback);
1027 void set_default_server(const String &p_name, int p_priority = 0);
1028 int find_server_id(const String &p_name);
1029 int get_servers_count();
1030 String get_server_name(int p_id);
1031 PhysicsServer3D *new_default_server();
1032 PhysicsServer3D *new_server(const String &p_name);
1033
1034 PhysicsServer3DManager();
1035 ~PhysicsServer3DManager();
1036};
1037
1038VARIANT_ENUM_CAST(PhysicsServer3D::ShapeType);
1039VARIANT_ENUM_CAST(PhysicsServer3D::SpaceParameter);
1040VARIANT_ENUM_CAST(PhysicsServer3D::AreaParameter);
1041VARIANT_ENUM_CAST(PhysicsServer3D::AreaSpaceOverrideMode);
1042VARIANT_ENUM_CAST(PhysicsServer3D::BodyMode);
1043VARIANT_ENUM_CAST(PhysicsServer3D::BodyParameter);
1044VARIANT_ENUM_CAST(PhysicsServer3D::BodyDampMode);
1045VARIANT_ENUM_CAST(PhysicsServer3D::BodyState);
1046VARIANT_ENUM_CAST(PhysicsServer3D::BodyAxis);
1047VARIANT_ENUM_CAST(PhysicsServer3D::PinJointParam);
1048VARIANT_ENUM_CAST(PhysicsServer3D::JointType);
1049VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointParam);
1050VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointFlag);
1051VARIANT_ENUM_CAST(PhysicsServer3D::SliderJointParam);
1052VARIANT_ENUM_CAST(PhysicsServer3D::ConeTwistJointParam);
1053VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisParam);
1054VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisFlag);
1055VARIANT_ENUM_CAST(PhysicsServer3D::AreaBodyStatus);
1056VARIANT_ENUM_CAST(PhysicsServer3D::ProcessInfo);
1057
1058#endif // PHYSICS_SERVER_3D_H
1059