Skip to content

Commit

Permalink
Fixed issues with manipulation of the main 3D view as well as restruc…
Browse files Browse the repository at this point in the history
…tured SimulationApp code to support ROS2 interface.
  • Loading branch information
patrykcieslak committed Oct 6, 2023
1 parent 1ff9a89 commit 658523b
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 148 deletions.
6 changes: 2 additions & 4 deletions Library/include/core/ConsoleSimulationApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ namespace sf
bool hasGraphics();

protected:
virtual void Loop();
void Init();
void LoopInternal();
void StartSimulation();
void ResumeSimulation();
void StopSimulation();

private:
void Init();

SDL_Thread* simulationThread;

static int RunSimulation(void* data);
};

Expand Down
10 changes: 7 additions & 3 deletions Library/include/core/GraphicalSimulationApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,21 @@ namespace sf

//! A method returning a mutable reference to the helper object rendering settings.
HelperSettings& getHelperSettings();

//! A method used to enable frame rate limitting.
void setLimitFramerate(bool enabled);

protected:
void Loop();
void Init();
void LoopInternal();
void CleanUp();

void StartSimulation();
void ResumeSimulation();
void StopSimulation();

virtual void InitializeGUI();

private:
void Init();
void InitializeSDL();
void RenderLoop();

Expand All @@ -191,6 +193,7 @@ namespace sf
bool* joystickButtons;
int16_t* joystickAxes;
uint8_t* joystickHats;
SDL_Event mouseWasDown;

IMGUI* gui;
OpenGLPipeline* glPipeline;
Expand All @@ -212,6 +215,7 @@ namespace sf
HelperSettings hSettings;
GLuint timeQuery[2];
GLint timeQueryPingpong;
bool limitFramerate;

static int RenderLoadingScreen(void* data);
static int RunSimulation(void* data);
Expand Down
9 changes: 6 additions & 3 deletions Library/include/core/SimulationApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ namespace sf

//! A method informing if the simulation is running.
bool isRunning();

//! A method informing if the simulation has finished.
bool hasFinished();

//! A method returning the path to the directory containing simulation data.
std::string getDataPath();

Expand All @@ -88,8 +88,10 @@ namespace sf
static SimulationApp* getApp();

protected:
void Loop();

virtual void Init();
virtual void Loop() = 0;
virtual void LoopInternal() = 0;
virtual void CleanUp();
virtual void Quit();

Expand All @@ -99,6 +101,7 @@ namespace sf
virtual void StopSimulation();

Console* console;
uint64_t startTime;

private:
SimulationManager* simulation;
Expand Down
5 changes: 2 additions & 3 deletions Library/src/core/ConsoleSimulationApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ void ConsoleSimulationApp::Init()
cInfo("Ready for running...");
}

void ConsoleSimulationApp::Loop()
void ConsoleSimulationApp::LoopInternal()
{
while(!hasFinished())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

void ConsoleSimulationApp::StartSimulation()
Expand Down
Loading

0 comments on commit 658523b

Please sign in to comment.