Mercurial > touhou
comparison pytouhou/ui/opengl/sprite.pyx @ 514:3d4410de78e1
Remove some useless optimisations now that cython does them for us.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 05 Dec 2013 20:40:11 +0100 |
parents | 5e3e0b09a531 |
children | b3193b43a86c |
comparison
equal
deleted
inserted
replaced
513:5e3e0b09a531 | 514:3d4410de78e1 |
---|---|
17 | 17 |
18 from pytouhou.utils.matrix cimport Matrix | 18 from pytouhou.utils.matrix cimport Matrix |
19 from .renderer cimport Texture #XXX | 19 from .renderer cimport Texture #XXX |
20 | 20 |
21 | 21 |
22 cpdef object get_sprite_rendering_data(Sprite sprite): | 22 cpdef tuple get_sprite_rendering_data(Sprite sprite): |
23 cdef double tx, ty, tw, th, sx, sy, rx, ry, rz, tox, toy | 23 cdef double tx, ty, tw, th, sx, sy, rx, ry, rz, tox, toy |
24 cdef object tmp1, tmp2 | |
25 | 24 |
26 if not sprite.changed: | 25 if not sprite.changed: |
27 return sprite._rendering_data | 26 return sprite._rendering_data |
28 | 27 |
29 tmp1 = .5 | 28 vertmat = Matrix([-.5, .5, .5, -.5, |
30 tmp2 = -.5 | 29 -.5, -.5, .5, .5, |
31 vertmat = Matrix([tmp2, tmp1, tmp1, tmp2, | |
32 tmp2, tmp2, tmp1, tmp1, | |
33 0, 0, 0, 0, | 30 0, 0, 0, 0, |
34 1, 1, 1, 1]) | 31 1, 1, 1, 1]) |
35 | 32 |
36 tx, ty, tw, th = sprite.texcoords | 33 tx, ty, tw, th = sprite.texcoords |
37 sx, sy = sprite.rescale | 34 sx, sy = sprite.rescale |
57 if sprite.allow_dest_offset: | 54 if sprite.allow_dest_offset: |
58 vertmat.translate(sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2]) | 55 vertmat.translate(sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2]) |
59 if sprite.corner_relative_placement: # Reposition | 56 if sprite.corner_relative_placement: # Reposition |
60 vertmat.translate(width / 2, height / 2, 0) | 57 vertmat.translate(width / 2, height / 2, 0) |
61 | 58 |
62 x_1 = 1 / <double>sprite.anm.size[0] | 59 size = sprite.anm.size |
63 y_1 = 1 / <double>sprite.anm.size[1] | 60 x_1 = 1 / <double>size[0] |
61 y_1 = 1 / <double>size[1] | |
64 tox, toy = sprite.texoffsets | 62 tox, toy = sprite.texoffsets |
65 uvs = (tx * x_1 + tox, | 63 uvs = (tx * x_1 + tox, |
66 (tx + tw) * x_1 + tox, | 64 (tx + tw) * x_1 + tox, |
67 ty * y_1 + toy, | 65 ty * y_1 + toy, |
68 (ty + th) * y_1 + toy) | 66 (ty + th) * y_1 + toy) |