mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add new mat4.tostring overload
This commit is contained in:
parent
88b21262a3
commit
097d4e3c6b
2 changed files with 18 additions and 3 deletions
|
|
@ -159,13 +159,27 @@ static int l_transpose(lua::State* L) {
|
|||
|
||||
static int l_tostring(lua::State* L) {
|
||||
auto matrix = lua::tomat4(L, 1);
|
||||
bool multiline = lua::toboolean(L, 2);
|
||||
std::stringstream ss;
|
||||
ss << "mat4 {\n";
|
||||
ss << "mat4 {";
|
||||
if (multiline) {
|
||||
ss << "\n";
|
||||
}
|
||||
for (uint y = 0; y < 4; y++) {
|
||||
for (uint x = 0; x < 4; x++) {
|
||||
ss << "\t" << matrix[y][x];
|
||||
if (multiline) {
|
||||
ss << "\t" << matrix[y][x];
|
||||
} else if (x > 0) {
|
||||
ss << " " << matrix[y][x];
|
||||
} else {
|
||||
ss << matrix[y][x];
|
||||
}
|
||||
}
|
||||
if (multiline) {
|
||||
ss << "\n";
|
||||
} else {
|
||||
ss << "; ";
|
||||
}
|
||||
ss << "\n";
|
||||
}
|
||||
ss << "}";
|
||||
return lua::pushstring(L, ss.str());
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ namespace lua {
|
|||
pop(L);
|
||||
}
|
||||
}
|
||||
pop(L);
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue