diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index 17ebc02e..999ccc75 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(rwgame pausestate.cpp menustate.cpp debugstate.cpp + benchmarkstate.cpp DrawUI.cpp diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 41f0bbc2..ab746008 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -4,6 +4,7 @@ #include "DrawUI.hpp" #include "ingamestate.hpp" #include "menustate.hpp" +#include "benchmarkstate.hpp" #include "debug/HttpServer.hpp" #include @@ -38,6 +39,7 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[]) bool newgame = false; bool test = false; std::string startSave; + std::string benchFile; for( int i = 1; i < argc; ++i ) { @@ -69,6 +71,10 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[]) { startSave = argv[i+1]; } + if( strcmp( "--benchmark", argv[i]) == 0 && i+1 < argc ) + { + benchFile = argv[i+1]; + } } @@ -81,7 +87,6 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[]) sf::ContextSettings cs; cs.depthBits = 32; window.create(sf::VideoMode(w, h), "", style, cs); - window.setVerticalSyncEnabled(true); window.setMouseCursorVisible(false); log.addReciever(&logPrinter); @@ -130,7 +135,11 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[]) } auto loading = new LoadingState(this); - if( newgame ) + if (! benchFile.empty()) + { + loading->setNextState(new BenchmarkState(this, benchFile)); + } + else if( newgame ) { if( test ) { @@ -171,7 +180,7 @@ void RWGame::newGame() return; } - state = new GameState; + state = new GameState(); world = new GameWorld(&log, &work, data); world->dynamicsWorld->setDebugDrawer(debug); @@ -317,6 +326,9 @@ int RWGame::run() while ( accum >= GAME_TIMESTEP ) { StateManager::get().tick(GAME_TIMESTEP); + if (StateManager::get().states.size() == 0) { + break; + } tick(GAME_TIMESTEP); @@ -337,7 +349,9 @@ int RWGame::run() render(alpha, timer); - StateManager::get().draw(renderer); + if (StateManager::get().states.size() > 0) { + StateManager::get().draw(renderer); + } window.display(); } diff --git a/rwgame/debugstate.cpp b/rwgame/debugstate.cpp index 5b140372..cf2f5f32 100644 --- a/rwgame/debugstate.cpp +++ b/rwgame/debugstate.cpp @@ -112,6 +112,9 @@ DebugState::DebugState(RWGame* game, const glm::vec3& vp, const glm::quat& vd) m->addEntry(Menu::lambda("Full Armour", [=] { game->getPlayer()->getCharacter()->getCurrentState().armour = 100.f; }, entryHeight)); + m->addEntry(Menu::lambda("Cull Here", [=] { + game->getRenderer()->setCullOverride(true, _debugCam); + }, entryHeight)); this->enterMenu(m); @@ -224,6 +227,9 @@ void DebugState::handleEvent(const sf::Event &e) case sf::Keyboard::LShift: _sonicMode = true; break; + case sf::Keyboard::P: + printCameraDetails(); + break; } break; case sf::Event::KeyReleased: @@ -246,6 +252,13 @@ void DebugState::handleEvent(const sf::Event &e) State::handleEvent(e); } +void DebugState::printCameraDetails() +{ + std::cout << " " << _debugCam.position.x << " " << _debugCam.position.y << " " << _debugCam.position.z + << " " << _debugCam.rotation.x << " " << _debugCam.rotation.y << " " << _debugCam.rotation.z + << " " << _debugCam.rotation.w << std::endl; +} + void DebugState::spawnVehicle(unsigned int id) { auto ch = game->getPlayer()->getCharacter(); diff --git a/rwgame/debugstate.hpp b/rwgame/debugstate.hpp index 433f99d4..6f274ad3 100644 --- a/rwgame/debugstate.hpp +++ b/rwgame/debugstate.hpp @@ -21,6 +21,8 @@ public: virtual void handleEvent(const sf::Event& event); + void printCameraDetails(); + void spawnVehicle(unsigned int id); const ViewCamera& getCamera();