Add option for endless loop

parent 085f8a30
...@@ -157,6 +157,10 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -157,6 +157,10 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
allowStep = paused; allowStep = paused;
simulation->restart(); simulation->restart();
break; break;
case SDLK_l:
// Change loop
simulation->toogleLoop();
break;
case SDLK_w: case SDLK_w:
// Switch rendering mode // Switch rendering mode
visualization->toggleRenderingMode(); visualization->toggleRenderingMode();
...@@ -264,7 +268,7 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -264,7 +268,7 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
scenarios[4] = new SWE_AsagiScenario( scenarios[4] = new SWE_AsagiScenario(
ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_bath.nc", ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_bath.nc",
ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_displ.nc", ASAGI_INPUT_DIR "tohoku_gebco_ucsb3_500m_hawaii_displ.nc",
(float) 28800., simulationArea); (float) 18800., simulationArea);
visInfos[4] = new SWE_AsagiJapanSmallVisInfo(); visInfos[4] = new SWE_AsagiJapanSmallVisInfo();
} }
...@@ -288,7 +292,7 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -288,7 +292,7 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
scenarios[5] = new SWE_AsagiScenario( scenarios[5] = new SWE_AsagiScenario(
ASAGI_INPUT_DIR "chile_gebco_usgs_2000m_bath.nc", ASAGI_INPUT_DIR "chile_gebco_usgs_2000m_bath.nc",
ASAGI_INPUT_DIR "chile_gebco_usgs_500m_displ.nc", ASAGI_INPUT_DIR "chile_gebco_usgs_500m_displ.nc",
(float) 28800., simulationArea); (float) 50000., simulationArea);
} }
simulation->loadNewScenario(scenarios[5]); simulation->loadNewScenario(scenarios[5]);
...@@ -310,7 +314,7 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) { ...@@ -310,7 +314,7 @@ bool Controller::handleKeyPress( SDL_keysym *keysym) {
scenarios[6] = new SWE_AsagiScenario( scenarios[6] = new SWE_AsagiScenario(
ASAGI_INPUT_DIR "chile_gebco_usgs_2000m_bath.nc", ASAGI_INPUT_DIR "chile_gebco_usgs_2000m_bath.nc",
ASAGI_INPUT_DIR "chile_gebco_usgs_500m_displ.nc", ASAGI_INPUT_DIR "chile_gebco_usgs_500m_displ.nc",
(float) 28800., simulationArea); (float) 20000., simulationArea);
} }
simulation->loadNewScenario(scenarios[6]); simulation->loadNewScenario(scenarios[6]);
......
...@@ -74,6 +74,12 @@ void Simulation::resize(float factor) ...@@ -74,6 +74,12 @@ void Simulation::resize(float factor)
*/ */
void Simulation::runCuda(struct cudaGraphicsResource **vbo_resource, struct cudaGraphicsResource **vbo_normals) void Simulation::runCuda(struct cudaGraphicsResource **vbo_resource, struct cudaGraphicsResource **vbo_normals)
{ {
if (loop) {
// Restart?
if (curTime >= scenario->endSimulation())
restart();
}
// map OpenGL buffer object for writing from CUDA // map OpenGL buffer object for writing from CUDA
float3 *dptr, *dptr2; float3 *dptr, *dptr2;
std::size_t num_bytes, num_bytes2; std::size_t num_bytes, num_bytes2;
......
...@@ -53,6 +53,8 @@ class Simulation { ...@@ -53,6 +53,8 @@ class Simulation {
void getScalingApproximation(float &bScale, float &bOffset, float &wScale); void getScalingApproximation(float &bScale, float &bOffset, float &wScale);
void toogleLoop() { loop = !loop; }
private: private:
// Default scenario (used when no other scenario is specified) // Default scenario (used when no other scenario is specified)
SWE_SplashingPoolScenario defaultScenario; SWE_SplashingPoolScenario defaultScenario;
...@@ -72,6 +74,9 @@ class Simulation { ...@@ -72,6 +74,9 @@ class Simulation {
// Is this our first simulation step? // Is this our first simulation step?
int isFirstStep; int isFirstStep;
// Do endless loop?
bool loop;
// Compute new water surface // Compute new water surface
void calculateWaterSurface(float3* destBuffer); void calculateWaterSurface(float3* destBuffer);
// Compute normals of the water surface for shading // Compute normals of the water surface for shading
......
...@@ -60,6 +60,7 @@ Visualization::Visualization(int windowWidth, int windowHeight, const char* wind ...@@ -60,6 +60,7 @@ Visualization::Visualization(int windowWidth, int windowHeight, const char* wind
text->addText(" Space: Pause/Resume"); text->addText(" Space: Pause/Resume");
text->addText(" ->: Next frame (when paused)"); text->addText(" ->: Next frame (when paused)");
text->addText(" r: Restart scenario"); text->addText(" r: Restart scenario");
text->addText(" l: Endless loop");
text->addText(" +/-: Scale wave height"); text->addText(" +/-: Scale wave height");
text->addText("Mouse:"); text->addText("Mouse:");
text->addText(" Left button: rotate"); text->addText(" Left button: rotate");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment