@@ -5,38 +5,50 @@ Integrator::Integrator() {
55
66}
77
8- void Integrator::AddIntegrable (Particule& integrable) {
8+ void Integrator::AddIntegrable (Integrable* integrable) {
99 m_integrableList.push_back (integrable);
1010}
1111
12+
1213void Integrator::UpdateAll (double time) {
14+ m_fixedDeltaTime += time;
15+ m_timeToAdjustFrameRate += time;
16+ if (m_timeToAdjustFrameRate > 1 / m_fixeFrameRate) {
17+ for (Integrable* integrable : m_integrableList) {
18+ integrable->recalculateAll (m_fixedDeltaTime);
19+ }
20+
21+
22+ m_timeToAdjustFrameRate -= 1 / m_fixeFrameRate;
23+ if (m_timeToAdjustFrameRate > 1 ) {
24+ m_timeToAdjustFrameRate -= 1 ;
25+ }
26+ m_fixedDeltaTime = 0 ;
27+ }
1328
14- for (Particule integrable : m_integrableList) {
15- integrable.recalculateAll (time);
16- }
1729}
1830
1931void Integrator::boucle () {
20- double deltaTime=0 ;
21- int numbTest = 0 ;
22- while (!m_StopPhysics) {
23-
24- auto start = std::chrono::high_resolution_clock::now ();
25- if (deltaTime != 0 ) {
26- UpdateAll (deltaTime);
27- }
28- using namespace std ::chrono_literals;
29- std::this_thread::sleep_for (2000ms);
30- auto end = std::chrono::high_resolution_clock::now ();
32+ // double deltaTime=0;
33+ // int numbTest = 0;
34+ // while (!m_StopPhysics) {
35+ //
36+ // auto start = std::chrono::high_resolution_clock::now();
37+ // if (deltaTime != 0) {
38+ // UpdateAll(deltaTime);
39+ // }
40+ // using namespace std::chrono_literals;
41+ // std::this_thread::sleep_for(2000ms);
42+ // auto end = std::chrono::high_resolution_clock::now();
3143
3244
33- deltaTime =std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count ();
34- deltaTime *= 0.000000001 ;
35- printf (" time = %f \n " , deltaTime);
36-
37- if (numbTest >= 5 ) {
38- m_StopPhysics = true ;
39- }
40- numbTest += 1 ;
41- }
45+ // deltaTime =std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
46+ // deltaTime *= 0.000000001;
47+ // printf("time = %f \n", deltaTime);
48+ //
49+ // if (numbTest >= 5) {
50+ // m_StopPhysics = true;
51+ // }
52+ // numbTest += 1;
53+ // }
4254}
0 commit comments