|
|
@@ -1,6 +1,7 @@
|
|
|
#include "Base.h"
|
|
|
#include "ScriptController.h"
|
|
|
#include "lua_MathUtil.h"
|
|
|
+#include "Base.h"
|
|
|
#include "MathUtil.h"
|
|
|
|
|
|
namespace gameplay
|
|
|
@@ -12,7 +13,11 @@ void luaRegister_MathUtil()
|
|
|
{
|
|
|
{NULL, NULL}
|
|
|
};
|
|
|
- const luaL_Reg* lua_statics = NULL;
|
|
|
+ const luaL_Reg lua_statics[] =
|
|
|
+ {
|
|
|
+ {"smooth", lua_MathUtil_static_smooth},
|
|
|
+ {NULL, NULL}
|
|
|
+ };
|
|
|
std::vector<std::string> scopePath;
|
|
|
|
|
|
ScriptUtil::registerClass("MathUtil", lua_members, NULL, lua_MathUtil__gc, lua_statics, scopePath);
|
|
|
@@ -65,4 +70,86 @@ int lua_MathUtil__gc(lua_State* state)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+int lua_MathUtil_static_smooth(lua_State* state)
|
|
|
+{
|
|
|
+ // Get the number of parameters.
|
|
|
+ int paramCount = lua_gettop(state);
|
|
|
+
|
|
|
+ // Attempt to match the parameters to a valid binding.
|
|
|
+ switch (paramCount)
|
|
|
+ {
|
|
|
+ case 4:
|
|
|
+ {
|
|
|
+ if ((lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA) &&
|
|
|
+ lua_type(state, 2) == LUA_TNUMBER &&
|
|
|
+ lua_type(state, 3) == LUA_TNUMBER &&
|
|
|
+ lua_type(state, 4) == LUA_TNUMBER)
|
|
|
+ {
|
|
|
+ // Get parameter 1 off the stack.
|
|
|
+ ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(1);
|
|
|
+
|
|
|
+ // Get parameter 2 off the stack.
|
|
|
+ float param2 = (float)luaL_checknumber(state, 2);
|
|
|
+
|
|
|
+ // Get parameter 3 off the stack.
|
|
|
+ float param3 = (float)luaL_checknumber(state, 3);
|
|
|
+
|
|
|
+ // Get parameter 4 off the stack.
|
|
|
+ float param4 = (float)luaL_checknumber(state, 4);
|
|
|
+
|
|
|
+ MathUtil::smooth(param1, param2, param3, param4);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "lua_MathUtil_static_smooth - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_error(state);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 5:
|
|
|
+ {
|
|
|
+ if ((lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA) &&
|
|
|
+ lua_type(state, 2) == LUA_TNUMBER &&
|
|
|
+ lua_type(state, 3) == LUA_TNUMBER &&
|
|
|
+ lua_type(state, 4) == LUA_TNUMBER &&
|
|
|
+ lua_type(state, 5) == LUA_TNUMBER)
|
|
|
+ {
|
|
|
+ // Get parameter 1 off the stack.
|
|
|
+ ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(1);
|
|
|
+
|
|
|
+ // Get parameter 2 off the stack.
|
|
|
+ float param2 = (float)luaL_checknumber(state, 2);
|
|
|
+
|
|
|
+ // Get parameter 3 off the stack.
|
|
|
+ float param3 = (float)luaL_checknumber(state, 3);
|
|
|
+
|
|
|
+ // Get parameter 4 off the stack.
|
|
|
+ float param4 = (float)luaL_checknumber(state, 4);
|
|
|
+
|
|
|
+ // Get parameter 5 off the stack.
|
|
|
+ float param5 = (float)luaL_checknumber(state, 5);
|
|
|
+
|
|
|
+ MathUtil::smooth(param1, param2, param3, param4, param5);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "lua_MathUtil_static_smooth - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_error(state);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 4 or 5).");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
}
|