[CHG] Optimization in tile calculation

i only modded DrawTile, if this mod is ok for all and fully tested
we need to make this change to all functions the needs calculation like this.
(drawpart, drawtilequad, etc...)
This commit is contained in:
N0NameN0 2009-11-10 09:50:41 +00:00
parent db1246ce52
commit 8f2e7413e5
3 changed files with 9 additions and 4 deletions

View file

@ -111,5 +111,7 @@ void GRRLIB_InitTileSet (GRRLIB_texImg *tex,
tex->nbtileh = tex->h / tileh;
tex->tilestart = tilestart;
tex->tiledtex = true;
tex->ofnormaltexx = 1.0F/tex->nbtilew;
tex->ofnormaltexy = 1.0F/tex->nbtileh;
GRRLIB_SetHandle( tex, 0, 0 );
}

View file

@ -177,10 +177,10 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
if (tex == NULL || tex->data == NULL) return ;
// The 0.001f/x is the frame correction formula by spiffen
s1 = (( (frame %tex->nbtilew) ) /(f32)tex->nbtilew) +(0.001f /tex->w);
s2 = (( (frame %tex->nbtilew) +1) /(f32)tex->nbtilew) -(0.001f /tex->w);
t1 = (((int)(frame /tex->nbtilew) ) /(f32)tex->nbtileh) +(0.001f /tex->h);
t2 = (((int)(frame /tex->nbtilew) +1) /(f32)tex->nbtileh) -(0.001f /tex->h);
s1 = (frame % tex->nbtilew) * tex->ofnormaltexx;
s2 = s1 + tex->ofnormaltexx;
t1 = (int)(frame/tex->nbtilew) * tex->ofnormaltexy;
t2 = t1 + tex->ofnormaltexy;
GX_InitTexObj(&texObj, tex->data,
tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh,

View file

@ -115,6 +115,9 @@ typedef struct GRRLIB_texImg {
uint nbtilew; /**< Number of tiles for the x axis. */
uint nbtileh; /**< Number of tiles for the y axis. */
uint tilestart; /**< Offset to tile starting position. */
f32 ofnormaltexx; /**< Offset of normalized texture on x */
f32 ofnormaltexy; /**< Offset of normalized texture on y */
void *data; /**< Pointer to the texture data. */
} GRRLIB_texImg;