optimizations

This commit is contained in:
Chris Danford
2002-08-19 20:02:30 +00:00
parent fc68b90acc
commit 0e5f97143e
19 changed files with 221 additions and 102 deletions
+4
View File
@@ -1163,6 +1163,10 @@ CHANGE: Background Movies now start playing at beat 0, and the movie should
OPTIMIZATION: New deferred rendering architecture uses more CPU in order to
create more efficient operations for the graphics card.
BUG FIX: Select Group no longer crashes with > 15 groups.
CHANGE: Last edited song is selected upon entering Edit Menu.
BUG FIX: "Indirect BPM changes" (track 08) work again. This was causing
"0 BPM" segments to be added to songs like MAX300.
BUG FIX: Fixed life meter stream alignment (I hope!)
------------------------CVS after 3.00 beta 5----------------
OPTIMIZATION: Much faster song loading.
+12 -6
View File
@@ -49,7 +49,15 @@ Actor::Actor()
}
void Actor::Draw() // set the world matrix and calculate actor properties, the call DrawPrimitives
void Actor::Draw()
{
// call the most-derived versions
this->BeginDraw();
this->DrawPrimitives(); // call the most-derived version of DrawPrimitives();
this->EndDraw();
}
void Actor::BeginDraw() // set the world matrix and calculate actor properties
{
DISPLAY->PushMatrix(); // we're actually going to do some drawing in this function
@@ -141,12 +149,10 @@ void Actor::Draw() // set the world matrix and calculate actor properties, the
DISPLAY->RotateY( m_temp_rotation.y );
if( m_temp_rotation.z != 0 )
DISPLAY->RotateZ( m_temp_rotation.z );
}
this->DrawPrimitives(); // call the most-derived version of DrawPrimitives();
void Actor::EndDraw()
{
DISPLAY->PopMatrix();
}
+4 -2
View File
@@ -41,8 +41,10 @@ public:
virtual void Restore() {};
virtual void Invalidate() {};
virtual void Draw(); // set up the world matrix, then calls DrawPrimitives()
virtual void DrawPrimitives() = 0;
virtual void Draw(); // calls, BeginDraw, DrawPrimitives, EndDraw
virtual void BeginDraw(); // pushes transform onto world matrix stack
virtual void DrawPrimitives() = 0; // override with Actor specific action
virtual void EndDraw(); // pops transform from world matrix stack
virtual void Update( float fDeltaTime );
virtual float GetX() { return m_pos.x; };
+2 -2
View File
@@ -254,10 +254,10 @@ void BitmapText::DrawPrimitives()
DISPLAY->TranslateLocal( m_fShadowLength, m_fShadowLength, 0 ); // shift by 5 units
DWORD dwColor = D3DXCOLOR(0,0,0,0.5f*m_temp_colorDiffuse[0].a); // semi-transparent black
int i;
for( i=0; i<iNumV; i++ )
v[i].color = dwColor;
for( i=0; i<iNumV; i+=4 )
DISPLAY->AddQuad( &v[i] );
@@ -300,10 +300,10 @@ void BitmapText::DrawPrimitives()
if( m_temp_colorGlow.a != 0 )
{
DISPLAY->SetColorDiffuse();
int i;
for( i=0; i<iNumV; i++ )
v[i].color = m_temp_colorGlow;
for( i=0; i<iNumV; i+=4 )
DISPLAY->AddQuad( &v[i] );
}
+7 -3
View File
@@ -16,11 +16,15 @@
#include "PrefsManager.h"
//
// Important!!!! Do not use these macros during gameplay. They return very slowly. Cache them in a member.
//
#define JUDGEMENT_DISPLAY_TIME THEME->GetMetricF("HoldJudgement","DisplayTime")
HoldJudgement::HoldJudgement()
{
m_fDisplayTime = JUDGEMENT_DISPLAY_TIME;
m_fDisplayCountdown = 0;
m_sprJudgement.Load( THEME->GetPathTo("Graphics","gameplay hold judgement") );
m_sprJudgement.StopAnimating();
@@ -57,21 +61,21 @@ void HoldJudgement::SetHoldJudgement( HoldNoteScore hns )
default: ASSERT( false );
}
m_fDisplayCountdown = JUDGEMENT_DISPLAY_TIME;
m_fDisplayCountdown = m_fDisplayTime;
if( hns == HNS_NG )
{
// falling down
m_sprJudgement.SetY( -10 );
m_sprJudgement.SetZoom( 1.0f );
m_sprJudgement.BeginTweening( JUDGEMENT_DISPLAY_TIME );
m_sprJudgement.BeginTweening( m_fDisplayTime );
m_sprJudgement.SetTweenY( 10 );
}
else // hns == HNS_OK
{
// zooming out
m_sprJudgement.SetZoom( 1.5f );
m_sprJudgement.BeginTweening( JUDGEMENT_DISPLAY_TIME/3.0f );
m_sprJudgement.BeginTweening( m_fDisplayTime/3.0f );
m_sprJudgement.SetTweenZoom( 1.0f );
}
}
+4 -8
View File
@@ -1,18 +1,15 @@
#pragma once
/*
-----------------------------------------------------------------------------
File: HoldJudgement.h
Class: HoldJudgement
Desc: A graphic displayed in the HoldJudgement during Dancing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#ifndef _HoldJudgement_H_
#define _HoldJudgement_H_
#include "Sprite.h"
#include "ActorFrame.h"
#include "Song.h"
@@ -30,7 +27,6 @@ public:
protected:
Sprite m_sprJudgement;
float m_fDisplayTime;
float m_fDisplayCountdown;
};
#endif
+29 -18
View File
@@ -17,9 +17,13 @@
#include "GameState.h"
#define METER_WIDTH THEME->GetMetricF("LifeMeterBar","MeterWidth")
#define METER_HEIGHT THEME->GetMetricF("LifeMeterBar","MeterHeight")
//
// Important!!!! Do not use these macros during gameplay. They return very slowly. Cache them in a member.
//
#define METER_WIDTH THEME->GetMetricI("LifeMeterBar","MeterWidth")
#define METER_HEIGHT THEME->GetMetricI("LifeMeterBar","MeterHeight")
#define DANGER_THRESHOLD THEME->GetMetricF("LifeMeterBar","DangerThreshold")
const float FAIL_THRESHOLD = 0;
@@ -37,10 +41,13 @@ LifeMeterBar::LifeMeterBar()
m_fLifeVelocity = 0;
m_fHotAlpha = 0;
m_bFailedEarlier = false;
m_iMeterWidth = METER_WIDTH;
m_iMeterHeight = METER_HEIGHT;
m_fDangerThreshold = DANGER_THRESHOLD;
m_quadBlackBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
m_quadBlackBackground.SetZoomX( METER_WIDTH );
m_quadBlackBackground.SetZoomY( METER_HEIGHT );
m_quadBlackBackground.SetZoomX( m_iMeterWidth );
m_quadBlackBackground.SetZoomY( m_iMeterHeight );
m_frame.AddSubActor( &m_quadBlackBackground );
m_sprStreamNormal.Load( THEME->GetPathTo("Graphics","gameplay lifemeter stream normal") );
@@ -137,7 +144,7 @@ bool LifeMeterBar::IsHot()
bool LifeMeterBar::IsInDanger()
{
return m_fLifePercentage < DANGER_THRESHOLD;
return m_fLifePercentage < m_fDangerThreshold;
}
bool LifeMeterBar::IsFailing()
@@ -165,13 +172,18 @@ void LifeMeterBar::Update( float fDeltaTime )
m_fLifeVelocity /= 4; // make some drag
CLAMP( m_fTrailingLifePercentage, 0, 1 );
m_fHotAlpha += IsHot() ? +fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fHotAlpha, 0, 1 );
}
void LifeMeterBar::DrawPrimitives()
{
// set custom texture coords
CRect rectSize(
int( -METER_WIDTH/2 ),
int( -METER_HEIGHT/2 ),
int( -METER_WIDTH/2 + METER_WIDTH * m_fTrailingLifePercentage ),
int( -METER_HEIGHT/2 + METER_HEIGHT) );
static RECT rectSize;
rectSize.left = -m_iMeterWidth/2;
rectSize.top = -m_iMeterHeight/2;
rectSize.right = -m_iMeterWidth/2 + roundf(m_iMeterWidth*m_fTrailingLifePercentage);
rectSize.bottom = +m_iMeterHeight/2;
float fPrecentOffset = TIMER->GetTimeSinceStart();
fPrecentOffset -= (int)fPrecentOffset;
@@ -182,19 +194,17 @@ void LifeMeterBar::Update( float fDeltaTime )
m_fTrailingLifePercentage - fPrecentOffset,
1 );
m_sprStreamNormal.StretchTo( rectSize );
m_sprStreamNormal.StretchTo( &rectSize );
m_sprStreamNormal.SetCustomTextureRect( frectCustomTexCoords );
m_sprStreamHot.StretchTo( rectSize );
m_sprStreamHot.StretchTo( &rectSize );
m_sprStreamHot.SetCustomTextureRect( frectCustomTexCoords );
m_fHotAlpha += IsHot() ? +fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fHotAlpha, 0, 1 );
m_sprStreamHot.SetDiffuseColor( D3DXCOLOR(1,1,1,m_fHotAlpha) );
}
void LifeMeterBar::DrawPrimitives()
{
float fPercentRed = (m_fTrailingLifePercentage<DANGER_THRESHOLD) ? sinf( TIMER->GetTimeSinceStart()*D3DX_PI*4 )/2+0.5f : 0;
float fPercentRed = (m_fTrailingLifePercentage<m_fDangerThreshold) ? sinf( TIMER->GetTimeSinceStart()*D3DX_PI*4 )/2+0.5f : 0;
m_quadBlackBackground.SetDiffuseColor( D3DXCOLOR(fPercentRed*0.8f,0,0,1) );
if( !GAMESTATE->IsPlayerEnabled(m_PlayerNumber) )
@@ -202,6 +212,7 @@ void LifeMeterBar::DrawPrimitives()
m_sprStreamNormal.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprStreamHot.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
}
ActorFrame::DrawPrimitives();
}
+3
View File
@@ -47,4 +47,7 @@ private:
float m_fLifeVelocity; // how m_fTrailingLifePercentage approaches m_fLifePercentage
float m_fHotAlpha;
bool m_bFailedEarlier; // set this to true when life dips below 0
int m_iMeterWidth;
int m_iMeterHeight;
float m_fDangerThreshold;
};
+4
View File
@@ -207,16 +207,20 @@ void MenuElements::DrawPrimitives()
void MenuElements::DrawTopLayer()
{
BeginDraw();
m_frameTopBar.Draw();
m_frameBottomBar.Draw();
m_textHelp.Draw();
m_KeepAlive.Draw();
m_Wipe.Draw();
EndDraw();
}
void MenuElements::DrawBottomLayer()
{
BeginDraw();
m_sprBG.Draw();
EndDraw();
}
void MenuElements::StopTimer()
+72 -22
View File
@@ -253,41 +253,92 @@ void WheelItemDisplay::DrawPrimitives()
{
case TYPE_SECTION:
m_sprSectionBar.Draw();
m_textSectionName.Draw();
break;
case TYPE_ROULETTE:
m_sprSectionBar.Draw();
m_textRoulette.Draw();
break;
case TYPE_SONG:
{
m_sprSongBar.Draw();
m_MusicStatusDisplay.Draw();
m_TextBanner.Draw();
for( int p=0; p<NUM_PLAYERS; p++ )
m_GradeDisplay[p].Draw();
if( m_fPercentGray > 0 )
{
m_sprSongBar.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,m_fPercentGray) );
m_sprSongBar.Draw();
m_sprSongBar.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,0) );
}
}
case TYPE_SONG:
m_sprSongBar.Draw();
break;
case TYPE_COURSE:
m_sprSongBar.Draw();
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
m_textSectionName.Draw();
break;
case TYPE_ROULETTE:
m_textRoulette.Draw();
break;
case TYPE_SONG:
m_TextBanner.Draw();
break;
case TYPE_COURSE:
m_textCourse.Draw();
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
break;
case TYPE_SONG:
m_MusicStatusDisplay.Draw();
break;
case TYPE_COURSE:
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
break;
case TYPE_SONG:
int p;
for( p=0; p<NUM_PLAYERS; p++ )
m_GradeDisplay[p].Draw();
break;
case TYPE_COURSE:
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
break;
case TYPE_SONG:
if( m_fPercentGray > 0 )
{
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,m_fPercentGray) );
m_sprSongBar.Draw();
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,0) );
}
break;
case TYPE_COURSE:
break;
default:
ASSERT(0);
}
}
MusicWheel::MusicWheel()
{
LOG->Trace( "MusicWheel::MusicWheel()" );
@@ -733,7 +784,6 @@ void MusicWheel::DrawPrimitives()
display.Draw();
}
ActorFrame::DrawPrimitives();
}
+2 -2
View File
@@ -54,14 +54,14 @@ public:
class WheelItemDisplay : public WheelItemData,
public Actor
public ActorFrame
{
public:
WheelItemDisplay();
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
CString GetSectionName() { return m_sSectionName; }
void LoadFromWheelItemData( WheelItemData* pWID );
+1 -1
View File
@@ -196,7 +196,7 @@ void NoteField::DrawPrimitives()
//
int iFirstMeasureToDraw = int(fFirstBeatToDraw)/BEATS_PER_MEASURE;
int iLastMeasureToDraw = (int(fLastBeatToDraw)/BEATS_PER_MEASURE)+1;
for( i=iFirstMeasureToDraw; i<=fLastBeatToDraw; i++ )
for( i=iFirstMeasureToDraw; i<=iLastMeasureToDraw; i++ )
DrawMeasureBar( i );
//
+6 -1
View File
@@ -531,13 +531,18 @@ void RageDisplay::FlushQueue()
if( m_iNumVerts == 0 )
return;
ASSERT( (m_iNumVerts % 3) == 0 );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, m_iNumVerts/3, m_vertQueue, sizeof(RAGEVERTEX) );
m_iNumVerts = 0;
/*
RAGEVERTEX* v;
m_pVB->Lock( 0, 0, (BYTE**)&v, 0 );
memcpy( v, m_vertQueue, sizeof(RAGEVERTEX)*m_iNumVerts );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_iNumVerts/3 );
m_pVB->Unlock();
m_iNumVerts = 0;
*/
m_iDrawsSinceLastCheck++;
}
+7 -1
View File
@@ -35,6 +35,13 @@ const int MAX_NUM_VERTICIES = MAX_NUM_QUADS*4; // 4 verticies per quad
//
// Chris:
// I did a lot of testing, and drawing indexed primitives is SLOWER than duplicating
// verticies and not indexing. In fact, drawing indexed primitives is about 30% slower.
//
class RageDisplay
{
friend class RageTexture;
@@ -138,7 +145,6 @@ private:
//
protected:
RAGEVERTEX m_vertQueue[MAX_NUM_VERTICIES];
D3DCOLOR m_addColors[MAX_NUM_VERTICIES];
int m_iNumVerts;
public:
+44 -16
View File
@@ -62,20 +62,10 @@ ScreenEditMenu::ScreenEditMenu()
{
LOG->Trace( "ScreenEditMenu::ScreenEditMenu()" );
// data structures
m_SelectedRow = ROW_GROUP;
SONGMAN->GetGroupNames( m_sGroups );
GAMEMAN->GetNotesTypesForGame( GAMESTATE->m_CurGame, m_NotesTypes );
m_iSelectedGroup = 0;
m_iSelectedSong = 0;
m_iSelectedNotesType = 0;
m_iSelectedNotes = 0;
m_textGroup.LoadFromFont( THEME->GetPathTo("Fonts","header1") );
m_textGroup.SetXY( GROUP_X, GROUP_Y );
m_textGroup.SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) );
m_textGroup.SetText( "blah" );
this->AddSubActor( &m_textGroup );
m_Banner.SetXY( SONG_BANNER_X, SONG_BANNER_Y );
@@ -98,16 +88,54 @@ ScreenEditMenu::ScreenEditMenu()
m_textNotesType.LoadFromFont( THEME->GetPathTo("Fonts","header1") );
m_textNotesType.SetXY( GAME_STYLE_X, GAME_STYLE_Y );
m_textNotesType.SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) );
m_textNotesType.SetText( "blah" );
this->AddSubActor( &m_textNotesType );
m_textNotes.LoadFromFont( THEME->GetPathTo("Fonts","header1") );
m_textNotes.SetXY( STEPS_X, STEPS_Y );
m_textNotes.SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) );
m_textNotes.SetText( "blah" );
this->AddSubActor( &m_textNotes );
// data structures
m_SelectedRow = ROW_GROUP;
AfterRowChange();
OnGroupChange();
SONGMAN->GetGroupNames( m_sGroups );
GAMEMAN->GetNotesTypesForGame( GAMESTATE->m_CurGame, m_NotesTypes );
m_iSelectedGroup = 0;
m_iSelectedSong = 0;
m_iSelectedNotesType = 0;
m_iSelectedNotes = 0;
if( GAMESTATE->m_pCurSong )
{
int i;
for( i=0; i<m_sGroups.GetSize(); i++ )
if( GAMESTATE->m_pCurSong->m_sGroupName == m_sGroups[i] )
m_iSelectedGroup = i;
OnGroupChange();
for( i=0; i<m_pSongs.GetSize(); i++ )
if( GAMESTATE->m_pCurSong == m_pSongs[i] )
m_iSelectedSong = i;
OnSongChange();
for( i=0; i<m_NotesTypes.GetSize(); i++ )
if( GAMESTATE->GetCurrentStyleDef()->m_NotesType == m_NotesTypes[i] )
m_iSelectedNotesType = i;
OnNotesTypeChange();
for( i=0; i<m_pNotess.GetSize(); i++ )
if( GAMESTATE->m_pCurNotes[PLAYER_1] == m_pNotess[i] )
m_iSelectedNotes = i;
OnNotesChange();
}
else
OnGroupChange();
m_textExplanation.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
@@ -248,10 +276,10 @@ void ScreenEditMenu::OnNotesTypeChange()
m_iSelectedNotes = 0;
OnStepsChange();
OnNotesChange();
}
void ScreenEditMenu::OnStepsChange()
void ScreenEditMenu::OnNotesChange()
{
m_iSelectedNotes = clamp( m_iSelectedNotes, 0, m_pNotess.GetSize()-1 );
@@ -308,7 +336,7 @@ void ScreenEditMenu::MenuLeft( const PlayerNumber p )
if( m_iSelectedNotes == 0 ) // can't go left any further
return;
m_iSelectedNotes--;
OnStepsChange();
OnNotesChange();
break;
default:
ASSERT(false);
@@ -341,7 +369,7 @@ void ScreenEditMenu::MenuRight( const PlayerNumber p )
if( m_iSelectedNotes == m_pNotess.GetSize()-1 ) // can't go right any further
return;
m_iSelectedNotes++;
OnStepsChange();
OnNotesChange();
break;
default:
ASSERT(false);
+15 -15
View File
@@ -39,7 +39,7 @@ private:
void OnGroupChange();
void OnSongChange();
void OnNotesTypeChange();
void OnStepsChange();
void OnNotesChange();
CString GetSelectedGroup() { return m_sGroups[m_iSelectedGroup]; };
Song* GetSelectedSong() { return m_pSongs[m_iSelectedSong]; };
@@ -60,31 +60,31 @@ private:
MenuElements m_Menu;
CStringArray m_sGroups;
int m_iSelectedGroup; // index into m_sGroups
BitmapText m_textGroup;
int m_iSelectedGroup; // index into m_sGroups
BitmapText m_textGroup;
CArray<Song*, Song*> m_pSongs;
int m_iSelectedSong; // index into m_pSongs
Banner m_Banner;
int m_iSelectedSong; // index into m_pSongs
Banner m_Banner;
TextBanner m_TextBanner;
Sprite m_sprArrowLeft;
Sprite m_sprArrowRight;
Sprite m_sprArrowLeft;
Sprite m_sprArrowRight;
CArray<NotesType, NotesType> m_NotesTypes;
int m_iSelectedNotesType; // index into m_NotesTypes
BitmapText m_textNotesType;
int m_iSelectedNotesType; // index into m_NotesTypes
BitmapText m_textNotesType;
CArray<Notes*, Notes*> m_pNotess;
int m_iSelectedNotes; // index into m_pNotess
BitmapText m_textNotes;
int m_iSelectedNotes; // index into m_pNotess
BitmapText m_textNotes;
BitmapText m_textExplanation;
BitmapText m_textExplanation;
TransitionFade m_Fade;
TransitionFade m_Fade;
RandomSample m_soundChangeMusic;
RandomSample m_soundSelect;
RandomSample m_soundChangeMusic;
RandomSample m_soundSelect;
};
+2 -2
View File
@@ -409,7 +409,7 @@ void ScreenSelectDifficulty::ChangeTo( const PlayerNumber pn, int iSelectionWas,
}
}
m_soundChange.PlayRandom();
m_soundChange.Play();
}
void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
@@ -418,7 +418,7 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn )
return;
m_bChosen[pn] = true;
m_soundSelect.PlayRandom();
m_soundSelect.Play();
int iSelection = m_iSelection[pn];
switch( iSelection )
+2 -2
View File
@@ -58,8 +58,8 @@ private:
Sprite m_sprArrowShadow[NUM_PLAYERS];
Sprite m_sprOK[NUM_PLAYERS];
RandomSample m_soundChange;
RandomSample m_soundSelect;
RageSoundSample m_soundChange;
RageSoundSample m_soundSelect;
bool m_bPlayedChallengeSound;
+1 -1
View File
@@ -569,7 +569,7 @@ bool Song::LoadFromBMSDir( CString sDir )
value_name = line;
}
if( 0==stricmp(value_name, sTagToLookFor) == 0 )
if( 0==stricmp(value_name, sTagToLookFor) )
{
fBPM = (float)atof( value_data );
break;