1 /**
2 * Copyright (c) 2006-2012 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 
21 #include "wrap_CircleShape.h"
22 
23 namespace love
24 {
25 namespace physics
26 {
27 namespace box2d
28 {
luax_checkcircleshape(lua_State * L,int idx)29 	CircleShape * luax_checkcircleshape(lua_State * L, int idx)
30 	{
31 		return luax_checktype<CircleShape>(L, idx, "CircleShape", PHYSICS_CIRCLE_SHAPE_T);
32 	}
33 
w_CircleShape_getRadius(lua_State * L)34 	int w_CircleShape_getRadius(lua_State * L)
35 	{
36 		CircleShape * c = luax_checkcircleshape(L, 1);
37 		lua_pushnumber(L, c->getRadius());
38 		return 1;
39 	}
40 
w_CircleShape_setRadius(lua_State * L)41 	int w_CircleShape_setRadius(lua_State * L)
42 	{
43         CircleShape * c = luax_checkcircleshape(L, 1);
44         float r = (float)luaL_checknumber(L, 2);
45 		c->setRadius(r);
46 		return 0;
47 	}
48 
49 	static const luaL_Reg functions[] = {
50 		{ "getRadius", w_CircleShape_getRadius },
51 		{ "setRadius", w_CircleShape_setRadius },
52 		// From Shape.
53 		{ "getType", w_Shape_getType },
54 		{ "getRadius", w_Shape_getRadius },
55 		{ "getChildCount", w_Shape_getChildCount },
56 		{ "testPoint", w_Shape_testPoint },
57 		{ "rayCast", w_Shape_rayCast },
58 		{ "computeAABB", w_Shape_computeAABB },
59 		{ "computeMass", w_Shape_computeMass },
60 		{ 0, 0 }
61 	};
62 
luaopen_circleshape(lua_State * L)63 	extern "C" int luaopen_circleshape(lua_State * L)
64 	{
65 		return luax_register_type(L, "CircleShape", functions);
66 	}
67 
68 } // box2d
69 } // physics
70 } // love
71