physics_server_3d_extension.h 22 KB

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