trimesh_desc_concat
This commit is contained in:
parent
2bf947018c
commit
fff7690222
64
src/luaapi.c
64
src/luaapi.c
@ -2287,6 +2287,67 @@ static int dagame_net_punch(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dagame_mdl_desc_append(lua_State *L) {
|
||||||
|
float offsetX = lua_tonumber(L, 3);
|
||||||
|
float offsetY = lua_tonumber(L, 4);
|
||||||
|
float offsetZ = lua_tonumber(L, 5);
|
||||||
|
|
||||||
|
lua_getfield(L, 1, "positions");
|
||||||
|
lua_getfield(L, 2, "positions");
|
||||||
|
|
||||||
|
lua_len(L, -2);
|
||||||
|
lua_len(L, -2);
|
||||||
|
size_t bigPositions = lua_tointeger(L, -2);
|
||||||
|
size_t smallPositions = lua_tointeger(L, -1);
|
||||||
|
lua_pop(L, 2);
|
||||||
|
|
||||||
|
for(size_t i = 1; i <= smallPositions; i += 3) {
|
||||||
|
lua_rawgeti(L, -1, i + 0);
|
||||||
|
lua_rawgeti(L, -2, i + 1);
|
||||||
|
lua_rawgeti(L, -3, i + 2);
|
||||||
|
float posX = lua_tonumber(L, -3) + offsetX;
|
||||||
|
float posY = lua_tonumber(L, -2) + offsetY;
|
||||||
|
float posZ = lua_tonumber(L, -1) + offsetZ;
|
||||||
|
lua_pop(L, 3);
|
||||||
|
|
||||||
|
lua_pushnumber(L, posX);
|
||||||
|
lua_rawseti(L, -3, bigPositions + i + 0);
|
||||||
|
|
||||||
|
lua_pushnumber(L, posY);
|
||||||
|
lua_rawseti(L, -3, bigPositions + i + 1);
|
||||||
|
|
||||||
|
lua_pushnumber(L, posZ);
|
||||||
|
lua_rawseti(L, -3, bigPositions + i + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_pop(L, 2);
|
||||||
|
|
||||||
|
lua_getfield(L, 1, "indices");
|
||||||
|
lua_getfield(L, 2, "indices");
|
||||||
|
|
||||||
|
lua_len(L, -1);
|
||||||
|
size_t smallIndices = lua_tointeger(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_len(L, -2);
|
||||||
|
size_t bigIndices = lua_tointeger(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
bigPositions /= 3;
|
||||||
|
|
||||||
|
for(size_t i = 1; i <= smallIndices; i++) {
|
||||||
|
lua_rawgeti(L, -1, i);
|
||||||
|
size_t j = lua_tointeger(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
lua_pushinteger(L, j + bigPositions);
|
||||||
|
lua_rawseti(L, -3, ++bigIndices);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_pop(L, 2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#include<GLFW/glfw3.h>
|
#include<GLFW/glfw3.h>
|
||||||
static int os_time(lua_State *L) {
|
static int os_time(lua_State *L) {
|
||||||
lua_pushnumber(L, glfwGetTime() - LuaapiStartTime);
|
lua_pushnumber(L, glfwGetTime() - LuaapiStartTime);
|
||||||
@ -2408,6 +2469,9 @@ void luaapi_init() {
|
|||||||
lua_pushcfunction(L, dagame_mdl);
|
lua_pushcfunction(L, dagame_mdl);
|
||||||
lua_setfield(L, -2, "mdl");
|
lua_setfield(L, -2, "mdl");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_mdl_desc_append);
|
||||||
|
lua_setfield(L, -2, "trimesh_desc_concat");
|
||||||
|
|
||||||
lua_pushcfunction(L, dagame_trimesh);
|
lua_pushcfunction(L, dagame_trimesh);
|
||||||
lua_setfield(L, -2, "trimesh");
|
lua_setfield(L, -2, "trimesh");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user