add vecn.sub(...), .mul(...), .div(...), .length(...), .normalize(...)
This commit is contained in:
@@ -328,6 +328,22 @@ namespace lua {
|
||||
setglobal(L, name);
|
||||
}
|
||||
|
||||
template<int n>
|
||||
inline glm::vec<n, float> tovec(lua::State* L, int idx) {
|
||||
pushvalue(L, idx);
|
||||
if (!istable(L, idx) || objlen(L, idx) < n) {
|
||||
throw std::runtime_error("value must be an array of "+std::to_string(n)+" numbers");
|
||||
}
|
||||
glm::vec<n, float> vec;
|
||||
for (int i = 0; i < n; i++) {
|
||||
rawgeti(L, 1);
|
||||
vec[i] = tonumber(L, -1);
|
||||
pop(L);
|
||||
}
|
||||
pop(L);
|
||||
return vec;
|
||||
}
|
||||
|
||||
inline glm::vec2 tovec2(lua::State* L, int idx) {
|
||||
pushvalue(L, idx);
|
||||
if (!istable(L, idx) || objlen(L, idx) < 2) {
|
||||
|
||||
Reference in New Issue
Block a user