Skip to content

Commit

Permalink
Fix draw order of hit effects
Browse files Browse the repository at this point in the history
  • Loading branch information
ASleepyCat committed Apr 2, 2021
1 parent c5edaf1 commit d30b913
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions Main/include/Track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Track : Unique, public IAsyncLoadable
void DrawObjectState(RenderQueue& rq, class BeatmapPlayback& playback, ObjectState* obj, bool active, const std::unordered_set<MapTime> chipFXTimes[2]);
// Things like the laser pointers, hit bar and effect
void DrawOverlays(RenderQueue& rq);
void DrawHitEffects(RenderQueue& rq);
// Draws a plane over the track
void DrawTrackOverlay(RenderQueue& rq, Texture texture, float heightOffset = 0.05f, float widthScale = 1.0f);
// Draw a centered sprite at pos, relative from the track
Expand Down
13 changes: 8 additions & 5 deletions Main/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,16 +905,18 @@ class Game_Impl : public Game
}
}

RenderQueue hitObjectsRq(g_gl, rs);

/// TODO: Performance impact analysis.
m_track->DrawLaserBase(renderQueue, m_playback, m_currentObjectSet);
m_track->DrawLaserBase(hitObjectsRq, m_playback, m_currentObjectSet);

// Draw the base track + time division ticks
m_track->DrawBase(renderQueue);

for(auto& object : m_currentObjectSet)
{
if(m_hiddenObjects.find(object) == m_hiddenObjects.end())
m_track->DrawObjectState(renderQueue, m_playback, object, m_scoring.IsObjectHeld(object), chipFXTimes);
m_track->DrawObjectState(hitObjectsRq, m_playback, object, m_scoring.IsObjectHeld(object), chipFXTimes);
}
if(m_showCover)
m_track->DrawTrackCover(renderQueue);
Expand All @@ -923,6 +925,7 @@ class Game_Impl : public Game
// this is because otherwise some of the scoring elements would get clipped to
// the track's near and far planes
rs = m_camera.CreateRenderState(false);
RenderQueue hitEffectsRq(g_gl, rs);
RenderQueue scoringRq(g_gl, rs);

// Copy over laser position and extend info
Expand All @@ -941,12 +944,12 @@ class Game_Impl : public Game
m_track->laserPositions[i] = m_scoring.laserPositions[i];
m_track->laserPointerOpacity[i] = (1.0f - Math::Clamp<float>(m_scoring.timeSinceLaserUsed[i] / 0.5f - 1.0f, 0, 1));
}
m_track->DrawHitEffects(hitEffectsRq);
m_track->DrawOverlays(scoringRq);
float comboZoom = Math::Max(0.0f, (1.0f - (m_comboAnimation.SecondsAsFloat() / 0.2f)) * 0.5f);
//m_track->DrawCombo(scoringRq, m_scoring.currentComboCounter, m_comboColors[m_scoring.comboState], 1.0f + comboZoom);

// Render queues
renderQueue.Process();
hitEffectsRq.Process();
hitObjectsRq.Process();
scoringRq.Process();
glFlush();

Expand Down
13 changes: 9 additions & 4 deletions Main/src/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ void Track::DrawObjectState(RenderQueue& rq, class BeatmapPlayback& playback, Ob

Transform buttonTransform = trackOrigin;
buttonTransform *= Transform::Translation(buttonPos);
float scale = 1.0f;
float scale;
if(isHold) // Hold Note?
{
float trackScale = (playback.DurationToViewDistanceAtTime(mobj->time, mobj->hold.duration) / viewRange) / length;
Expand Down Expand Up @@ -608,18 +608,23 @@ void Track::DrawObjectState(RenderQueue& rq, class BeatmapPlayback& playback, Ob
}
}
}

void Track::DrawOverlays(class RenderQueue& rq)
{
// Draw button hit effect sprites
for (auto& hfx : m_hitEffects)
hfx->Draw(rq);
for (auto& bfx : m_buttonHitEffects)
bfx.Draw(rq);


if (timedHitEffect->time > 0.0f)
timedHitEffect->Draw(rq);
}

void Track::DrawHitEffects(RenderQueue& rq)
{
for (auto& bfx : m_buttonHitEffects)
bfx.Draw(rq);
}

void Track::DrawTrackOverlay(RenderQueue& rq, Texture texture, float heightOffset /*= 0.05f*/, float widthScale /*= 1.0f*/)
{
MaterialParameterSet params;
Expand Down

0 comments on commit d30b913

Please sign in to comment.