mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add gfx.blockwraps.set_tints
This commit is contained in:
parent
e423c74628
commit
c47432c979
5 changed files with 54 additions and 22 deletions
|
|
@ -10,9 +10,13 @@ static int l_wrap(lua::State* L) {
|
|||
auto position = lua::tovec3(L, 1);
|
||||
std::string texture = lua::require_string(L, 2);
|
||||
float emission = lua::isnumber(L, 3) ? lua::tonumber(L, 3) : 1.0f;
|
||||
glm::vec3 tint = lua::istable(L, 4) ? lua::tovec3(L, 4) : glm::vec3(1.0f);
|
||||
|
||||
return lua::pushinteger(
|
||||
L, renderer->blockWraps->add(position, std::move(texture), emission)
|
||||
L,
|
||||
renderer->blockWraps->add(
|
||||
position, std::move(texture), std::move(tint), emission
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -60,11 +64,26 @@ static int l_set_faces(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_tints(lua::State* L) {
|
||||
if (auto wrapper = renderer->blockWraps->get(lua::tointeger(L, 1))) {
|
||||
for (int i = 0; i < wrapper->textureFaces.size(); i++) {
|
||||
if (lua::isnil(L, 2 + i)) {
|
||||
wrapper->tints[i] = glm::vec3(1.0f);
|
||||
} else {
|
||||
wrapper->tints[i] = lua::tovec3(L, 2 + i);
|
||||
}
|
||||
}
|
||||
wrapper->dirtySides = 0xFF;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg blockwrapslib[] = {
|
||||
{"wrap", lua::wrap<l_wrap>},
|
||||
{"unwrap", lua::wrap<l_unwrap>},
|
||||
{"set_pos", lua::wrap<l_set_pos>},
|
||||
{"set_texture", lua::wrap<l_set_texture>},
|
||||
{"set_faces", lua::wrap<l_set_faces>},
|
||||
{"set_tints", lua::wrap<l_set_tints>},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue