2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-10-11 12:15:41 +08:00
|
|
|
Copyright (c) 2021 Bytedance Inc.
|
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
#include "scripting/lua-bindings/manual/base/lua_axis_base_manual.hpp"
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_PHYSICS
|
2021-12-25 10:04:45 +08:00
|
|
|
# include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
# include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
|
|
|
# include "scripting/lua-bindings/manual/CCLuaValue.h"
|
|
|
|
# include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
|
|
|
# include "2d/CCScene.h"
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
# ifndef AX_SAFE_DELETE_ARRAY
|
2021-12-25 10:04:45 +08:00
|
|
|
# define do \
|
|
|
|
{ \
|
|
|
|
if (p) \
|
|
|
|
{ \
|
|
|
|
delete[](p); \
|
|
|
|
(p) = nullptr; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsBody_getJoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsBody", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsBody*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsBody_getJoints'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
auto& ret = cobj->getJoints();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_newtable(tolua_S);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (ret.empty())
|
|
|
|
return 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
auto iter = ret.begin();
|
|
|
|
int indexTable = 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
for (; iter != ret.end(); ++iter)
|
|
|
|
{
|
|
|
|
if (nullptr == *iter)
|
|
|
|
continue;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pushnumber(tolua_S, (lua_Number)indexTable);
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(tolua_S, (void*)(*iter), getLuaTypeName(*iter, "ax.PhysicsJoint"));
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
++indexTable;
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getJoints", argc, 0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsBody_getJoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsWorld* cobj = nullptr;
|
2021-10-11 12:15:41 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsWorld", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsWorld*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsWorld_getScene'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Scene& ret = cobj->getScene();
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
auto className = getLuaTypeName<Ref>(&ret, "ax.Scene");
|
2021-06-18 12:23:10 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (int)(ret._ID);
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &(ret._luaID);
|
2021-12-25 10:04:45 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)(&ret), className);
|
|
|
|
|
|
|
|
} while (0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getScene", argc, 0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsWorld_getScene'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsWorld_rayCast(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsWorld* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsWorld", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsWorld*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsWorld_rayCast'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
std::function<bool(axis::PhysicsWorld&, const axis::PhysicsRayCastInfo&, void*)> arg0;
|
|
|
|
axis::Vec2 arg1;
|
|
|
|
axis::Vec2 arg2;
|
2014-03-10 14:04:58 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2022-07-20 18:41:33 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-20 18:41:33 +08:00
|
|
|
arg0 = [handler, stack](axis::PhysicsWorld& world, const axis::PhysicsRayCastInfo& info,
|
2021-12-25 10:04:45 +08:00
|
|
|
void* data) -> bool {
|
2022-07-20 18:41:33 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
auto Ls = stack->getLuaState();
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(Ls, (void*)(&world), getLuaTypeName(&world, "ax.PhysicsWorld"));
|
2021-11-15 19:05:08 +08:00
|
|
|
physics_raycastinfo_to_luaval(Ls, info);
|
|
|
|
return stack->executeFunctionByHandler(handler, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
} while (0);
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.PhysicsWorld:rayCast");
|
|
|
|
ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.PhysicsWorld:rayCast");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2022-07-20 18:41:33 +08:00
|
|
|
{
|
|
|
|
stack->removeScriptHandler(handler);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-20 18:41:33 +08:00
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->rayCast(arg0, arg1, arg2, nullptr);
|
2022-07-20 18:41:33 +08:00
|
|
|
stack->removeScriptHandler(handler);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "rayCast", argc, 4);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsWorld_rayCast'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsWorld_queryRect(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsWorld* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsWorld", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsWorld*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsWorld_queryRect'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
std::function<bool(axis::PhysicsWorld&, axis::PhysicsShape&, void*)> arg0;
|
|
|
|
axis::Rect arg1;
|
2014-03-10 14:04:58 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2022-07-20 18:41:33 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-20 18:41:33 +08:00
|
|
|
arg0 = [handler,stack](axis::PhysicsWorld& world, axis::PhysicsShape& shape, void* data) -> bool {
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
auto Ls = stack->getLuaState();
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(Ls, (void*)(&world), getLuaTypeName(&world, "ax.PhysicsWorld"));
|
|
|
|
toluafix_pushusertype_ccobject(Ls, shape._ID, &shape._luaID, (void*)(&shape), "ax.PhysicsShape");
|
2021-11-15 19:05:08 +08:00
|
|
|
return stack->executeFunctionByHandler(handler, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
} while (0);
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_rect(tolua_S, 3, &arg1, "ax.PhysicsWorld:queryRect");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2022-07-20 18:41:33 +08:00
|
|
|
{
|
|
|
|
stack->removeScriptHandler(handler);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-20 18:41:33 +08:00
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->queryRect(arg0, arg1, nullptr);
|
2022-07-20 18:41:33 +08:00
|
|
|
stack->removeScriptHandler(handler);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "queryRect", argc, 3);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsWorld_queryRect'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsWorld_queryPoint(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsWorld* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsWorld", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsWorld*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsWorld_queryPoint'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
std::function<bool(axis::PhysicsWorld&, axis::PhysicsShape&, void*)> arg0;
|
|
|
|
axis::Vec2 arg1;
|
2014-03-10 14:04:58 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2022-07-20 18:41:33 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-20 18:41:33 +08:00
|
|
|
arg0 = [handler,stack](axis::PhysicsWorld& world, axis::PhysicsShape& shape, void* data) -> bool {
|
2021-12-25 10:04:45 +08:00
|
|
|
auto Ls = stack->getLuaState();
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(Ls, (void*)(&world), getLuaTypeName(&world, "ax.PhysicsWorld"));
|
|
|
|
toluafix_pushusertype_ccobject(Ls, shape._ID, &shape._luaID, (void*)(&shape), "ax.PhysicsShape");
|
2021-11-15 19:05:08 +08:00
|
|
|
return stack->executeFunctionByHandler(handler, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
};
|
|
|
|
assert(false);
|
2021-12-25 10:04:45 +08:00
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.PhysicsWorld:queryPoint");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2022-07-20 18:41:33 +08:00
|
|
|
{
|
|
|
|
stack->removeScriptHandler(handler);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-20 18:41:33 +08:00
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->queryPoint(arg0, arg1, nullptr);
|
2022-07-20 18:41:33 +08:00
|
|
|
stack->removeScriptHandler(handler);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "queryPoint", argc, 3);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsWorld_queryPoint'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsBody_createPolygon(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsBody", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0 = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
int arg1 = 0;
|
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createPolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createPolygon(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret->_ID;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createPolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsBody:createPolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createPolygon(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-03-10 14:04:58 +08:00
|
|
|
|
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret->_ID;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
|
|
|
axis::Vec2 arg3;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createPolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsBody:createPolygon");
|
|
|
|
ok &= luaval_to_vec2(tolua_S, 4, &arg3, "ax.PhysicsBody:createPolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createPolygon(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret->_ID;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "createPolygon", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsBody_createPolygon'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsBody", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createEdgePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createEdgePolygon(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
|
|
|
int ID = ret->_ID;
|
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createEdgePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsBody:createEdgePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createEdgePolygon(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
|
|
|
int ID = ret->_ID;
|
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2014-03-10 14:04:58 +08:00
|
|
|
double arg3;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createEdgePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsBody:createEdgePolygon");
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &arg3, "ax.PhysicsBody:createEdgePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createEdgePolygon(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
|
|
|
int ID = ret->_ID;
|
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgePolygon", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsBody_createEdgePolygon'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsBody", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createEdgeChain");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createEdgeChain(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret->_ID;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createEdgeChain");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsBody:createEdgeChain");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createEdgeChain(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret->_ID;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2014-03-10 14:04:58 +08:00
|
|
|
double arg3;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsBody:createEdgeChain");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsBody:createEdgeChain");
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &arg3, "ax.PhysicsBody:createEdgeChain");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsBody* ret = axis::PhysicsBody::createEdgeChain(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret->_ID;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = &ret->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)ret, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeChain", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsBody_createEdgeChain'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShape_recenterPoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShape", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShape:recenterPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShape::recenterPoints(arg0, arg1);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShape:recenterPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 3, &arg2, "ax.PhysicsShape:recenterPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShape::recenterPoints(arg0, arg1, arg2);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "recenterPoints", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShape_recenterPoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShape_getPolygonCenter(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShape", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShape:getPolygonCenter");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 ret = axis::PhysicsShape::getPolygonCenter(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_to_luaval(tolua_S, ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "getPolygonCenter", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShape_getPolygonCenter'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapeBox_getPoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeBox* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsShapeBox", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsShapeBox*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsShapeBox_getPoints'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg0[4];
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->getPoints(arg0);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, 4);
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getPoints", argc, 1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapeBox_getPoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapePolygon_getPoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapePolygon* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsShapePolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsShapePolygon*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsShapePolygon_getPoints'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int count = cobj->getPointsCount();
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0 = new axis::Vec2[count];
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->getPoints(arg0);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, count);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getPoints", argc, 1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapePolygon_getPoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapePolygon_create(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShapePolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapePolygon* ret = axis::PhysicsShapePolygon::create(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapePolygon>(tolua_S, "ax.PhysicsShapePolygon",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapePolygon*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsShapePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapePolygon* ret = axis::PhysicsShapePolygon::create(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapePolygon>(tolua_S, "ax.PhysicsShapePolygon",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapePolygon*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
|
|
|
axis::Vec2 arg3;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsShapePolygon:create");
|
|
|
|
ok &= luaval_to_vec2(tolua_S, 4, &arg3, "ax.PhysicsShapePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapePolygon* ret = axis::PhysicsShapePolygon::create(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapePolygon>(tolua_S, "ax.PhysicsShapePolygon",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapePolygon*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "create", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapePolygon_create'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapePolygon_calculateArea(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShapePolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapePolygon:calculateArea");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
double ret = axis::PhysicsShapePolygon::calculateArea(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "calculateArea", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapePolygon_calculateArea'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapePolygon_calculateMoment(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShapePolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double arg0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg1;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg2 = 0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &arg0, "ax.PhysicsShapePolygon:calculateMoment");
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 3, &arg1, &arg2, "ax.PhysicsShapePolygon:calculateMoment");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg1)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg1, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
double ret = axis::PhysicsShapePolygon::calculateMoment(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg1);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double arg0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg1;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg2 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg3;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &arg0, "ax.PhysicsShapePolygon:calculateMoment");
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 3, &arg1, &arg2, "ax.PhysicsShapePolygon:calculateMoment");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg1)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg1, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 4, &arg3, "ax.PhysicsShapePolygon:calculateMoment");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
double ret = axis::PhysicsShapePolygon::calculateMoment(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg1);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "calculateMoment", argc, 3);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapePolygon_calculateMoment'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapeEdgeBox_getPoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgeBox* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsShapeEdgeBox", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsShapeEdgeBox*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsShapeEdgeBox_getPoints'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int count = cobj->getPointsCount();
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0 = new axis::Vec2[count];
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->getPoints(arg0);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, count);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getPoints", argc, 1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapeEdgeBox_getPoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapeEdgePolygon_getPoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgePolygon* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsShapeEdgePolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsShapeEdgePolygon*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsShapeEdgePolygon_getPoints'",
|
2021-12-25 10:04:45 +08:00
|
|
|
NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int count = cobj->getPointsCount();
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0 = new axis::Vec2[count];
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->getPoints(arg0);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, count);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getPoints", argc, 1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapeEdgePolygon_getPoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapeEdgeChain_getPoints(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgeChain* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PhysicsShapeEdgeChain", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PhysicsShapeEdgeChain*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_physics_PhysicsShapeEdgeChain_getPoints'", NULL);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int count = cobj->getPointsCount();
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0 = new axis::Vec2[count];
|
2014-03-10 14:04:58 +08:00
|
|
|
cobj->getPoints(arg0);
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(tolua_S, arg0, count);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2015-05-07 16:15:24 +08:00
|
|
|
return 1;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "getPoints", argc, 1);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapeEdgeChain_getPoints'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerPhysicsContact_registerScriptHandler(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-10 14:04:58 +08:00
|
|
|
EventListenerPhysicsContact* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerPhysicsContact", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
self = static_cast<EventListenerPhysicsContact*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S,
|
2022-07-12 21:31:54 +08:00
|
|
|
"invalid 'self' in function 'tolua_axis_EventListenerPhysicsContact_registerScriptHandler'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(tolua_S, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
2014-03-10 14:04:58 +08:00
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::HandlerType type =
|
|
|
|
static_cast<ScriptHandlerMgr::HandlerType>((int)tolua_tonumber(tolua_S, 3, 0));
|
2014-03-10 14:04:58 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_BEGIN:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
|
|
|
|
self->onContactBegin = [handler](PhysicsContact& contact) -> bool {
|
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(&contact, "ax.PhysicsContact");
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ret = stack->executeFunctionByHandler(handler, 1);
|
|
|
|
stack->clean();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_PRESOLVE:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
|
|
|
|
self->onContactPreSolve = [handler](PhysicsContact& contact, PhysicsContactPreSolve& solve) -> bool {
|
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(&contact, "ax.PhysicsContact");
|
|
|
|
tolua_pushusertype(stack->getLuaState(), &solve, "ax.PhysicsContactPreSolve");
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ret = stack->executeFunctionByHandler(handler, 2);
|
|
|
|
stack->clean();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_POSTSOLVE:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
|
|
|
|
self->onContactPostSolve = [handler](PhysicsContact& contact, const PhysicsContactPostSolve& solve) {
|
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(&contact, "ax.PhysicsContact");
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushusertype(stack->getLuaState(), const_cast<PhysicsContactPostSolve*>(&solve),
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.PhysicsContactPostSolve");
|
2021-12-25 10:04:45 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
|
|
|
stack->clean();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_SEPARATE:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
|
|
|
|
self->onContactSeparate = [handler](PhysicsContact& contact) {
|
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(&contact, "ax.PhysicsContact");
|
2021-12-25 10:04:45 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 1);
|
|
|
|
stack->clean();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-12-01 15:53:41 +08:00
|
|
|
luaL_error(tolua_S, "'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'registerScriptHandler'.", &tolua_err);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapeEdgePolygon_create(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShapeEdgePolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapeEdgePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgePolygon* ret = axis::PhysicsShapeEdgePolygon::create(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapeEdgePolygon>(tolua_S, "ax.PhysicsShapeEdgePolygon",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapeEdgePolygon*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapeEdgePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsShapeEdgePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgePolygon* ret = axis::PhysicsShapeEdgePolygon::create(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapeEdgePolygon>(tolua_S, "ax.PhysicsShapeEdgePolygon",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapeEdgePolygon*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2014-03-10 14:04:58 +08:00
|
|
|
double arg3;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapeEdgePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsShapeEdgePolygon:create");
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &arg3, "ax.PhysicsShapeEdgePolygon:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgePolygon* ret = axis::PhysicsShapeEdgePolygon::create(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapeEdgePolygon>(tolua_S, "ax.PhysicsShapeEdgePolygon",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapeEdgePolygon*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "create", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapeEdgePolygon_create'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_physics_PhysicsShapeEdgeChain_create(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.PhysicsShapeEdgeChain", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapeEdgeChain:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgeChain* ret = axis::PhysicsShapeEdgeChain::create(arg0, arg1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapeEdgeChain>(tolua_S, "ax.PhysicsShapeEdgeChain",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapeEdgeChain*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapeEdgeChain:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsShapeEdgeChain:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgeChain* ret = axis::PhysicsShapeEdgeChain::create(arg0, arg1, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapeEdgeChain>(tolua_S, "ax.PhysicsShapeEdgeChain",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapeEdgeChain*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arg0;
|
2014-03-10 14:04:58 +08:00
|
|
|
int arg1 = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial arg2;
|
2014-03-10 14:04:58 +08:00
|
|
|
double arg3;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok = luaval_to_array_of_vec2(tolua_S, 2, &arg0, &arg1, "ax.PhysicsShapeEdgeChain:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == arg0)
|
|
|
|
{
|
|
|
|
LUA_PRECONDITION(arg0, "Invalid Native Object");
|
|
|
|
}
|
|
|
|
} while (0);
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_physics_material(tolua_S, 3, &arg2, "ax.PhysicsShapeEdgeChain:create");
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &arg3, "ax.PhysicsShapeEdgeChain:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsShapeEdgeChain* ret = axis::PhysicsShapeEdgeChain::create(arg0, arg1, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PhysicsShapeEdgeChain>(tolua_S, "ax.PhysicsShapeEdgeChain",
|
2022-07-11 17:50:21 +08:00
|
|
|
(axis::PhysicsShapeEdgeChain*)ret);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "create", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_physics_PhysicsShapeEdgeChain_create'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_physics_manual(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsBody");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getJoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsBody_getJoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "createPolygon");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsBody_createPolygon);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "createEdgeChain");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsBody_createEdgeChain);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "createEdgePolygon");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsBody_createEdgePolygon);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsShape");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "recenterPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShape_recenterPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "getPolygonCenter");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShape_getPolygonCenter);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "getPolyonCenter");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShape_getPolygonCenter);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsShapeBox");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapeBox_getPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsShapeEdgeBox");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapeEdgeBox_getPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsShapePolygon");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapePolygon_getPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "create");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapePolygon_create);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "calculateArea");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapePolygon_calculateArea);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "calculateMoment");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapePolygon_calculateMoment);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsShapeEdgePolygon");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapeEdgePolygon_getPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "create");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapeEdgePolygon_create);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsShapeEdgeChain");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapeEdgeChain_getPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "create");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsShapeEdgeChain_create);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PhysicsWorld");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getScene");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsWorld_getScene);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "queryPoint");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsWorld_queryPoint);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "queryRect");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsWorld_queryRect);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "rayCast");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_physics_PhysicsWorld_rayCast);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pushstring(tolua_S, "DEBUGDRAW_NONE");
|
|
|
|
lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_NONE);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pushstring(tolua_S, "DEBUGDRAW_SHAPE");
|
|
|
|
lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_SHAPE);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pushstring(tolua_S, "DEBUGDRAW_JOINT");
|
|
|
|
lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_JOINT);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pushstring(tolua_S, "DEBUGDRAW_CONTACT");
|
|
|
|
lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_CONTACT);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pushstring(tolua_S, "DEBUGDRAW_ALL");
|
|
|
|
lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_ALL);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerPhysicsContact");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_function(tolua_S, "registerScriptHandler",
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_axis_EventListenerPhysicsContact_registerScriptHandler);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
|
|
|
|
tolua_constant(tolua_S, "PHYSICS_INFINITY", PHYSICS_INFINITY);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-19 19:45:24 +08:00
|
|
|
#endif
|