mirror of https://github.com/bjornbytes/lovr.git
Initialize vec3 from mat4
Rotation and scaling is lost, only position is extracted from mat4.
This commit is contained in:
parent
c4e0ace182
commit
c314824304
|
@ -488,8 +488,15 @@ int l_lovrVec3Set(lua_State* L) {
|
||||||
float x = luax_optfloat(L, 2, 0.f);
|
float x = luax_optfloat(L, 2, 0.f);
|
||||||
vec3_set(v, x, luax_optfloat(L, 3, x), luax_optfloat(L, 4, x));
|
vec3_set(v, x, luax_optfloat(L, 3, x), luax_optfloat(L, 4, x));
|
||||||
} else {
|
} else {
|
||||||
vec3 u = luax_checkvector(L, 2, V_VEC3, "vec3 or number");
|
VectorType t;
|
||||||
vec3_init(v, u);
|
float* p = luax_tovector(L, 2, &t);
|
||||||
|
if (p && t == V_VEC3) {
|
||||||
|
vec3_init(v, p);
|
||||||
|
} else if (p && t == V_MAT4) {
|
||||||
|
vec3_set(v, p[12], p[13], p[14]);
|
||||||
|
} else{
|
||||||
|
luaL_typerror(L, 2, "vec3, mat4, or number");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lua_settop(L, 1);
|
lua_settop(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue