| 1 | /**************************************************************************/ |
| 2 | /* physics_server_3d_extension.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_EXTENSION_H |
| 32 | #define PHYSICS_SERVER_3D_EXTENSION_H |
| 33 | |
| 34 | #include "core/extension/ext_wrappers.gen.inc" |
| 35 | #include "core/object/script_language.h" |
| 36 | #include "core/variant/native_ptr.h" |
| 37 | #include "core/variant/type_info.h" |
| 38 | #include "core/variant/typed_array.h" |
| 39 | #include "servers/physics_server_3d.h" |
| 40 | |
| 41 | class PhysicsDirectBodyState3DExtension : public PhysicsDirectBodyState3D { |
| 42 | GDCLASS(PhysicsDirectBodyState3DExtension, PhysicsDirectBodyState3D); |
| 43 | |
| 44 | protected: |
| 45 | static void _bind_methods(); |
| 46 | |
| 47 | public: |
| 48 | // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. |
| 49 | |
| 50 | EXBIND0RC(Vector3, get_total_gravity) |
| 51 | EXBIND0RC(real_t, get_total_angular_damp) |
| 52 | EXBIND0RC(real_t, get_total_linear_damp) |
| 53 | |
| 54 | EXBIND0RC(Vector3, get_center_of_mass) |
| 55 | EXBIND0RC(Vector3, get_center_of_mass_local) |
| 56 | EXBIND0RC(Basis, get_principal_inertia_axes) |
| 57 | EXBIND0RC(real_t, get_inverse_mass) |
| 58 | EXBIND0RC(Vector3, get_inverse_inertia) |
| 59 | EXBIND0RC(Basis, get_inverse_inertia_tensor) |
| 60 | |
| 61 | EXBIND1(set_linear_velocity, const Vector3 &) |
| 62 | EXBIND0RC(Vector3, get_linear_velocity) |
| 63 | |
| 64 | EXBIND1(set_angular_velocity, const Vector3 &) |
| 65 | EXBIND0RC(Vector3, get_angular_velocity) |
| 66 | |
| 67 | EXBIND1(set_transform, const Transform3D &) |
| 68 | EXBIND0RC(Transform3D, get_transform) |
| 69 | |
| 70 | EXBIND1RC(Vector3, get_velocity_at_local_position, const Vector3 &) |
| 71 | |
| 72 | EXBIND1(apply_central_impulse, const Vector3 &) |
| 73 | EXBIND2(apply_impulse, const Vector3 &, const Vector3 &) |
| 74 | EXBIND1(apply_torque_impulse, const Vector3 &) |
| 75 | |
| 76 | EXBIND1(apply_central_force, const Vector3 &) |
| 77 | EXBIND2(apply_force, const Vector3 &, const Vector3 &) |
| 78 | EXBIND1(apply_torque, const Vector3 &) |
| 79 | |
| 80 | EXBIND1(add_constant_central_force, const Vector3 &) |
| 81 | EXBIND2(add_constant_force, const Vector3 &, const Vector3 &) |
| 82 | EXBIND1(add_constant_torque, const Vector3 &) |
| 83 | |
| 84 | EXBIND1(set_constant_force, const Vector3 &) |
| 85 | EXBIND0RC(Vector3, get_constant_force) |
| 86 | |
| 87 | EXBIND1(set_constant_torque, const Vector3 &) |
| 88 | EXBIND0RC(Vector3, get_constant_torque) |
| 89 | |
| 90 | EXBIND1(set_sleep_state, bool) |
| 91 | EXBIND0RC(bool, is_sleeping) |
| 92 | |
| 93 | EXBIND0RC(int, get_contact_count) |
| 94 | |
| 95 | EXBIND1RC(Vector3, get_contact_local_position, int) |
| 96 | EXBIND1RC(Vector3, get_contact_local_normal, int) |
| 97 | EXBIND1RC(Vector3, get_contact_impulse, int) |
| 98 | EXBIND1RC(int, get_contact_local_shape, int) |
| 99 | EXBIND1RC(Vector3, get_contact_local_velocity_at_position, int) |
| 100 | EXBIND1RC(RID, get_contact_collider, int) |
| 101 | EXBIND1RC(Vector3, get_contact_collider_position, int) |
| 102 | EXBIND1RC(ObjectID, get_contact_collider_id, int) |
| 103 | EXBIND1RC(Object *, get_contact_collider_object, int) |
| 104 | EXBIND1RC(int, get_contact_collider_shape, int) |
| 105 | EXBIND1RC(Vector3, get_contact_collider_velocity_at_position, int) |
| 106 | |
| 107 | EXBIND0RC(real_t, get_step) |
| 108 | |
| 109 | EXBIND0(integrate_forces) |
| 110 | EXBIND0R(PhysicsDirectSpaceState3D *, get_space_state) |
| 111 | |
| 112 | PhysicsDirectBodyState3DExtension(); |
| 113 | }; |
| 114 | |
| 115 | typedef PhysicsDirectSpaceState3D::RayResult PhysicsServer3DExtensionRayResult; |
| 116 | typedef PhysicsDirectSpaceState3D::ShapeResult PhysicsServer3DExtensionShapeResult; |
| 117 | typedef PhysicsDirectSpaceState3D::ShapeRestInfo PhysicsServer3DExtensionShapeRestInfo; |
| 118 | |
| 119 | GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionRayResult) |
| 120 | GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionShapeResult) |
| 121 | GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionShapeRestInfo) |
| 122 | |
| 123 | class PhysicsDirectSpaceState3DExtension : public PhysicsDirectSpaceState3D { |
| 124 | GDCLASS(PhysicsDirectSpaceState3DExtension, PhysicsDirectSpaceState3D); |
| 125 | |
| 126 | thread_local static const HashSet<RID> *exclude; |
| 127 | |
| 128 | protected: |
| 129 | static void _bind_methods(); |
| 130 | bool is_body_excluded_from_query(const RID &p_body) const; |
| 131 | |
| 132 | GDVIRTUAL9R(bool, _intersect_ray, const Vector3 &, const Vector3 &, uint32_t, bool, bool, bool, bool, bool, GDExtensionPtr<PhysicsServer3DExtensionRayResult>) |
| 133 | GDVIRTUAL6R(int, _intersect_point, const Vector3 &, uint32_t, bool, bool, GDExtensionPtr<PhysicsServer3DExtensionShapeResult>, int) |
| 134 | GDVIRTUAL9R(int, _intersect_shape, RID, const Transform3D &, const Vector3 &, real_t, uint32_t, bool, bool, GDExtensionPtr<PhysicsServer3DExtensionShapeResult>, int) |
| 135 | GDVIRTUAL10R(bool, _cast_motion, RID, const Transform3D &, const Vector3 &, real_t, uint32_t, bool, bool, GDExtensionPtr<real_t>, GDExtensionPtr<real_t>, GDExtensionPtr<PhysicsServer3DExtensionShapeRestInfo>) |
| 136 | GDVIRTUAL10R(bool, _collide_shape, RID, const Transform3D &, const Vector3 &, real_t, uint32_t, bool, bool, GDExtensionPtr<Vector3>, int, GDExtensionPtr<int>) |
| 137 | GDVIRTUAL8R(bool, _rest_info, RID, const Transform3D &, const Vector3 &, real_t, uint32_t, bool, bool, GDExtensionPtr<PhysicsServer3DExtensionShapeRestInfo>) |
| 138 | GDVIRTUAL2RC(Vector3, _get_closest_point_to_object_volume, RID, const Vector3 &) |
| 139 | |
| 140 | public: |
| 141 | virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override { |
| 142 | exclude = &p_parameters.exclude; |
| 143 | bool ret = false; |
| 144 | GDVIRTUAL_REQUIRED_CALL(_intersect_ray, p_parameters.from, p_parameters.to, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, p_parameters.hit_from_inside, p_parameters.hit_back_faces, p_parameters.pick_ray, &r_result, ret); |
| 145 | exclude = nullptr; |
| 146 | return ret; |
| 147 | } |
| 148 | virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { |
| 149 | exclude = &p_parameters.exclude; |
| 150 | int ret = false; |
| 151 | GDVIRTUAL_REQUIRED_CALL(_intersect_point, p_parameters.position, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret); |
| 152 | exclude = nullptr; |
| 153 | return ret; |
| 154 | } |
| 155 | virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { |
| 156 | exclude = &p_parameters.exclude; |
| 157 | int ret = 0; |
| 158 | GDVIRTUAL_REQUIRED_CALL(_intersect_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret); |
| 159 | exclude = nullptr; |
| 160 | return ret; |
| 161 | } |
| 162 | virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info = nullptr) override { |
| 163 | exclude = &p_parameters.exclude; |
| 164 | bool ret = false; |
| 165 | GDVIRTUAL_REQUIRED_CALL(_cast_motion, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, &p_closest_safe, &p_closest_unsafe, r_info, ret); |
| 166 | exclude = nullptr; |
| 167 | return ret; |
| 168 | } |
| 169 | virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override { |
| 170 | exclude = &p_parameters.exclude; |
| 171 | bool ret = false; |
| 172 | GDVIRTUAL_REQUIRED_CALL(_collide_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, &r_result_count, ret); |
| 173 | exclude = nullptr; |
| 174 | return ret; |
| 175 | } |
| 176 | virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override { |
| 177 | exclude = &p_parameters.exclude; |
| 178 | bool ret = false; |
| 179 | GDVIRTUAL_REQUIRED_CALL(_rest_info, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_info, ret); |
| 180 | exclude = nullptr; |
| 181 | return ret; |
| 182 | } |
| 183 | |
| 184 | virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override { |
| 185 | Vector3 ret; |
| 186 | GDVIRTUAL_REQUIRED_CALL(_get_closest_point_to_object_volume, p_object, p_point, ret); |
| 187 | return ret; |
| 188 | } |
| 189 | |
| 190 | PhysicsDirectSpaceState3DExtension(); |
| 191 | }; |
| 192 | |
| 193 | typedef PhysicsServer3D::MotionCollision PhysicsServer3DExtensionMotionCollision; |
| 194 | typedef PhysicsServer3D::MotionResult PhysicsServer3DExtensionMotionResult; |
| 195 | |
| 196 | GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionMotionCollision) |
| 197 | GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionMotionResult) |
| 198 | |
| 199 | class PhysicsServer3DExtension : public PhysicsServer3D { |
| 200 | GDCLASS(PhysicsServer3DExtension, PhysicsServer3D); |
| 201 | |
| 202 | protected: |
| 203 | static void _bind_methods(); |
| 204 | |
| 205 | public: |
| 206 | // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. |
| 207 | |
| 208 | /* SHAPE API */ |
| 209 | |
| 210 | EXBIND0R(RID, world_boundary_shape_create) |
| 211 | EXBIND0R(RID, separation_ray_shape_create) |
| 212 | EXBIND0R(RID, sphere_shape_create) |
| 213 | EXBIND0R(RID, box_shape_create) |
| 214 | EXBIND0R(RID, capsule_shape_create) |
| 215 | EXBIND0R(RID, cylinder_shape_create) |
| 216 | EXBIND0R(RID, convex_polygon_shape_create) |
| 217 | EXBIND0R(RID, concave_polygon_shape_create) |
| 218 | EXBIND0R(RID, heightmap_shape_create) |
| 219 | EXBIND0R(RID, custom_shape_create) |
| 220 | |
| 221 | EXBIND2(shape_set_data, RID, const Variant &) |
| 222 | EXBIND2(shape_set_custom_solver_bias, RID, real_t) |
| 223 | |
| 224 | EXBIND2(shape_set_margin, RID, real_t) |
| 225 | EXBIND1RC(real_t, shape_get_margin, RID) |
| 226 | |
| 227 | EXBIND1RC(ShapeType, shape_get_type, RID) |
| 228 | EXBIND1RC(Variant, shape_get_data, RID) |
| 229 | EXBIND1RC(real_t, shape_get_custom_solver_bias, RID) |
| 230 | |
| 231 | /* SPACE API */ |
| 232 | |
| 233 | EXBIND0R(RID, space_create) |
| 234 | EXBIND2(space_set_active, RID, bool) |
| 235 | EXBIND1RC(bool, space_is_active, RID) |
| 236 | |
| 237 | EXBIND3(space_set_param, RID, SpaceParameter, real_t) |
| 238 | EXBIND2RC(real_t, space_get_param, RID, SpaceParameter) |
| 239 | |
| 240 | EXBIND1R(PhysicsDirectSpaceState3D *, space_get_direct_state, RID) |
| 241 | |
| 242 | EXBIND2(space_set_debug_contacts, RID, int) |
| 243 | EXBIND1RC(Vector<Vector3>, space_get_contacts, RID) |
| 244 | EXBIND1RC(int, space_get_contact_count, RID) |
| 245 | |
| 246 | /* AREA API */ |
| 247 | |
| 248 | //EXBIND0RID(area); |
| 249 | EXBIND0R(RID, area_create) |
| 250 | |
| 251 | EXBIND2(area_set_space, RID, RID) |
| 252 | EXBIND1RC(RID, area_get_space, RID) |
| 253 | |
| 254 | EXBIND4(area_add_shape, RID, RID, const Transform3D &, bool) |
| 255 | EXBIND3(area_set_shape, RID, int, RID) |
| 256 | EXBIND3(area_set_shape_transform, RID, int, const Transform3D &) |
| 257 | EXBIND3(area_set_shape_disabled, RID, int, bool) |
| 258 | |
| 259 | EXBIND1RC(int, area_get_shape_count, RID) |
| 260 | EXBIND2RC(RID, area_get_shape, RID, int) |
| 261 | EXBIND2RC(Transform3D, area_get_shape_transform, RID, int) |
| 262 | |
| 263 | EXBIND2(area_remove_shape, RID, int) |
| 264 | EXBIND1(area_clear_shapes, RID) |
| 265 | |
| 266 | EXBIND2(area_attach_object_instance_id, RID, ObjectID) |
| 267 | EXBIND1RC(ObjectID, area_get_object_instance_id, RID) |
| 268 | |
| 269 | EXBIND3(area_set_param, RID, AreaParameter, const Variant &) |
| 270 | EXBIND2(area_set_transform, RID, const Transform3D &) |
| 271 | |
| 272 | EXBIND2RC(Variant, area_get_param, RID, AreaParameter) |
| 273 | EXBIND1RC(Transform3D, area_get_transform, RID) |
| 274 | |
| 275 | EXBIND2(area_set_collision_layer, RID, uint32_t) |
| 276 | EXBIND1RC(uint32_t, area_get_collision_layer, RID) |
| 277 | |
| 278 | EXBIND2(area_set_collision_mask, RID, uint32_t) |
| 279 | EXBIND1RC(uint32_t, area_get_collision_mask, RID) |
| 280 | |
| 281 | EXBIND2(area_set_monitorable, RID, bool) |
| 282 | EXBIND2(area_set_ray_pickable, RID, bool) |
| 283 | |
| 284 | EXBIND2(area_set_monitor_callback, RID, const Callable &) |
| 285 | EXBIND2(area_set_area_monitor_callback, RID, const Callable &) |
| 286 | |
| 287 | /* BODY API */ |
| 288 | |
| 289 | //EXBIND2RID(body,BodyMode,bool); |
| 290 | EXBIND0R(RID, body_create) |
| 291 | |
| 292 | EXBIND2(body_set_space, RID, RID) |
| 293 | EXBIND1RC(RID, body_get_space, RID) |
| 294 | |
| 295 | EXBIND2(body_set_mode, RID, BodyMode) |
| 296 | EXBIND1RC(BodyMode, body_get_mode, RID) |
| 297 | |
| 298 | EXBIND4(body_add_shape, RID, RID, const Transform3D &, bool) |
| 299 | EXBIND3(body_set_shape, RID, int, RID) |
| 300 | EXBIND3(body_set_shape_transform, RID, int, const Transform3D &) |
| 301 | EXBIND3(body_set_shape_disabled, RID, int, bool) |
| 302 | |
| 303 | EXBIND1RC(int, body_get_shape_count, RID) |
| 304 | EXBIND2RC(RID, body_get_shape, RID, int) |
| 305 | EXBIND2RC(Transform3D, body_get_shape_transform, RID, int) |
| 306 | |
| 307 | EXBIND2(body_remove_shape, RID, int) |
| 308 | EXBIND1(body_clear_shapes, RID) |
| 309 | |
| 310 | EXBIND2(body_attach_object_instance_id, RID, ObjectID) |
| 311 | EXBIND1RC(ObjectID, body_get_object_instance_id, RID) |
| 312 | |
| 313 | EXBIND2(body_set_enable_continuous_collision_detection, RID, bool) |
| 314 | EXBIND1RC(bool, body_is_continuous_collision_detection_enabled, RID) |
| 315 | |
| 316 | EXBIND2(body_set_collision_layer, RID, uint32_t) |
| 317 | EXBIND1RC(uint32_t, body_get_collision_layer, RID) |
| 318 | |
| 319 | EXBIND2(body_set_collision_mask, RID, uint32_t) |
| 320 | EXBIND1RC(uint32_t, body_get_collision_mask, RID) |
| 321 | |
| 322 | EXBIND2(body_set_collision_priority, RID, real_t) |
| 323 | EXBIND1RC(real_t, body_get_collision_priority, RID) |
| 324 | |
| 325 | EXBIND2(body_set_user_flags, RID, uint32_t) |
| 326 | EXBIND1RC(uint32_t, body_get_user_flags, RID) |
| 327 | |
| 328 | EXBIND3(body_set_param, RID, BodyParameter, const Variant &) |
| 329 | EXBIND2RC(Variant, body_get_param, RID, BodyParameter) |
| 330 | |
| 331 | EXBIND1(body_reset_mass_properties, RID) |
| 332 | |
| 333 | EXBIND3(body_set_state, RID, BodyState, const Variant &) |
| 334 | EXBIND2RC(Variant, body_get_state, RID, BodyState) |
| 335 | |
| 336 | EXBIND2(body_apply_central_impulse, RID, const Vector3 &) |
| 337 | EXBIND3(body_apply_impulse, RID, const Vector3 &, const Vector3 &) |
| 338 | EXBIND2(body_apply_torque_impulse, RID, const Vector3 &) |
| 339 | |
| 340 | EXBIND2(body_apply_central_force, RID, const Vector3 &) |
| 341 | EXBIND3(body_apply_force, RID, const Vector3 &, const Vector3 &) |
| 342 | EXBIND2(body_apply_torque, RID, const Vector3 &) |
| 343 | |
| 344 | EXBIND2(body_add_constant_central_force, RID, const Vector3 &) |
| 345 | EXBIND3(body_add_constant_force, RID, const Vector3 &, const Vector3 &) |
| 346 | EXBIND2(body_add_constant_torque, RID, const Vector3 &) |
| 347 | |
| 348 | EXBIND2(body_set_constant_force, RID, const Vector3 &) |
| 349 | EXBIND1RC(Vector3, body_get_constant_force, RID) |
| 350 | |
| 351 | EXBIND2(body_set_constant_torque, RID, const Vector3 &) |
| 352 | EXBIND1RC(Vector3, body_get_constant_torque, RID) |
| 353 | |
| 354 | EXBIND2(body_set_axis_velocity, RID, const Vector3 &) |
| 355 | |
| 356 | EXBIND3(body_set_axis_lock, RID, BodyAxis, bool) |
| 357 | EXBIND2RC(bool, body_is_axis_locked, RID, BodyAxis) |
| 358 | |
| 359 | EXBIND2(body_add_collision_exception, RID, RID) |
| 360 | EXBIND2(body_remove_collision_exception, RID, RID) |
| 361 | |
| 362 | GDVIRTUAL1RC(TypedArray<RID>, _body_get_collision_exceptions, RID) |
| 363 | |
| 364 | void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) override { |
| 365 | TypedArray<RID> ret; |
| 366 | GDVIRTUAL_REQUIRED_CALL(_body_get_collision_exceptions, p_body, ret); |
| 367 | for (int i = 0; i < ret.size(); i++) { |
| 368 | p_exceptions->push_back(ret[i]); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | EXBIND2(body_set_max_contacts_reported, RID, int) |
| 373 | EXBIND1RC(int, body_get_max_contacts_reported, RID) |
| 374 | |
| 375 | EXBIND2(body_set_contacts_reported_depth_threshold, RID, real_t) |
| 376 | EXBIND1RC(real_t, body_get_contacts_reported_depth_threshold, RID) |
| 377 | |
| 378 | EXBIND2(body_set_omit_force_integration, RID, bool) |
| 379 | EXBIND1RC(bool, body_is_omitting_force_integration, RID) |
| 380 | |
| 381 | EXBIND2(body_set_state_sync_callback, RID, const Callable &) |
| 382 | EXBIND3(body_set_force_integration_callback, RID, const Callable &, const Variant &) |
| 383 | |
| 384 | EXBIND2(body_set_ray_pickable, RID, bool) |
| 385 | |
| 386 | GDVIRTUAL8RC(bool, _body_test_motion, RID, const Transform3D &, const Vector3 &, real_t, int, bool, bool, GDExtensionPtr<PhysicsServer3DExtensionMotionResult>) |
| 387 | |
| 388 | thread_local static const HashSet<RID> *exclude_bodies; |
| 389 | thread_local static const HashSet<ObjectID> *exclude_objects; |
| 390 | |
| 391 | bool body_test_motion_is_excluding_body(RID p_body) const; |
| 392 | bool body_test_motion_is_excluding_object(ObjectID p_object) const; |
| 393 | |
| 394 | bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override { |
| 395 | bool ret = false; |
| 396 | exclude_bodies = &p_parameters.exclude_bodies; |
| 397 | exclude_objects = &p_parameters.exclude_objects; |
| 398 | GDVIRTUAL_REQUIRED_CALL(_body_test_motion, p_body, p_parameters.from, p_parameters.motion, p_parameters.margin, p_parameters.max_collisions, p_parameters.collide_separation_ray, p_parameters.recovery_as_collision, r_result, ret); |
| 399 | exclude_bodies = nullptr; |
| 400 | exclude_objects = nullptr; |
| 401 | return ret; |
| 402 | } |
| 403 | |
| 404 | EXBIND1R(PhysicsDirectBodyState3D *, body_get_direct_state, RID) |
| 405 | |
| 406 | /* SOFT BODY API */ |
| 407 | |
| 408 | EXBIND0R(RID, soft_body_create) |
| 409 | |
| 410 | EXBIND2(soft_body_update_rendering_server, RID, PhysicsServer3DRenderingServerHandler *) |
| 411 | |
| 412 | EXBIND2(soft_body_set_space, RID, RID) |
| 413 | EXBIND1RC(RID, soft_body_get_space, RID) |
| 414 | |
| 415 | EXBIND2(soft_body_set_ray_pickable, RID, bool) |
| 416 | |
| 417 | EXBIND2(soft_body_set_collision_layer, RID, uint32_t) |
| 418 | EXBIND1RC(uint32_t, soft_body_get_collision_layer, RID) |
| 419 | |
| 420 | EXBIND2(soft_body_set_collision_mask, RID, uint32_t) |
| 421 | EXBIND1RC(uint32_t, soft_body_get_collision_mask, RID) |
| 422 | |
| 423 | EXBIND2(soft_body_add_collision_exception, RID, RID) |
| 424 | EXBIND2(soft_body_remove_collision_exception, RID, RID) |
| 425 | |
| 426 | GDVIRTUAL1RC(TypedArray<RID>, _soft_body_get_collision_exceptions, RID) |
| 427 | |
| 428 | void soft_body_get_collision_exceptions(RID p_soft_body, List<RID> *p_exceptions) override { |
| 429 | TypedArray<RID> ret; |
| 430 | GDVIRTUAL_REQUIRED_CALL(_soft_body_get_collision_exceptions, p_soft_body, ret); |
| 431 | for (int i = 0; i < ret.size(); i++) { |
| 432 | p_exceptions->push_back(ret[i]); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | EXBIND3(soft_body_set_state, RID, BodyState, const Variant &) |
| 437 | EXBIND2RC(Variant, soft_body_get_state, RID, BodyState) |
| 438 | |
| 439 | EXBIND2(soft_body_set_transform, RID, const Transform3D &) |
| 440 | |
| 441 | EXBIND2(soft_body_set_simulation_precision, RID, int) |
| 442 | EXBIND1RC(int, soft_body_get_simulation_precision, RID) |
| 443 | |
| 444 | EXBIND2(soft_body_set_total_mass, RID, real_t) |
| 445 | EXBIND1RC(real_t, soft_body_get_total_mass, RID) |
| 446 | |
| 447 | EXBIND2(soft_body_set_linear_stiffness, RID, real_t) |
| 448 | EXBIND1RC(real_t, soft_body_get_linear_stiffness, RID) |
| 449 | |
| 450 | EXBIND2(soft_body_set_pressure_coefficient, RID, real_t) |
| 451 | EXBIND1RC(real_t, soft_body_get_pressure_coefficient, RID) |
| 452 | |
| 453 | EXBIND2(soft_body_set_damping_coefficient, RID, real_t) |
| 454 | EXBIND1RC(real_t, soft_body_get_damping_coefficient, RID) |
| 455 | |
| 456 | EXBIND2(soft_body_set_drag_coefficient, RID, real_t) |
| 457 | EXBIND1RC(real_t, soft_body_get_drag_coefficient, RID) |
| 458 | |
| 459 | EXBIND2(soft_body_set_mesh, RID, RID) |
| 460 | |
| 461 | EXBIND1RC(AABB, soft_body_get_bounds, RID) |
| 462 | |
| 463 | EXBIND3(soft_body_move_point, RID, int, const Vector3 &) |
| 464 | EXBIND2RC(Vector3, soft_body_get_point_global_position, RID, int) |
| 465 | |
| 466 | EXBIND1(soft_body_remove_all_pinned_points, RID) |
| 467 | EXBIND3(soft_body_pin_point, RID, int, bool) |
| 468 | EXBIND2RC(bool, soft_body_is_point_pinned, RID, int) |
| 469 | |
| 470 | /* JOINT API */ |
| 471 | |
| 472 | EXBIND0R(RID, joint_create) |
| 473 | EXBIND1(joint_clear, RID) |
| 474 | |
| 475 | EXBIND5(joint_make_pin, RID, RID, const Vector3 &, RID, const Vector3 &) |
| 476 | |
| 477 | EXBIND3(pin_joint_set_param, RID, PinJointParam, real_t) |
| 478 | EXBIND2RC(real_t, pin_joint_get_param, RID, PinJointParam) |
| 479 | |
| 480 | EXBIND2(pin_joint_set_local_a, RID, const Vector3 &) |
| 481 | EXBIND1RC(Vector3, pin_joint_get_local_a, RID) |
| 482 | |
| 483 | EXBIND2(pin_joint_set_local_b, RID, const Vector3 &) |
| 484 | EXBIND1RC(Vector3, pin_joint_get_local_b, RID) |
| 485 | |
| 486 | EXBIND5(joint_make_hinge, RID, RID, const Transform3D &, RID, const Transform3D &) |
| 487 | EXBIND7(joint_make_hinge_simple, RID, RID, const Vector3 &, const Vector3 &, RID, const Vector3 &, const Vector3 &) |
| 488 | |
| 489 | EXBIND3(hinge_joint_set_param, RID, HingeJointParam, real_t) |
| 490 | EXBIND2RC(real_t, hinge_joint_get_param, RID, HingeJointParam) |
| 491 | |
| 492 | EXBIND3(hinge_joint_set_flag, RID, HingeJointFlag, bool) |
| 493 | EXBIND2RC(bool, hinge_joint_get_flag, RID, HingeJointFlag) |
| 494 | |
| 495 | EXBIND5(joint_make_slider, RID, RID, const Transform3D &, RID, const Transform3D &) |
| 496 | |
| 497 | EXBIND3(slider_joint_set_param, RID, SliderJointParam, real_t) |
| 498 | EXBIND2RC(real_t, slider_joint_get_param, RID, SliderJointParam) |
| 499 | |
| 500 | EXBIND5(joint_make_cone_twist, RID, RID, const Transform3D &, RID, const Transform3D &) |
| 501 | |
| 502 | EXBIND3(cone_twist_joint_set_param, RID, ConeTwistJointParam, real_t) |
| 503 | EXBIND2RC(real_t, cone_twist_joint_get_param, RID, ConeTwistJointParam) |
| 504 | |
| 505 | EXBIND5(joint_make_generic_6dof, RID, RID, const Transform3D &, RID, const Transform3D &) |
| 506 | |
| 507 | EXBIND4(generic_6dof_joint_set_param, RID, Vector3::Axis, G6DOFJointAxisParam, real_t) |
| 508 | EXBIND3RC(real_t, generic_6dof_joint_get_param, RID, Vector3::Axis, G6DOFJointAxisParam) |
| 509 | |
| 510 | EXBIND4(generic_6dof_joint_set_flag, RID, Vector3::Axis, G6DOFJointAxisFlag, bool) |
| 511 | EXBIND3RC(bool, generic_6dof_joint_get_flag, RID, Vector3::Axis, G6DOFJointAxisFlag) |
| 512 | |
| 513 | EXBIND1RC(JointType, joint_get_type, RID) |
| 514 | |
| 515 | EXBIND2(joint_set_solver_priority, RID, int) |
| 516 | EXBIND1RC(int, joint_get_solver_priority, RID) |
| 517 | |
| 518 | EXBIND2(joint_disable_collisions_between_bodies, RID, bool) |
| 519 | EXBIND1RC(bool, joint_is_disabled_collisions_between_bodies, RID) |
| 520 | |
| 521 | /* MISC */ |
| 522 | |
| 523 | GDVIRTUAL1(_free_rid, RID) |
| 524 | virtual void free(RID p_rid) override { |
| 525 | GDVIRTUAL_REQUIRED_CALL(_free_rid, p_rid); |
| 526 | } |
| 527 | |
| 528 | EXBIND1(set_active, bool) |
| 529 | |
| 530 | EXBIND0(init) |
| 531 | EXBIND1(step, real_t) |
| 532 | EXBIND0(sync) |
| 533 | EXBIND0(flush_queries) |
| 534 | EXBIND0(end_sync) |
| 535 | EXBIND0(finish) |
| 536 | |
| 537 | EXBIND0RC(bool, is_flushing_queries) |
| 538 | EXBIND1R(int, get_process_info, ProcessInfo) |
| 539 | |
| 540 | PhysicsServer3DExtension(); |
| 541 | ~PhysicsServer3DExtension(); |
| 542 | }; |
| 543 | |
| 544 | #endif // PHYSICS_SERVER_3D_EXTENSION_H |
| 545 | |