From d1fbf3f1f56f14095926793a766d174052bfaeae Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 7 Feb 2005 21:00:21 +0000 Subject: [PATCH] Only iterate over the section of a hold note that's on screen. Fixes slowness with extremely long hold notes; now, even if a hold note has a MAX_NOTE_ROW duration (which would be a bug), we shouldn't slow down. --- stepmania/src/NoteDisplay.cpp | 30 +++++++++++++++++++++++------- stepmania/src/NoteDisplay.h | 4 ++-- stepmania/src/NoteField.cpp | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index ff5e2596e4..2a23f3e8f2 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -669,7 +669,8 @@ void NoteDisplay::DrawHoldTopCap( const TapNote& tn, int iCol, int iBeat, const } -void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow ) +void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, + float fYStartOffset, float fYEndOffset ) { // // Draw the body (always wavy) @@ -701,14 +702,29 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iBeat, const bo if( bGlow ) fColorScale = 1; + /* Only draw the section that's within the range specified. If a hold note is + * very long, don't process or draw the part outside of the range. Don't change + * fYBodyTop or fYBodyBottom; they need to be left alone to calculate texture + * coordinates. */ + float fDrawYBodyTop; + float fDrawYBodyBottom; + { + float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYStartOffset, m_fYReverseOffsetPixels ); + fDrawYBodyTop = max( fYBodyTop, fYStartPos ); + } + { + float fYEndPos = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYEndOffset, m_fYReverseOffsetPixels ); + fDrawYBodyBottom = min( fYBodyBottom, fYEndPos ); + } + // top to bottom bool bAllAreTransparent = true; bool bLast = false; - for( float fY = fYBodyTop; !bLast; fY += fYStep ) + for( float fY = fDrawYBodyTop; !bLast; fY += fYStep ) { - if( fY >= fYBodyBottom ) + if( fY >= fDrawYBodyBottom ) { - fY = fYBodyBottom; + fY = fDrawYBodyBottom; bLast = true; } @@ -926,7 +942,7 @@ void NoteDisplay::DrawHoldHead( const TapNote& tn, int iCol, int iBeat, const bo } } -void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iBeat, bool bIsBeingHeld, bool bIsActive, const HoldNoteResult &Result, float fPercentFadeToFail, bool bDrawGlowOnly, float fReverseOffsetPixels ) +void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iBeat, bool bIsBeingHeld, bool bIsActive, const HoldNoteResult &Result, float fPercentFadeToFail, bool bDrawGlowOnly, float fReverseOffsetPixels, float fYStartOffset, float fYEndOffset ) { int iEndBeat = iBeat + tn.iDuration; @@ -972,7 +988,7 @@ void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iBeat, bool bIsBein if( !bFlipHeadAndTail ) DrawHoldBottomCap( tn, iCol, iBeat, bIsBeingHeld, fYHead, fYTail, fYStep, fPercentFadeToFail, fColorScale, bDrawGlowOnly ); - DrawHoldBody( tn, iCol, iBeat, bIsBeingHeld, fYHead, fYTail, fYStep, fPercentFadeToFail, fColorScale, bDrawGlowOnly ); + DrawHoldBody( tn, iCol, iBeat, bIsBeingHeld, fYHead, fYTail, fYStep, fPercentFadeToFail, fColorScale, bDrawGlowOnly, fYStartOffset, fYEndOffset ); if( bFlipHeadAndTail ) DrawHoldTopCap( tn, iCol, iBeat, bIsBeingHeld, fYHead, fYTail, fYStep, fPercentFadeToFail, fColorScale, bDrawGlowOnly ); @@ -984,7 +1000,7 @@ void NoteDisplay::DrawHold( const TapNote &tn, int iCol, int iBeat, bool bIsBein // now, draw the glow pass if( !bDrawGlowOnly ) - DrawHold( tn, iCol, iBeat, bIsBeingHeld, bIsActive, Result, fPercentFadeToFail, true, fReverseOffsetPixels ); + DrawHold( tn, iCol, iBeat, bIsBeingHeld, bIsActive, Result, fPercentFadeToFail, true, fReverseOffsetPixels, fYStartOffset, fYEndOffset ); } void NoteDisplay::DrawActor( Actor* pActor, int iCol, float fBeat, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels, bool bUseLighting ) diff --git a/stepmania/src/NoteDisplay.h b/stepmania/src/NoteDisplay.h index ecfd6ce224..d5a1612a6a 100644 --- a/stepmania/src/NoteDisplay.h +++ b/stepmania/src/NoteDisplay.h @@ -23,7 +23,7 @@ public: void DrawActor( Actor* pActor, int iCol, float fBeat, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels, bool bUseLighting ); void DrawTap( int iCol, float fBeat, bool bOnSameRowAsHoldStart, bool bIsAddition, bool bIsMine, float fPercentFadeToFail, float fLife, float fReverseOffsetPixels ); - void DrawHold( const TapNote& tn, int iCol, int iBeat, bool bIsBeingHeld, bool bIsActive, const HoldNoteResult &Result, float fPercentFadeToFail, bool bDrawGlowOnly, float fReverseOffsetPixels ); + void DrawHold( const TapNote& tn, int iCol, int iBeat, bool bIsBeingHeld, bool bIsActive, const HoldNoteResult &Result, float fPercentFadeToFail, bool bDrawGlowOnly, float fReverseOffsetPixels, float fYStartOffset, float fYEndOffset ); bool DrawHoldHeadForTapsOnSameRow() const; @@ -40,7 +40,7 @@ protected: void DrawHoldBottomCap( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow ); void DrawHoldTopCap( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow ); - void DrawHoldBody( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow ); + void DrawHoldBody( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fYTail, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fYStartOffset, float fYEndOffset ); void DrawHoldTail( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYTail, float fPercentFadeToFail, float fColorScale, bool bGlow ); void DrawHoldHead( const TapNote& tn, int iCol, int iBeat, const bool bIsBeingHeld, float fYHead, float fPercentFadeToFail, float fColorScale, bool bGlow ); diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 0078b4d3d4..38af8c389f 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -601,7 +601,7 @@ void NoteField::DrawPrimitives() bIsInSelectionRange = (m_iBeginMarker <= iStartRow && iEndRow < m_iEndMarker); NoteDisplayCols *nd = CurDisplay->second; - nd->display[c].DrawHold( tn, c, iStartRow, bIsHoldingNote, bIsActive, Result, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail, false, m_fYReverseOffsetPixels ); + nd->display[c].DrawHold( tn, c, iStartRow, bIsHoldingNote, bIsActive, Result, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail, false, m_fYReverseOffsetPixels, (float) iFirstPixelToDraw, (float) iLastPixelToDraw ); } }