瀏覽代碼

The 'dimension' field is no longer needed when passing matrices-as-flat-tables to Shader:sendMatrix.

Alex Szpakowski 9 年之前
父節點
當前提交
ec17811aa9
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      src/modules/graphics/opengl/wrap_Shader.cpp

+ 4 - 5
src/modules/graphics/opengl/wrap_Shader.cpp

@@ -25,6 +25,7 @@
 #include <string>
 #include <iostream>
 #include <algorithm>
+#include <cmath>
 
 namespace love
 {
@@ -242,6 +243,8 @@ int w_Shader_sendMatrix(lua_State *L)
 
 		if (!lua_isnoneornil(L, -1))
 			dimension = (int) lua_tointeger(L, -1);
+		else
+			dimension = (int) sqrtf((float) luax_objlen(L, 3));
 
 		lua_pop(L, 1);
 	}
@@ -265,11 +268,7 @@ int w_Shader_sendMatrix(lua_State *L)
 		lua_pop(L, 1);
 
 		if (!table_of_tables)
-		{
-			lua_getfield(L, 3+i, "dimension");
-			other_dimension = lua_tointeger(L, -1);
-			lua_pop(L, 1);
-		}
+			other_dimension = (int) sqrtf((float) luax_objlen(L, 3+i));
 
 		if (other_dimension != dimension)
 		{