Skip to content

Commit

Permalink
Client: Spectator: Only add overview entities if rendering (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Dec 17, 2023
1 parent d339391 commit 90642e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/game/client/hud/spectator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,22 @@ void CHudSpectator::SetWayInterpolation(cameraWayPoint_t *prev, cameraWayPoint_t
}
}

bool CHudSpectator::ShouldDrawOverview()
{
// draw only in sepctator mode
if (!g_iUser1)
return false;

// Only draw the overview if Map Mode is selected for this view
if (m_iDrawCycle == 0 && ((g_iUser1 != OBS_MAP_FREE) && (g_iUser1 != OBS_MAP_CHASE)))
return false;

if (m_iDrawCycle == 1 && m_pip->value < INSET_MAP_FREE)
return false;

return true;
}

bool CHudSpectator::GetDirectorCamera(Vector &position, Vector &angle)
{
float now = gHUD.m_flTime;
Expand Down Expand Up @@ -1654,15 +1670,7 @@ void CHudSpectator::DrawOverviewEntities()

void CHudSpectator::DrawOverview()
{
// draw only in sepctator mode
if (!g_iUser1)
return;

// Only draw the overview if Map Mode is selected for this view
if (m_iDrawCycle == 0 && ((g_iUser1 != OBS_MAP_FREE) && (g_iUser1 != OBS_MAP_CHASE)))
return;

if (m_iDrawCycle == 1 && m_pip->value < INSET_MAP_FREE)
if (!ShouldDrawOverview())
return;

DrawOverviewLayer();
Expand All @@ -1686,6 +1694,11 @@ void CHudSpectator::CheckOverviewEntities()

bool CHudSpectator::AddOverviewEntity(int type, struct cl_entity_s *ent, const char *modelname)
{
// AddOverviewEntity is called every frame. Overview entity list is only cleared
// when it is drawn. So don't add any entities if not rendering.
if (!ShouldDrawOverview())
return false;

HSPRITE hSprite = 0;
double duration = -1.0f; // duration -1 means show it only this frame;

Expand Down
3 changes: 3 additions & 0 deletions src/game/client/hud/spectator.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class CHudSpectator : public CHudElemBase<CHudSpectator>
int m_lastSecondaryObject;

cameraWayPoint_t m_CamPath[MAX_CAM_WAYPOINTS];

//! @returns Whether overview should be rendered this frame.
bool ShouldDrawOverview();
};

#endif // SPECTATOR_H

0 comments on commit 90642e7

Please sign in to comment.