From 1a68fadc1b81c9a85135d9250dc65c27c0875362 Mon Sep 17 00:00:00 2001 From: Pablo Amorin Date: Tue, 13 Aug 2019 12:20:44 -0300 Subject: [PATCH 1/2] [Feature] Half-Pixel correction on prebuilt atlasses --- oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp b/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp index 412008603..0ba20e0de 100644 --- a/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp +++ b/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp @@ -159,7 +159,11 @@ namespace oxygine float iw = 1.0f / texture->getWidth(); float ih = 1.0f / texture->getHeight(); - RectF srcRect(x * iw, y * ih, bbox_w * iw, bbox_h * ih); + RectF srcRect( + (x+0.5) * iw, + (y+0.5) * ih, + (bbox_w-1) * iw, + (bbox_h-1) * ih); float fs = frame_scale; RectF destRect( From 78d98703adb7a7662de8d08cca46910e472b83c9 Mon Sep 17 00:00:00 2001 From: Pablo Amorin Date: Wed, 14 Aug 2019 10:36:30 -0300 Subject: [PATCH 2/2] [FIX] Added XML Param hpc to enable/disable Half pixel correction on a per resource basis [Feature] compiling with -DENABLE_HPC makes true the hpc default for all pregenerated atlases --- oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp | 9 +++------ oxygine/src/oxygine/res/ResAtlasPrebuilt.h | 5 +++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp b/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp index 0ba20e0de..f6571243c 100644 --- a/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp +++ b/oxygine/src/oxygine/res/ResAtlasPrebuilt.cpp @@ -121,13 +121,13 @@ namespace oxygine if (columns) { + bool hpc = child_node.attribute("hpc").as_bool(HPC_DEFAULT); animationFrames frames; int frames_count = rows * columns; frames.reserve(frames_count); ResAnim* ra = new ResAnim(this); - OX_ASSERT(meta_frames); @@ -159,11 +159,8 @@ namespace oxygine float iw = 1.0f / texture->getWidth(); float ih = 1.0f / texture->getHeight(); - RectF srcRect( - (x+0.5) * iw, - (y+0.5) * ih, - (bbox_w-1) * iw, - (bbox_h-1) * ih); + RectF srcRect(x * iw, y * ih, bbox_w * iw, bbox_h * ih); + if (hpc) srcRect.expand2(Vector2(-0.5f*iw, -0.5f*ih)); float fs = frame_scale; RectF destRect( diff --git a/oxygine/src/oxygine/res/ResAtlasPrebuilt.h b/oxygine/src/oxygine/res/ResAtlasPrebuilt.h index d23a3708b..8bd3d0b48 100644 --- a/oxygine/src/oxygine/res/ResAtlasPrebuilt.h +++ b/oxygine/src/oxygine/res/ResAtlasPrebuilt.h @@ -1,5 +1,10 @@ #pragma once #include "ResAtlas.h" +#ifdef FORCE_HPC +#define HPC_DEFAULT true +#else +#define HPC_DEFAULT false +#endif namespace oxygine {