Fix to some of the rank icon rendering issues.

This was SVN commit r3767.
This commit is contained in:
Matei 2006-04-14 08:25:29 +00:00
parent d5383db5fc
commit 8d7e2ff00a
3 changed files with 16 additions and 10 deletions

View File

@ -84,7 +84,7 @@ public:
//Rank properties
float m_rankWidth;
int m_rankHeight;
float m_rankHeight;
CStr m_rankName;
// Minimap properties

View File

@ -104,7 +104,7 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation, cons
// FIXME: janwas: this was uninitialized, which leads to disaster if
// its value happens to be positive.
// setting to what seems to be a reasonable default.
m_sectorDivs = 4;
m_sectorDivs = 4;
if ( m_sectorDivs >= 0 )
{
m_sectorAngles.resize(m_sectorDivs);
@ -1151,8 +1151,11 @@ void CEntity::renderHealthBar()
if( m_healthBarHeight < 0 )
return; // negative bar height means don't display health bar
float fraction;
if(m_healthMax == 0) fraction = 1.0f;
else fraction = clamp(m_healthCurr / m_healthMax, 0.0f, 1.0f);
CVector2D pos = getScreenCoords( m_healthBarHeight );
float fraction = clamp(m_healthCurr / m_healthMax, 0.0f, 1.0f);
float x1 = pos.x - m_healthBarSize/2;
float x2 = pos.x + m_healthBarSize/2;
float y = g_yres - pos.y;
@ -1185,8 +1188,11 @@ void CEntity::renderStaminaBar()
if( m_staminaBarHeight < 0 )
return; // negative bar height means don't display stamina bar
float fraction;
if(m_staminaMax == 0) fraction = 1.0f;
else fraction = clamp(m_staminaCurr / m_staminaMax, 0.0f, 1.0f);
CVector2D pos = getScreenCoords( m_staminaBarHeight );
float fraction = clamp(m_staminaCurr / m_staminaMax, 0.0f, 1.0f);
float x1 = pos.x - m_staminaBarSize/2;
float x2 = pos.x + m_staminaBarSize/2;
float y = g_yres - pos.y;
@ -1214,7 +1220,7 @@ void CEntity::renderRank()
if( !m_bounds )
return;
if( m_rankHeight < 0 )
return; // negative height means don't display stamina bar
return; // negative height means don't display rank
//Check for valid texture
if( g_Selection.m_unitUITextures.find( m_rankName ) == g_Selection.m_unitUITextures.end() )
return;
@ -1238,13 +1244,13 @@ void CEntity::renderRank()
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, g_Renderer.m_Options.m_LodBias);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f); glVertex3f( x2, y2, 0 );
glTexCoord2f(1.0f, 1.0f); glVertex3f( x2, y1, 0 );
glTexCoord2f(0.0f, 1.0f); glVertex3f( x1, y1,0 );
glTexCoord2f(0.0f, 0.0f); glVertex3f( x1, y2, 0 );
glTexCoord2f(0.0f, 1.0f); glVertex3f( x1, y1, 0 );
glTexCoord2f(1.0f, 1.0f); glVertex3f( x2, y1, 0 );
glTexCoord2f(1.0f, 0.0f); glVertex3f( x2, y2, 0 );
glEnd();
}

View File

@ -133,7 +133,7 @@ public:
//Rank properties
float m_rankHeight;
int m_rankWidth;
float m_rankWidth;
CStr m_rankName;
bool m_healthDecay;