[Change] Optimized getSpriteFromDir somewhat.

This commit is contained in:
Allanis 2013-02-26 18:47:14 +00:00
parent ffd806bea6
commit 21deb8709d

View File

@ -325,13 +325,17 @@ int gl_isTrans(const glTexture* t, const int x, const int y) {
// Set x and y to be the appropriate sprite for glTexture using dir. // Set x and y to be the appropriate sprite for glTexture using dir.
void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir) { void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir) {
int s = (int)(dir / (2.0*M_PI / (t->sy*t->sx))); int s, sx, sy;
s = (int)(dir / (2.0*M_PI / (t->sy*t->sx)));
sx = t->sx;
sy = t->sy;
// Make sure the sprite is "in range". // Make sure the sprite is "in range".
if(s > (int)(t->sy*t->sx)-1) s = s % (int)(t->sy*t->sx); if(s > (sy*sx-1)) s = s % (sy*sx);
*x = s % (int)t->sx; *x = s % sx;
*y = s / (int)t->sy; *y = s / sy;
} }
// ================ // ================