1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-15 18:57:08 +00:00
This commit is contained in:
Lars Mueller 2025-05-31 03:12:09 +02:00
parent 8bf38e3a71
commit ebb1ead848
3 changed files with 17 additions and 10 deletions

View file

@ -35,13 +35,20 @@ read_globals = {
string = {fields = {"split", "trim"}}, string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn", "indexof", "insert_all", "key_value_swap"}}, table = {fields = {"copy", "getn", "indexof", "insert_all", "key_value_swap"}},
math = {fields = {"hypot", "round"}}, math = {fields = {"hypot", "round"}},
}
-- Busted-style unit testing -- Busted-style unit testing
local bustitute = {
read_globals = {
"describe", "describe",
"it", "it",
assert = {fields = {"same", "equals"}}, assert = {fields = {"same", "equals"}},
},
} }
files["mods/unittests/matrix4.lua"] = bustitute
files["mods/unittests/rotation.lua"] = bustitute
globals = { globals = {
"aborted", "aborted",
"minetest", "minetest",

View file

@ -44,7 +44,7 @@ inline core::matrix4 &LuaMatrix4::create(lua_State *L)
int LuaMatrix4::l_identity(lua_State *L) int LuaMatrix4::l_identity(lua_State *L)
{ {
create(L) = core::IdentityMatrix; create(L) = core::matrix4();
return 1; return 1;
} }
@ -69,7 +69,7 @@ int LuaMatrix4::l_translation(lua_State *L)
{ {
v3f translation = readParam<v3f>(L, 1); v3f translation = readParam<v3f>(L, 1);
core::matrix4 &matrix = create(L); core::matrix4 &matrix = create(L);
matrix = core::IdentityMatrix; matrix = core::matrix4();
matrix.setTranslation(translation); matrix.setTranslation(translation);
return 1; return 1;
} }
@ -86,7 +86,7 @@ int LuaMatrix4::l_scale(lua_State *L)
{ {
v3f scale = readParam<v3f>(L, 1); v3f scale = readParam<v3f>(L, 1);
core::matrix4 &matrix = create(L); core::matrix4 &matrix = create(L);
matrix = core::IdentityMatrix; matrix = core::matrix4();
matrix.setScale(scale); matrix.setScale(scale);
return 1; return 1;
} }
@ -96,7 +96,7 @@ int LuaMatrix4::l_reflection(lua_State *L)
v3f normal = readParam<v3f>(L, 1); v3f normal = readParam<v3f>(L, 1);
normal.normalize(); normal.normalize();
core::matrix4 &matrix = create(L); core::matrix4 &matrix = create(L);
matrix = core::IdentityMatrix; matrix = core::matrix4();
// TODO move to CMatrix4 // TODO move to CMatrix4
f32 factor = 2.0f / normal.getLengthSQ(); f32 factor = 2.0f / normal.getLengthSQ();
auto subtract_scaled_row = [&](int i, f32 scalar) { auto subtract_scaled_row = [&](int i, f32 scalar) {