mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
.
This commit is contained in:
parent
8bf38e3a71
commit
ebb1ead848
3 changed files with 17 additions and 10 deletions
|
@ -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
|
|
||||||
"describe",
|
|
||||||
"it",
|
|
||||||
assert = {fields = {"same", "equals"}},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Busted-style unit testing
|
||||||
|
local bustitute = {
|
||||||
|
read_globals = {
|
||||||
|
"describe",
|
||||||
|
"it",
|
||||||
|
assert = {fields = {"same", "equals"}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
files["mods/unittests/matrix4.lua"] = bustitute
|
||||||
|
files["mods/unittests/rotation.lua"] = bustitute
|
||||||
|
|
||||||
globals = {
|
globals = {
|
||||||
"aborted",
|
"aborted",
|
||||||
"minetest",
|
"minetest",
|
||||||
|
|
|
@ -55,7 +55,7 @@ it("copy", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("unpack", function()
|
it("unpack", function()
|
||||||
assert.equals(mat1, Matrix4.new(mat1:unpack()))
|
assert.equals(mat1, Matrix4.new(mat1:unpack()))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("transform", function()
|
describe("transform", function()
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue