# HG changeset patch # User Emmanuel Gil Peyrot # Date 1371046042 -7200 # Node ID 2428296cccab475329ff87f409a14387b10f39b7 # Parent 9d790ca73c135066616666a131e3fd774c6a0329 Remove indirect access to Matrix values. diff --git a/pytouhou/ui/renderer.pyx b/pytouhou/ui/renderer.pyx --- a/pytouhou/ui/renderer.pyx +++ b/pytouhou/ui/renderer.pyx @@ -176,11 +176,12 @@ cdef class Renderer: cpdef ortho_2d(self, left, right, bottom, top): mat = Matrix() - mat[0][0] = 2 / (right - left) - mat[1][1] = 2 / (top - bottom) - mat[2][2] = -1 - mat[3][0] = -(right + left) / (right - left) - mat[3][1] = -(top + bottom) / (top - bottom) + data = mat.data + data[0][0] = 2 / (right - left) + data[1][1] = 2 / (top - bottom) + data[2][2] = -1 + data[3][0] = -(right + left) / (right - left) + data[3][1] = -(top + bottom) / (top - bottom) return mat @@ -207,12 +208,13 @@ cdef class Renderer: right = top * aspect mat = Matrix() - mat[0][0] = (2 * z_near) / (right - left) - mat[1][1] = (2 * z_near) / (top - bottom) - mat[2][2] = -(z_far + z_near) / (z_far - z_near) - mat[2][3] = -1 - mat[3][2] = -(2 * z_far * z_near) / (z_far - z_near) - mat[3][3] = 0 + data = mat.data + data[0][0] = (2 * z_near) / (right - left) + data[1][1] = (2 * z_near) / (top - bottom) + data[2][2] = -(z_far + z_near) / (z_far - z_near) + data[2][3] = -1 + data[3][2] = -(2 * z_far * z_near) / (z_far - z_near) + data[3][3] = 0 return mat diff --git a/pytouhou/utils/matrix.pyx b/pytouhou/utils/matrix.pyx --- a/pytouhou/utils/matrix.pyx +++ b/pytouhou/utils/matrix.pyx @@ -24,15 +24,14 @@ cdef class Matrix: [0, 0, 0, 1]] - def __getitem__(Matrix self, key): - return self.data[key] - - def __mul__(Matrix self, Matrix other): out = Matrix() + d1 = self.data + d2 = other.data + d3 = out.data for i in xrange(4): for j in xrange(4): - out[i][j] = sum(self[i][k] * other[k][j] for k in xrange(4)) + d3[i][j] = sum(d1[i][k] * d2[k][j] for k in xrange(4)) return out