From 1a0b496d3b5c2445d49e66d37db747dc1367ed37 Mon Sep 17 00:00:00 2001 From: Xane Date: Mon, 9 Mar 2009 02:08:28 +0000 Subject: [PATCH] [CHG] Say goodbye to GRRLIB_SetOffset. [CHG] SetMidHandle can now be turned on/off. --- GRRLIB/GRRLIB/GRRLIB.c | 35 +++++++++++++++++------------------ GRRLIB/GRRLIB/GRRLIB.h | 3 +-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB.c b/GRRLIB/GRRLIB/GRRLIB.c index a6d353f..53257a6 100644 --- a/GRRLIB/GRRLIB/GRRLIB.c +++ b/GRRLIB/GRRLIB/GRRLIB.c @@ -565,7 +565,7 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, struct GRRLIB_texImg tex, float d guMtxRotAxisDeg (m2, &axis, degrees); guMtxConcat(m2, m1, m); - guMtxTransApply(m, m, xpos+width+tex.handlex+tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley+tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); + guMtxTransApply(m, m, xpos+width+tex.handlex-tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley-tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); guMtxConcat(GXmodelView2D, m, mv); GX_LoadPosMtxImm(mv, GX_PNMTX0); @@ -683,7 +683,7 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, struct GRRLIB_texImg tex, float Vector axis = (Vector) {0, 0, 1 }; guMtxRotAxisDeg(m2, &axis, degrees); guMtxConcat(m2, m1, m); - guMtxTransApply(m, m, xpos+width+tex.handlex+tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley+tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); + guMtxTransApply(m, m, xpos+width+tex.handlex-tex.offsetx+(scaleX*( -tex.handley*sin(-DegToRad(degrees)) - tex.handlex*cos(-DegToRad(degrees)) )), ypos+height+tex.handley-tex.offsety+(scaleX*( -tex.handley*cos(-DegToRad(degrees)) + tex.handlex*sin(-DegToRad(degrees)) )), 0); guMtxConcat(GXmodelView2D, m, mv); GX_LoadPosMtxImm(mv, GX_PNMTX0); @@ -821,26 +821,25 @@ void GRRLIB_SetHandle( struct GRRLIB_texImg * tex, int x, int y ) { } } -/** - * Set a texture's X and Y offset (e.g. for rotation). - * @param tex The texture to set the handle on. - * @param x The x-coordinate of the offset. - * @param y The y-coordinate of the offset. - */ -void GRRLIB_SetOffset( struct GRRLIB_texImg * tex, int x, int y ) { - tex->offsetx = x; - tex->offsety = y; -} - /** * Center a texture's handles (e.g. for rotation). * @param tex The texture to center. */ -void GRRLIB_SetMidHandle( struct GRRLIB_texImg * tex ) { - tex->handlex = 0; - tex->handley = 0; - tex->offsetx = 0; - tex->offsety = 0; +void GRRLIB_SetMidHandle( struct GRRLIB_texImg * tex, bool enabled ) { + if (enabled) { + if (tex->tiledtex) { + tex->offsetx = (((int)tex->tilew)/2); + tex->offsety = (((int)tex->tileh)/2); + } else { + tex->offsetx = (((int)tex->w)/2); + tex->offsety = (((int)tex->h)/2); + } + GRRLIB_SetHandle(tex, tex->offsetx, tex->offsety); + } else { + GRRLIB_SetHandle(tex, 0, 0); + tex->offsetx = 0; + tex->offsety = 0; + } } /** diff --git a/GRRLIB/GRRLIB/GRRLIB.h b/GRRLIB/GRRLIB/GRRLIB.h index c5659e4..e9f82b2 100644 --- a/GRRLIB/GRRLIB/GRRLIB.h +++ b/GRRLIB/GRRLIB/GRRLIB.h @@ -140,8 +140,7 @@ void GRRLIB_ClipDrawing( int x, int y, int width, int height ); void GRRLIB_ClipReset(); void GRRLIB_SetHandle(struct GRRLIB_texImg * tex, int x, int y); -void GRRLIB_SetOffset( struct GRRLIB_texImg * tex, int x, int y ); -void GRRLIB_SetMidHandle(struct GRRLIB_texImg * tex); +void GRRLIB_SetMidHandle( struct GRRLIB_texImg * tex, bool enabled ); u32 GRRLIB_GetPixelFromtexImg(int x, int y, struct GRRLIB_texImg tex); void GRRLIB_SetPixelTotexImg(int x, int y, struct GRRLIB_texImg tex, u32 color);