From 30af2522933d9caeca59d21e79c07f1be8862a8e Mon Sep 17 00:00:00 2001 From: BynaryCobweb Date: Wed, 7 Dec 2016 12:34:41 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20de=20bug,=20ajout=20d'une=20m?= =?UTF-8?q?=C3=A9thode=20utilitaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulation/Simulation.cpp | 6 +++--- simulation/utils.h | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/simulation/Simulation.cpp b/simulation/Simulation.cpp index fa4407a..162ce0b 100644 --- a/simulation/Simulation.cpp +++ b/simulation/Simulation.cpp @@ -1,4 +1,4 @@ -// +// // Created by louis on 19/11/16. // @@ -458,8 +458,8 @@ void Simulation::update(double time, bool printInfos) { if (_pause) return; //Mise à jour du monde (précision ~ 1h) t*10e6 - const double timeScale = _timeScale * time * (_reverse ? -1 : 1); - const double baseStep = _physicalStep; + const double timeScale = _timeScale * time; + const double baseStep = _physicalStep * (_reverse ? -1 : 1); _world->step(baseStep, (int) fabs(timeScale / baseStep)); // Affichage diff --git a/simulation/utils.h b/simulation/utils.h index 02123d9..d8a1374 100644 --- a/simulation/utils.h +++ b/simulation/utils.h @@ -1,4 +1,4 @@ -// +// // Created by louis on 13/11/16. // @@ -132,4 +132,18 @@ inline bool startsWith(const std::string & item, const std::string & prefix) { return true; } +inline bool endsWith(const std::string & item, const std::string & suffix) { + if (item.size() < suffix.size()) { + return false; + } + + for (int i = item.size(), j = suffix.size(); j >= 0; i--, j--) { + if (item[i] != suffix[j]) { + return false; + } + } + + return true; +} + #endif // SIMULATION_UTILS_H \ No newline at end of file