physics_2d_server.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*************************************************************************/
  2. /* physics_2d_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_2d_server.h"
  30. #include "print_string.h"
  31. Physics2DServer * Physics2DServer::singleton=NULL;
  32. void Physics2DDirectBodyState::integrate_forces() {
  33. real_t step = get_step();
  34. Vector2 lv = get_linear_velocity();
  35. lv+=get_total_gravity() * step;
  36. real_t 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* Physics2DDirectBodyState::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. Physics2DServer * Physics2DServer::get_singleton() {
  51. return singleton;
  52. }
  53. void Physics2DDirectBodyState::_bind_methods() {
  54. ObjectTypeDB::bind_method(_MD("get_total_gravity"),&Physics2DDirectBodyState::get_total_gravity);
  55. ObjectTypeDB::bind_method(_MD("get_total_density"),&Physics2DDirectBodyState::get_total_density);
  56. ObjectTypeDB::bind_method(_MD("get_inverse_mass"),&Physics2DDirectBodyState::get_inverse_mass);
  57. ObjectTypeDB::bind_method(_MD("get_inverse_inertia"),&Physics2DDirectBodyState::get_inverse_inertia);
  58. ObjectTypeDB::bind_method(_MD("set_linear_velocity","velocity"),&Physics2DDirectBodyState::set_linear_velocity);
  59. ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&Physics2DDirectBodyState::get_linear_velocity);
  60. ObjectTypeDB::bind_method(_MD("set_angular_velocity","velocity"),&Physics2DDirectBodyState::set_angular_velocity);
  61. ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&Physics2DDirectBodyState::get_angular_velocity);
  62. ObjectTypeDB::bind_method(_MD("set_transform","transform"),&Physics2DDirectBodyState::set_transform);
  63. ObjectTypeDB::bind_method(_MD("get_transform"),&Physics2DDirectBodyState::get_transform);
  64. ObjectTypeDB::bind_method(_MD("set_sleep_state","enabled"),&Physics2DDirectBodyState::set_sleep_state);
  65. ObjectTypeDB::bind_method(_MD("is_sleeping"),&Physics2DDirectBodyState::is_sleeping);
  66. ObjectTypeDB::bind_method(_MD("get_contact_count"),&Physics2DDirectBodyState::get_contact_count);
  67. ObjectTypeDB::bind_method(_MD("get_contact_local_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_local_pos);
  68. ObjectTypeDB::bind_method(_MD("get_contact_local_normal","contact_idx"),&Physics2DDirectBodyState::get_contact_local_normal);
  69. ObjectTypeDB::bind_method(_MD("get_contact_local_shape","contact_idx"),&Physics2DDirectBodyState::get_contact_local_shape);
  70. ObjectTypeDB::bind_method(_MD("get_contact_collider","contact_idx"),&Physics2DDirectBodyState::get_contact_collider);
  71. ObjectTypeDB::bind_method(_MD("get_contact_collider_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_pos);
  72. ObjectTypeDB::bind_method(_MD("get_contact_collider_id","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_id);
  73. ObjectTypeDB::bind_method(_MD("get_contact_collider_object","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_object);
  74. ObjectTypeDB::bind_method(_MD("get_contact_collider_shape","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_shape);
  75. ObjectTypeDB::bind_method(_MD("get_contact_collider_velocity_at_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_velocity_at_pos);
  76. ObjectTypeDB::bind_method(_MD("get_step"),&Physics2DDirectBodyState::get_step);
  77. ObjectTypeDB::bind_method(_MD("integrate_forces"),&Physics2DDirectBodyState::integrate_forces);
  78. ObjectTypeDB::bind_method(_MD("get_space_state:Physics2DDirectSpaceState"),&Physics2DDirectBodyState::get_space_state);
  79. }
  80. Physics2DDirectBodyState::Physics2DDirectBodyState() {}
  81. ///////////////////////////////////////////////////////
  82. Variant Physics2DDirectSpaceState::_intersect_ray(const Vector2& p_from, const Vector2& p_to,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
  83. RayResult inters;
  84. Set<RID> exclude;
  85. for(int i=0;i<p_exclude.size();i++)
  86. exclude.insert(p_exclude[i]);
  87. bool res = intersect_ray(p_from,p_to,inters,exclude,p_user_mask);
  88. if (!res)
  89. return Variant();
  90. Dictionary d(true);
  91. d["position"]=inters.position;
  92. d["normal"]=inters.normal;
  93. d["collider_id"]=inters.collider_id;
  94. d["collider"]=inters.collider;
  95. d["shape"]=inters.shape;
  96. d["rid"]=inters.rid;
  97. return d;
  98. }
  99. Variant Physics2DDirectSpaceState::_intersect_shape(const RID& p_shape, const Matrix32& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
  100. ERR_FAIL_INDEX_V(p_result_max,4096,Variant());
  101. if (p_result_max<=0)
  102. return Variant();
  103. Set<RID> exclude;
  104. for(int i=0;i<p_exclude.size();i++)
  105. exclude.insert(p_exclude[i]);
  106. ShapeResult *res=(ShapeResult*)alloca(p_result_max*sizeof(ShapeResult));
  107. int rc = intersect_shape(p_shape,p_xform,Vector2(),res,p_result_max,exclude,p_user_mask);
  108. if (rc==0)
  109. return Variant();
  110. Ref<Physics2DShapeQueryResult> result = memnew( Physics2DShapeQueryResult );
  111. result->result.resize(rc);
  112. for(int i=0;i<rc;i++)
  113. result->result[i]=res[i];
  114. return result;
  115. }
  116. Variant Physics2DDirectSpaceState::_cast_motion(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
  117. Set<RID> exclude;
  118. for(int i=0;i<p_exclude.size();i++)
  119. exclude.insert(p_exclude[i]);
  120. MotionCastCollision mcc;
  121. bool result = cast_motion(p_shape,p_xform,p_motion,mcc,exclude,p_user_mask);
  122. if (!result)
  123. return Variant();
  124. Dictionary d(true);
  125. d["point"]=mcc.point;
  126. d["normal"]=mcc.normal;
  127. d["rid"]=mcc.rid;
  128. d["collider_id"]=mcc.collider_id;
  129. d["collider"]=mcc.collider;
  130. d["shape"]=mcc.shape;
  131. return d;
  132. }
  133. Physics2DDirectSpaceState::Physics2DDirectSpaceState() {
  134. }
  135. void Physics2DDirectSpaceState::_bind_methods() {
  136. ObjectTypeDB::bind_method(_MD("intersect_ray:Dictionary","from","to","exclude","umask"),&Physics2DDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0));
  137. ObjectTypeDB::bind_method(_MD("intersect_shape:Physics2DShapeQueryResult","shape","xform","result_max","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
  138. ObjectTypeDB::bind_method(_MD("cast_motion","shape","xform","motion","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
  139. }
  140. int Physics2DShapeQueryResult::get_result_count() const {
  141. return result.size();
  142. }
  143. RID Physics2DShapeQueryResult::get_result_rid(int p_idx) const {
  144. return result[p_idx].rid;
  145. }
  146. ObjectID Physics2DShapeQueryResult::get_result_object_id(int p_idx) const {
  147. return result[p_idx].collider_id;
  148. }
  149. Object* Physics2DShapeQueryResult::get_result_object(int p_idx) const {
  150. return result[p_idx].collider;
  151. }
  152. int Physics2DShapeQueryResult::get_result_object_shape(int p_idx) const {
  153. return result[p_idx].shape;
  154. }
  155. Physics2DShapeQueryResult::Physics2DShapeQueryResult() {
  156. }
  157. void Physics2DShapeQueryResult::_bind_methods() {
  158. ObjectTypeDB::bind_method(_MD("get_result_count"),&Physics2DShapeQueryResult::get_result_count);
  159. ObjectTypeDB::bind_method(_MD("get_result_rid","idx"),&Physics2DShapeQueryResult::get_result_rid);
  160. ObjectTypeDB::bind_method(_MD("get_result_object_id","idx"),&Physics2DShapeQueryResult::get_result_object_id);
  161. ObjectTypeDB::bind_method(_MD("get_result_object","idx"),&Physics2DShapeQueryResult::get_result_object);
  162. ObjectTypeDB::bind_method(_MD("get_result_object_shape","idx"),&Physics2DShapeQueryResult::get_result_object_shape);
  163. }
  164. ///////////////////////////////////////
  165. void Physics2DServer::_bind_methods() {
  166. ObjectTypeDB::bind_method(_MD("shape_create","type"),&Physics2DServer::shape_create);
  167. ObjectTypeDB::bind_method(_MD("shape_set_data","shape","data"),&Physics2DServer::shape_set_data);
  168. ObjectTypeDB::bind_method(_MD("shape_get_type","shape"),&Physics2DServer::shape_get_type);
  169. ObjectTypeDB::bind_method(_MD("shape_get_data","shape"),&Physics2DServer::shape_get_data);
  170. ObjectTypeDB::bind_method(_MD("space_create"),&Physics2DServer::space_create);
  171. ObjectTypeDB::bind_method(_MD("space_set_active","space","active"),&Physics2DServer::space_set_active);
  172. ObjectTypeDB::bind_method(_MD("space_is_active","space"),&Physics2DServer::space_is_active);
  173. ObjectTypeDB::bind_method(_MD("space_set_param","space","param","value"),&Physics2DServer::space_set_param);
  174. ObjectTypeDB::bind_method(_MD("space_get_param","space","param"),&Physics2DServer::space_get_param);
  175. ObjectTypeDB::bind_method(_MD("space_get_direct_state:Physics2DDirectSpaceState","space"),&Physics2DServer::space_get_direct_state);
  176. ObjectTypeDB::bind_method(_MD("area_create"),&Physics2DServer::area_create);
  177. ObjectTypeDB::bind_method(_MD("area_set_space","area","space"),&Physics2DServer::area_set_space);
  178. ObjectTypeDB::bind_method(_MD("area_get_space","area"),&Physics2DServer::area_get_space);
  179. ObjectTypeDB::bind_method(_MD("area_set_space_override_mode","area","mode"),&Physics2DServer::area_set_space_override_mode);
  180. ObjectTypeDB::bind_method(_MD("area_get_space_override_mode","area"),&Physics2DServer::area_get_space_override_mode);
  181. ObjectTypeDB::bind_method(_MD("area_add_shape","area","shape","transform"),&Physics2DServer::area_set_shape,DEFVAL(Matrix32()));
  182. ObjectTypeDB::bind_method(_MD("area_set_shape","area","shape_idx","shape"),&Physics2DServer::area_get_shape);
  183. ObjectTypeDB::bind_method(_MD("area_set_shape_transform","area","shape_idx","transform"),&Physics2DServer::area_set_shape_transform);
  184. ObjectTypeDB::bind_method(_MD("area_get_shape_count","area"),&Physics2DServer::area_get_shape_count);
  185. ObjectTypeDB::bind_method(_MD("area_get_shape","area","shape_idx"),&Physics2DServer::area_get_shape);
  186. ObjectTypeDB::bind_method(_MD("area_get_shape_transform","area","shape_idx"),&Physics2DServer::area_get_shape_transform);
  187. ObjectTypeDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape);
  188. ObjectTypeDB::bind_method(_MD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes);
  189. ObjectTypeDB::bind_method(_MD("area_set_param","area","param","value"),&Physics2DServer::area_get_param);
  190. ObjectTypeDB::bind_method(_MD("area_set_transform","area","transform"),&Physics2DServer::area_get_transform);
  191. ObjectTypeDB::bind_method(_MD("area_get_param","area","param"),&Physics2DServer::area_get_param);
  192. ObjectTypeDB::bind_method(_MD("area_get_transform","area"),&Physics2DServer::area_get_transform);
  193. ObjectTypeDB::bind_method(_MD("area_attach_object_instance_ID","area","id"),&Physics2DServer::area_attach_object_instance_ID);
  194. ObjectTypeDB::bind_method(_MD("area_get_object_instance_ID","area"),&Physics2DServer::area_get_object_instance_ID);
  195. ObjectTypeDB::bind_method(_MD("area_set_monitor_callback","receiver","method"),&Physics2DServer::area_set_monitor_callback);
  196. ObjectTypeDB::bind_method(_MD("body_create","mode","init_sleeping"),&Physics2DServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));
  197. ObjectTypeDB::bind_method(_MD("body_set_space","body","space"),&Physics2DServer::body_set_space);
  198. ObjectTypeDB::bind_method(_MD("body_get_space","body"),&Physics2DServer::body_get_space);
  199. ObjectTypeDB::bind_method(_MD("body_set_mode","body","mode"),&Physics2DServer::body_set_mode);
  200. ObjectTypeDB::bind_method(_MD("body_get_mode","body"),&Physics2DServer::body_get_mode);
  201. ObjectTypeDB::bind_method(_MD("body_add_shape","body","shape","transform"),&Physics2DServer::body_add_shape,DEFVAL(Matrix32()));
  202. ObjectTypeDB::bind_method(_MD("body_set_shape","body","shape_idx","shape"),&Physics2DServer::body_set_shape);
  203. ObjectTypeDB::bind_method(_MD("body_set_shape_transform","body","shape_idx","transform"),&Physics2DServer::body_set_shape_transform);
  204. ObjectTypeDB::bind_method(_MD("body_get_shape_count","body"),&Physics2DServer::body_get_shape_count);
  205. ObjectTypeDB::bind_method(_MD("body_get_shape","body","shape_idx"),&Physics2DServer::body_get_shape);
  206. ObjectTypeDB::bind_method(_MD("body_get_shape_transform","body","shape_idx"),&Physics2DServer::body_get_shape_transform);
  207. ObjectTypeDB::bind_method(_MD("body_remove_shape","body","shape_idx"),&Physics2DServer::body_remove_shape);
  208. ObjectTypeDB::bind_method(_MD("body_clear_shapes","body"),&Physics2DServer::body_clear_shapes);
  209. ObjectTypeDB::bind_method(_MD("body_set_shape_as_trigger","body","shape_idx","enable"),&Physics2DServer::body_set_shape_as_trigger);
  210. ObjectTypeDB::bind_method(_MD("body_is_shape_set_as_trigger","body","shape_idx"),&Physics2DServer::body_is_shape_set_as_trigger);
  211. ObjectTypeDB::bind_method(_MD("body_attach_object_instance_ID","body","id"),&Physics2DServer::body_attach_object_instance_ID);
  212. ObjectTypeDB::bind_method(_MD("body_get_object_instance_ID","body"),&Physics2DServer::body_get_object_instance_ID);
  213. ObjectTypeDB::bind_method(_MD("body_set_continuous_collision_detection_mode","body","mode"),&Physics2DServer::body_set_continuous_collision_detection_mode);
  214. ObjectTypeDB::bind_method(_MD("body_get_continuous_collision_detection_mode","body"),&Physics2DServer::body_get_continuous_collision_detection_mode);
  215. //ObjectTypeDB::bind_method(_MD("body_set_user_flags","flags""),&Physics2DServer::body_set_shape,DEFVAL(Matrix32));
  216. //ObjectTypeDB::bind_method(_MD("body_get_user_flags","body","shape_idx","shape"),&Physics2DServer::body_get_shape);
  217. ObjectTypeDB::bind_method(_MD("body_set_param","body","param","value"),&Physics2DServer::body_set_param);
  218. ObjectTypeDB::bind_method(_MD("body_get_param","body","param"),&Physics2DServer::body_get_param);
  219. ObjectTypeDB::bind_method(_MD("body_set_state","body","state","value"),&Physics2DServer::body_set_state);
  220. ObjectTypeDB::bind_method(_MD("body_get_state","body","state"),&Physics2DServer::body_get_state);
  221. ObjectTypeDB::bind_method(_MD("body_apply_impulse","body","pos","impulse"),&Physics2DServer::body_apply_impulse);
  222. ObjectTypeDB::bind_method(_MD("body_set_axis_velocity","body","axis_velocity"),&Physics2DServer::body_set_axis_velocity);
  223. ObjectTypeDB::bind_method(_MD("body_add_collision_exception","body","excepted_body"),&Physics2DServer::body_add_collision_exception);
  224. ObjectTypeDB::bind_method(_MD("body_remove_collision_exception","body","excepted_body"),&Physics2DServer::body_remove_collision_exception);
  225. // virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
  226. ObjectTypeDB::bind_method(_MD("body_set_max_contacts_reported","body","amount"),&Physics2DServer::body_set_max_contacts_reported);
  227. ObjectTypeDB::bind_method(_MD("body_get_max_contacts_reported","body"),&Physics2DServer::body_get_max_contacts_reported);
  228. ObjectTypeDB::bind_method(_MD("body_set_omit_force_integration","body","enable"),&Physics2DServer::body_set_omit_force_integration);
  229. ObjectTypeDB::bind_method(_MD("body_is_omitting_force_integration","body"),&Physics2DServer::body_is_omitting_force_integration);
  230. ObjectTypeDB::bind_method(_MD("body_set_force_integration_callback","body","receiver","method"),&Physics2DServer::body_set_force_integration_callback);
  231. /* JOINT API */
  232. ObjectTypeDB::bind_method(_MD("joint_set_param","joint","param","value"),&Physics2DServer::joint_set_param);
  233. ObjectTypeDB::bind_method(_MD("joint_get_param","joint","param"),&Physics2DServer::joint_get_param);
  234. ObjectTypeDB::bind_method(_MD("pin_joint_create","anchor","body_a","body_b"),&Physics2DServer::pin_joint_create,DEFVAL(RID()));
  235. ObjectTypeDB::bind_method(_MD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&Physics2DServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
  236. ObjectTypeDB::bind_method(_MD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&Physics2DServer::damped_spring_joint_create,DEFVAL(RID()));
  237. ObjectTypeDB::bind_method(_MD("damped_string_joint_set_param","joint","param","value"),&Physics2DServer::damped_string_joint_set_param,DEFVAL(RID()));
  238. ObjectTypeDB::bind_method(_MD("damped_string_joint_get_param","joint","param"),&Physics2DServer::damped_string_joint_get_param);
  239. ObjectTypeDB::bind_method(_MD("joint_get_type","joint"),&Physics2DServer::joint_get_type);
  240. ObjectTypeDB::bind_method(_MD("free","rid"),&Physics2DServer::free);
  241. ObjectTypeDB::bind_method(_MD("set_active","active"),&Physics2DServer::set_active);
  242. // ObjectTypeDB::bind_method(_MD("init"),&Physics2DServer::init);
  243. // ObjectTypeDB::bind_method(_MD("step"),&Physics2DServer::step);
  244. // ObjectTypeDB::bind_method(_MD("sync"),&Physics2DServer::sync);
  245. //ObjectTypeDB::bind_method(_MD("flush_queries"),&Physics2DServer::flush_queries);
  246. BIND_CONSTANT( SHAPE_LINE );
  247. BIND_CONSTANT( SHAPE_SEGMENT );
  248. BIND_CONSTANT( SHAPE_CIRCLE );
  249. BIND_CONSTANT( SHAPE_RECTANGLE );
  250. BIND_CONSTANT( SHAPE_CAPSULE );
  251. BIND_CONSTANT( SHAPE_CONVEX_POLYGON );
  252. BIND_CONSTANT( SHAPE_CONCAVE_POLYGON );
  253. BIND_CONSTANT( SHAPE_CUSTOM );
  254. BIND_CONSTANT( AREA_PARAM_GRAVITY );
  255. BIND_CONSTANT( AREA_PARAM_GRAVITY_VECTOR );
  256. BIND_CONSTANT( AREA_PARAM_GRAVITY_IS_POINT );
  257. BIND_CONSTANT( AREA_PARAM_GRAVITY_POINT_ATTENUATION );
  258. BIND_CONSTANT( AREA_PARAM_DENSITY );
  259. BIND_CONSTANT( AREA_PARAM_PRIORITY );
  260. BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE );
  261. BIND_CONSTANT( AREA_SPACE_OVERRIDE_DISABLED );
  262. BIND_CONSTANT( AREA_SPACE_OVERRIDE_REPLACE );
  263. BIND_CONSTANT( BODY_MODE_STATIC );
  264. BIND_CONSTANT( BODY_MODE_KINEMATIC );
  265. BIND_CONSTANT( BODY_MODE_RIGID );
  266. BIND_CONSTANT( BODY_MODE_CHARACTER );
  267. BIND_CONSTANT( BODY_PARAM_BOUNCE );
  268. BIND_CONSTANT( BODY_PARAM_FRICTION );
  269. BIND_CONSTANT( BODY_PARAM_MASS );
  270. BIND_CONSTANT( BODY_PARAM_MAX );
  271. BIND_CONSTANT( BODY_STATE_TRANSFORM );
  272. BIND_CONSTANT( BODY_STATE_LINEAR_VELOCITY );
  273. BIND_CONSTANT( BODY_STATE_ANGULAR_VELOCITY );
  274. BIND_CONSTANT( BODY_STATE_SLEEPING );
  275. BIND_CONSTANT( BODY_STATE_CAN_SLEEP );
  276. BIND_CONSTANT( JOINT_PIN );
  277. BIND_CONSTANT( JOINT_GROOVE );
  278. BIND_CONSTANT( JOINT_DAMPED_SPRING );
  279. BIND_CONSTANT( DAMPED_STRING_REST_LENGTH );
  280. BIND_CONSTANT( DAMPED_STRING_STIFFNESS );
  281. BIND_CONSTANT( DAMPED_STRING_DAMPING );
  282. BIND_CONSTANT( CCD_MODE_DISABLED );
  283. BIND_CONSTANT( CCD_MODE_CAST_RAY );
  284. BIND_CONSTANT( CCD_MODE_CAST_SHAPE );
  285. // BIND_CONSTANT( TYPE_BODY );
  286. // BIND_CONSTANT( TYPE_AREA );
  287. BIND_CONSTANT( AREA_BODY_ADDED );
  288. BIND_CONSTANT( AREA_BODY_REMOVED );
  289. }
  290. Physics2DServer::Physics2DServer() {
  291. ERR_FAIL_COND( singleton!=NULL );
  292. singleton=this;
  293. }
  294. Physics2DServer::~Physics2DServer() {
  295. singleton=NULL;
  296. }