diff --git a/stepmania/src/NoteFieldPositioning.cpp b/stepmania/src/NoteFieldPositioning.cpp index 34bdaf1bc4..dd8c64c3ee 100644 --- a/stepmania/src/NoteFieldPositioning.cpp +++ b/stepmania/src/NoteFieldPositioning.cpp @@ -14,108 +14,45 @@ #include "GameDef.h" -/* This is similar in style to Actor::Command. However, Actors don't store - * matrix stacks; they only store offsets and scales, and compound them into - * a single transformations at once. This makes some things easy, but it's not - * convenient for generic 3d transforms. For that, we have this, which has the - * small subset of the actor commands that applies to raw matrices, and we apply - * commands in the order given. "scale,2;x,1;" is very different from - * "x,1;scale,2;". */ -static CString GetParam( const CStringArray& sParams, int iIndex, int& iMaxIndexAccessed ) -{ - iMaxIndexAccessed = max( iIndex, iMaxIndexAccessed ); - if( iIndex < int(sParams.size()) ) - return sParams[iIndex]; - else - return ""; -} - -void MatrixCommand(CString sCommandString, RageMatrix &mat) -{ - CStringArray asCommands; - split( sCommandString, ";", asCommands, true ); - - for( unsigned c=0; cWarn( sError ); -#if defined(WIN32) // XXX arch? - if( DISPLAY->IsWindowed() ) - MessageBox(NULL, sError, "MatrixCommand", MB_OK); -#endif - continue; - } - - - if( iMaxIndexAccessed != (int)asTokens.size()-1 ) - { - CString sError = ssprintf( "Wrong number of parameters in command '%s'. Expected %d but there are %d.", join(",",asTokens).GetString(), iMaxIndexAccessed+1, (int)asTokens.size() ); - LOG->Warn( sError ); -#if defined(WIN32) // XXX arch? - if( DISPLAY->IsWindowed() ) - MessageBox(NULL, sError, "MatrixCommand", MB_OK); -#endif - continue; - } - - RageMatrix a(mat); - RageMatrixMultiply(&mat, &a, &b); - } - -} - NoteFieldPositioning::Mode::Mode() { - for( int tn=0; tnMultMatrix((const float *) m_Position[tn]); + /* It's useful to be able to use Actors like this, functioning only + * for a transformation. However, this is a big waste of matrix + * stack space, as each of these will push. Profile this. XXX */ + m_Center.BeginDraw(); + if(tn != -1) + m_CenterTrack[tn].BeginDraw(); - if(m_fFov[tn]) - DISPLAY->EnterPerspective(m_fFov[tn]); + if(m_fFov) + DISPLAY->EnterPerspective(m_fFov); - DISPLAY->MultMatrix((const float *) m_PerspPosition[tn]); + m_Position.BeginDraw(); + if(tn == -1) + m_PositionBackdrop.BeginDraw(); + else + m_PositionTrack[tn].BeginDraw(); } -void NoteFieldPositioning::Mode::EndDrawTrack(int tn) const +void NoteFieldPositioning::Mode::EndDrawTrack(int tn) { - if(m_fFov[tn]) - DISPLAY->ExitPerspective(); -} + if(tn == -1) + m_PositionBackdrop.EndDraw(); + else + m_PositionTrack[tn].EndDraw(); + m_Position.EndDraw(); + if(m_fFov) + DISPLAY->ExitPerspective(); + + if(tn != -1) + m_CenterTrack[tn].EndDraw(); + m_Center.EndDraw(); +} NoteFieldPositioning::NoteFieldPositioning(CString fn) { @@ -128,24 +65,40 @@ NoteFieldPositioning::NoteFieldPositioning(CString fn) Mode m; const IniFile::key &k = i->second; + IniFile::key::const_iterator val; + + val = k.find("Name"); + ASSERT(val != k.end()); /* required */ + m.name = val->second; + + val = k.find("Backdrop"); + if(val != k.end()) + m.Backdrop = val->second; + + val = k.find("Center"); + if(val != k.end()) + m.m_Center.Command(val->second); + + val = k.find("FOV"); + if(val != k.end()) + m.m_fFov = float(atof(val->second.c_str())); + + val = k.find("Position"); + if(val != k.end()) + m.m_Position.Command(val->second); + + val = k.find("BackdropPosition"); + if(val != k.end()) + m.m_PositionBackdrop.Command(val->second); + for(int t = 0; t < MAX_NOTE_TRACKS; ++t) { - IniFile::key::const_iterator val; - - val = k.find("Name"); - ASSERT(val != k.end()); /* required */ - m.name = val->second; - - val = k.find(ssprintf("Track%i", t+1)); + val = k.find(ssprintf("Center%i", t+1)); if(val != k.end()) - MatrixCommand(val->second, m.m_Position[t]); - val = k.find(ssprintf("PTrack%i", t+1)); + m.m_CenterTrack[t].Command(val->second); + val = k.find(ssprintf("Position%i", t+1)); if(val != k.end()) - MatrixCommand(val->second, m.m_PerspPosition[t]); - - val = k.find(ssprintf("FOV%i", t+1)); - if(val != k.end()) - m.m_fFov[t] = float(atof(val->second.c_str())); + m.m_PositionTrack[t].Command(val->second); CString sGames; val = k.find("Games"); @@ -222,8 +175,37 @@ void NoteFieldPositioning::GetNamesForCurrentGame(vector &IDs) } } +/* XXX: Lots of GetID calls, which do a bunch of string compares; profile this. */ +CString NoteFieldPositioning::GetBackdropBGA(PlayerNumber pn) const +{ + const int mode = GetID(pn); + if(mode == -1) + return ""; /* none */ + LOG->Trace("bd %s", Modes[mode].Backdrop.c_str() ); + return Modes[mode].Backdrop; +} -void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn) const +void NoteFieldPositioning::BeginDrawBackdrop(PlayerNumber pn) +{ + const int mode = GetID(pn); + if(mode == -1) + return; + + DISPLAY->PushMatrix(); + Modes[mode].BeginDrawTrack(-1); +} + +void NoteFieldPositioning::EndDrawBackdrop(PlayerNumber pn) +{ + const int mode = GetID(pn); + if(mode == -1) + return; + + Modes[mode].EndDrawTrack(-1); + DISPLAY->PopMatrix(); +} + +void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn) { const int mode = GetID(pn); @@ -241,7 +223,7 @@ void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn) const } } -void NoteFieldPositioning::EndDrawTrack(PlayerNumber pn, int tn) const +void NoteFieldPositioning::EndDrawTrack(PlayerNumber pn, int tn) { const int mode = GetID(pn); diff --git a/stepmania/src/NoteFieldPositioning.h b/stepmania/src/NoteFieldPositioning.h index fd217a5faf..49da52a360 100644 --- a/stepmania/src/NoteFieldPositioning.h +++ b/stepmania/src/NoteFieldPositioning.h @@ -1,11 +1,11 @@ #ifndef NOTEFIELD_POSITIONING_H #define NOTEFIELD_POSITIONING_H -#include "RageMath.h" #include "PlayerNumber.h" #include "StyleDef.h" #include "PlayerNumber.h" #include "Style.h" +#include "Actor.h" #include @@ -16,16 +16,22 @@ class NoteFieldPositioning Mode(); bool MatchesCurrentGame() const; - void BeginDrawTrack(int tn) const; - void EndDrawTrack(int tn) const; + void BeginDrawTrack(int tn); + void EndDrawTrack(int tn); CString name; set