comparison pytouhou/utils/matrix.pyx @ 527:db28538cd399

Use Sprite C arrays instead of their tuple representation where it makes sense.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 18 Dec 2013 18:19:08 +0100
parents 6e3b3d5d4691
children e15672733c93
comparison
equal deleted inserted replaced
526:0b2a92a25245 527:db28538cd399
74 for i in xrange(4): 74 for i in xrange(4):
75 data[ i] *= x 75 data[ i] *= x
76 data[4+i] *= y 76 data[4+i] *= y
77 77
78 78
79 cdef void translate(Matrix *mat, float x, float y, float z) nogil: 79 cdef void translate(Matrix *mat, float[3] offset) nogil:
80 cdef float offset[3], item[3] 80 cdef float item[3]
81
82 offset[0] = x
83 offset[1] = y
84 offset[2] = z
85 81
86 data = <float*>mat 82 data = <float*>mat
87 for i in xrange(3): 83 for i in xrange(3):
88 item[i] = data[12+i] * offset[i] 84 item[i] = data[12+i] * offset[i]
89 85
91 for j in xrange(4): 87 for j in xrange(4):
92 data[4*i+j] += item[i] 88 data[4*i+j] += item[i]
93 89
94 90
95 cdef void translate2d(Matrix *mat, float x, float y) nogil: 91 cdef void translate2d(Matrix *mat, float x, float y) nogil:
96 translate(mat, x, y, 0) 92 cdef float[3] offset
93
94 offset[0] = x
95 offset[1] = y
96 offset[2] = 0
97
98 translate(mat, offset)
97 99
98 100
99 cdef void rotate_x(Matrix *mat, float angle) nogil: 101 cdef void rotate_x(Matrix *mat, float angle) nogil:
100 cdef float cos_a, sin_a 102 cdef float cos_a, sin_a
101 cdef float lines[8] 103 cdef float lines[8]