From 1b5616688ea64e1b32783dddcde22e7447a742ef Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 26 Apr 2020 21:50:52 +0200 Subject: tried to fix some half-pixel bugs --- src/core/common.h | 7 +++++++ src/extras/debugmenu.cpp | 20 ++++++++++---------- src/render/MBlur.cpp | 12 ++++++------ 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/core/common.h b/src/core/common.h index 2cc3d98c..0b4686d8 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -31,6 +31,7 @@ #define HIERNODEID(hier, i) ((hier)->nodeInfo[i].id) #define HANIMFRAMES(anim) ((anim)->keyframes) #else +#define RWHALFPIXEL // always d3d #define STREAMPOS(str) ((str)->Type.memory.position) #define STREAMFILE(str) ((str)->Type.file.fpFile) #define HIERNODEINFO(hier) ((hier)->pNodeInfo) @@ -38,6 +39,12 @@ #define HANIMFRAMES(anim) ((anim)->pFrames) #endif +#ifdef RWHALFPIXEL +#define HALFPX (0.5f) +#else +#define HALFPX (0.0f) +#endif + #define rwVENDORID_ROCKSTAR 0x0253F2 // Get rid of bullshit windows definitions, we're not running on an 8086 diff --git a/src/extras/debugmenu.cpp b/src/extras/debugmenu.cpp index f419e76f..1c5e26ee 100644 --- a/src/extras/debugmenu.cpp +++ b/src/extras/debugmenu.cpp @@ -1068,13 +1068,13 @@ drawArrow(RwRect r, int direction, int style) int top = r.y; int bottom = r.y+r.h; - float umin = 0.5f / width; - float vmin = 0.5f / height; - float umax = (width + 0.5f) / width; - float vmax = (height + 0.5f) / height; + float umin = HALFPX / width; + float vmin = HALFPX / height; + float umax = (width + HALFPX) / width; + float vmax = (height + HALFPX) / height; if(direction < 0){ - vmin = (height - 0.5f) / height; - vmax = -0.5f / height; + vmin = (height - HALFPX) / height; + vmax = -HALFPX / height; } if(style){ @@ -1167,10 +1167,10 @@ drawMouse(void) float h = RwRasterGetHeight(cursor); float recipz = 1.0f/RwCameraGetNearClipPlane(cam); - float umin = 0.5f / w; - float vmin = 0.5f / h; - float umax = (w + 0.5f) / w; - float vmax = (h + 0.5f) / h; + float umin = HALFPX / w; + float vmin = HALFPX / h; + float umax = (w + HALFPX) / w; + float vmax = (h + HALFPX) / h; vert = vertices; RwIm2DVertexSetScreenX(vert, x); diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index c3a25bce..68ec1194 100644 --- a/src/render/MBlur.cpp +++ b/src/render/MBlur.cpp @@ -58,13 +58,13 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect) float zero, xmax, ymax; if(RwRasterGetDepth(RwCameraGetRaster(cam)) == 16){ - zero = 0.5f; - xmax = rect->w + 0.5f; - ymax = rect->h + 0.5f; + zero = HALFPX; + xmax = rect->w + HALFPX; + ymax = rect->h + HALFPX; }else{ - zero = -0.5f; - xmax = rect->w - 0.5f; - ymax = rect->h - 0.5f; + zero = -HALFPX; + xmax = rect->w - HALFPX; + ymax = rect->h - HALFPX; } RwIm2DVertexSetScreenX(&Vertex[0], zero); -- cgit v1.2.3