Skip to content

Commit

Permalink
Remove now useless IsOnScreen function as it only does redundant checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
xwidghet committed Nov 5, 2016
1 parent cc491ff commit 0de46d1
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 44 deletions.
23 changes: 1 addition & 22 deletions src/NoteDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,23 +449,6 @@ inline float NoteRowToVisibleBeat( const PlayerState *pPlayerState, int iRow )
return NoteRowToBeat(iRow);
}

bool NoteDisplay::IsOnScreen( float fBeat, int iCol, int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels ) const
{
// IMPORTANT: Do not modify this function without also modifying the
// version that is in NoteField.cpp or coming up with a good way to
// merge them. -Kyz
// TRICKY: If boomerang is on, then ones in the range
// [iFirstRowToDraw,iLastRowToDraw] aren't necessarily visible.
// Test to see if this beat is visible before drawing.
float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBeat );
if( fYOffset > iDrawDistanceBeforeTargetsPixels ) // off screen
return false;
if( fYOffset < iDrawDistanceAfterTargetsPixels ) // off screen
return false;

return true;
}

bool NoteDisplay::DrawHoldsInRange(const NoteFieldRenderArgs& field_args,
const NoteColumnRenderArgs& column_args,
const vector<NoteData::TrackMap::const_iterator>& tap_set)
Expand Down Expand Up @@ -550,11 +533,7 @@ bool NoteDisplay::DrawTapsInRange(const NoteFieldRenderArgs& field_args,
int tap_row= (*tapit)->first;
const TapNote& tn= (*tapit)->second;

// TRICKY: If boomerang is on, then all notes in the range
// [first_row,last_row] aren't necessarily visible.
// Test every note to make sure it's on screen before drawing.
if(!IsOnScreen(NoteRowToBeat(tap_row), column_args.column,
field_args.draw_pixels_after_targets, field_args.draw_pixels_before_targets))
if (tap_row < field_args.first_row || tap_row > field_args.last_row)
{
continue; // skip
}
Expand Down
2 changes: 0 additions & 2 deletions src/NoteDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ class NoteDisplay

static void Update( float fDeltaTime );

bool IsOnScreen( float fBeat, int iCol, int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels ) const;

bool DrawHoldsInRange(const NoteFieldRenderArgs& field_args,
const NoteColumnRenderArgs& column_args,
const vector<NoteData::TrackMap::const_iterator>& tap_set);
Expand Down
19 changes: 1 addition & 18 deletions src/NoteField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,23 +708,6 @@ float FindLastDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceB
return fLastBeatToDraw;
}

bool NoteField::IsOnScreen( float fBeat, int iCol, int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels ) const
{
// IMPORTANT: Do not modify this function without also modifying the
// version that is in NoteDisplay.cpp or coming up with a good way to
// merge them. -Kyz
// TRICKY: If boomerang is on, then ones in the range
// [iFirstRowToDraw,iLastRowToDraw] aren't necessarily visible.
// Test to see if this beat is visible before drawing.
float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBeat );
if( fYOffset > iDrawDistanceBeforeTargetsPixels ) // off screen
return false;
if( fYOffset < iDrawDistanceAfterTargetsPixels ) // off screen
return false;

return true;
}

void NoteField::CalcPixelsBeforeAndAfterTargets()
{
const PlayerOptions& curr_options= m_pPlayerState->m_PlayerOptions.GetCurrent();
Expand Down Expand Up @@ -796,7 +779,7 @@ void NoteField::DrawPrimitives()
//LOG->Trace( "start = %f.1, end = %f.1", first_beat_to_draw-fSongBeat, last_beat_to_draw-fSongBeat );
//LOG->Trace( "Drawing elements %d through %d", m_FieldRenderArgs.first_row, m_FieldRenderArgs.last_row );

#define IS_ON_SCREEN(fBeat) (first_beat_to_draw <= (fBeat) && (fBeat) <= last_beat_to_draw && IsOnScreen(fBeat, 0, m_FieldRenderArgs.draw_pixels_after_targets, m_FieldRenderArgs.draw_pixels_before_targets))
#define IS_ON_SCREEN(fBeat) (first_beat_to_draw <= (fBeat) && (fBeat) <= last_beat_to_draw)

// Draw Receptors
{
Expand Down
2 changes: 0 additions & 2 deletions src/NoteField.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class NoteField : public ActorFrame
void CacheNoteSkin( const RString &sNoteSkin );
void UncacheNoteSkin( const RString &sNoteSkin );

bool IsOnScreen( float fBeat, int iCol, int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels ) const;

void DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels );

enum BeatBarType { measure, beat, half_beat, quarter_beat };
Expand Down

0 comments on commit 0de46d1

Please sign in to comment.