comparison pytouhou/ui/sprite.pyx @ 435:878273a984c4

Improve Matrix representation, using float[16] instead of imbricated python lists.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 07 Aug 2013 11:34:40 +0200
parents 3a7b36324611
children 723a3e67a223
comparison
equal deleted inserted replaced
434:18e4b121646b 435:878273a984c4
22 cdef Matrix vertmat 22 cdef Matrix vertmat
23 23
24 if not sprite.changed: 24 if not sprite.changed:
25 return sprite._rendering_data 25 return sprite._rendering_data
26 26
27 vertmat = Matrix([[-.5, .5, .5, -.5], 27 vertmat = Matrix([-.5, .5, .5, -.5,
28 [-.5, -.5, .5, .5], 28 -.5, -.5, .5, .5,
29 [ .0, .0, .0, .0], 29 .0, .0, .0, .0,
30 [ 1., 1., 1., 1.]]) 30 1., 1., 1., 1.])
31 31
32 tx, ty, tw, th = sprite.texcoords 32 tx, ty, tw, th = sprite.texcoords
33 sx, sy = sprite.rescale 33 sx, sy = sprite.rescale
34 width = sprite.width_override or (tw * sx) 34 width = sprite.width_override or (tw * sx)
35 height = sprite.height_override or (th * sy) 35 height = sprite.height_override or (th * sy)
62 uvs = (tx * x_1 + tox, 62 uvs = (tx * x_1 + tox,
63 (tx + tw) * x_1 + tox, 63 (tx + tw) * x_1 + tox,
64 ty * y_1 + toy, 64 ty * y_1 + toy,
65 (ty + th) * y_1 + toy) 65 (ty + th) * y_1 + toy)
66 66
67 (x1, x2 , x3, x4), (y1, y2, y3, y4), (z1, z2, z3, z4), _ = vertmat.data
68
69 key = sprite.anm.texture, sprite.blendfunc 67 key = sprite.anm.texture, sprite.blendfunc
70 r, g, b = sprite.color 68 r, g, b = sprite.color
71 values = ((x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4)), uvs, (r, g, b, sprite.alpha) 69 values = tuple([x for x in vertmat.data[:12]]), uvs, (r, g, b, sprite.alpha)
72 sprite._rendering_data = key, values 70 sprite._rendering_data = key, values
73 sprite.changed = False 71 sprite.changed = False
74 72
75 return sprite._rendering_data 73 return sprite._rendering_data
76 74