From 97192388b68a6fc42b7bbc0d340cff650cb26419 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 13 Feb 2014 08:03:56 -0800 Subject: [PATCH] Clamp float z in throughmode, rather than wrapping. Matches tests, fixes sky in Tales of Eternia (#4572.) --- GPU/Common/VertexDecoderCommon.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index dcea1c693..738fc9075 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -95,8 +95,8 @@ public: const float *f = (const float *)(data_ + decFmt_.posoff); memcpy(pos, f, 12); if (isThrough()) { - // Integer value passed in a float. Wraps and all, required for Monster Hunter. - pos[2] = (float)((u16)(s32)pos[2]) * (1.0f / 65535.0f); + // Integer value passed in a float. Clamped to 0, 65535. + pos[2] = pos[2] > 65535.0f ? 1.0f : (pos[2] < 0.0f ? 0.0f : pos[2] * (1.0f / 65535.0f)); } // See https://github.com/hrydgard/ppsspp/pull/3419, something is weird. } @@ -144,6 +144,10 @@ public: { const float *f = (const float *)(data_ + decFmt_.posoff); memcpy(pos, f, 12); + if (isThrough()) { + // Integer value passed in a float. Clamped to 0, 65535. + pos[2] = pos[2] > 65535.0f ? 65535.0f : (pos[2] < 0.0f ? 0.0f : pos[2]); + } // TODO: Does non-through need conversion? } break;