- 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)
This commit is contained in:
Braden Obrzut 2013-02-01 02:16:02 +00:00
parent b958215b50
commit 5965c45932
2 changed files with 15 additions and 6 deletions

View File

@ -1292,10 +1292,10 @@ public:
// Check for clipping // Check for clipping
if(cx != 0 || cy != 0 || cr != 0 || cb != 0) if(cx != 0 || cy != 0 || cr != 0 || cb != 0)
{ {
rcx = cx == 0 ? 0 : rx+(((double) cx/FRACUNIT)*xScale) - texture->GetScaledLeftOffsetDouble(); rcx = cx == 0 ? 0 : rx+((((double) cx/FRACUNIT) - texture->GetScaledLeftOffsetDouble())*xScale);
rcy = cy == 0 ? 0 : ry+(((double) cy/FRACUNIT)*yScale) - texture->GetScaledTopOffsetDouble(); rcy = cy == 0 ? 0 : ry+((((double) cy/FRACUNIT) - texture->GetScaledTopOffsetDouble())*yScale);
rcr = cr == 0 ? INT_MAX : rx+w-(((double) cr/FRACUNIT)*xScale) - texture->GetScaledLeftOffsetDouble(); rcr = cr == 0 ? INT_MAX : rx+w-((((double) cr/FRACUNIT) + texture->GetScaledLeftOffsetDouble())*xScale);
rcb = cb == 0 ? INT_MAX : ry+h-(((double) cb/FRACUNIT)*yScale) - texture->GetScaledTopOffsetDouble(); rcb = cb == 0 ? INT_MAX : ry+h-((((double) cb/FRACUNIT) + texture->GetScaledTopOffsetDouble())*yScale);
} }
if(clearDontDraw) if(clearDontDraw)

View File

@ -2330,7 +2330,8 @@ class CommandDrawBar : public SBarInfoCommand
public: public:
CommandDrawBar(SBarInfo *script) : SBarInfoCommand(script), CommandDrawBar(SBarInfo *script) : SBarInfoCommand(script),
border(0), horizontal(false), reverse(false), foreground(-1), 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; value = 0;
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1)) 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<fixed_t>((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100)); drawValue -= clamp<fixed_t>((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100));
else if(drawValue < value) else if(drawValue < value)
drawValue += clamp<fixed_t>((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100)); drawValue += clamp<fixed_t>((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<<FRACBITS, FRACUNIT*100));
@ -2727,6 +2735,7 @@ class CommandDrawBar : public SBarInfoCommand
int interpolationSpeed; int interpolationSpeed;
fixed_t drawValue; fixed_t drawValue;
fixed_t pixel;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////