From 5965c45932df5cf81c199a1b44ca84afaa0d6788 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Fri, 1 Feb 2013 02:16:02 +0000 Subject: [PATCH] - Fixed: Using interpolation on drawbar would sometimes result in the last pixel hanging longer than it should. - Improved draw bar clipping fix from last commit. SVN r4057 (trunk) --- src/g_shared/sbarinfo.cpp | 8 ++++---- src/g_shared/sbarinfo_commands.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index a94d041a7..09be47363 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -1292,10 +1292,10 @@ public: // Check for clipping if(cx != 0 || cy != 0 || cr != 0 || cb != 0) { - rcx = cx == 0 ? 0 : rx+(((double) cx/FRACUNIT)*xScale) - texture->GetScaledLeftOffsetDouble(); - rcy = cy == 0 ? 0 : ry+(((double) cy/FRACUNIT)*yScale) - texture->GetScaledTopOffsetDouble(); - rcr = cr == 0 ? INT_MAX : rx+w-(((double) cr/FRACUNIT)*xScale) - texture->GetScaledLeftOffsetDouble(); - rcb = cb == 0 ? INT_MAX : ry+h-(((double) cb/FRACUNIT)*yScale) - texture->GetScaledTopOffsetDouble(); + rcx = cx == 0 ? 0 : rx+((((double) cx/FRACUNIT) - texture->GetScaledLeftOffsetDouble())*xScale); + rcy = cy == 0 ? 0 : ry+((((double) cy/FRACUNIT) - texture->GetScaledTopOffsetDouble())*yScale); + rcr = cr == 0 ? INT_MAX : rx+w-((((double) cr/FRACUNIT) + texture->GetScaledLeftOffsetDouble())*xScale); + rcb = cb == 0 ? INT_MAX : ry+h-((((double) cb/FRACUNIT) + texture->GetScaledTopOffsetDouble())*yScale); } if(clearDontDraw) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 348f97e08..25ea27283 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -2330,7 +2330,8 @@ class CommandDrawBar : public SBarInfoCommand public: CommandDrawBar(SBarInfo *script) : SBarInfoCommand(script), border(0), horizontal(false), reverse(false), foreground(-1), - background(-1), type(HEALTH), interpolationSpeed(0), drawValue(0) + background(-1), type(HEALTH), interpolationSpeed(0), drawValue(0), + pixel(-1) { } @@ -2649,7 +2650,14 @@ class CommandDrawBar : public SBarInfoCommand value = 0; if(interpolationSpeed != 0 && (!hudChanged || level.time == 1)) { - if(value < drawValue) + // [BL] Since we used a percentage (in order to get the most fluid animation) + // we need to establish a cut off point so the last pixel won't hang as the animation slows + if(pixel == -1 && statusBar->Images[foreground]) + pixel = MAX(1, FRACUNIT/statusBar->Images[foreground]->GetWidth()); + + if(abs(drawValue - value) < pixel) + drawValue = value; + else if(value < drawValue) drawValue -= clamp((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<