1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-04 13:33:34 +00:00

Fix Pass:plane z scale / normal matrix;

Pass:plane was leaving its z scale uninitialized, which resulted in
a garbage normal matrix and other issues when using the transform in a
shader.  Planes were the only shape affected by this.
This commit is contained in:
bjorn 2023-04-26 17:27:00 -07:00
parent 7b6618310a
commit 4b8ada2690

View file

@ -59,7 +59,7 @@ int luax_readvec3(lua_State* L, int index, vec3 v, const char* expected) {
}
}
int luax_readscale(lua_State* L, int index, vec3 v, int components, const char* expected) {
int luax_readscale(lua_State* L, int index, vec4 v, int components, const char* expected) {
switch (lua_type(L, index)) {
case LUA_TNIL:
case LUA_TNONE:
@ -67,12 +67,12 @@ int luax_readscale(lua_State* L, int index, vec3 v, int components, const char*
return index + components;
case LUA_TNUMBER:
if (components == 1) {
v[0] = v[1] = v[2] = luax_optfloat(L, index++, 0.f);
v[0] = v[1] = v[2] = luax_tofloat(L, index++);
} else if (components == -2) { // -2 is special and means "2 components: xy and z"
v[0] = v[1] = luax_tofloat(L, index++);
v[2] = luax_optfloat(L, index++, 1.f);
} else {
v[0] = 1.f;
v[0] = v[1] = v[2] = 1.f;
for (int i = 0; i < components; i++) {
v[i] = luax_optfloat(L, index++, v[0]);
}