Mercurial > touhou
comparison pytouhou/ui/opengl/sprite.pyx @ 525:43ecf0f98f4d
Precalculate the inverse of the texture size at ANM load, to not recalculate at every sprite change.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 18 Dec 2013 18:15:45 +0100 |
parents | 6e3b3d5d4691 |
children | db28538cd399 |
comparison
equal
deleted
inserted
replaced
524:7f016dfbdfb1 | 525:43ecf0f98f4d |
---|---|
55 if sprite.allow_dest_offset: | 55 if sprite.allow_dest_offset: |
56 translate(&vertmat, sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2]) | 56 translate(&vertmat, sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2]) |
57 if sprite.corner_relative_placement: # Reposition | 57 if sprite.corner_relative_placement: # Reposition |
58 translate2d(&vertmat, width / 2, height / 2) | 58 translate2d(&vertmat, width / 2, height / 2) |
59 | 59 |
60 size = sprite.anm.size | 60 x_1 = sprite.anm.size_inv[0] |
61 x_1 = 1 / <double>size[0] | 61 y_1 = sprite.anm.size_inv[1] |
62 y_1 = 1 / <double>size[1] | |
63 tox, toy = sprite.texoffsets | 62 tox, toy = sprite.texoffsets |
64 uvs = (tx * x_1 + tox, | 63 uvs = (tx * x_1 + tox, |
65 (tx + tw) * x_1 + tox, | 64 (tx + tw) * x_1 + tox, |
66 ty * y_1 + toy, | 65 ty * y_1 + toy, |
67 (ty + th) * y_1 + toy) | 66 (ty + th) * y_1 + toy) |