physics_server.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*************************************************************************/
  2. /* physics_server.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  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. #include "physics_server.h"
  31. #include "print_string.h"
  32. PhysicsServer *PhysicsServer::singleton = NULL;
  33. void PhysicsDirectBodyState::integrate_forces() {
  34. real_t step = get_step();
  35. Vector3 lv = get_linear_velocity();
  36. lv += get_total_gravity() * step;
  37. Vector3 av = get_angular_velocity();
  38. float linear_damp = 1.0 - step * get_total_linear_damp();
  39. if (linear_damp < 0) // reached zero in the given time
  40. linear_damp = 0;
  41. float angular_damp = 1.0 - step * get_total_angular_damp();
  42. if (angular_damp < 0) // reached zero in the given time
  43. angular_damp = 0;
  44. lv *= linear_damp;
  45. av *= angular_damp;
  46. set_linear_velocity(lv);
  47. set_angular_velocity(av);
  48. }
  49. Object *PhysicsDirectBodyState::get_contact_collider_object(int p_contact_idx) const {
  50. ObjectID objid = get_contact_collider_id(p_contact_idx);
  51. Object *obj = ObjectDB::get_instance(objid);
  52. return obj;
  53. }
  54. PhysicsServer *PhysicsServer::get_singleton() {
  55. return singleton;
  56. }
  57. void PhysicsDirectBodyState::_bind_methods() {
  58. ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState::get_total_gravity);
  59. ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState::get_total_linear_damp);
  60. ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState::get_total_angular_damp);
  61. ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState::get_center_of_mass);
  62. ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState::get_principal_inertia_axes);
  63. ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState::get_inverse_mass);
  64. ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState::get_inverse_inertia);
  65. ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState::set_linear_velocity);
  66. ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState::get_linear_velocity);
  67. ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState::set_angular_velocity);
  68. ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState::get_angular_velocity);
  69. ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState::set_transform);
  70. ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState::get_transform);
  71. ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &PhysicsDirectBodyState::add_force);
  72. ClassDB::bind_method(D_METHOD("apply_impulse", "position", "j"), &PhysicsDirectBodyState::apply_impulse);
  73. ClassDB::bind_method(D_METHOD("apply_torqe_impulse", "j"), &PhysicsDirectBodyState::apply_torque_impulse);
  74. ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState::set_sleep_state);
  75. ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState::is_sleeping);
  76. ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState::get_contact_count);
  77. ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_position);
  78. ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_normal);
  79. ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_shape);
  80. ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider);
  81. ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_position);
  82. ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_id);
  83. ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_object);
  84. ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_shape);
  85. ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_velocity_at_position);
  86. ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState::get_step);
  87. ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState::integrate_forces);
  88. ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState::get_space_state);
  89. }
  90. PhysicsDirectBodyState::PhysicsDirectBodyState() {}
  91. ///////////////////////////////////////////////////////
  92. void PhysicsShapeQueryParameters::set_shape(const RES &p_shape) {
  93. ERR_FAIL_COND(p_shape.is_null());
  94. shape = p_shape->get_rid();
  95. }
  96. void PhysicsShapeQueryParameters::set_shape_rid(const RID &p_shape) {
  97. shape = p_shape;
  98. }
  99. RID PhysicsShapeQueryParameters::get_shape_rid() const {
  100. return shape;
  101. }
  102. void PhysicsShapeQueryParameters::set_transform(const Transform &p_transform) {
  103. transform = p_transform;
  104. }
  105. Transform PhysicsShapeQueryParameters::get_transform() const {
  106. return transform;
  107. }
  108. void PhysicsShapeQueryParameters::set_margin(float p_margin) {
  109. margin = p_margin;
  110. }
  111. float PhysicsShapeQueryParameters::get_margin() const {
  112. return margin;
  113. }
  114. void PhysicsShapeQueryParameters::set_collision_layer(int p_collision_layer) {
  115. collision_layer = p_collision_layer;
  116. }
  117. int PhysicsShapeQueryParameters::get_collision_layer() const {
  118. return collision_layer;
  119. }
  120. void PhysicsShapeQueryParameters::set_object_type_mask(int p_object_type_mask) {
  121. object_type_mask = p_object_type_mask;
  122. }
  123. int PhysicsShapeQueryParameters::get_object_type_mask() const {
  124. return object_type_mask;
  125. }
  126. void PhysicsShapeQueryParameters::set_exclude(const Vector<RID> &p_exclude) {
  127. exclude.clear();
  128. for (int i = 0; i < p_exclude.size(); i++)
  129. exclude.insert(p_exclude[i]);
  130. }
  131. Vector<RID> PhysicsShapeQueryParameters::get_exclude() const {
  132. Vector<RID> ret;
  133. ret.resize(exclude.size());
  134. int idx = 0;
  135. for (Set<RID>::Element *E = exclude.front(); E; E = E->next()) {
  136. ret[idx] = E->get();
  137. }
  138. return ret;
  139. }
  140. void PhysicsShapeQueryParameters::_bind_methods() {
  141. ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters::set_shape);
  142. ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters::set_shape_rid);
  143. ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters::get_shape_rid);
  144. ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters::set_transform);
  145. ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters::get_transform);
  146. ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters::set_margin);
  147. ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters::get_margin);
  148. ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &PhysicsShapeQueryParameters::set_collision_layer);
  149. ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsShapeQueryParameters::get_collision_layer);
  150. ClassDB::bind_method(D_METHOD("set_object_type_mask", "object_type_mask"), &PhysicsShapeQueryParameters::set_object_type_mask);
  151. ClassDB::bind_method(D_METHOD("get_object_type_mask"), &PhysicsShapeQueryParameters::get_object_type_mask);
  152. ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters::set_exclude);
  153. ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters::get_exclude);
  154. }
  155. PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() {
  156. margin = 0;
  157. collision_layer = 0x7FFFFFFF;
  158. object_type_mask = PhysicsDirectSpaceState::TYPE_MASK_COLLISION;
  159. }
  160. /////////////////////////////////////
  161. /*
  162. Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_collision_mask) {
  163. ERR_FAIL_INDEX_V(p_result_max,4096,Variant());
  164. if (p_result_max<=0)
  165. return Variant();
  166. Set<RID> exclude;
  167. for(int i=0;i<p_exclude.size();i++)
  168. exclude.insert(p_exclude[i]);
  169. ShapeResult *res=(ShapeResult*)alloca(p_result_max*sizeof(ShapeResult));
  170. int rc = intersect_shape(p_shape,p_xform,0,res,p_result_max,exclude);
  171. if (rc==0)
  172. return Variant();
  173. Ref<PhysicsShapeQueryResult> result = memnew( PhysicsShapeQueryResult );
  174. result->result.resize(rc);
  175. for(int i=0;i<rc;i++)
  176. result->result[i]=res[i];
  177. return result;
  178. }
  179. */
  180. Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, uint32_t p_object_type_mask) {
  181. RayResult inters;
  182. Set<RID> exclude;
  183. for (int i = 0; i < p_exclude.size(); i++)
  184. exclude.insert(p_exclude[i]);
  185. bool res = intersect_ray(p_from, p_to, inters, exclude, p_layers, p_object_type_mask);
  186. if (!res)
  187. return Dictionary();
  188. Dictionary d;
  189. d["position"] = inters.position;
  190. d["normal"] = inters.normal;
  191. d["collider_id"] = inters.collider_id;
  192. d["collider"] = inters.collider;
  193. d["shape"] = inters.shape;
  194. d["rid"] = inters.rid;
  195. return d;
  196. }
  197. Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) {
  198. Vector<ShapeResult> sr;
  199. sr.resize(p_max_results);
  200. int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, sr.ptr(), sr.size(), p_shape_query->exclude, p_shape_query->collision_layer, p_shape_query->object_type_mask);
  201. Array ret;
  202. ret.resize(rc);
  203. for (int i = 0; i < rc; i++) {
  204. Dictionary d;
  205. d["rid"] = sr[i].rid;
  206. d["collider_id"] = sr[i].collider_id;
  207. d["collider"] = sr[i].collider;
  208. d["shape"] = sr[i].shape;
  209. ret[i] = d;
  210. }
  211. return ret;
  212. }
  213. Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameters> &p_shape_query, const Vector3 &p_motion) {
  214. float closest_safe, closest_unsafe;
  215. bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_layer, p_shape_query->object_type_mask);
  216. if (!res)
  217. return Array();
  218. Array ret;
  219. ret.resize(2);
  220. ret[0] = closest_safe;
  221. ret[1] = closest_unsafe;
  222. return ret;
  223. }
  224. Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) {
  225. Vector<Vector3> ret;
  226. ret.resize(p_max_results * 2);
  227. int rc = 0;
  228. bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, ret.ptr(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_layer, p_shape_query->object_type_mask);
  229. if (!res)
  230. return Array();
  231. Array r;
  232. r.resize(rc * 2);
  233. for (int i = 0; i < rc * 2; i++)
  234. r[i] = ret[i];
  235. return r;
  236. }
  237. Dictionary PhysicsDirectSpaceState::_get_rest_info(const Ref<PhysicsShapeQueryParameters> &p_shape_query) {
  238. ShapeRestInfo sri;
  239. bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_layer, p_shape_query->object_type_mask);
  240. Dictionary r;
  241. if (!res)
  242. return r;
  243. r["point"] = sri.point;
  244. r["normal"] = sri.normal;
  245. r["rid"] = sri.rid;
  246. r["collider_id"] = sri.collider_id;
  247. r["shape"] = sri.shape;
  248. r["linear_velocity"] = sri.linear_velocity;
  249. return r;
  250. }
  251. PhysicsDirectSpaceState::PhysicsDirectSpaceState() {
  252. }
  253. void PhysicsDirectSpaceState::_bind_methods() {
  254. //ClassDB::bind_method(D_METHOD("intersect_ray","from","to","exclude","umask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0));
  255. //ClassDB::bind_method(D_METHOD("intersect_shape","shape","xform","result_max","exclude","umask"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
  256. ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_layer", "type_mask"), &PhysicsDirectSpaceState::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(TYPE_MASK_COLLISION));
  257. ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_intersect_shape, DEFVAL(32));
  258. ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState::_cast_motion);
  259. ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_collide_shape, DEFVAL(32));
  260. ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState::_get_rest_info);
  261. BIND_ENUM_CONSTANT(TYPE_MASK_STATIC_BODY);
  262. BIND_ENUM_CONSTANT(TYPE_MASK_KINEMATIC_BODY);
  263. BIND_ENUM_CONSTANT(TYPE_MASK_RIGID_BODY);
  264. BIND_ENUM_CONSTANT(TYPE_MASK_CHARACTER_BODY);
  265. BIND_ENUM_CONSTANT(TYPE_MASK_AREA);
  266. BIND_ENUM_CONSTANT(TYPE_MASK_COLLISION);
  267. }
  268. int PhysicsShapeQueryResult::get_result_count() const {
  269. return result.size();
  270. }
  271. RID PhysicsShapeQueryResult::get_result_rid(int p_idx) const {
  272. return result[p_idx].rid;
  273. }
  274. ObjectID PhysicsShapeQueryResult::get_result_object_id(int p_idx) const {
  275. return result[p_idx].collider_id;
  276. }
  277. Object *PhysicsShapeQueryResult::get_result_object(int p_idx) const {
  278. return result[p_idx].collider;
  279. }
  280. int PhysicsShapeQueryResult::get_result_object_shape(int p_idx) const {
  281. return result[p_idx].shape;
  282. }
  283. PhysicsShapeQueryResult::PhysicsShapeQueryResult() {
  284. }
  285. void PhysicsShapeQueryResult::_bind_methods() {
  286. ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult::get_result_count);
  287. ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult::get_result_rid);
  288. ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult::get_result_object_id);
  289. ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult::get_result_object);
  290. ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult::get_result_object_shape);
  291. }
  292. ///////////////////////////////////////
  293. void PhysicsServer::_bind_methods() {
  294. ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer::shape_create);
  295. ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer::shape_set_data);
  296. ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer::shape_get_type);
  297. ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer::shape_get_data);
  298. ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer::space_create);
  299. ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer::space_set_active);
  300. ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer::space_is_active);
  301. ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer::space_set_param);
  302. ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer::space_get_param);
  303. ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer::space_get_direct_state);
  304. ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer::area_create);
  305. ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer::area_set_space);
  306. ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer::area_get_space);
  307. ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer::area_set_space_override_mode);
  308. ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer::area_get_space_override_mode);
  309. ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform"), &PhysicsServer::area_add_shape, DEFVAL(Transform()));
  310. ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer::area_set_shape);
  311. ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer::area_set_shape_transform);
  312. ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer::area_get_shape_count);
  313. ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer::area_get_shape);
  314. ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer::area_get_shape_transform);
  315. ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer::area_remove_shape);
  316. ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer::area_clear_shapes);
  317. ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer::area_set_collision_layer);
  318. ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer::area_set_collision_mask);
  319. ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer::area_set_param);
  320. ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer::area_set_transform);
  321. ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer::area_get_param);
  322. ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer::area_get_transform);
  323. ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer::area_attach_object_instance_id);
  324. ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer::area_get_object_instance_id);
  325. ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer::area_set_monitor_callback);
  326. ClassDB::bind_method(D_METHOD("area_set_ray_pickable", "area", "enable"), &PhysicsServer::area_set_ray_pickable);
  327. ClassDB::bind_method(D_METHOD("area_is_ray_pickable", "area"), &PhysicsServer::area_is_ray_pickable);
  328. ClassDB::bind_method(D_METHOD("body_create", "mode", "init_sleeping"), &PhysicsServer::body_create, DEFVAL(BODY_MODE_RIGID), DEFVAL(false));
  329. ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer::body_set_space);
  330. ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer::body_get_space);
  331. ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer::body_set_mode);
  332. ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer::body_get_mode);
  333. ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer::body_set_collision_layer);
  334. ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer::body_get_collision_layer);
  335. ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer::body_set_collision_mask);
  336. ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer::body_get_collision_mask);
  337. ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform"), &PhysicsServer::body_add_shape, DEFVAL(Transform()));
  338. ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer::body_set_shape);
  339. ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer::body_set_shape_transform);
  340. ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer::body_get_shape_count);
  341. ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer::body_get_shape);
  342. ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer::body_get_shape_transform);
  343. ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer::body_remove_shape);
  344. ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer::body_clear_shapes);
  345. ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer::body_attach_object_instance_id);
  346. ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer::body_get_object_instance_id);
  347. ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer::body_set_enable_continuous_collision_detection);
  348. ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer::body_is_continuous_collision_detection_enabled);
  349. //ClassDB::bind_method(D_METHOD("body_set_user_flags","flags""),&PhysicsServer::body_set_shape,DEFVAL(Transform));
  350. //ClassDB::bind_method(D_METHOD("body_get_user_flags","body","shape_idx","shape"),&PhysicsServer::body_get_shape);
  351. ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer::body_set_param);
  352. ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer::body_get_param);
  353. ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer::body_set_state);
  354. ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer::body_get_state);
  355. ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer::body_apply_impulse);
  356. ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer::body_apply_torque_impulse);
  357. ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer::body_set_axis_velocity);
  358. ClassDB::bind_method(D_METHOD("body_set_axis_lock", "body", "axis"), &PhysicsServer::body_set_axis_lock);
  359. ClassDB::bind_method(D_METHOD("body_get_axis_lock", "body"), &PhysicsServer::body_get_axis_lock);
  360. ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer::body_add_collision_exception);
  361. ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer::body_remove_collision_exception);
  362. //virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
  363. ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer::body_set_max_contacts_reported);
  364. ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer::body_get_max_contacts_reported);
  365. ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer::body_set_omit_force_integration);
  366. ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer::body_is_omitting_force_integration);
  367. ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer::body_set_force_integration_callback, DEFVAL(Variant()));
  368. ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer::body_set_ray_pickable);
  369. ClassDB::bind_method(D_METHOD("body_is_ray_pickable", "body"), &PhysicsServer::body_is_ray_pickable);
  370. ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer::body_get_direct_state);
  371. /* JOINT API */
  372. BIND_ENUM_CONSTANT(JOINT_PIN);
  373. BIND_ENUM_CONSTANT(JOINT_HINGE);
  374. BIND_ENUM_CONSTANT(JOINT_SLIDER);
  375. BIND_ENUM_CONSTANT(JOINT_CONE_TWIST);
  376. BIND_ENUM_CONSTANT(JOINT_6DOF);
  377. ClassDB::bind_method(D_METHOD("joint_create_pin", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer::joint_create_pin);
  378. ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer::pin_joint_set_param);
  379. ClassDB::bind_method(D_METHOD("pin_joint_get_param", "joint", "param"), &PhysicsServer::pin_joint_get_param);
  380. ClassDB::bind_method(D_METHOD("pin_joint_set_local_a", "joint", "local_A"), &PhysicsServer::pin_joint_set_local_a);
  381. ClassDB::bind_method(D_METHOD("pin_joint_get_local_a", "joint"), &PhysicsServer::pin_joint_get_local_a);
  382. ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer::pin_joint_set_local_b);
  383. ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer::pin_joint_get_local_b);
  384. BIND_ENUM_CONSTANT(PIN_JOINT_BIAS);
  385. BIND_ENUM_CONSTANT(PIN_JOINT_DAMPING);
  386. BIND_ENUM_CONSTANT(PIN_JOINT_IMPULSE_CLAMP);
  387. BIND_ENUM_CONSTANT(HINGE_JOINT_BIAS);
  388. BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_UPPER);
  389. BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_LOWER);
  390. BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_BIAS);
  391. BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_SOFTNESS);
  392. BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_RELAXATION);
  393. BIND_ENUM_CONSTANT(HINGE_JOINT_MOTOR_TARGET_VELOCITY);
  394. BIND_ENUM_CONSTANT(HINGE_JOINT_MOTOR_MAX_IMPULSE);
  395. BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT);
  396. BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR);
  397. ClassDB::bind_method(D_METHOD("joint_create_hinge", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer::joint_create_hinge);
  398. ClassDB::bind_method(D_METHOD("hinge_joint_set_param", "joint", "param", "value"), &PhysicsServer::hinge_joint_set_param);
  399. ClassDB::bind_method(D_METHOD("hinge_joint_get_param", "joint", "param"), &PhysicsServer::hinge_joint_get_param);
  400. ClassDB::bind_method(D_METHOD("hinge_joint_set_flag", "joint", "flag", "enabled"), &PhysicsServer::hinge_joint_set_flag);
  401. ClassDB::bind_method(D_METHOD("hinge_joint_get_flag", "joint", "flag"), &PhysicsServer::hinge_joint_get_flag);
  402. ClassDB::bind_method(D_METHOD("joint_create_slider", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_slider);
  403. ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer::slider_joint_set_param);
  404. ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer::slider_joint_get_param);
  405. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_UPPER);
  406. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_LOWER);
  407. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS);
  408. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION);
  409. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_DAMPING);
  410. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_SOFTNESS);
  411. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_RESTITUTION);
  412. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_DAMPING);
  413. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS);
  414. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION);
  415. BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING);
  416. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_UPPER);
  417. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_LOWER);
  418. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS);
  419. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION);
  420. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_DAMPING);
  421. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS);
  422. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION);
  423. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_DAMPING);
  424. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS);
  425. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION);
  426. BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING);
  427. BIND_ENUM_CONSTANT(SLIDER_JOINT_MAX);
  428. ClassDB::bind_method(D_METHOD("joint_create_cone_twist", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_cone_twist);
  429. ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer::cone_twist_joint_set_param);
  430. ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer::cone_twist_joint_get_param);
  431. BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SWING_SPAN);
  432. BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_TWIST_SPAN);
  433. BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_BIAS);
  434. BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SOFTNESS);
  435. BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_RELAXATION);
  436. BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_LOWER_LIMIT);
  437. BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_UPPER_LIMIT);
  438. BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS);
  439. BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_RESTITUTION);
  440. BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_DAMPING);
  441. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_LOWER_LIMIT);
  442. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_UPPER_LIMIT);
  443. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS);
  444. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_DAMPING);
  445. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_RESTITUTION);
  446. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_FORCE_LIMIT);
  447. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_ERP);
  448. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY);
  449. BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT);
  450. BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT);
  451. BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT);
  452. BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_MOTOR);
  453. ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer::joint_get_type);
  454. ClassDB::bind_method(D_METHOD("joint_set_solver_priority", "joint", "priority"), &PhysicsServer::joint_set_solver_priority);
  455. ClassDB::bind_method(D_METHOD("joint_get_solver_priority", "joint"), &PhysicsServer::joint_get_solver_priority);
  456. ClassDB::bind_method(D_METHOD("joint_create_generic_6dof", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_generic_6dof);
  457. ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_param", "joint", "axis", "param", "value"), &PhysicsServer::generic_6dof_joint_set_param);
  458. ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_param", "joint", "axis", "param"), &PhysicsServer::generic_6dof_joint_get_param);
  459. ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag", "joint", "axis", "flag", "enable"), &PhysicsServer::generic_6dof_joint_set_flag);
  460. ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag", "joint", "axis", "flag"), &PhysicsServer::generic_6dof_joint_get_flag);
  461. /*
  462. ClassDB::bind_method(D_METHOD("joint_set_param","joint","param","value"),&PhysicsServer::joint_set_param);
  463. ClassDB::bind_method(D_METHOD("joint_get_param","joint","param"),&PhysicsServer::joint_get_param);
  464. ClassDB::bind_method(D_METHOD("pin_joint_create","anchor","body_a","body_b"),&PhysicsServer::pin_joint_create,DEFVAL(RID()));
  465. ClassDB::bind_method(D_METHOD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&PhysicsServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
  466. ClassDB::bind_method(D_METHOD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&PhysicsServer::damped_spring_joint_create,DEFVAL(RID()));
  467. ClassDB::bind_method(D_METHOD("damped_string_joint_set_param","joint","param","value"),&PhysicsServer::damped_string_joint_set_param,DEFVAL(RID()));
  468. ClassDB::bind_method(D_METHOD("damped_string_joint_get_param","joint","param"),&PhysicsServer::damped_string_joint_get_param);
  469. ClassDB::bind_method(D_METHOD("joint_get_type","joint"),&PhysicsServer::joint_get_type);
  470. */
  471. ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer::free);
  472. ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer::set_active);
  473. //ClassDB::bind_method(D_METHOD("init"),&PhysicsServer::init);
  474. //ClassDB::bind_method(D_METHOD("step"),&PhysicsServer::step);
  475. //ClassDB::bind_method(D_METHOD("sync"),&PhysicsServer::sync);
  476. //ClassDB::bind_method(D_METHOD("flush_queries"),&PhysicsServer::flush_queries);
  477. ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer::get_process_info);
  478. BIND_ENUM_CONSTANT(SHAPE_PLANE);
  479. BIND_ENUM_CONSTANT(SHAPE_RAY);
  480. BIND_ENUM_CONSTANT(SHAPE_SPHERE);
  481. BIND_ENUM_CONSTANT(SHAPE_BOX);
  482. BIND_ENUM_CONSTANT(SHAPE_CAPSULE);
  483. BIND_ENUM_CONSTANT(SHAPE_CONVEX_POLYGON);
  484. BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON);
  485. BIND_ENUM_CONSTANT(SHAPE_HEIGHTMAP);
  486. BIND_ENUM_CONSTANT(SHAPE_CUSTOM);
  487. BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY);
  488. BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR);
  489. BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT);
  490. BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE);
  491. BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION);
  492. BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP);
  493. BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP);
  494. BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY);
  495. BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED);
  496. BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE);
  497. BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE);
  498. BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE);
  499. BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE);
  500. BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
  501. BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
  502. BIND_ENUM_CONSTANT(BODY_MODE_RIGID);
  503. BIND_ENUM_CONSTANT(BODY_MODE_CHARACTER);
  504. BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
  505. BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);
  506. BIND_ENUM_CONSTANT(BODY_PARAM_MASS);
  507. BIND_ENUM_CONSTANT(BODY_PARAM_GRAVITY_SCALE);
  508. BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP);
  509. BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP);
  510. BIND_ENUM_CONSTANT(BODY_PARAM_MAX);
  511. BIND_ENUM_CONSTANT(BODY_STATE_TRANSFORM);
  512. BIND_ENUM_CONSTANT(BODY_STATE_LINEAR_VELOCITY);
  513. BIND_ENUM_CONSTANT(BODY_STATE_ANGULAR_VELOCITY);
  514. BIND_ENUM_CONSTANT(BODY_STATE_SLEEPING);
  515. BIND_ENUM_CONSTANT(BODY_STATE_CAN_SLEEP);
  516. /*
  517. BIND_ENUM_CONSTANT( JOINT_PIN );
  518. BIND_ENUM_CONSTANT( JOINT_GROOVE );
  519. BIND_ENUM_CONSTANT( JOINT_DAMPED_SPRING );
  520. BIND_ENUM_CONSTANT( DAMPED_STRING_REST_LENGTH );
  521. BIND_ENUM_CONSTANT( DAMPED_STRING_STIFFNESS );
  522. BIND_ENUM_CONSTANT( DAMPED_STRING_DAMPING );
  523. */
  524. //BIND_ENUM_CONSTANT( TYPE_BODY );
  525. //BIND_ENUM_CONSTANT( TYPE_AREA );
  526. BIND_ENUM_CONSTANT(AREA_BODY_ADDED);
  527. BIND_ENUM_CONSTANT(AREA_BODY_REMOVED);
  528. BIND_ENUM_CONSTANT(INFO_ACTIVE_OBJECTS);
  529. BIND_ENUM_CONSTANT(INFO_COLLISION_PAIRS);
  530. BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT);
  531. BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
  532. BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION);
  533. BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION);
  534. BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
  535. BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
  536. BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
  537. BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO);
  538. BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
  539. BIND_ENUM_CONSTANT(BODY_AXIS_LOCK_DISABLED);
  540. BIND_ENUM_CONSTANT(BODY_AXIS_LOCK_X);
  541. BIND_ENUM_CONSTANT(BODY_AXIS_LOCK_Y);
  542. BIND_ENUM_CONSTANT(BODY_AXIS_LOCK_Z);
  543. }
  544. PhysicsServer::PhysicsServer() {
  545. ERR_FAIL_COND(singleton != NULL);
  546. singleton = this;
  547. }
  548. PhysicsServer::~PhysicsServer() {
  549. singleton = NULL;
  550. }