mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
add new skeleton:get_color, skeleton:set_color overloads
This commit is contained in:
parent
f5f17b7746
commit
ad22763a1f
2 changed files with 19 additions and 5 deletions
|
|
@ -58,8 +58,8 @@ local Skeleton = {__index={
|
||||||
index=function(self, s) return __skeleton.index(self.eid, s) end,
|
index=function(self, s) return __skeleton.index(self.eid, s) end,
|
||||||
is_visible=function(self, i) return __skeleton.is_visible(self.eid, i) end,
|
is_visible=function(self, i) return __skeleton.is_visible(self.eid, i) end,
|
||||||
set_visible=function(self, i, b) return __skeleton.set_visible(self.eid, i, b) end,
|
set_visible=function(self, i, b) return __skeleton.set_visible(self.eid, i, b) end,
|
||||||
get_color=function(self) return __skeleton.get_color(self.eid) end,
|
get_color=function(self, ...) return __skeleton.get_color(self.eid, ...) end,
|
||||||
set_color=function(self, color) return __skeleton.set_color(self.eid, color) end,
|
set_color=function(self, color, ...) return __skeleton.set_color(self.eid, color, ...) end,
|
||||||
set_interpolated=function(self, b) return __skeleton.set_interpolated(self.eid, b) end,
|
set_interpolated=function(self, b) return __skeleton.set_interpolated(self.eid, b) end,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,19 @@ static int l_set_visible(lua::State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static glm::vec4 to_color(lua::State* L, int idx) {
|
||||||
|
if (lua::objlen(L, idx) > 3) {
|
||||||
|
return lua::tovec4(L, idx);
|
||||||
|
}
|
||||||
|
return glm::vec4(lua::tovec3(L, idx), 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
static int l_get_color(lua::State* L) {
|
static int l_get_color(lua::State* L) {
|
||||||
if (auto skeleton = get_skeleton(L)) {
|
if (auto skeleton = get_skeleton(L)) {
|
||||||
|
if (lua::isnumber(L, 2)) {
|
||||||
|
auto index = index_range_check(*skeleton, lua::tointeger(L, 2));
|
||||||
|
return lua::pushvec(L, skeleton->boneTints[index]);
|
||||||
|
}
|
||||||
return lua::pushvec(L, skeleton->tint);
|
return lua::pushvec(L, skeleton->tint);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -156,9 +167,12 @@ static int l_get_color(lua::State* L) {
|
||||||
|
|
||||||
static int l_set_color(lua::State* L) {
|
static int l_set_color(lua::State* L) {
|
||||||
if (auto skeleton = get_skeleton(L)) {
|
if (auto skeleton = get_skeleton(L)) {
|
||||||
skeleton->tint = lua::objlen(L, 2) > 3
|
if (lua::isnumber(L, 2)) {
|
||||||
? lua::tovec4(L, 2)
|
auto index = index_range_check(*skeleton, lua::tointeger(L, 2));
|
||||||
: glm::vec4(lua::tovec3(L, 2), 1.0f);
|
skeleton->boneTints[index] = to_color(L, 3);
|
||||||
|
} else {
|
||||||
|
skeleton->tint = to_color(L, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue