lua_PhysicsCollisionShape.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_PhysicsCollisionShape.h"
  4. #include "Base.h"
  5. #include "Game.h"
  6. #include "Node.h"
  7. #include "PhysicsCollisionShape.h"
  8. #include "Properties.h"
  9. #include "Ref.h"
  10. #include "lua_PhysicsCollisionShapeType.h"
  11. namespace gameplay
  12. {
  13. void luaRegister_PhysicsCollisionShape()
  14. {
  15. const luaL_Reg lua_members[] =
  16. {
  17. {"addRef", lua_PhysicsCollisionShape_addRef},
  18. {"getRefCount", lua_PhysicsCollisionShape_getRefCount},
  19. {"getType", lua_PhysicsCollisionShape_getType},
  20. {"release", lua_PhysicsCollisionShape_release},
  21. {NULL, NULL}
  22. };
  23. const luaL_Reg lua_statics[] =
  24. {
  25. {"box", lua_PhysicsCollisionShape_static_box},
  26. {"capsule", lua_PhysicsCollisionShape_static_capsule},
  27. {"heightfield", lua_PhysicsCollisionShape_static_heightfield},
  28. {"mesh", lua_PhysicsCollisionShape_static_mesh},
  29. {"sphere", lua_PhysicsCollisionShape_static_sphere},
  30. {NULL, NULL}
  31. };
  32. std::vector<std::string> scopePath;
  33. ScriptUtil::registerClass("PhysicsCollisionShape", lua_members, NULL, lua_PhysicsCollisionShape__gc, lua_statics, scopePath);
  34. }
  35. static PhysicsCollisionShape* getInstance(lua_State* state)
  36. {
  37. void* userdata = luaL_checkudata(state, 1, "PhysicsCollisionShape");
  38. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsCollisionShape' expected.");
  39. return (PhysicsCollisionShape*)((ScriptUtil::LuaObject*)userdata)->instance;
  40. }
  41. int lua_PhysicsCollisionShape__gc(lua_State* state)
  42. {
  43. // Get the number of parameters.
  44. int paramCount = lua_gettop(state);
  45. // Attempt to match the parameters to a valid binding.
  46. switch (paramCount)
  47. {
  48. case 1:
  49. {
  50. if ((lua_type(state, 1) == LUA_TUSERDATA))
  51. {
  52. void* userdata = luaL_checkudata(state, 1, "PhysicsCollisionShape");
  53. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsCollisionShape' expected.");
  54. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  55. if (object->owns)
  56. {
  57. PhysicsCollisionShape* instance = (PhysicsCollisionShape*)object->instance;
  58. SAFE_RELEASE(instance);
  59. }
  60. return 0;
  61. }
  62. else
  63. {
  64. lua_pushstring(state, "lua_PhysicsCollisionShape__gc - Failed to match the given parameters to a valid function signature.");
  65. lua_error(state);
  66. }
  67. break;
  68. }
  69. default:
  70. {
  71. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  72. lua_error(state);
  73. break;
  74. }
  75. }
  76. return 0;
  77. }
  78. int lua_PhysicsCollisionShape_addRef(lua_State* state)
  79. {
  80. // Get the number of parameters.
  81. int paramCount = lua_gettop(state);
  82. // Attempt to match the parameters to a valid binding.
  83. switch (paramCount)
  84. {
  85. case 1:
  86. {
  87. if ((lua_type(state, 1) == LUA_TUSERDATA))
  88. {
  89. PhysicsCollisionShape* instance = getInstance(state);
  90. instance->addRef();
  91. return 0;
  92. }
  93. else
  94. {
  95. lua_pushstring(state, "lua_PhysicsCollisionShape_addRef - Failed to match the given parameters to a valid function signature.");
  96. lua_error(state);
  97. }
  98. break;
  99. }
  100. default:
  101. {
  102. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  103. lua_error(state);
  104. break;
  105. }
  106. }
  107. return 0;
  108. }
  109. int lua_PhysicsCollisionShape_getRefCount(lua_State* state)
  110. {
  111. // Get the number of parameters.
  112. int paramCount = lua_gettop(state);
  113. // Attempt to match the parameters to a valid binding.
  114. switch (paramCount)
  115. {
  116. case 1:
  117. {
  118. if ((lua_type(state, 1) == LUA_TUSERDATA))
  119. {
  120. PhysicsCollisionShape* instance = getInstance(state);
  121. unsigned int result = instance->getRefCount();
  122. // Push the return value onto the stack.
  123. lua_pushunsigned(state, result);
  124. return 1;
  125. }
  126. else
  127. {
  128. lua_pushstring(state, "lua_PhysicsCollisionShape_getRefCount - Failed to match the given parameters to a valid function signature.");
  129. lua_error(state);
  130. }
  131. break;
  132. }
  133. default:
  134. {
  135. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  136. lua_error(state);
  137. break;
  138. }
  139. }
  140. return 0;
  141. }
  142. int lua_PhysicsCollisionShape_getType(lua_State* state)
  143. {
  144. // Get the number of parameters.
  145. int paramCount = lua_gettop(state);
  146. // Attempt to match the parameters to a valid binding.
  147. switch (paramCount)
  148. {
  149. case 1:
  150. {
  151. if ((lua_type(state, 1) == LUA_TUSERDATA))
  152. {
  153. PhysicsCollisionShape* instance = getInstance(state);
  154. PhysicsCollisionShape::Type result = instance->getType();
  155. // Push the return value onto the stack.
  156. lua_pushstring(state, lua_stringFromEnum_PhysicsCollisionShapeType(result));
  157. return 1;
  158. }
  159. else
  160. {
  161. lua_pushstring(state, "lua_PhysicsCollisionShape_getType - Failed to match the given parameters to a valid function signature.");
  162. lua_error(state);
  163. }
  164. break;
  165. }
  166. default:
  167. {
  168. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  169. lua_error(state);
  170. break;
  171. }
  172. }
  173. return 0;
  174. }
  175. int lua_PhysicsCollisionShape_release(lua_State* state)
  176. {
  177. // Get the number of parameters.
  178. int paramCount = lua_gettop(state);
  179. // Attempt to match the parameters to a valid binding.
  180. switch (paramCount)
  181. {
  182. case 1:
  183. {
  184. if ((lua_type(state, 1) == LUA_TUSERDATA))
  185. {
  186. PhysicsCollisionShape* instance = getInstance(state);
  187. instance->release();
  188. return 0;
  189. }
  190. else
  191. {
  192. lua_pushstring(state, "lua_PhysicsCollisionShape_release - Failed to match the given parameters to a valid function signature.");
  193. lua_error(state);
  194. }
  195. break;
  196. }
  197. default:
  198. {
  199. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  200. lua_error(state);
  201. break;
  202. }
  203. }
  204. return 0;
  205. }
  206. int lua_PhysicsCollisionShape_static_box(lua_State* state)
  207. {
  208. // Get the number of parameters.
  209. int paramCount = lua_gettop(state);
  210. // Attempt to match the parameters to a valid binding.
  211. switch (paramCount)
  212. {
  213. case 0:
  214. {
  215. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box());
  216. if (returnPtr)
  217. {
  218. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  219. object->instance = returnPtr;
  220. object->owns = true;
  221. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  222. lua_setmetatable(state, -2);
  223. }
  224. else
  225. {
  226. lua_pushnil(state);
  227. }
  228. return 1;
  229. break;
  230. }
  231. case 1:
  232. {
  233. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  234. {
  235. // Get parameter 1 off the stack.
  236. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true);
  237. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*param1));
  238. if (returnPtr)
  239. {
  240. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  241. object->instance = returnPtr;
  242. object->owns = true;
  243. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  244. lua_setmetatable(state, -2);
  245. }
  246. else
  247. {
  248. lua_pushnil(state);
  249. }
  250. return 1;
  251. }
  252. else
  253. {
  254. lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - Failed to match the given parameters to a valid function signature.");
  255. lua_error(state);
  256. }
  257. break;
  258. }
  259. case 2:
  260. {
  261. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  262. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  263. {
  264. // Get parameter 1 off the stack.
  265. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true);
  266. // Get parameter 2 off the stack.
  267. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  268. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*param1, *param2));
  269. if (returnPtr)
  270. {
  271. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  272. object->instance = returnPtr;
  273. object->owns = true;
  274. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  275. lua_setmetatable(state, -2);
  276. }
  277. else
  278. {
  279. lua_pushnil(state);
  280. }
  281. return 1;
  282. }
  283. else
  284. {
  285. lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - Failed to match the given parameters to a valid function signature.");
  286. lua_error(state);
  287. }
  288. break;
  289. }
  290. case 3:
  291. {
  292. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  293. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  294. lua_type(state, 3) == LUA_TBOOLEAN)
  295. {
  296. // Get parameter 1 off the stack.
  297. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true);
  298. // Get parameter 2 off the stack.
  299. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  300. // Get parameter 3 off the stack.
  301. bool param3 = ScriptUtil::luaCheckBool(state, 3);
  302. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::box(*param1, *param2, param3));
  303. if (returnPtr)
  304. {
  305. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  306. object->instance = returnPtr;
  307. object->owns = true;
  308. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  309. lua_setmetatable(state, -2);
  310. }
  311. else
  312. {
  313. lua_pushnil(state);
  314. }
  315. return 1;
  316. }
  317. else
  318. {
  319. lua_pushstring(state, "lua_PhysicsCollisionShape_static_box - Failed to match the given parameters to a valid function signature.");
  320. lua_error(state);
  321. }
  322. break;
  323. }
  324. default:
  325. {
  326. lua_pushstring(state, "Invalid number of parameters (expected 0, 1, 2 or 3).");
  327. lua_error(state);
  328. break;
  329. }
  330. }
  331. return 0;
  332. }
  333. int lua_PhysicsCollisionShape_static_capsule(lua_State* state)
  334. {
  335. // Get the number of parameters.
  336. int paramCount = lua_gettop(state);
  337. // Attempt to match the parameters to a valid binding.
  338. switch (paramCount)
  339. {
  340. case 0:
  341. {
  342. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule());
  343. if (returnPtr)
  344. {
  345. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  346. object->instance = returnPtr;
  347. object->owns = true;
  348. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  349. lua_setmetatable(state, -2);
  350. }
  351. else
  352. {
  353. lua_pushnil(state);
  354. }
  355. return 1;
  356. break;
  357. }
  358. case 2:
  359. {
  360. if (lua_type(state, 1) == LUA_TNUMBER &&
  361. lua_type(state, 2) == LUA_TNUMBER)
  362. {
  363. // Get parameter 1 off the stack.
  364. float param1 = (float)luaL_checknumber(state, 1);
  365. // Get parameter 2 off the stack.
  366. float param2 = (float)luaL_checknumber(state, 2);
  367. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(param1, param2));
  368. if (returnPtr)
  369. {
  370. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  371. object->instance = returnPtr;
  372. object->owns = true;
  373. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  374. lua_setmetatable(state, -2);
  375. }
  376. else
  377. {
  378. lua_pushnil(state);
  379. }
  380. return 1;
  381. }
  382. else
  383. {
  384. lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - Failed to match the given parameters to a valid function signature.");
  385. lua_error(state);
  386. }
  387. break;
  388. }
  389. case 3:
  390. {
  391. if (lua_type(state, 1) == LUA_TNUMBER &&
  392. lua_type(state, 2) == LUA_TNUMBER &&
  393. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
  394. {
  395. // Get parameter 1 off the stack.
  396. float param1 = (float)luaL_checknumber(state, 1);
  397. // Get parameter 2 off the stack.
  398. float param2 = (float)luaL_checknumber(state, 2);
  399. // Get parameter 3 off the stack.
  400. Vector3* param3 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  401. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(param1, param2, *param3));
  402. if (returnPtr)
  403. {
  404. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  405. object->instance = returnPtr;
  406. object->owns = true;
  407. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  408. lua_setmetatable(state, -2);
  409. }
  410. else
  411. {
  412. lua_pushnil(state);
  413. }
  414. return 1;
  415. }
  416. else
  417. {
  418. lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - Failed to match the given parameters to a valid function signature.");
  419. lua_error(state);
  420. }
  421. break;
  422. }
  423. case 4:
  424. {
  425. if (lua_type(state, 1) == LUA_TNUMBER &&
  426. lua_type(state, 2) == LUA_TNUMBER &&
  427. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  428. lua_type(state, 4) == LUA_TBOOLEAN)
  429. {
  430. // Get parameter 1 off the stack.
  431. float param1 = (float)luaL_checknumber(state, 1);
  432. // Get parameter 2 off the stack.
  433. float param2 = (float)luaL_checknumber(state, 2);
  434. // Get parameter 3 off the stack.
  435. Vector3* param3 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  436. // Get parameter 4 off the stack.
  437. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  438. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::capsule(param1, param2, *param3, param4));
  439. if (returnPtr)
  440. {
  441. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  442. object->instance = returnPtr;
  443. object->owns = true;
  444. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  445. lua_setmetatable(state, -2);
  446. }
  447. else
  448. {
  449. lua_pushnil(state);
  450. }
  451. return 1;
  452. }
  453. else
  454. {
  455. lua_pushstring(state, "lua_PhysicsCollisionShape_static_capsule - Failed to match the given parameters to a valid function signature.");
  456. lua_error(state);
  457. }
  458. break;
  459. }
  460. default:
  461. {
  462. lua_pushstring(state, "Invalid number of parameters (expected 0, 2, 3 or 4).");
  463. lua_error(state);
  464. break;
  465. }
  466. }
  467. return 0;
  468. }
  469. int lua_PhysicsCollisionShape_static_heightfield(lua_State* state)
  470. {
  471. // Get the number of parameters.
  472. int paramCount = lua_gettop(state);
  473. // Attempt to match the parameters to a valid binding.
  474. switch (paramCount)
  475. {
  476. case 1:
  477. {
  478. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  479. {
  480. // Get parameter 1 off the stack.
  481. Image* param1 = ScriptUtil::getObjectPointer<Image>(1, "Image", false);
  482. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::heightfield(param1));
  483. if (returnPtr)
  484. {
  485. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  486. object->instance = returnPtr;
  487. object->owns = true;
  488. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  489. lua_setmetatable(state, -2);
  490. }
  491. else
  492. {
  493. lua_pushnil(state);
  494. }
  495. return 1;
  496. }
  497. else
  498. {
  499. lua_pushstring(state, "lua_PhysicsCollisionShape_static_heightfield - Failed to match the given parameters to a valid function signature.");
  500. lua_error(state);
  501. }
  502. break;
  503. }
  504. default:
  505. {
  506. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  507. lua_error(state);
  508. break;
  509. }
  510. }
  511. return 0;
  512. }
  513. int lua_PhysicsCollisionShape_static_mesh(lua_State* state)
  514. {
  515. // Get the number of parameters.
  516. int paramCount = lua_gettop(state);
  517. // Attempt to match the parameters to a valid binding.
  518. switch (paramCount)
  519. {
  520. case 1:
  521. {
  522. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  523. {
  524. // Get parameter 1 off the stack.
  525. Mesh* param1 = ScriptUtil::getObjectPointer<Mesh>(1, "Mesh", false);
  526. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::mesh(param1));
  527. if (returnPtr)
  528. {
  529. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  530. object->instance = returnPtr;
  531. object->owns = true;
  532. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  533. lua_setmetatable(state, -2);
  534. }
  535. else
  536. {
  537. lua_pushnil(state);
  538. }
  539. return 1;
  540. }
  541. else
  542. {
  543. lua_pushstring(state, "lua_PhysicsCollisionShape_static_mesh - Failed to match the given parameters to a valid function signature.");
  544. lua_error(state);
  545. }
  546. break;
  547. }
  548. default:
  549. {
  550. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  551. lua_error(state);
  552. break;
  553. }
  554. }
  555. return 0;
  556. }
  557. int lua_PhysicsCollisionShape_static_sphere(lua_State* state)
  558. {
  559. // Get the number of parameters.
  560. int paramCount = lua_gettop(state);
  561. // Attempt to match the parameters to a valid binding.
  562. switch (paramCount)
  563. {
  564. case 0:
  565. {
  566. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere());
  567. if (returnPtr)
  568. {
  569. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  570. object->instance = returnPtr;
  571. object->owns = true;
  572. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  573. lua_setmetatable(state, -2);
  574. }
  575. else
  576. {
  577. lua_pushnil(state);
  578. }
  579. return 1;
  580. break;
  581. }
  582. case 1:
  583. {
  584. if (lua_type(state, 1) == LUA_TNUMBER)
  585. {
  586. // Get parameter 1 off the stack.
  587. float param1 = (float)luaL_checknumber(state, 1);
  588. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(param1));
  589. if (returnPtr)
  590. {
  591. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  592. object->instance = returnPtr;
  593. object->owns = true;
  594. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  595. lua_setmetatable(state, -2);
  596. }
  597. else
  598. {
  599. lua_pushnil(state);
  600. }
  601. return 1;
  602. }
  603. else
  604. {
  605. lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - Failed to match the given parameters to a valid function signature.");
  606. lua_error(state);
  607. }
  608. break;
  609. }
  610. case 2:
  611. {
  612. if (lua_type(state, 1) == LUA_TNUMBER &&
  613. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  614. {
  615. // Get parameter 1 off the stack.
  616. float param1 = (float)luaL_checknumber(state, 1);
  617. // Get parameter 2 off the stack.
  618. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  619. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(param1, *param2));
  620. if (returnPtr)
  621. {
  622. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  623. object->instance = returnPtr;
  624. object->owns = true;
  625. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  626. lua_setmetatable(state, -2);
  627. }
  628. else
  629. {
  630. lua_pushnil(state);
  631. }
  632. return 1;
  633. }
  634. else
  635. {
  636. lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - Failed to match the given parameters to a valid function signature.");
  637. lua_error(state);
  638. }
  639. break;
  640. }
  641. case 3:
  642. {
  643. if (lua_type(state, 1) == LUA_TNUMBER &&
  644. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  645. lua_type(state, 3) == LUA_TBOOLEAN)
  646. {
  647. // Get parameter 1 off the stack.
  648. float param1 = (float)luaL_checknumber(state, 1);
  649. // Get parameter 2 off the stack.
  650. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  651. // Get parameter 3 off the stack.
  652. bool param3 = ScriptUtil::luaCheckBool(state, 3);
  653. void* returnPtr = (void*)new PhysicsCollisionShape::Definition(PhysicsCollisionShape::sphere(param1, *param2, param3));
  654. if (returnPtr)
  655. {
  656. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  657. object->instance = returnPtr;
  658. object->owns = true;
  659. luaL_getmetatable(state, "PhysicsCollisionShapeDefinition");
  660. lua_setmetatable(state, -2);
  661. }
  662. else
  663. {
  664. lua_pushnil(state);
  665. }
  666. return 1;
  667. }
  668. else
  669. {
  670. lua_pushstring(state, "lua_PhysicsCollisionShape_static_sphere - Failed to match the given parameters to a valid function signature.");
  671. lua_error(state);
  672. }
  673. break;
  674. }
  675. default:
  676. {
  677. lua_pushstring(state, "Invalid number of parameters (expected 0, 1, 2 or 3).");
  678. lua_error(state);
  679. break;
  680. }
  681. }
  682. return 0;
  683. }
  684. }