Mercurial > touhou
comparison pytouhou/ui/sprite.pyx @ 397:c5ba11ede097
Don’t duplicate values in sprite rendering data.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 06 Feb 2013 21:41:05 +0100 |
parents | 9e2cbb2c2c64 |
children | 3a7b36324611 |
comparison
equal
deleted
inserted
replaced
396:34a91f918e7c | 397:c5ba11ede097 |
---|---|
57 vertmat.translate(width / 2., height / 2., 0.) | 57 vertmat.translate(width / 2., height / 2., 0.) |
58 | 58 |
59 x_1 = 1. / sprite.anm.size[0] | 59 x_1 = 1. / sprite.anm.size[0] |
60 y_1 = 1. / sprite.anm.size[1] | 60 y_1 = 1. / sprite.anm.size[1] |
61 tox, toy = sprite.texoffsets | 61 tox, toy = sprite.texoffsets |
62 uvs = [tx * x_1 + tox, 1. - (ty * y_1 + toy), | 62 uvs = (tx * x_1 + tox, |
63 (tx + tw) * x_1 + tox, 1. - (ty * y_1 + toy), | 63 (tx + tw) * x_1 + tox, |
64 (tx + tw) * x_1 + tox, 1. - ((ty + th) * y_1 + toy), | 64 1. - (ty * y_1 + toy), |
65 tx * x_1 + tox, 1. - ((ty + th) * y_1 + toy)] | 65 1. - ((ty + th) * y_1 + toy)) |
66 | 66 |
67 (x1, x2 , x3, x4), (y1, y2, y3, y4), (z1, z2, z3, z4), _ = vertmat.data | 67 (x1, x2 , x3, x4), (y1, y2, y3, y4), (z1, z2, z3, z4), _ = vertmat.data |
68 | 68 |
69 key = sprite.anm.texture, sprite.blendfunc | 69 key = sprite.anm.texture, sprite.blendfunc |
70 r, g, b = sprite.color | 70 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] * 4 | 71 values = ((x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4)), uvs, (r, g, b, sprite.alpha) |
72 sprite._rendering_data = key, values | 72 sprite._rendering_data = key, values |
73 sprite.changed = False | 73 sprite.changed = False |
74 | 74 |
75 return sprite._rendering_data | 75 return sprite._rendering_data |
76 | 76 |