physics_server.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /*************************************************************************/
  2. /* physics_server.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #include "physics_server.h"
  30. #include "print_string.h"
  31. PhysicsServer * PhysicsServer::singleton=NULL;
  32. void PhysicsDirectBodyState::integrate_forces() {
  33. real_t step = get_step();
  34. Vector3 lv = get_linear_velocity();
  35. lv+=get_total_gravity() * step;
  36. Vector3 av = get_angular_velocity();
  37. float damp = 1.0 - step * get_total_density();
  38. if (damp<0) // reached zero in the given time
  39. damp=0;
  40. lv*=damp;
  41. av*=damp;
  42. set_linear_velocity(lv);
  43. set_angular_velocity(av);
  44. }
  45. Object* PhysicsDirectBodyState::get_contact_collider_object(int p_contact_idx) const {
  46. ObjectID objid = get_contact_collider_id(p_contact_idx);
  47. Object *obj = ObjectDB::get_instance( objid );
  48. return obj;
  49. }
  50. PhysicsServer * PhysicsServer::get_singleton() {
  51. return singleton;
  52. }
  53. void PhysicsDirectBodyState::_bind_methods() {
  54. ObjectTypeDB::bind_method(_MD("get_total_gravity"),&PhysicsDirectBodyState::get_total_gravity);
  55. ObjectTypeDB::bind_method(_MD("get_total_density"),&PhysicsDirectBodyState::get_total_density);
  56. ObjectTypeDB::bind_method(_MD("get_inverse_mass"),&PhysicsDirectBodyState::get_inverse_mass);
  57. ObjectTypeDB::bind_method(_MD("get_inverse_inertia"),&PhysicsDirectBodyState::get_inverse_inertia);
  58. ObjectTypeDB::bind_method(_MD("set_linear_velocity","velocity"),&PhysicsDirectBodyState::set_linear_velocity);
  59. ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&PhysicsDirectBodyState::get_linear_velocity);
  60. ObjectTypeDB::bind_method(_MD("set_angular_velocity","velocity"),&PhysicsDirectBodyState::set_angular_velocity);
  61. ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&PhysicsDirectBodyState::get_angular_velocity);
  62. ObjectTypeDB::bind_method(_MD("set_transform","transform"),&PhysicsDirectBodyState::set_transform);
  63. ObjectTypeDB::bind_method(_MD("get_transform"),&PhysicsDirectBodyState::get_transform);
  64. ObjectTypeDB::bind_method(_MD("add_force","force","pos"),&PhysicsDirectBodyState::add_force);
  65. ObjectTypeDB::bind_method(_MD("apply_impulse","pos","j"),&PhysicsDirectBodyState::apply_impulse);
  66. ObjectTypeDB::bind_method(_MD("set_sleep_state","enabled"),&PhysicsDirectBodyState::set_sleep_state);
  67. ObjectTypeDB::bind_method(_MD("is_sleeping"),&PhysicsDirectBodyState::is_sleeping);
  68. ObjectTypeDB::bind_method(_MD("get_contact_count"),&PhysicsDirectBodyState::get_contact_count);
  69. ObjectTypeDB::bind_method(_MD("get_contact_local_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_local_pos);
  70. ObjectTypeDB::bind_method(_MD("get_contact_local_normal","contact_idx"),&PhysicsDirectBodyState::get_contact_local_normal);
  71. ObjectTypeDB::bind_method(_MD("get_contact_local_shape","contact_idx"),&PhysicsDirectBodyState::get_contact_local_shape);
  72. ObjectTypeDB::bind_method(_MD("get_contact_collider","contact_idx"),&PhysicsDirectBodyState::get_contact_collider);
  73. ObjectTypeDB::bind_method(_MD("get_contact_collider_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_pos);
  74. ObjectTypeDB::bind_method(_MD("get_contact_collider_id","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_id);
  75. ObjectTypeDB::bind_method(_MD("get_contact_collider_object","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_object);
  76. ObjectTypeDB::bind_method(_MD("get_contact_collider_shape","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_shape);
  77. ObjectTypeDB::bind_method(_MD("get_contact_collider_velocity_at_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_velocity_at_pos);
  78. ObjectTypeDB::bind_method(_MD("get_step"),&PhysicsDirectBodyState::get_step);
  79. ObjectTypeDB::bind_method(_MD("integrate_forces"),&PhysicsDirectBodyState::integrate_forces);
  80. ObjectTypeDB::bind_method(_MD("get_space_state:PhysicsDirectSpaceState"),&PhysicsDirectBodyState::get_space_state);
  81. }
  82. PhysicsDirectBodyState::PhysicsDirectBodyState() {}
  83. ///////////////////////////////////////////////////////
  84. Variant PhysicsDirectSpaceState::_intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
  85. RayResult inters;
  86. Set<RID> exclude;
  87. for(int i=0;i<p_exclude.size();i++)
  88. exclude.insert(p_exclude[i]);
  89. bool res = intersect_ray(p_from,p_to,inters,exclude,p_user_mask);
  90. if (!res)
  91. return Variant();
  92. Dictionary d;
  93. d["position"]=inters.position;
  94. d["normal"]=inters.normal;
  95. d["collider_id"]=inters.collider_id;
  96. d["collider"]=inters.collider;
  97. d["shape"]=inters.shape;
  98. d["rid"]=inters.rid;
  99. return d;
  100. }
  101. Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
  102. ERR_FAIL_INDEX_V(p_result_max,4096,Variant());
  103. if (p_result_max<=0)
  104. return Variant();
  105. Set<RID> exclude;
  106. for(int i=0;i<p_exclude.size();i++)
  107. exclude.insert(p_exclude[i]);
  108. ShapeResult *res=(ShapeResult*)alloca(p_result_max*sizeof(ShapeResult));
  109. int rc = intersect_shape(p_shape,p_xform,res,p_result_max,exclude,p_user_mask);
  110. if (rc==0)
  111. return Variant();
  112. Ref<PhysicsShapeQueryResult> result = memnew( PhysicsShapeQueryResult );
  113. result->result.resize(rc);
  114. for(int i=0;i<rc;i++)
  115. result->result[i]=res[i];
  116. return result;
  117. }
  118. PhysicsDirectSpaceState::PhysicsDirectSpaceState() {
  119. }
  120. void PhysicsDirectSpaceState::_bind_methods() {
  121. ObjectTypeDB::bind_method(_MD("intersect_ray","from","to","exclude","umask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0));
  122. ObjectTypeDB::bind_method(_MD("intersect_shape:PhysicsShapeQueryResult","shape","xform","result_max","exclude","umask"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
  123. }
  124. int PhysicsShapeQueryResult::get_result_count() const {
  125. return result.size();
  126. }
  127. RID PhysicsShapeQueryResult::get_result_rid(int p_idx) const {
  128. return result[p_idx].rid;
  129. }
  130. ObjectID PhysicsShapeQueryResult::get_result_object_id(int p_idx) const {
  131. return result[p_idx].collider_id;
  132. }
  133. Object* PhysicsShapeQueryResult::get_result_object(int p_idx) const {
  134. return result[p_idx].collider;
  135. }
  136. int PhysicsShapeQueryResult::get_result_object_shape(int p_idx) const {
  137. return result[p_idx].shape;
  138. }
  139. PhysicsShapeQueryResult::PhysicsShapeQueryResult() {
  140. }
  141. void PhysicsShapeQueryResult::_bind_methods() {
  142. ObjectTypeDB::bind_method(_MD("get_result_count"),&PhysicsShapeQueryResult::get_result_count);
  143. ObjectTypeDB::bind_method(_MD("get_result_rid","idx"),&PhysicsShapeQueryResult::get_result_rid);
  144. ObjectTypeDB::bind_method(_MD("get_result_object_id","idx"),&PhysicsShapeQueryResult::get_result_object_id);
  145. ObjectTypeDB::bind_method(_MD("get_result_object","idx"),&PhysicsShapeQueryResult::get_result_object);
  146. ObjectTypeDB::bind_method(_MD("get_result_object_shape","idx"),&PhysicsShapeQueryResult::get_result_object_shape);
  147. }
  148. ///////////////////////////////////////
  149. void PhysicsServer::_bind_methods() {
  150. ObjectTypeDB::bind_method(_MD("shape_create","type"),&PhysicsServer::shape_create);
  151. ObjectTypeDB::bind_method(_MD("shape_set_data","shape","data"),&PhysicsServer::shape_set_data);
  152. ObjectTypeDB::bind_method(_MD("shape_get_type","shape"),&PhysicsServer::shape_get_type);
  153. ObjectTypeDB::bind_method(_MD("shape_get_data","shape"),&PhysicsServer::shape_get_data);
  154. ObjectTypeDB::bind_method(_MD("space_create"),&PhysicsServer::space_create);
  155. ObjectTypeDB::bind_method(_MD("space_set_active","space","active"),&PhysicsServer::space_set_active);
  156. ObjectTypeDB::bind_method(_MD("space_is_active","space"),&PhysicsServer::space_is_active);
  157. ObjectTypeDB::bind_method(_MD("space_set_param","space","param","value"),&PhysicsServer::space_set_param);
  158. ObjectTypeDB::bind_method(_MD("space_get_param","space","param"),&PhysicsServer::space_get_param);
  159. ObjectTypeDB::bind_method(_MD("space_get_direct_state:PhysicsDirectSpaceState","space"),&PhysicsServer::space_get_direct_state);
  160. ObjectTypeDB::bind_method(_MD("area_create"),&PhysicsServer::area_create);
  161. ObjectTypeDB::bind_method(_MD("area_set_space","area","space"),&PhysicsServer::area_set_space);
  162. ObjectTypeDB::bind_method(_MD("area_get_space","area"),&PhysicsServer::area_get_space);
  163. ObjectTypeDB::bind_method(_MD("area_set_space_override_mode","area","mode"),&PhysicsServer::area_set_space_override_mode);
  164. ObjectTypeDB::bind_method(_MD("area_get_space_override_mode","area"),&PhysicsServer::area_get_space_override_mode);
  165. ObjectTypeDB::bind_method(_MD("area_add_shape","area","shape","transform"),&PhysicsServer::area_set_shape,DEFVAL(Transform()));
  166. ObjectTypeDB::bind_method(_MD("area_set_shape","area","shape_idx","shape"),&PhysicsServer::area_get_shape);
  167. ObjectTypeDB::bind_method(_MD("area_set_shape_transform","area","shape_idx","transform"),&PhysicsServer::area_set_shape_transform);
  168. ObjectTypeDB::bind_method(_MD("area_get_shape_count","area"),&PhysicsServer::area_get_shape_count);
  169. ObjectTypeDB::bind_method(_MD("area_get_shape","area","shape_idx"),&PhysicsServer::area_get_shape);
  170. ObjectTypeDB::bind_method(_MD("area_get_shape_transform","area","shape_idx"),&PhysicsServer::area_get_shape_transform);
  171. ObjectTypeDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&PhysicsServer::area_remove_shape);
  172. ObjectTypeDB::bind_method(_MD("area_clear_shapes","area"),&PhysicsServer::area_clear_shapes);
  173. ObjectTypeDB::bind_method(_MD("area_set_param","area","param","value"),&PhysicsServer::area_get_param);
  174. ObjectTypeDB::bind_method(_MD("area_set_transform","area","transform"),&PhysicsServer::area_get_transform);
  175. ObjectTypeDB::bind_method(_MD("area_get_param","area","param"),&PhysicsServer::area_get_param);
  176. ObjectTypeDB::bind_method(_MD("area_get_transform","area"),&PhysicsServer::area_get_transform);
  177. ObjectTypeDB::bind_method(_MD("area_attach_object_instance_ID","area","id"),&PhysicsServer::area_attach_object_instance_ID);
  178. ObjectTypeDB::bind_method(_MD("area_get_object_instance_ID","area"),&PhysicsServer::area_get_object_instance_ID);
  179. ObjectTypeDB::bind_method(_MD("area_set_monitor_callback","receiver","method"),&PhysicsServer::area_set_monitor_callback);
  180. ObjectTypeDB::bind_method(_MD("body_create","mode","init_sleeping"),&PhysicsServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));
  181. ObjectTypeDB::bind_method(_MD("body_set_space","body","space"),&PhysicsServer::body_set_space);
  182. ObjectTypeDB::bind_method(_MD("body_get_space","body"),&PhysicsServer::body_get_space);
  183. ObjectTypeDB::bind_method(_MD("body_set_mode","body","mode"),&PhysicsServer::body_set_mode);
  184. ObjectTypeDB::bind_method(_MD("body_get_mode","body"),&PhysicsServer::body_get_mode);
  185. ObjectTypeDB::bind_method(_MD("body_add_shape","body","shape","transform"),&PhysicsServer::body_add_shape,DEFVAL(Transform()));
  186. ObjectTypeDB::bind_method(_MD("body_set_shape","body","shape_idx","shape"),&PhysicsServer::body_set_shape);
  187. ObjectTypeDB::bind_method(_MD("body_set_shape_transform","body","shape_idx","transform"),&PhysicsServer::body_set_shape_transform);
  188. ObjectTypeDB::bind_method(_MD("body_get_shape_count","body"),&PhysicsServer::body_get_shape_count);
  189. ObjectTypeDB::bind_method(_MD("body_get_shape","body","shape_idx"),&PhysicsServer::body_get_shape);
  190. ObjectTypeDB::bind_method(_MD("body_get_shape_transform","body","shape_idx"),&PhysicsServer::body_get_shape_transform);
  191. ObjectTypeDB::bind_method(_MD("body_remove_shape","body","shape_idx"),&PhysicsServer::body_remove_shape);
  192. ObjectTypeDB::bind_method(_MD("body_clear_shapes","body"),&PhysicsServer::body_clear_shapes);
  193. ObjectTypeDB::bind_method(_MD("body_attach_object_instance_ID","body","id"),&PhysicsServer::body_attach_object_instance_ID);
  194. ObjectTypeDB::bind_method(_MD("body_get_object_instance_ID","body"),&PhysicsServer::body_get_object_instance_ID);
  195. ObjectTypeDB::bind_method(_MD("body_set_enable_continuous_collision_detection","body","enable"),&PhysicsServer::body_set_enable_continuous_collision_detection);
  196. ObjectTypeDB::bind_method(_MD("body_is_continuous_collision_detection_enabled","body"),&PhysicsServer::body_is_continuous_collision_detection_enabled);
  197. //ObjectTypeDB::bind_method(_MD("body_set_user_flags","flags""),&PhysicsServer::body_set_shape,DEFVAL(Transform));
  198. //ObjectTypeDB::bind_method(_MD("body_get_user_flags","body","shape_idx","shape"),&PhysicsServer::body_get_shape);
  199. ObjectTypeDB::bind_method(_MD("body_set_param","body","param","value"),&PhysicsServer::body_set_param);
  200. ObjectTypeDB::bind_method(_MD("body_get_param","body","param"),&PhysicsServer::body_get_param);
  201. ObjectTypeDB::bind_method(_MD("body_static_simulate_motion","body","new_xform"),&PhysicsServer::body_static_simulate_motion);
  202. ObjectTypeDB::bind_method(_MD("body_set_state","body","state","value"),&PhysicsServer::body_set_state);
  203. ObjectTypeDB::bind_method(_MD("body_get_state","body","state"),&PhysicsServer::body_get_state);
  204. ObjectTypeDB::bind_method(_MD("body_apply_impulse","body","pos","impulse"),&PhysicsServer::body_apply_impulse);
  205. ObjectTypeDB::bind_method(_MD("body_set_axis_velocity","body","axis_velocity"),&PhysicsServer::body_set_axis_velocity);
  206. ObjectTypeDB::bind_method(_MD("body_set_axis_lock","body","axis"),&PhysicsServer::body_set_axis_lock);
  207. ObjectTypeDB::bind_method(_MD("body_get_axis_lock","body"),&PhysicsServer::body_set_axis_lock);
  208. ObjectTypeDB::bind_method(_MD("body_add_collision_exception","body","excepted_body"),&PhysicsServer::body_add_collision_exception);
  209. ObjectTypeDB::bind_method(_MD("body_remove_collision_exception","body","excepted_body"),&PhysicsServer::body_remove_collision_exception);
  210. // virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
  211. ObjectTypeDB::bind_method(_MD("body_set_max_contacts_reported","body","amount"),&PhysicsServer::body_set_max_contacts_reported);
  212. ObjectTypeDB::bind_method(_MD("body_get_max_contacts_reported","body"),&PhysicsServer::body_get_max_contacts_reported);
  213. ObjectTypeDB::bind_method(_MD("body_set_omit_force_integration","body","enable"),&PhysicsServer::body_set_omit_force_integration);
  214. ObjectTypeDB::bind_method(_MD("body_is_omitting_force_integration","body"),&PhysicsServer::body_is_omitting_force_integration);
  215. ObjectTypeDB::bind_method(_MD("body_set_force_integration_callback","body","receiver","method","userdata"),&PhysicsServer::body_set_force_integration_callback,DEFVAL(Variant()));
  216. /* JOINT API */
  217. /*
  218. ObjectTypeDB::bind_method(_MD("joint_set_param","joint","param","value"),&PhysicsServer::joint_set_param);
  219. ObjectTypeDB::bind_method(_MD("joint_get_param","joint","param"),&PhysicsServer::joint_get_param);
  220. ObjectTypeDB::bind_method(_MD("pin_joint_create","anchor","body_a","body_b"),&PhysicsServer::pin_joint_create,DEFVAL(RID()));
  221. ObjectTypeDB::bind_method(_MD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&PhysicsServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
  222. ObjectTypeDB::bind_method(_MD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&PhysicsServer::damped_spring_joint_create,DEFVAL(RID()));
  223. ObjectTypeDB::bind_method(_MD("damped_string_joint_set_param","joint","param","value"),&PhysicsServer::damped_string_joint_set_param,DEFVAL(RID()));
  224. ObjectTypeDB::bind_method(_MD("damped_string_joint_get_param","joint","param"),&PhysicsServer::damped_string_joint_get_param);
  225. ObjectTypeDB::bind_method(_MD("joint_get_type","joint"),&PhysicsServer::joint_get_type);
  226. */
  227. ObjectTypeDB::bind_method(_MD("free","rid"),&PhysicsServer::free);
  228. ObjectTypeDB::bind_method(_MD("set_active","active"),&PhysicsServer::set_active);
  229. // ObjectTypeDB::bind_method(_MD("init"),&PhysicsServer::init);
  230. // ObjectTypeDB::bind_method(_MD("step"),&PhysicsServer::step);
  231. // ObjectTypeDB::bind_method(_MD("sync"),&PhysicsServer::sync);
  232. //ObjectTypeDB::bind_method(_MD("flush_queries"),&PhysicsServer::flush_queries);
  233. BIND_CONSTANT( SHAPE_PLANE );
  234. BIND_CONSTANT( SHAPE_RAY );
  235. BIND_CONSTANT( SHAPE_SPHERE );
  236. BIND_CONSTANT( SHAPE_BOX );
  237. BIND_CONSTANT( SHAPE_CAPSULE );
  238. BIND_CONSTANT( SHAPE_CONVEX_POLYGON );
  239. BIND_CONSTANT( SHAPE_CONCAVE_POLYGON );
  240. BIND_CONSTANT( SHAPE_HEIGHTMAP );
  241. BIND_CONSTANT( SHAPE_CUSTOM );
  242. BIND_CONSTANT( AREA_PARAM_GRAVITY );
  243. BIND_CONSTANT( AREA_PARAM_GRAVITY_VECTOR );
  244. BIND_CONSTANT( AREA_PARAM_GRAVITY_IS_POINT );
  245. BIND_CONSTANT( AREA_PARAM_GRAVITY_POINT_ATTENUATION );
  246. BIND_CONSTANT( AREA_PARAM_DENSITY );
  247. BIND_CONSTANT( AREA_PARAM_PRIORITY );
  248. BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE );
  249. BIND_CONSTANT( AREA_SPACE_OVERRIDE_DISABLED );
  250. BIND_CONSTANT( AREA_SPACE_OVERRIDE_REPLACE );
  251. BIND_CONSTANT( BODY_MODE_STATIC );
  252. BIND_CONSTANT( BODY_MODE_KINEMATIC );
  253. BIND_CONSTANT( BODY_MODE_RIGID );
  254. BIND_CONSTANT( BODY_MODE_CHARACTER );
  255. BIND_CONSTANT( BODY_PARAM_BOUNCE );
  256. BIND_CONSTANT( BODY_PARAM_FRICTION );
  257. BIND_CONSTANT( BODY_PARAM_MASS );
  258. BIND_CONSTANT( BODY_PARAM_MAX );
  259. BIND_CONSTANT( BODY_STATE_TRANSFORM );
  260. BIND_CONSTANT( BODY_STATE_LINEAR_VELOCITY );
  261. BIND_CONSTANT( BODY_STATE_ANGULAR_VELOCITY );
  262. BIND_CONSTANT( BODY_STATE_SLEEPING );
  263. BIND_CONSTANT( BODY_STATE_CAN_SLEEP );
  264. /*
  265. BIND_CONSTANT( JOINT_PIN );
  266. BIND_CONSTANT( JOINT_GROOVE );
  267. BIND_CONSTANT( JOINT_DAMPED_SPRING );
  268. BIND_CONSTANT( DAMPED_STRING_REST_LENGTH );
  269. BIND_CONSTANT( DAMPED_STRING_STIFFNESS );
  270. BIND_CONSTANT( DAMPED_STRING_DAMPING );
  271. */
  272. // BIND_CONSTANT( TYPE_BODY );
  273. // BIND_CONSTANT( TYPE_AREA );
  274. BIND_CONSTANT( AREA_BODY_ADDED );
  275. BIND_CONSTANT( AREA_BODY_REMOVED );
  276. }
  277. PhysicsServer::PhysicsServer() {
  278. ERR_FAIL_COND( singleton!=NULL );
  279. singleton=this;
  280. }
  281. PhysicsServer::~PhysicsServer() {
  282. singleton=NULL;
  283. }