2
0

wrap_Body.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. /**
  2. * Copyright (c) 2006-2020 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #include "wrap_Body.h"
  21. #include "wrap_Physics.h"
  22. namespace love
  23. {
  24. namespace physics
  25. {
  26. namespace box2d
  27. {
  28. Body *luax_checkbody(lua_State *L, int idx)
  29. {
  30. Body *b = luax_checktype<Body>(L, idx);
  31. if (b->body == 0)
  32. luaL_error(L, "Attempt to use destroyed body.");
  33. return b;
  34. }
  35. int w_Body_getX(lua_State *L)
  36. {
  37. Body *t = luax_checkbody(L, 1);
  38. lua_pushnumber(L, t->getX());
  39. return 1;
  40. }
  41. int w_Body_getY(lua_State *L)
  42. {
  43. Body *t = luax_checkbody(L, 1);
  44. lua_pushnumber(L, t->getY());
  45. return 1;
  46. }
  47. int w_Body_getAngle(lua_State *L)
  48. {
  49. Body *t = luax_checkbody(L, 1);
  50. lua_pushnumber(L, t->getAngle());
  51. return 1;
  52. }
  53. int w_Body_getPosition(lua_State *L)
  54. {
  55. Body *t = luax_checkbody(L, 1);
  56. float x_o, y_o;
  57. t->getPosition(x_o, y_o);
  58. lua_pushnumber(L, x_o);
  59. lua_pushnumber(L, y_o);
  60. return 2;
  61. }
  62. int w_Body_getTransform(lua_State *L)
  63. {
  64. Body *t = luax_checkbody(L, 1);
  65. float x_o, y_o;
  66. t->getPosition(x_o, y_o);
  67. lua_pushnumber(L, x_o);
  68. lua_pushnumber(L, y_o);
  69. lua_pushnumber(L, t->getAngle());
  70. return 3;
  71. }
  72. int w_Body_getLinearVelocity(lua_State *L)
  73. {
  74. Body *t = luax_checkbody(L, 1);
  75. float x_o, y_o;
  76. t->getLinearVelocity(x_o, y_o);
  77. lua_pushnumber(L, x_o);
  78. lua_pushnumber(L, y_o);
  79. return 2;
  80. }
  81. int w_Body_getWorldCenter(lua_State *L)
  82. {
  83. Body *t = luax_checkbody(L, 1);
  84. float x_o, y_o;
  85. t->getWorldCenter(x_o, y_o);
  86. lua_pushnumber(L, x_o);
  87. lua_pushnumber(L, y_o);
  88. return 2;
  89. }
  90. int w_Body_getLocalCenter(lua_State *L)
  91. {
  92. Body *t = luax_checkbody(L, 1);
  93. float x_o, y_o;
  94. t->getLocalCenter(x_o, y_o);
  95. lua_pushnumber(L, x_o);
  96. lua_pushnumber(L, y_o);
  97. return 2;
  98. }
  99. int w_Body_getAngularVelocity(lua_State *L)
  100. {
  101. Body *t = luax_checkbody(L, 1);
  102. lua_pushnumber(L, t->getAngularVelocity());
  103. return 1;
  104. }
  105. int w_Body_getKinematicState(lua_State *L)
  106. {
  107. Body *t = luax_checkbody(L, 1);
  108. b2Vec2 pos_o, vel_o;
  109. float a_o, da_o;
  110. t->getKinematicState(pos_o, a_o, vel_o, da_o);
  111. lua_pushnumber(L, pos_o.x);
  112. lua_pushnumber(L, pos_o.y);
  113. lua_pushnumber(L, a_o);
  114. lua_pushnumber(L, vel_o.x);
  115. lua_pushnumber(L, vel_o.y);
  116. lua_pushnumber(L, da_o);
  117. return 6;
  118. }
  119. int w_Body_getMass(lua_State *L)
  120. {
  121. Body *t = luax_checkbody(L, 1);
  122. lua_pushnumber(L, t->getMass());
  123. return 1;
  124. }
  125. int w_Body_getInertia(lua_State *L)
  126. {
  127. Body *t = luax_checkbody(L, 1);
  128. lua_pushnumber(L, t->getInertia());
  129. return 1;
  130. }
  131. int w_Body_getMassData(lua_State *L)
  132. {
  133. Body *t = luax_checkbody(L, 1);
  134. lua_remove(L, 1);
  135. return t->getMassData(L);
  136. }
  137. int w_Body_getAngularDamping(lua_State *L)
  138. {
  139. Body *t = luax_checkbody(L, 1);
  140. lua_pushnumber(L, t->getAngularDamping());
  141. return 1;
  142. }
  143. int w_Body_getLinearDamping(lua_State *L)
  144. {
  145. Body *t = luax_checkbody(L, 1);
  146. lua_pushnumber(L, t->getLinearDamping());
  147. return 1;
  148. }
  149. int w_Body_getGravityScale(lua_State *L)
  150. {
  151. Body *t = luax_checkbody(L, 1);
  152. lua_pushnumber(L, t->getGravityScale());
  153. return 1;
  154. }
  155. int w_Body_getType(lua_State *L)
  156. {
  157. Body *t = luax_checkbody(L, 1);
  158. const char *type = "";
  159. Body::getConstant(t->getType(), type);
  160. lua_pushstring(L, type);
  161. return 1;
  162. }
  163. int w_Body_applyLinearImpulse(lua_State *L)
  164. {
  165. Body *t = luax_checkbody(L, 1);
  166. float jx = (float)luaL_checknumber(L, 2);
  167. float jy = (float)luaL_checknumber(L, 3);
  168. int nargs = lua_gettop(L);
  169. if (nargs <= 3 || (nargs == 4 && lua_type(L, 4) == LUA_TBOOLEAN))
  170. {
  171. bool awake = luax_optboolean(L, 4, true);
  172. t->applyLinearImpulse(jx, jy, awake);
  173. }
  174. else if (nargs >= 5)
  175. {
  176. float rx = (float)luaL_checknumber(L, 4);
  177. float ry = (float)luaL_checknumber(L, 5);
  178. bool awake = luax_optboolean(L, 6, true);
  179. t->applyLinearImpulse(jx, jy, rx, ry, awake);
  180. }
  181. else
  182. {
  183. return luaL_error(L, "Wrong number of parameters.");
  184. }
  185. return 0;
  186. }
  187. int w_Body_applyAngularImpulse(lua_State *L)
  188. {
  189. Body *t = luax_checkbody(L, 1);
  190. float i = (float)luaL_checknumber(L, 2);
  191. bool awake = luax_optboolean(L, 3, true);
  192. t->applyAngularImpulse(i, awake);
  193. return 0;
  194. }
  195. int w_Body_applyTorque(lua_State *L)
  196. {
  197. Body *t = luax_checkbody(L, 1);
  198. float arg = (float)luaL_checknumber(L, 2);
  199. bool awake = luax_optboolean(L, 3, true);
  200. t->applyTorque(arg, awake);
  201. return 0;
  202. }
  203. int w_Body_applyForce(lua_State *L)
  204. {
  205. Body *t = luax_checkbody(L, 1);
  206. float fx = (float)luaL_checknumber(L, 2);
  207. float fy = (float)luaL_checknumber(L, 3);
  208. int nargs = lua_gettop(L);
  209. if (nargs <= 3 || (nargs == 4 && lua_type(L, 4) == LUA_TBOOLEAN))
  210. {
  211. bool awake = luax_optboolean(L, 4, true);
  212. t->applyForce(fx, fy, awake);
  213. }
  214. else if (lua_gettop(L) >= 5)
  215. {
  216. float rx = (float)luaL_checknumber(L, 4);
  217. float ry = (float)luaL_checknumber(L, 5);
  218. bool awake = luax_optboolean(L, 6, true);
  219. t->applyForce(fx, fy, rx, ry, awake);
  220. }
  221. else
  222. {
  223. return luaL_error(L, "Wrong number of parameters.");
  224. }
  225. return 0;
  226. }
  227. int w_Body_setX(lua_State *L)
  228. {
  229. Body *t = luax_checkbody(L, 1);
  230. float arg1 = (float)luaL_checknumber(L, 2);
  231. luax_catchexcept(L, [&](){ t->setX(arg1); });
  232. return 0;
  233. }
  234. int w_Body_setY(lua_State *L)
  235. {
  236. Body *t = luax_checkbody(L, 1);
  237. float arg1 = (float)luaL_checknumber(L, 2);
  238. luax_catchexcept(L, [&](){ t->setY(arg1); });
  239. return 0;
  240. }
  241. int w_Body_setTransform(lua_State *L)
  242. {
  243. Body *t = luax_checkbody(L, 1);
  244. float x = (float)luaL_checknumber(L, 2);
  245. float y = (float)luaL_checknumber(L, 3);
  246. float angle = (float)luaL_checknumber(L, 4);
  247. luax_catchexcept(L, [&](){
  248. t->setPosition(x, y);
  249. t->setAngle(angle);
  250. });
  251. return 0;
  252. }
  253. int w_Body_setLinearVelocity(lua_State *L)
  254. {
  255. Body *t = luax_checkbody(L, 1);
  256. float arg1 = (float)luaL_checknumber(L, 2);
  257. float arg2 = (float)luaL_checknumber(L, 3);
  258. t->setLinearVelocity(arg1, arg2);
  259. return 0;
  260. }
  261. int w_Body_setAngle(lua_State *L)
  262. {
  263. Body *t = luax_checkbody(L, 1);
  264. float arg1 = (float)luaL_checknumber(L, 2);
  265. luax_catchexcept(L, [&](){ t->setAngle(arg1); });
  266. return 0;
  267. }
  268. int w_Body_setAngularVelocity(lua_State *L)
  269. {
  270. Body *t = luax_checkbody(L, 1);
  271. float arg1 = (float)luaL_checknumber(L, 2);
  272. t->setAngularVelocity(arg1);
  273. return 0;
  274. }
  275. int w_Body_setPosition(lua_State *L)
  276. {
  277. Body *t = luax_checkbody(L, 1);
  278. float arg1 = (float)luaL_checknumber(L, 2);
  279. float arg2 = (float)luaL_checknumber(L, 3);
  280. luax_catchexcept(L, [&](){ t->setPosition(arg1, arg2); });
  281. return 0;
  282. }
  283. int w_Body_setKinematicState(lua_State *L)
  284. {
  285. Body *t = luax_checkbody(L, 1);
  286. float x = (float)luaL_checknumber(L, 2);
  287. float y = (float)luaL_checknumber(L, 3);
  288. float a = (float)luaL_checknumber(L, 4);
  289. float dx = (float)luaL_checknumber(L, 5);
  290. float dy = (float)luaL_checknumber(L, 6);
  291. float da = (float)luaL_checknumber(L, 7);
  292. luax_catchexcept(L, [&](){ t->setKinematicState(b2Vec2(x, y), a, b2Vec2(dx, dy), da); });
  293. return 0;
  294. }
  295. int w_Body_resetMassData(lua_State *L)
  296. {
  297. Body *t = luax_checkbody(L, 1);
  298. luax_catchexcept(L, [&](){ t->resetMassData(); });
  299. return 0;
  300. }
  301. int w_Body_setMassData(lua_State *L)
  302. {
  303. Body *t = luax_checkbody(L, 1);
  304. float x = (float)luaL_checknumber(L, 2);
  305. float y = (float)luaL_checknumber(L, 3);
  306. float m = (float)luaL_checknumber(L, 4);
  307. float i = (float)luaL_checknumber(L, 5);
  308. luax_catchexcept(L, [&](){ t->setMassData(x, y, m, i); });
  309. return 0;
  310. }
  311. int w_Body_setMass(lua_State *L)
  312. {
  313. Body *t = luax_checkbody(L, 1);
  314. float m = (float)luaL_checknumber(L, 2);
  315. luax_catchexcept(L, [&](){ t->setMass(m); });
  316. return 0;
  317. }
  318. int w_Body_setInertia(lua_State *L)
  319. {
  320. Body *t = luax_checkbody(L, 1);
  321. float i = (float)luaL_checknumber(L, 2);
  322. luax_catchexcept(L, [&](){ t->setInertia(i); });
  323. return 0;
  324. }
  325. int w_Body_setAngularDamping(lua_State *L)
  326. {
  327. Body *t = luax_checkbody(L, 1);
  328. float arg1 = (float)luaL_checknumber(L, 2);
  329. t->setAngularDamping(arg1);
  330. return 0;
  331. }
  332. int w_Body_setLinearDamping(lua_State *L)
  333. {
  334. Body *t = luax_checkbody(L, 1);
  335. float arg1 = (float)luaL_checknumber(L, 2);
  336. t->setLinearDamping(arg1);
  337. return 0;
  338. }
  339. int w_Body_setGravityScale(lua_State *L)
  340. {
  341. Body *t = luax_checkbody(L, 1);
  342. float arg1 = (float)luaL_checknumber(L, 2);
  343. t->setGravityScale(arg1);
  344. return 0;
  345. }
  346. int w_Body_setType(lua_State *L)
  347. {
  348. Body *t = luax_checkbody(L, 1);
  349. const char *typeStr = luaL_checkstring(L, 2);
  350. Body::Type type;
  351. Body::getConstant(typeStr, type);
  352. luax_catchexcept(L, [&](){ t->setType(type); });
  353. return 0;
  354. }
  355. int w_Body_getWorldPoint(lua_State *L)
  356. {
  357. Body *t = luax_checkbody(L, 1);
  358. float x = (float)luaL_checknumber(L, 2);
  359. float y = (float)luaL_checknumber(L, 3);
  360. float x_o, y_o;
  361. t->getWorldPoint(x, y, x_o, y_o);
  362. lua_pushnumber(L, x_o);
  363. lua_pushnumber(L, y_o);
  364. return 2;
  365. }
  366. int w_Body_getWorldVector(lua_State *L)
  367. {
  368. Body *t = luax_checkbody(L, 1);
  369. float x = (float)luaL_checknumber(L, 2);
  370. float y = (float)luaL_checknumber(L, 3);
  371. float x_o, y_o;
  372. t->getWorldVector(x, y, x_o, y_o);
  373. lua_pushnumber(L, x_o);
  374. lua_pushnumber(L, y_o);
  375. return 2;
  376. }
  377. int w_Body_getWorldPoints(lua_State *L)
  378. {
  379. Body *t = luax_checkbody(L, 1);
  380. lua_remove(L, 1);
  381. return t->getWorldPoints(L);
  382. }
  383. int w_Body_getLocalPoint(lua_State *L)
  384. {
  385. Body *t = luax_checkbody(L, 1);
  386. float x = (float)luaL_checknumber(L, 2);
  387. float y = (float)luaL_checknumber(L, 3);
  388. float x_o, y_o;
  389. t->getLocalPoint(x, y, x_o, y_o);
  390. lua_pushnumber(L, x_o);
  391. lua_pushnumber(L, y_o);
  392. return 2;
  393. }
  394. int w_Body_getLocalVector(lua_State *L)
  395. {
  396. Body *t = luax_checkbody(L, 1);
  397. float x = (float)luaL_checknumber(L, 2);
  398. float y = (float)luaL_checknumber(L, 3);
  399. float x_o, y_o;
  400. t->getLocalVector(x, y, x_o, y_o);
  401. lua_pushnumber(L, x_o);
  402. lua_pushnumber(L, y_o);
  403. return 2;
  404. }
  405. int w_Body_getLinearVelocityFromWorldPoint(lua_State *L)
  406. {
  407. Body *t = luax_checkbody(L, 1);
  408. float x = (float)luaL_checknumber(L, 2);
  409. float y = (float)luaL_checknumber(L, 3);
  410. float x_o, y_o;
  411. t->getLinearVelocityFromWorldPoint(x, y, x_o, y_o);
  412. lua_pushnumber(L, x_o);
  413. lua_pushnumber(L, y_o);
  414. return 2;
  415. }
  416. int w_Body_getLinearVelocityFromLocalPoint(lua_State *L)
  417. {
  418. Body *t = luax_checkbody(L, 1);
  419. float x = (float)luaL_checknumber(L, 2);
  420. float y = (float)luaL_checknumber(L, 3);
  421. float x_o, y_o;
  422. t->getLinearVelocityFromLocalPoint(x, y, x_o, y_o);
  423. lua_pushnumber(L, x_o);
  424. lua_pushnumber(L, y_o);
  425. return 2;
  426. }
  427. int w_Body_isBullet(lua_State *L)
  428. {
  429. Body *t = luax_checkbody(L, 1);
  430. luax_pushboolean(L, t->isBullet());
  431. return 1;
  432. }
  433. int w_Body_setBullet(lua_State *L)
  434. {
  435. Body *t = luax_checkbody(L, 1);
  436. bool b = luax_checkboolean(L, 2);
  437. t->setBullet(b);
  438. return 0;
  439. }
  440. int w_Body_isActive(lua_State *L)
  441. {
  442. Body *t = luax_checkbody(L, 1);
  443. luax_pushboolean(L, t->isActive());
  444. return 1;
  445. }
  446. int w_Body_isAwake(lua_State *L)
  447. {
  448. Body *t = luax_checkbody(L, 1);
  449. luax_pushboolean(L, t->isAwake());
  450. return 1;
  451. }
  452. int w_Body_setSleepingAllowed(lua_State *L)
  453. {
  454. Body *t = luax_checkbody(L, 1);
  455. bool b = luax_checkboolean(L, 2);
  456. t->setSleepingAllowed(b);
  457. return 0;
  458. }
  459. int w_Body_isSleepingAllowed(lua_State *L)
  460. {
  461. Body *t = luax_checkbody(L, 1);
  462. lua_pushboolean(L, t->isSleepingAllowed());
  463. return 1;
  464. }
  465. int w_Body_setActive(lua_State *L)
  466. {
  467. Body *t = luax_checkbody(L, 1);
  468. bool b = luax_checkboolean(L, 2);
  469. luax_catchexcept(L, [&](){ t->setActive(b); });
  470. return 0;
  471. }
  472. int w_Body_setAwake(lua_State *L)
  473. {
  474. Body *t = luax_checkbody(L, 1);
  475. bool b = luax_checkboolean(L, 2);
  476. t->setAwake(b);
  477. return 0;
  478. }
  479. int w_Body_setFixedRotation(lua_State *L)
  480. {
  481. Body *t = luax_checkbody(L, 1);
  482. bool b = luax_checkboolean(L, 2);
  483. luax_catchexcept(L, [&](){ t->setFixedRotation(b); });
  484. return 0;
  485. }
  486. int w_Body_isFixedRotation(lua_State *L)
  487. {
  488. Body *t = luax_checkbody(L, 1);
  489. bool b = t->isFixedRotation();
  490. luax_pushboolean(L, b);
  491. return 1;
  492. }
  493. int w_Body_isTouching(lua_State *L)
  494. {
  495. Body *t = luax_checkbody(L, 1);
  496. Body *other = luax_checkbody(L, 2);
  497. luax_pushboolean(L, t->isTouching(other));
  498. return 1;
  499. }
  500. int w_Body_getWorld(lua_State *L)
  501. {
  502. Body *t = luax_checkbody(L, 1);
  503. World *world = t->getWorld();
  504. luax_pushtype(L, world);
  505. return 1;
  506. }
  507. int w_Body_getFixtures(lua_State *L)
  508. {
  509. Body *t = luax_checkbody(L, 1);
  510. lua_remove(L, 1);
  511. int n = 0;
  512. luax_catchexcept(L, [&](){ n = t->getFixtures(L); });
  513. return n;
  514. }
  515. int w_Body_getJoints(lua_State *L)
  516. {
  517. Body *t = luax_checkbody(L, 1);
  518. lua_remove(L, 1);
  519. int n = 0;
  520. luax_catchexcept(L, [&](){ n = t->getJoints(L); });
  521. return n;
  522. }
  523. int w_Body_getContacts(lua_State *L)
  524. {
  525. Body *t = luax_checkbody(L, 1);
  526. lua_remove(L, 1);
  527. int n = 0;
  528. luax_catchexcept(L, [&](){ n = t->getContacts(L); });
  529. return n;
  530. }
  531. int w_Body_destroy(lua_State *L)
  532. {
  533. Body *t = luax_checkbody(L, 1);
  534. luax_catchexcept(L, [&](){ t->destroy(); });
  535. return 0;
  536. }
  537. int w_Body_isDestroyed(lua_State *L)
  538. {
  539. Body *b = luax_checktype<Body>(L, 1);
  540. luax_pushboolean(L, b->body == nullptr);
  541. return 1;
  542. }
  543. int w_Body_setUserData(lua_State *L)
  544. {
  545. Body *t = luax_checkbody(L, 1);
  546. lua_remove(L, 1);
  547. return t->setUserData(L);
  548. }
  549. int w_Body_getUserData(lua_State *L)
  550. {
  551. Body *t = luax_checkbody(L, 1);
  552. lua_remove(L, 1);
  553. return t->getUserData(L);
  554. }
  555. static const luaL_Reg w_Body_functions[] =
  556. {
  557. { "getX", w_Body_getX },
  558. { "getY", w_Body_getY },
  559. { "getAngle", w_Body_getAngle },
  560. { "getPosition", w_Body_getPosition },
  561. { "getTransform", w_Body_getTransform },
  562. { "setTransform", w_Body_setTransform },
  563. { "getLinearVelocity", w_Body_getLinearVelocity },
  564. { "getWorldCenter", w_Body_getWorldCenter },
  565. { "getLocalCenter", w_Body_getLocalCenter },
  566. { "getAngularVelocity", w_Body_getAngularVelocity },
  567. { "getKinematicState", w_Body_getKinematicState },
  568. { "getMass", w_Body_getMass },
  569. { "getInertia", w_Body_getInertia },
  570. { "getMassData", w_Body_getMassData },
  571. { "getAngularDamping", w_Body_getAngularDamping },
  572. { "getLinearDamping", w_Body_getLinearDamping },
  573. { "getGravityScale", w_Body_getGravityScale },
  574. { "getType", w_Body_getType },
  575. { "applyLinearImpulse", w_Body_applyLinearImpulse },
  576. { "applyAngularImpulse", w_Body_applyAngularImpulse },
  577. { "applyTorque", w_Body_applyTorque },
  578. { "applyForce", w_Body_applyForce },
  579. { "setX", w_Body_setX },
  580. { "setY", w_Body_setY },
  581. { "setLinearVelocity", w_Body_setLinearVelocity },
  582. { "setAngle", w_Body_setAngle },
  583. { "setAngularVelocity", w_Body_setAngularVelocity },
  584. { "setPosition", w_Body_setPosition },
  585. { "setKinematicState", w_Body_setKinematicState },
  586. { "resetMassData", w_Body_resetMassData },
  587. { "setMassData", w_Body_setMassData },
  588. { "setMass", w_Body_setMass },
  589. { "setInertia", w_Body_setInertia },
  590. { "setAngularDamping", w_Body_setAngularDamping },
  591. { "setLinearDamping", w_Body_setLinearDamping },
  592. { "setGravityScale", w_Body_setGravityScale },
  593. { "setType", w_Body_setType },
  594. { "getWorldPoint", w_Body_getWorldPoint },
  595. { "getWorldVector", w_Body_getWorldVector },
  596. { "getWorldPoints", w_Body_getWorldPoints },
  597. { "getLocalPoint", w_Body_getLocalPoint },
  598. { "getLocalVector", w_Body_getLocalVector },
  599. { "getLinearVelocityFromWorldPoint", w_Body_getLinearVelocityFromWorldPoint },
  600. { "getLinearVelocityFromLocalPoint", w_Body_getLinearVelocityFromLocalPoint },
  601. { "isBullet", w_Body_isBullet },
  602. { "setBullet", w_Body_setBullet },
  603. { "isActive", w_Body_isActive },
  604. { "isAwake", w_Body_isAwake },
  605. { "setSleepingAllowed", w_Body_setSleepingAllowed },
  606. { "isSleepingAllowed", w_Body_isSleepingAllowed },
  607. { "setActive", w_Body_setActive },
  608. { "setAwake", w_Body_setAwake },
  609. { "setFixedRotation", w_Body_setFixedRotation },
  610. { "isFixedRotation", w_Body_isFixedRotation },
  611. { "isTouching", w_Body_isTouching },
  612. { "getWorld", w_Body_getWorld },
  613. { "getFixtures", w_Body_getFixtures },
  614. { "getJoints", w_Body_getJoints },
  615. { "getContacts", w_Body_getContacts },
  616. { "destroy", w_Body_destroy },
  617. { "isDestroyed", w_Body_isDestroyed },
  618. { "setUserData", w_Body_setUserData },
  619. { "getUserData", w_Body_getUserData },
  620. { 0, 0 }
  621. };
  622. extern "C" int luaopen_body(lua_State *L)
  623. {
  624. return luax_register_type(L, &Body::type, w_Body_functions, nullptr);
  625. }
  626. } // box2d
  627. } // physics
  628. } // love